#development

1 messages · Page 1799 of 1

lyric mountain
#

I see the pun there

vivid fulcrum
#

it's just so they don't have to reimplements algorithms that discord is asking for

#

reimplement*

rocky hearth
#

Im extending the Guild like this and....

#

cant typecast it

earnest phoenix
#

Maybe TS being drunk there? Try ignoring it with @ts-ignore and see if it works

rocky hearth
#

it does work, but ts is being stupid here.
ignoring it, would make guild of any type

autumn rampart
#

anyone good with distube

#
const Discord = require('discord.js');

module.exports = {
    name: 'resume',
    aliases: ['r'],
    description: 'pauses a song/nasheed',

    async execute (client, message, args) {
        if(!message.member.voice.channel)  return message.reply('Pleases be in a vc to use this command.');
        
        await client.distube.resume(message)
        await message.channel.send("**Resumed Playing!**") 
    }
}
#

the resume command does not work

rocky hearth
#

distube??

autumn rampart
#
lament rock
#

ytdl-core-discord gets opus streams by default and for streams which are not opus, it passes them through ffmpeg iirc

#

since not all yt vids return opus streams

#

but most do

rocky hearth
long crow
#

I'd say same,

autumn rampart
lament rock
#

if you're passing them straight into a voice lib, I would use ytdl-core-discord, but if you plan to pass it through ffmpeg anyways for filter support, you should use ytdl-core

long crow
#

last time I used it, always get slapped with the error ECONNRESET both package.

lament rock
#

I'd rather just use a web server like LavaLink to handle everything for me (which is what I do currently, but I'm working on re-implementing LavaLink's protocols into a remake of LavaLink in node.js)

earnest phoenix
#

yea, that's the best way to go

lament rock
#

Horizontally scale your apps

vivid fulcrum
#

lavalink is absolute garbage

lament rock
#

It's concept isn't. It's implementation leaves quite a bit of performance on the table.

#

Dealing with 1GB in prod with < 10 players

earnest phoenix
#

The current implemention is not really the best but rewriting the whole lib would be a good way to go

lament rock
#

which is why I'm remaking it

#

3s to boot LL and 0.1s to boot mine

long crow
lament rock
long crow
#

not sure how it'll be

earnest phoenix
lament rock
earnest phoenix
#

Not sure about the VoiceLink lib thats being developed by the d.js team but it might be good

lament rock
#

I'm competing with d.js team in most aspects it seems. Reimplemented d.js' protocols in a cacheless lib, making my own discord api typings module hippoaaagggh and now it seems like they wanna make a LavaLink 2: Electic Boogaloo

pale vessel
#

making my own discord api typings module
I'm interested 👀

lament rock
#

I need to update it since it hasn't been updated in a bit of time

lament rock
#

fr

#

I'm going through the pain of making a ThreadPool

#

Promise based

pale vessel
#

What happened here?

lament rock
#

Yes

#

I'm lazy

#

also, I don't think StageChannels actually have much different data from VoiceChannels

#

other than type 13

earnest phoenix
modest maple
#

Fancy some unsafe in your life ```rust
let success = match layout {
PixelLayout::RGB => {
let stride = width * 3;
WebPPictureImportRGB(picture_ptr, image.as_ptr(), stride)
}
PixelLayout::RGBA => {
let stride = width * 4;
WebPPictureImportRGBA(picture_ptr, image.as_ptr(), stride)
}
};

if success != 0 {
    panic!("fuck, memory error.")
}```
sudden geyser
#

yuck too similar

lament rock
#

rs

hidden nacelle
#

can i make someone unable to use my bot?

lament rock
#

check if the id of the user interacting with your bot is in a blacklist

hidden nacelle
#

there's this guy i hate a lot and he's in a server i'm making a bot for

#

so i want to blacklist him from using the bot

tranquil coral
#

انا عربي

digital ibex
#

hi so,

#

anything i can use to like

#

make the code better?

#

cuz uh, i have:

#

rn :/

tranquil coral
#

#ping

#

!ping

#

-ping

pliant gorgeBOT
#

Pong!

digital ibex
tranquil coral
#

!pong

#

K

#

where do you life @digital ibex

digital ibex
#

what?

tranquil coral
#

where you life

digital ibex
#

why

tranquil coral
#

from *

#

Where you from

digital ibex
#

it doesnt matter

#

?

earnest phoenix
tranquil coral
#

I don't speek English

digital ibex
solemn latch
digital ibex
#

oh yeah

#

thank

earnest phoenix
#

Switch cases wouldn't make that any better

digital ibex
#

what would ?

lament rock
# digital ibex

A lot of the code seems duplicated. Where you use firstNames.*, you can use a ternary for values based on boolean values

Example:

gender === "male" ? firstNames.male : gender === "female" ? firstNames.female : any
// ...rest of code
digital ibex
#

ye looks more clean

#

will do

#

u kno what i can with the hundred if statements

#

?

limber mica
earnest phoenix
# digital ibex what would ?

For all of those if statements to see which variables to concatenate into the template string and return, you could basically use the logical OR operator in a template string to make it all a lot cleaner and easier, example:

return `${x || ''} ${y || ''} ${z || ''}`;
sudden geyser
#

yuck

digital ibex
#

yeah alr thank

#

will do

#

👍

lament rock
#

Hot take: switch cases don't make code look better

vivid fulcrum
#

just make js functional

#

🧠

vivid fulcrum
#

x.or(y) and make or a global prototype

#

you should totally do this

sudden geyser
#

(or x y)

true ravine
#

Might sound like a dumb question but if you don't have the guild members intent do you just not get sent any of the guild member related packets (for events like guildMemberAdd)

vivid fulcrum
#

yup

true ravine
#

Epic thanks

vivid fulcrum
lament rock
#
Object.prototype.or = (value: any) => {
  if (Boolean(this)) return this;
  else return value;
}
#

get your app flagged as Prototype pollution

earnest phoenix
#

Just open a TC39 proposal for it like a gigachad

earnest phoenix
#

So I made this embed gif on my Discord bot, heres the code:

async def video(ctx):
  embed = discord.Embed(color = discord.Colour.red())

  embed.set_image(url = "https://tenor.com/view/wall-talking-talking-to-self-alone-lonely-gif-5869985")
  await ctx.send(embed=embed)

However for some reason the video is simply loading and loading without actually playing anything, would anyone be able to help?

vivid fulcrum
#

you need to provide the direct url to the image

#

not the url to the website

earnest phoenix
#

ohhh

#

alright yeah it works now

native tinsel
#

I need help with something, i made a webhook that sends a command for a discord bot, but that command doesn't work for the webhook bot itself, tho it works for me. How do i fix this? (Discord.py)

modest maple
#

you shouldnt have a bot responding to another bot

#

webhooks are classed as a bot

#

so discord.py will ignore them in it's command handler

native tinsel
#

like, i dont want it to ignore

modest maple
#

why do you want it in the first place

native tinsel
#

Its a specific thing , its not like a main bot im developing to become famous

#

can u help with the problem?

#

@modest maple

modest maple
#

Tldr no you cant

#

Come up with a diffrent system

native tinsel
#

Someone suggested get_command and call it, but how could i do that with the webhook

solemn latch
#

generally speaking this is a bad idea.

#

if you need two programs to talk to each other why not just do that through traditional methods?

#

or, if you goal is to make it look like two bots are talking to each other/responding to each other I would recommend doing it through those traditional methods.

latent heron
#
if let 0001..9999 != port { panic!("Port is improper."); }
#

this is why I feel like nobody should trust me with rust code

modest maple
#

Especially when your port ranges are incorrect mmLul

latent heron
#

its certainly a really shitty way of checking if my port is within boundaries

#

but the webserver is also not planning to extend past 9999, so

modest maple
#

Why dont... You just only accept a u16 size

#

Instead of usize or other type

latent heron
#

I did that as a really quick and dirty way to check

modest maple
#

Or even check the bit length of the integer

boreal iron
#

@latent heron Could you solve ur issue?

latent heron
#

yeah

boreal iron
#

Alright solved my issue, too
Came back after a break with a damn easy solution I didn’t even think of when I was stuck before

west spoke
#

Is it possible to modify/get user banners for bot accounts?

boreal iron
#

You mean an avatar?

west spoke
#

No

#

For example, this

latent heron
#

No

west spoke
#

Aww

boreal iron
#

Huh wtf is that

#

Not even aware of this exists KEKW

lyric mountain
#

bots dont have nitro

west spoke
#

Shame

solemn latch
#

Remember when bots had all nitro features?

west spoke
#

Yes

boreal iron
sudden geyser
#

It would be cool if bots could set banners

#

@solemn latch !!!

boreal iron
#

most important thing ever

sudden geyser
#

The !!! was for some scammer post

earnest phoenix
#

bots used to have nitro? huh never knew

limber mica
#

Is there a way to create an invite from a server in the bot.on('guildCreate') function?

lyric mountain
#

Then it got greedy

bright thorn
#

am making new esports bot anyone can give me a name for my bot any suggestions

sudden geyser
#

Esports Bot

bright thorn
sudden geyser
#

EsBot

bright thorn
#

Last name bot not good

quartz kindle
#

brontosaurus

sudden geyser
#

EsDock

bright thorn
#

thats good

sudden geyser
#

Dock is a play on port since a port is also known as a harbor (which is a dock)

pale vessel
#

EsFileExplorer

sudden geyser
#

EsFE

sudden geyser
#

don't know what that is

bright thorn
sudden geyser
#

confuzzled

bright thorn
#

what is your coding language

sudden geyser
#

I use a variety.

limber mica
#

Is there any way to create an invite to a server when the bot joins it?

limber mica
#

Because i want the invite to be one thing instead of it being generated again and again once ;invite is fired

#

So i can read it from the database and its only 1 invite all the time for that server

limber mica
#

I need to know the function for it

bright thorn
#

you do for each guild

#

i am using for each guild

limber mica
limber mica
bright thorn
#

you can make a loop for a command

#

for each guild

#

for system channel

limber mica
opal plank
#

@limber mica@bright thorn btoh of you, would highly recommend NOT use forEach

opal plank
#

and use for ... of

#

or for...in

#

depending what you doing

limber mica
#

Im creating an invite to a guild upon joining

bright thorn
#
 await guild.channels.cache
        .filter(channel => channel.type === "text") //added this line, should work like a charm
        .first()
        .createInvite()
        .then((invite) => embed.addField("Invite link", invite.url, true))
        .catch(() => embed.addField("Invite link", "Missing permissions", true));
bright thorn
#

you can use this

#

for each may be dangerous

#

my bot in 5 guild so i did for each

#

👀

opal plank
#

thats a bad thing to do

#

why do u need an invite in the first place?

bright thorn
#

we got

opal plank
#

you shouldnt need an invite at all

bright thorn
#

in console we can ask to owners

opal plank
#

that'd be breach of privacy

limber mica
#

So when a user does an invite command it fetches it from the database to prevent multiple invite creations

opal plank
#

use the bot to ask the owner or a mod if u can join

#

why not just fecthInvites?

sudden geyser
#

forEach is mostly used for side effects, but most things in JS are side effects

#

It's not as bad as people say it is

limber mica
opal plank
#

idk how they do in d.js, but u can fetch all invites existing from a guild

bright thorn
#

my bot is in 5 guild so i did for each

opal plank
#

something like that i suppose

opal plank
#

its a bad practice altogether

limber mica
opal plank
#

javascript/typescript

bright thorn
#

when my7 bot join a server then bot can create a link i can

opal plank
#

WHY do u need server invite

limber mica
#

FOR AN INVITE COMMAND

opal plank
#

and does your bot SAY, EXPLICITLY, it will make an invite for you?

#

fetch the invites rather than make one

#

just make one if theres none

earnest phoenix
bright thorn
limber mica
#

Ok, i will do that

opal plank
#

let me get the docs rq

limber mica
opal plank
#

@limber mica same for u

#

check if the size is 0

#

if it is, fallback to making one

#

otherwise just grab whichever comes

earnest phoenix
#

smh

bright thorn
#

oh

#

i got it

lyric mountain
#

Remember to explicitly ask for permission before handling invites tho

opal plank
#

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#

this

#

and make sure its noted on ur bot

limber mica
opal plank
#

not necessarily

#

mention that it does it on ur bots page

#

so whoever adds your bot are clearly aware of it

lyric mountain
#

Invites fall under sensitive data

opal plank
#

^^

limber mica
#

I log basic stuff such as the owner, name, member count and the owner id for blacklist reasons

opal plank
#

thats why i wask asking both you and puk why you both needed invites

#

cuz grabbing guilds's invites with a bot for you/other to join is a break of policy

lyric mountain
#

As well as messages, hidden channels, mutual guilds, guilds bot is in, etc

opal plank
#

you should not share/exploit sensitive data from private guilds

lyric mountain
#

Ids, command usage, channel count, etc are fine to log

opal plank
#

there are loopholes, but i wont mention them

limber mica
opal plank
#

if u using it for developing purposes, should be fine

lyric mountain
#

As the owner of the bot you already have access to all that info, you just can't leak them

opal plank
#

anyone on ur "team"(if u have one) should be fine too

#

just dont use it without explicit permission

lyric mountain
#

Think of it as a NDA

limber mica
lyric mountain
#

You CAN use that data, but it must remain secret at all times

opal plank
#

then no need to pay attention to what i said

limber mica
#

I only get publicly viewable data

limber mica
#

I dont do that

#

I dont make those crappy trojan bots

lyric mountain
#

So you're fine

opal plank
#

yeah

#

just be careful with some minor things

#

like for example you joining the server for debugging purposes. always ask for permission first via the bot

#

its not because the bot is there that you have been given permission to join

limber mica
opal plank
#

thats fine

#

just ASK first

#

if they say its fine, join

#

otherwise avoid it

lyric mountain
#

On-site support request command is quite handy if the other end isn't used to discord

distant cobalt
#
setTimeout(function(){ 
    console.log('hi')           
}, 5000);``` for some reason this isn't working. I put this in a while loop and the while loop works but the settimeout isn't. it's not printing `hi`
opal plank
#

wow

limber mica
#

Lol

opal plank
#

while() loop?

limber mica
#

That hurts me

opal plank
limber mica
opal plank
#

while() can be dangerous

distant cobalt
#

huh

opal plank
#

anyway

#

u should use fat arrow

#

since you technically calling an anon function

#

or, trying to, at least

distant cobalt
#

like this? =>

opal plank
#

yeah

boreal iron
opal plank
#

() => {console.log()}

lament rock
#

@earnest phoenix it begins

limber mica
#

Hey erwin, how do i calculate usr count? Do i just send the calculations across all the shards and just go from there?

opal plank
distant cobalt
opal plank
#

broadcastEval i think?

#

i use a different lib(which is a lot better than djs)

#

so for me, i just loop through the shards

limber mica
earnest phoenix
distant cobalt
#

i did this js setTimeout(function() => { everything had red lines

opal plank
#

for me its this simple

distant cobalt
#

that's just one line

opal plank
opal plank
#

users is memberCount
_users is just all the users CACHED

limber mica
opal plank
#

literally everything

lament rock
#

Trying to decode a stream to get a length is painful as fuck. The lib I'm using is able to decode this info VERY quickly for mp3 and mp4, but vorbis kinda causes it to wait for the stream to end which takes a long time and wastes bandwidth.

opal plank
lyric mountain
#

Using semicolon even when optional, good boy/girl

distant cobalt
opal plank
#

told you not to use that tho

#

just fat arrow

lament rock
#

I need to investigate if a single frame of a chunk supplies enough metadata

lyric mountain
#

The only lang I don't use semis is groovy

#

Because it yells at me when I use em

earnest phoenix
lament rock
#

Very. More research required

#

I need to make this as efficient as possible

opal plank
#

function(){} is just a nameless function, which is basically an anon function, but its declared
() => {} is also a nameless function, but it does not get declared and cant be called again(unless assigned to a variable)

#

basically , use-case

#

if u need a function multiple times, use function

#

if u need it once, use fat arrow

#

there ARE execptions for this rule

#

such as using this

#

but thats not something you'll likely use for a while

limber mica
#

Dammit @opal plank why did’nt you tell me this existed earlier

opal plank
#

see @earnest phoenix ?

#

i should say it MORE often

earnest phoenix
opal plank
#

so people see it

lyric mountain
#

Chances are you'll never use this unless going into oop

opal plank
earnest phoenix
lyric mountain
#

So if you find yourself having to use it you're in the right path

lament rock
#

Nah. Could probably route the input stream into another readable and limit how many chunks are piped to the readable

opal plank
lament rock
#

Time to test yay

limber mica
opal plank
distant cobalt
#
TypeError [INVALID_TYPE]: Supplied data.type is not a valid MessageComponentType.```
what does this mean?
opal plank
#

looks like you trying to send them in a lib that doesnt have support for them yet

distant cobalt
opal plank
#

MessageComponentType

distant cobalt
#

you mean the masked link?

opal plank
#

this implies you trying to use dropdowns or buttons

#

what?

errant flax
#

what r dropdowns

opal plank
#

Message's now have Components

errant flax
#

never heard of it

opal plank
#

which have types

distant cobalt
opal plank
#

@errant flax ^^

errant flax
#

oh select menus

distant cobalt
opal plank
#

technically they are dropdowns, but yeah

#

the actual name is Select Menus

#

technically

opal plank
#

you havent given the rest of the trace

#

so i cant tell

limber mica
opal plank
#

theres a whole slashClient which has its commandHandler for slashcommands

errant flax
#

that isnt slash commands

opal plank
#

ik it isnt

#

im talçking to infinity dev

limber mica
opal plank
#

ew

#

no

#

just detritus-client

#

npm i detritus-client@beta

#

thats all u need

limber mica
#

Im talking for slash commands

opal plank
#

look at my screenshot

limber mica
#

Im built on disc.js

opal plank
#

those ARE slash commands

#

like i said, i dont know how to do them in dsicord.js, i use detritus

#

which has a command handler built in for it

#

both for normal commands and slash commands

opal plank
limber mica
#

I will figure it out

#

Or not use it :)

opal plank
#

or you could switch libs while ur app is small

errant flax
#

imagine switching libs on a big app aaafrog

limber mica
#

Its not that small…

opal plank
#

wouldnt be that problematic tbh

#

probably about a day or two of work

limber mica
opal plank
#

most methods are the same

#

same structure too

errant flax
#

imagine switching languages on a big app isee

opal plank
#

<client>.guilds.cache
<client>.channels.cache
<client>.users.cache
<message>.reply()
<.message>.author
<message>.member

#

all that stuff u normally use is there

limber mica
#

Is deterius type script?

opal plank
#

most you'd have to do is switch <channel>.send() to <channel>.createMessage()
and thats about it

#

it is, but can be used in js just fine

#

so you can abuse the typescript if u want

#

everything is typed

limber mica
#

Im too lazy to switch

#

Discord.js works just fine for me :)

lyric mountain
limber mica
#

Look who is here

#

Million

lyric mountain
#

Switched the script engine for my tcg

#

From beanshell to groovy

crimson vapor
errant flax
#

imagine deleting ur app mimu_yathink

limber mica
opal plank
#

look at this shit

#

getting feedback as you type

lyric mountain
#

"only" 485 effects rewritten

opal plank
lyric mountain
#

Erwin don't be horni for intellisense

opal plank
#

i do be horni for intellisense

limber mica
#

Lol

opal plank
#

and u cant stop me nor my horniness

limber mica
#

IntelliJ go brr

#

Ima ho to bed now

#

Ight night

opal plank
#

enjoy non-coding time

limber mica
#

Finally sweet release from caffeine for 2-4 hours

opal plank
#

switch to detritus or be forever stuck with the nodepad level devs

opal plank
#

now we run before voltrex and company comes screeching at me for advertising it

limber mica
#

Lol

#

No sleep development is ehat puts infinity in my name

#

It never ends

#

😢

#

Help me

lyric mountain
#

Everyone gangsta until you meet context auto-complete and javadocs

opal plank
#

who needs docs anyway

#

intellisense ftw

limber mica
#

Docs are for nerds

#

And newbies

opal plank
#

detritus do need to up its docs/examples games tho. But its good that cake is focused on bringing out new features and improving the lib instead

#

for those who use it(me included), its much better a dev that works on actually getting shit done than a bunch of devs that do whatever the fuck this is

#

||the bait has been set, now we run||

clear marlin
#

they put a hella lot of effort on the discord.js documentation

crimson vapor
#

true

opal plank
crimson vapor
#

looks like shit now tho

opal plank
#

^^

clear marlin
#

nah, I tend to like it

#

but still Erwin, however good detritus maybe, discord.js will always remain on the top

opal plank
prime mist
#

I'm all for it. Being on top means supporting Javascript beginners lol.

opal plank
#

thats my selling point a lot of times

#

ts helps begginers

#

js is too flexible

#

and detritus offers command handler out of the gate

#

its greatly reduces ur struggles in actually making a bot

#

focusing on the functionality of ur bot rather than the structure

#

worst case scenario you have people doing a massive chain of
<client>.add(command)
instead of
else/if command === 'command';

but that still has its gains since the library would handle ratelimits, cooldowns, all that jaz already

#

how many times have u seen people do <client>.cooldowns coming here saying with an error that cooldowns is undefined or something of the sort. At its core, ts is just another helping tool to catch bugs as you write code, rather than waiting for that error to pop up

#

this is more of a TS/detritus combo than just detritus tbh

#

typescript, while annoying a lot of the times, is a good long term investment for devs

drifting shell
#

Is erwin advertising detritus to everyone again Hmmm

opal plank
#

specially if they plan to switch to strong typed langs in the future

drifting shell
#

Time to bonk erwin

clear marlin
#

Well, tbh userbase does play an important role in software. Discord.js has a large userbase, leading to people making guides or example bots etc. This helps new end users, to create a bot in discord.js, by referring to all of those guides and the extensive documentation discord.js has.

opal plank
#

in terms of documentation, you right, but documentation doesnt necessarily correlate to userbase

#

specially cuz most of the userbase abuses from it, and doesnt contribute

#

say, for example, detritus would have the same layout and examples as discord.js

#

now what?

#

which of the libs is "better" ?

#

discord.js cuz it has more users?

#

or detritus because it has more quality?

#

by quality i mean both QoL and optimizations

clear marlin
#

detritus is better, in terms of quality.

opal plank
#

mst of the stuff in guides is already covered internally by detritus

#

take for example, music bots, slash commands, command handling, that sort of thing

limber mica
#

I may switch to detritus, but what makes it complicated is my event handler and all that

opal plank
#

that'd generally be the most

clear marlin
#

But if we talk about beginners, people who want to try out the discord api for the first time. Discord.js always reigns first.

opal plank
#

ontop of it, you'd have wrappers n stuff

opal plank
#

in a perfect world, where both detritus and d.js have the same docs quality

#

why would discordjs be better

#

not with guides

#

just purely docs

clear marlin
#

As I said, detritus is as good.

prime mist
#

Beginners will use whatever pops up first on Google.

clear marlin
#

but discord.js just has an ample amount of guides, examples and articles on the internet

#

just what tim said

opal plank
#

also, dont take this wrongly, trying to gather data so we can possibly improve what we got so far

#

not arguing for the sake of it(though i am)

clear marlin
#

nah, its fine.

opal plank
#

it just doesnt fit in my mind that, if detritus would have docs(with examples, n stuff), that it would be worse for begginers

#

both in the short term, and longterm, i think detritus/ts would be best

#

and i exaplained well the ts part

#

with the strong typed langs in case you plan on branching out, also gives a good understanding of how objects work

#

as far as detritus, it would take, i'd say, a good 40% of the docs/guides out there

#

since most of those guides are meant for begginers

clear marlin
#

The next big thing about discord.js is the amount of frameworks it can adapt to. Like akairo, klasa

#

sapphire

opal plank
#

the others 60% i would assume would be stuff specific to databases, functions, music, that sort of thing

#

but those were built FOR discord.js, no?

#

when they were built, it had it in mind

#

if thats the case, im bunching them with the 60% of the "rest" i suggested, into functions/packages

#

packages would be a good argument too

#

for discord.js, i mean

#

with a big userbase, you'll have plenty of packages to chose frmo if u dont want to code it yourself

#

which can be both good and bad, but if you're a user willing to get something out, it'd be worth it

clear marlin
#

that's what I mean. Userbase plays an important role, not in quality but usage

opal plank
#

thats indeed a good point

clear marlin
#

and since you're making software you need people to use it

opal plank
#

thats also true

#

in fairness its not as unused as it seems

clear marlin
#

people will target the first thing they find, which in most cases would be discord.js

opal plank
#

but its not even a fraction of discord.js's

clear marlin
#

and discord.js bot making is like all over the internet

opal plank
#

393 vs 214k

#

its clear detritus does not have a chance in userbase

clear marlin
#

yeah

opal plank
#

but you've made ur point

#

packages and an ecosystem do play a big role around a lib

earnest phoenix
#

the next big thing for detritus is a new awesome lib to depend on it

opal plank
#

just get groovy to use it

#

or some big botum

#

ggez

#

even tho notSoBot is using it

#

nothing to sneer at

drifting shell
#

Didnt notsobot get blacklsited on topgg?

opal plank
#

indeed

#

i cant recall why

clear marlin
#

good idea, create detritus guides

#

and maybe youtube tutorials

lament rock
#

similar reasons as to why it as well as it's owner got banned from Discord most likely

earnest phoenix
#

im still waiting for that deno port of detritus

opal plank
earnest phoenix
#

It uses native node apis so esm.sh cant bundle it

opal plank
#

for not having a help command

clear marlin
#

anidiot's guide on detritus

#

that cool

drifting shell
#

I swear it did something dodgy ages ago that it got removed for

opal plank
lament rock
#

something about racism

earnest phoenix
clear marlin
#

if that happens tho detritus could gain userbase

opal plank
#

theres some misinformation there, like i said

clear marlin
#

oo

opal plank
#

she took a break, so its not fixed

drifting shell
#

This episode of Erwin is sponsored by Detritus

opal plank
#

Welcome to ym TED talk

earnest phoenix
#

detritus seems kinda cool

opal plank
#

it is, it just doesnt have docs, basically

#

luckily me and million are bringing out some commented example/repos

#

not a guide, but at least some examples on how to do things

earnest phoenix
#

what about a code playground?

opal plank
#

wdym?

earnest phoenix
#

people can test detritus in the browser

drifting shell
#

Million

#

You mean

#

THE million

opal plank
#

im not sure that'd be doable tbh

drifting shell
#

Jk millions not famous

opal plank
#

websockets n such

earnest phoenix
#

It can be

opal plank
#

ive never seen it

#

so its new territory for me

drifting shell
#

Yeah

#

Its perfectly doable

#

Its just a question of whether its worth it

#

Lol

earnest phoenix
#

send the detritus code and your bot token over HTTPS to your server, let it execute the code in a sandbox then pipe the errors to the client

opal plank
#

so, an eval command

#

im not fucking with that again

earnest phoenix
#

yeah

opal plank
#

not risking it lol

earnest phoenix
#

use a seperate server

opal plank
#

it'd have to be a docker, inside a vm, inside a sandbox level of shit

earnest phoenix
#

why would you need docker for that?

opal plank
#

docker has an amazing sandbox does it not?

clear marlin
#

woah that's a big brain

earnest phoenix
opal plank
#

it do tho

earnest phoenix
#

Pog

clear marlin
#

@opal plank detritus sandbox mmLol

opal plank
#

u du it

#

eval client.token

#

ggez

earnest phoenix
#

Or better, use the server to webpack detritus with the bot code then the client runs the code

#

or you can just make a codesandbox template

wheat mesa
#

Honestly I would use detritus and learn ts for it, I just prefer djs for the docs

opal plank
#

big brain

#

i'd say its worth using detritus, specially u are active in development/new features

earnest phoenix
opal plank
#

but thats only my biased opinion

earnest phoenix
#

tried and failed a lot of times trying to use it

opal plank
#

sounds like a u problem

#

not a ts/detritus one

#

u know u can always ask lmao

earnest phoenix
#

can you use detritus in normal js

opal plank
#

havent seen u ask ts questions here

#

u can yeah

opal plank
earnest phoenix
opal plank
#

also are the docs

#

shit u not

#

the docs, even though its a "pure ts lib" is in js

#

the docs themselves are ts tho

wheat mesa
earnest phoenix
#

ty

#

but i dont write bots

clear marlin
#

you would always use discord.js

#

for one reason

#

guides and tutorials

wheat mesa
#

Yes

earnest phoenix
#

detritusjs.guide when

opal plank
#

detritus handles commandHandling, new features AND ram optimization greatly. If u need any of the previously stated, use it. Otherwise you'll just end up learning typescript, and thats pretty much it

earnest phoenix
#

ram optimization is necessary for replit
Replit keeps killing my nextjs processes for too much ram

opal plank
#

if u want a bot, for 4 servers, with a ping command, i'd argue either of them will work just fine

clear marlin
#

lmao, yk what Erwin. I'll do a detritus guide on our blog mmLol

opal plank
#

poggers

wheat mesa
#

I don’t have any great ideas for bots quite really, so I wouldn’t need any of the optimization of resources as likely nothing I make would be popular

opal plank
lament rock
#

The way to get popular seems to be shameless ads and vote locking. Just make a 100% vote locked bot

earnest phoenix
clear marlin
#

and I'm sure there'll be a good amount of people seeing it. We over 40k reads a month mmLol

opal plank
wheat mesa
opal plank
#

indeed, you right

#

learning strong typed language is always a good thing

#

and ts in general, for me at least, is an invaluable tool for coding in js

#

THOUGH, im warning, you'll fight with it quite a bit in the beggining

wheat mesa
earnest phoenix
#

The catch errors before runtime thing is awesome but the type system is very weird

opal plank
#

there are very, very, very rare quirks of it. Most of the time, if something isnt working, its because you're doing it wrong

clear marlin
#

strong typed, easy language === "golang" always

opal plank
#

indeed

opal plank
#

thats about it

#

HOW you do, thats what changes

earnest phoenix
#

i wonder how esbuild is written in golang but can be run through require("esbuild")

inner fulcrum
#

@umbral canyon there a ping command lmao

client.on('message', message => {
  if (message.content === '!ping') {
    message.channel.send("pong")
  }
});
clear marlin
opal plank
inner fulcrum
#

;-;

#

wat

clear marlin
#

so its basically
golang -> C -> nodejs

opal plank
#
let prefix = "!";
CommandClient.add({
  name: 'ping',
  run({message}) {
    message.channel.createMessage('pong')
  }
})

@wheat mesa this should be a good example

opal plank
#

to detritus

earnest phoenix
#

let for prefix nice

opal plank
#

same thing, right?

inner fulcrum
#

lmao

opal plank
#

now here is where things come in handy with detritus

clear marlin
inner fulcrum
#
let prefix = "!"
client.on('message', message => {
  if (message.content === `${prefix}` + 'ping') {
    message.channel.send("pong")
  }
});
#

u saying this?

earnest phoenix
opal plank
#
let prefix = "!";
CommandClient.add({
  name: 'ping',
  ratelimits: [{limit:5, type:'channel', timeout: 5000}],
  run({message}) {
    message.channel.createMessage('pong')
  }
})

and now u got ratelimits based on a channel, so only 5 commands can be used every 5 seconds

clear marlin
inner fulcrum
#

i know

#

discord.js epic

earnest phoenix
#

i despise python

opal plank
#
let prefix = "!";
CommandClient.add({
  name: 'ping',
  aliases: ['pong'],
  ratelimits: [{limit:5, type:'channel', timeout: 5000}],
  run({message}) {
    message.channel.createMessage('pong')
  }
})

and now u got aliases

inner fulcrum
#

eh py is good but js is also good

#

¯_(ツ)_/¯

earnest phoenix
#

the forced intendation

opal plank
#

having it built in completely removes the need for having to write all that unecessary code they teach u with cooldowns, alieases, all that

earnest phoenix
#

:(

opal plank
earnest phoenix
#

is that why theres braces around message

opal plank
#

this is what we actually get from the parameters

#

i just descrutured it

clear marlin
#

ruby has force indentation too, but its far more better than python

opal plank
#

so it matches the example they sent

earnest phoenix
#

How can message be falsy?

opal plank
#

good question, thats on me, not on the lib

#

shit code

prime mist
opal plank
clear marlin
opal plank
#

its never null| undefined

earnest phoenix
#

Also if youre using optional chaining for cc then if it is undefined the message should be undefined too right?

opal plank
#

ignore the bad code lmao

clear marlin
#

that's like everytime, I code. " You had 4 spaces( needed 2)."

opal plank
#

otherwise i'll go to the other repo which actually has decent code

tulip heart
#

-bots

gilded plankBOT
opal plank
#

but yeah, its redudant to check that

prime mist
clear marlin
#

lmao

earnest phoenix
#

is dart worth learning

clear marlin
#

n

#

o

#

you know nodejs?

prime mist
clear marlin
#

just use react native

#

or ionic

#

or cordova

#

ALTERNATIVES TO FLUTTER/DART

earnest phoenix
#

not necessarily for flutter/ui

prime mist
#

dart isn't too bad, has a small learning curve. The recent sound null safety changes are nice.

earnest phoenix
#

side note: trying to use dart is the reason i fucked up my linux

clear marlin
#

dart, is a bit expert friendly tho

inner fulcrum
#

the fact that monke

opal plank
#

oh, almost forgot

#

if im not online, ask there

tame kestrel
#

oh thanks for the invite

#

lets goo

clear marlin
opal plank
#

cake and evan are massive brain devs, should be absolutely fine with any non-ts questions u have

#

ts they are good, but i wouldnt rely too much on that

#

like, 7/10 expertise

#

specially cake

clear marlin
#

ookk

opal plank
#

im prob a 5.5/10

#

i can struggle my way thru typescript

earnest phoenix
#

nice rules i can spam there

wheat mesa
earnest phoenix
#

commando weirdsip

earnest phoenix
opal plank
opal plank
#

screeches in detritus

earnest phoenix
#

I dont have a dog
I had 7 pigeons tho

opal plank
#

i'll kiss each one of them then

earnest phoenix
#

They flew away tho

opal plank
#

i'll fly with them

#

and watch as you regret ever recommending commando

prime mist
#

Hmm, who are these people using my discord client? I thought I was the only one using it lol.

lament rock
#

@earnest phoenix I was able to make it work instantly. Apparently, you can pipe a very small amount of chunks into a stream and it'll still contain that metadata.
I limited 4 chunks into a class I made which I aptly named a LimitedReadWriteStream which is just an extension of stream.Transform.

class LimitedReadWriteStream extends stream.Transform {
    public limit: number | undefined;
    public chunkAmount = 0;

    public constructor(chunkLimit?: number) {
        super();
        this.limit = chunkLimit;
    }

    public _transform(chunk: any, encoding: BufferEncoding, done: stream.TransformCallback) {
        if (!this.limit || this.chunkAmount < this.limit) this.push(chunk, encoding);
        if (this.limit && this.chunkAmount >= this.limit) this.end();
        this.chunkAmount++;
        done();
    }
}

implementation:

// message is an instance of http.IncomingMessage
const readwrite = new LimitedReadWriteStream(4);
message.pipe(readwrite);
const parsed = await metadata.parseStream(readwrite, { mimeType: message.headers["content-type"], size: message.headers["content-length"] ? Number(message.headers["content-length"]) : undefined }, { duration: false, skipCovers: true, skipPostHeaders: true, includeChapters: false });
message.destroy();
earnest phoenix
#

Only two of em were females so

🏳️‍🌈:rainbow_flag:🏳️‍🌈

lament rock
#

I also learned that chunk sizes are by default 16KB

opal plank
#

shinobu emotes

earnest phoenix
#

You know you can just put an || after Number(stuff) instead of using ternary

lament rock
#

I need to pass either a number or undefined to that option or else it produces unintended side effects. I know what I'm doing.

earnest phoenix
lament rock
earnest phoenix
lament rock
#

might try 1 chunk for shits and giggles

#

Nah. Didn't work too well. It ended up saying that the song was -80ms long

clear marlin
#

Voltrex

earnest phoenix
#

LULW What to expect from a single chunk

alpine star
#

Ñ

earnest phoenix
clear marlin
earnest phoenix
#

God damn, using RxJS like a chad

prime mist
#

rxjs ❤️

clear marlin
#

@earnest phoenix my last article went fire lmao

earnest phoenix
clear marlin
#

out of the 1.6k only 966 read it sadge

earnest phoenix
#

I mean, 966 readers is still not bad

#

Yall should make a detritus medium

#

For blogs and stuff

clear marlin
#

I mean I've got more than that before

#

but

earnest phoenix
#

Shrug

clear marlin
earnest phoenix
#

10 embeds + 4096 character limit in each description

errant flax
#

such a random limit tbh lookaround

earnest phoenix
errant flax
#

so how many characters total can fit in an embed noobthonk

earnest phoenix
#

8,048 characters in each embed

errant flax
#

dam

#

thats a lot + 10 embeds in a single message

earnest phoenix
#

I can already see mobile users (including myself) scared from this

errant flax
#

i am mobile

#

what r the limits for embeds btw

#

i wanna crash discord hmm

earnest phoenix
#

Limit for what of embeds

errant flax
#

titles description footer etc

errant flax
prime mist
earnest phoenix
prime mist
#

Is there a way to make ranges that I didn't know about? Because I actually care about that hah.

errant flax
#

Math.floor(Math.random()*5)
chooses between 1-5

#

@prime mist

wheat mesa
#

I believe... that... he knows that...

#

Just saying 😛

prime mist
errant flax
#

so u mean like
its chooses to
5-10 etc etc?

prime mist
#

range(0, 5) -> [0, 1, 2, 3, 4]

errant flax
#

oh u can do that with for loops ig then push the numbers? like

arr=[]
for (let i = 0;i<length;i++){
arr.push(0)
}
prime mist
#

Hah yep. Nice.

#

I'll stick with [...Array(count).keys()] for the time being.

earnest phoenix
#

or just
Array(count).fill().map(_ => "z");

#

what kind probleam happen here

#

Read the first word on line 26

#

yes

#

return stops the function

#

wht i do so

#

remove the return???

#

where

#

brother

earnest phoenix
craggy pine
earnest phoenix
#

oh

#

ok

prime mist
earnest phoenix
#

@prime mist the for loop fill method for the range is better than your [...Array(number).keys()] method

#

now it wotk

#

@earnest phoenix see up image

#

good

#

is error work

#

also visual studio should have told you that the return stops the function

earnest phoenix
#
    const connection = await channel.join();
    queueConstruct.connection = connection;
    play(queueConstruct.songs[0]);
  } catch (error) {
    console.error(`I could not join the voice channel: ${error}`);
    message.client.queue.delete(message.guild.id);
    await channel.leave();
    return sendError(`I could not join the voice channel: ${error}`, message.channel);
  }```
#

is this work

#

for config error

prime mist
earnest phoenix
earnest phoenix
earnest phoenix
earnest phoenix
#

As you were talking about ranges earlier

earnest phoenix
#

That's slower than what I showed

earnest phoenix
# earnest phoenix Array(rangeEnd).fill().map((x,i) => i + rangeStart);
    at Object.run (/home/container/commands/connect.js:18:5)
    at module.exports (/home/container/events/message.js:29:13)
    at Client.emit (events.js:376:20)
    at MessageCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
    at WebSocket.onMessage (/home/container/node_modules/discord.js/node_modules/ws/lib/event-target.js:132:16)
    at WebSocket.emit (events.js:376:20)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:62) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:62) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
#

DUDE

#

Try reading your errors instead of spam pinging me

#

bot cnt send message

#

but termianl comes

#

with this

#

i make permission handler message

#

whe user cnt give permission to bot

#

send message

#

read the error

#

error is undefined

#

my english is not good

#

bro

#

i am from assam

#

error is not defined

#

hmm

#

how can fix it pls help me 1 time coder bro

#

😭

#

define error

#

if you're making a discord bot it is assumed that you know simple javascript

wheat mesa
#

Learn js before making a bot! Makes life a lot easier.

earnest phoenix
#

Both for you and the people trying to help you

prime mist
#

Lol funny that. Learn to code before coding?

wheat mesa
#

^^

earnest phoenix
#

Lol funny that. Learn to write before writing?

earnest phoenix
earnest phoenix
#

ya british nhi bata

#

kuch

#

us liya ak last time help kar do na

#

muja define nhi ho raha ha ma kar raha red mark a raha ha

wheat mesa
#

uh

#

@earnest phoenix ask for help here rather than in DMs with me please.

wheat mesa
#

You need to define error in your code

#

The error is clear on what's wrong

earnest phoenix
earnest phoenix
# wheat mesa The error is clear on what's wrong
    at Object.run (/home/container/commands/connect.js:18:5)
    at module.exports (/home/container/events/message.js:29:13)
    at Client.emit (events.js:376:20)
    at MessageCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
    at WebSocket.onMessage (/home/container/node_modules/discord.js/node_modules/ws/lib/event-target.js:132:16)
    at WebSocket.emit (events.js:376:20)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:62) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:62) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
wheat mesa
#

Sending the same error over and over doesn't give me any more information than I already had

earnest phoenix
# wheat mesa Sending the same error over and over doesn't give me any more information than I...
  const channel = message.member.voice.channel;
  if (!channel)
    return message.channel.send(
      "**You must Join a voice channel before using this command!**"
    );

  if (!channel.permissionsFor(message.client.user).has("CONNECT"))
    return error("**I don't have permission to join the voice channel**");

  if (!channel.permissionsFor(message.client.user).has("SPEAK"))
    return error("**I don't have permission to speak in the voice channel**");

  await channel.join();

    message.channel.send(
    new MessageEmbed()
      .setDescription("👍 **Joined the voice channel **")
      .setColor("#ffb700")
  );
  try {
    const connection = await channel.join();
    queueConstruct.connection = connection;
    play(queueConstruct.songs[0]);
  } catch (error) {
    console.error(``);
    message.client.queue.delete(message.guild.id);
    await channel.leave();
    return message.channel.send(`**:Animated_Cross448: I cannot have any kind of permission to join voice channel**`, message.channel);
  }



},

};```
#

main codes

#

of join

wheat mesa
#

This is your connect.js file, right?

earnest phoenix
#
    const connection = await channel.join();
    queueConstruct.connection = connection;
    play(queueConstruct.songs[0]);
  } catch (error) {
    console.error(``);
    message.client.queue.delete(message.guild.id);
    await channel.leave();
    return message.channel.send(`**:Animated_Cross448: I cannot have any kind of permission to join voice channel**`, message.channel);
  }```
earnest phoenix
earnest phoenix
#

for catch error

lusty quest
earnest phoenix
lusty quest
#

well, i would replace error by message.reply or message.channel.send

wheat mesa
#

^^

earnest phoenix
#

also why would someone send the error object instead of error.message

earnest phoenix
wheat mesa
#

That is a very basic error. You should learn JS before making a bot, as if you knew JS there, that would be very simple to fix yourself.

earnest phoenix
#

He says he's from India that's why he doesn't understand english

#

huge insult

#

:(

wheat mesa
#

It's not

earnest phoenix
wheat mesa
#

Precisely

earnest phoenix
#

error is called as a method

#

Yeah

#

😔 all think i dum

#

wtf

#

ungrateful

wheat mesa
#

We didn't say that

#

Everyone starts somewhere in programming

earnest phoenix
#

channel.permissionsFor is also called with a user object

wheat mesa
#

However, making discord bots is probably not the best way to start out

earnest phoenix
#

your first project should be an html document with a button event listener that outputs hello world on click

tame kestrel
# earnest phoenix 😔 all think i dum

There's a difference between intelligence and knowledge.

The people here may be pushy with wanting people to be knowledgeable about programming, but none of them think you are dumb.

wheat mesa
#

I learned a great deal about JS from making bots, and as you said, it's a big jump from the basics.

#

It can be very overwhelming if you're not sure about at least the basics

rose warren
#

Depends if you like being thrown in on the deep end

#

But there's nothing wrong with starting out on a Discord bot imo

earnest phoenix
#

petition to put a This guide assumes you have prior knowledge about javascript. Trying to make a bot without knowing the basics is possible but *very hard*. banner above every discordjs.guide page

#

mami sahi khati thi dunai ma apno koi nhi hota

earnest phoenix
#

welcome back to my blocklist

earnest phoenix
#

you cnt denfine right

rose warren
earnest phoenix
#

right

#

lets get back to coding

rose warren
#

This channel is for development

wheat mesa
#

I am having a sudden impulse to swap to detritus because I'm bored

earnest phoenix
#

im making a custom newtab extension for chrome and im making a clock. What should be the interval in which it rechecks the time and displays it?

lusty quest
#

the docs are not good, but you get usually features Day1

#

also it does stuff like Sharding differently

earnest phoenix
#

I have a 1 second interval calling setState with the new time

wheat mesa
#

Yeah

earnest phoenix
#

????

long crow
#

Kids

earnest phoenix
#

what are you trying to do

#

It's probably matching the start of the string

#

Try using anchors

wheat mesa
earnest phoenix
#

At the end too