#development
1 messages · Page 1799 of 1
it's just so they don't have to reimplements algorithms that discord is asking for
reimplement*
Maybe TS being drunk there? Try ignoring it with @ts-ignore and see if it works
it does work, but ts is being stupid here.
ignoring it, would make guild of any type
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
distube??
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
so using ytdl-core-discord is better than ytdl-core, right?
I'd say same,
any idea how would i fix it\
yea
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
last time I used it, always get slapped with the error ECONNRESET both package.
https://www.npmjs.com/package/youtube-dl-exec using this now
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)
yea, that's the best way to go
Horizontally scale your apps
lavalink is absolute garbage
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
The current implemention is not really the best but rewriting the whole lib would be a good way to go
Got this too on WIP https://github.com/discordjs/voicelink/pull/1 ¯_(ツ)_/¯
not sure how it'll be
After rewriting it name it MagmaLink 

Not sure about the VoiceLink lib thats being developed by the d.js team but it might be good
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
and now it seems like they wanna make a LavaLink 2: Electic Boogaloo
making my own discord api typings module
I'm interested 👀
I need to update it since it hasn't been updated in a bit of time
Budget LavaLink
What happened here?

Yes
I'm lazy
also, I don't think StageChannels actually have much different data from VoiceChannels
other than type 13

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.")
}```
yuck too similar
rs
can i make someone unable to use my bot?
check if the id of the user interacting with your bot is in a blacklist
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
انا عربي
hi so,
anything i can use to like
make the code better?
cuz uh, i have:
rn :/
Pong!
what?
where you life
why
This is a development channel, #general or #general-int for off-topic conversation
btw can anyone help me with #development message
use switch cases
Switch cases wouldn't make that any better
what would ?
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
case statement / switch Depends on how you name it
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 || ''}`;
yuck
Hot take: switch cases don't make code look better
I agree
(or x y)
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)
yup
Epic thanks
if you'd like to read more into it, here's the doc link https://discord.com/developers/docs/topics/gateway#list-of-intents
Object.prototype.or = (value: any) => {
if (Boolean(this)) return this;
else return value;
}
get your app flagged as Prototype pollution
Just open a TC39 proposal for it like a gigachad
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?
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)
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
Any way to fix it?
like, i dont want it to ignore
why do you want it in the first place
Its a specific thing , its not like a main bot im developing to become famous
can u help with the problem?
@modest maple
Im sure theres a solution
Someone suggested get_command and call it, but how could i do that with the webhook
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.
if let 0001..9999 != port { panic!("Port is improper."); }
this is why I feel like nobody should trust me with rust code
Especially when your port ranges are incorrect 
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

I did that as a really quick and dirty way to check
Or even check the bit length of the integer
@latent heron Could you solve ur issue?
yeah
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
Is it possible to modify/get user banners for bot accounts?
You mean an avatar?
No
Aww
no
bots dont have nitro
Shame
Remember when bots had all nitro features?
lmao another stupid reason to spend ur money for
most important thing ever
The !!! was for some scammer post
bots used to have nitro? huh never knew
Is there a way to create an invite from a server in the bot.on('guildCreate') function?
Ye, that was actually a hacky way for discord to allow bots to use emotes from anywhere
Then it got greedy
am making new esports bot anyone can give me a name for my bot any suggestions
Esports Bot
Some thing different
EsBot
Last name bot not good
brontosaurus
EsDock
Dock is a play on port since a port is also known as a harbor (which is a dock)
EsFileExplorer
EsFE
means esports dock
don't know what that is
your library ?
confuzzled
what is your coding language
I use a variety.
wtf 
thats all
cya
Is there any way to create an invite to a server when the bot joins it?
yeah
but why ?
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
you cant do for particular guild
you do for each guild
i am using for each guild
So in a bot.on(guildcreate) statement i cant do it?
How would i go about that
not guild create
you can make a loop for a command
for each guild
for system channel
So ‘for each (client.guild) {}’
@limber mica@bright thorn btoh of you, would highly recommend NOT use forEach
So HOW then?
Im creating an invite to a guild upon joining
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));
you can use this
for each may be dangerous
my bot in 5 guild so i did for each
👀
dont
thats a bad thing to do
why do u need an invite in the first place?
you shouldnt need an invite at all
in console we can ask to owners
that'd be breach of privacy
So when a user does an invite command it fetches it from the database to prevent multiple invite creations
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
Nani?!?!
my bot is in 5 guild so i did for each
something like that i suppose
second time u say this
its a bad practice altogether
What language is this?
javascript/typescript
when my7 bot join a server then bot can create a link i can
WHY do u need server invite
FOR AN INVITE COMMAND
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
can’t you create one when they acc want one
how?
Ok, i will do that
let me get the docs rq
Way it creates it will create a lot if they use invite command alot
@limber mica same for u
check if the size is 0
if it is, fallback to making one
otherwise just grab whichever comes
smh
Remember to explicitly ask for permission before handling invites tho
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
this
and make sure its noted on ur bot
So i need to ask the user to fetch invites?
not necessarily
mention that it does it on ur bots page
so whoever adds your bot are clearly aware of it
Invites fall under sensitive data
^^
I log basic stuff such as the owner, name, member count and the owner id for blacklist reasons
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
As well as messages, hidden channels, mutual guilds, guilds bot is in, etc
you should not share/exploit sensitive data from private guilds
Ids, command usage, channel count, etc are fine to log
I store none of those
there are loopholes, but i wont mention them
Only i have access to the data
if u using it for developing purposes, should be fine
As the owner of the bot you already have access to all that info, you just can't leak them
anyone on ur "team"(if u have one) should be fine too
just dont use it without explicit permission
Think of it as a NDA
Im solo ;-;
You CAN use that data, but it must remain secret at all times
then no need to pay attention to what i said
I only get publicly viewable data
Sharing it is not good to do
I dont do that
I dont make those crappy trojan bots
So you're fine
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
Now im going to make a command just for me that does that, thank you for the idea XD
On-site support request command is quite handy if the other end isn't used to discord
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`
wow
Lol
That hurts me


while() can be dangerous
huh
anyway
u should use fat arrow
since you technically calling an anon function
or, trying to, at least
like this? =>
yeah
I would say JavaScript is dangerous not the loop but hey… 
() => {console.log()}
@earnest phoenix it begins
Hey erwin, how do i calculate usr count? Do i just send the calculations across all the shards and just go from there?
not technically wrong
that you'd have to check in the docs
ok
broadcastEval i think?
i use a different lib(which is a lot better than djs)
so for me, i just loop through the shards
What is it…

i did this js setTimeout(function() => { everything had red lines
Close the function???
for me its this simple
detritus.js
users is memberCount
_users is just all the users CACHED
What nakes it better?
literally everything
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.
@limber mica #development message read that
Using semicolon even when optional, good boy/girl
the red line on the => and it says js '{' expected.
who wouldnt
told you not to use that tho
just fat arrow
I need to investigate if a single frame of a chunk supplies enough metadata
Damn, if it actually waits until the stream ends; its kinda unpog
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
Dammit @opal plank why did’nt you tell me this existed earlier
i literally say this every 5 minutes
see @earnest phoenix ?
i should say it MORE often
Good luck on finding a way to get the info without waiting for the stream to end, gotta use another lib I guess
so people see it
Chances are you'll never use this unless going into oop


So if you find yourself having to use it you're in the right path
Nah. Could probably route the input stream into another readable and limit how many chunks are piped to the readable
i have some links if u interested
that might work actually
Time to test 
Send em please
sure, sec
TypeError [INVALID_TYPE]: Supplied data.type is not a valid MessageComponentType.```
what does this mean?
- docs http://detritusjs.com/
- cake's good bot code https://github.com/cakedan/notsobot.ts/tree/master/
- erwin's basic bot https://github.com/erwin1234777/detritus-example
- server invite https://discord.gg/gAv6TYuR
- theres also millions's slash command bot https://github.com/Million900o/slash-command-bot
you probably trying dropdowns, arent u?
looks like you trying to send them in a lib that doesnt have support for them yet
wdym
MessageComponentType
you mean the masked link?
no
what r dropdowns
Message's now have Components
never heard of it
which have types
i already know how to do it
oh select menus
ohh
technically they are dropdowns, but yeah
the actual name is Select Menus
technically
but yeah, either u or someone is sending a dropdown message, most likely
you havent given the rest of the trace
so i cant tell
How the hell, and how do you do slash commands?
theres a whole slashClient which has its commandHandler for slashcommands
that isnt slash commands
Is this the npm package https://www.npmjs.com/package/discord-slash-commands-client
Im talking for slash commands
look at my screenshot
Im built on disc.js
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
this pic shows one example of it
imagine switching libs on a big app 
Its not that small…
Major issues
imagine switching languages on a big app 
<client>.guilds.cache
<client>.channels.cache
<client>.users.cache
<message>.reply()
<.message>.author
<message>.member
all that stuff u normally use is there
Is deterius type script?
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

Did it in the last 3 days lul
aaaaaaa
https://github.com/Million900o/slash-command-bot
I kinda fucked with the structure to not copy and paste code but it still is an example
imagine deleting ur app 
Good choice
"only" 485 effects rewritten

Erwin don't be horni for intellisense
i do be horni for intellisense
Lol
enjoy non-coding time
Finally sweet release from caffeine for 2-4 hours
switch to detritus or be forever stuck with the nodepad level devs
Lol
No sleep development is ehat puts infinity in my name
It never ends
😢
Help me
Everyone gangsta until you meet context auto-complete and javadocs
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||
they put a hella lot of effort on the discord.js documentation
true
and almost none on the lib

looks like shit now tho
^^
nah, I tend to like it
but still Erwin, however good detritus maybe, discord.js will always remain on the top
as "top" i hope you mean in userbase, not as in quality

I'm all for it. Being on top means supporting Javascript beginners lol.
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
Is erwin advertising detritus to everyone again 
specially if they plan to switch to strong typed langs in the future
always
Time to bonk erwin
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.
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
detritus is better, in terms of quality.
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
I may switch to detritus, but what makes it complicated is my event handler and all that
that'd generally be the most
But if we talk about beginners, people who want to try out the discord api for the first time. Discord.js always reigns first.
ontop of it, you'd have wrappers n stuff
this is where i'd like to argue
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
As I said, detritus is as good.
Beginners will use whatever pops up first on Google.
but discord.js just has an ample amount of guides, examples and articles on the internet
just what tim said
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)
nah, its fine.
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
The next big thing about discord.js is the amount of frameworks it can adapt to. Like akairo, klasa
sapphire
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
that's what I mean. Userbase plays an important role, not in quality but usage
and since you're making software you need people to use it
people will target the first thing they find, which in most cases would be discord.js
and discord.js bot making is like all over the internet
yeah
the next big thing for detritus is a new awesome lib to depend on it
just get groovy to use it
or some big botum
ggez
even tho notSoBot is using it
nothing to sneer at
Didnt notsobot get blacklsited on topgg?
similar reasons as to why it as well as it's owner got banned from Discord most likely
im still waiting for that deno port of detritus
evie was working on one, but she's taking a break for a while now
for not having a help command
I swear it did something dodgy ages ago that it got removed for
she started it, but she got some info wrong, and she told me she'd be on a break. someone else needs to pick it up
something about racism
literally anidiotsguide
if that happens tho detritus could gain userbase
theres some misinformation there, like i said
oo
she took a break, so its not fixed
Yeah that was it
This episode of Erwin is sponsored by Detritus
detritus seems kinda cool
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
what about a code playground?
wdym?
people can test detritus in the browser
im not sure that'd be doable tbh
Jk millions not famous
websockets n such
It can be
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
yeah
not risking it lol
use a seperate server
it'd have to be a docker, inside a vm, inside a sandbox level of shit
why would you need docker for that?
docker has an amazing sandbox does it not?
woah that's a big brain

Pog
@opal plank detritus sandbox 
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
Honestly I would use detritus and learn ts for it, I just prefer djs for the docs
big brain
i'd say its worth using detritus, specially u are active in development/new features
i would rather jump off a cliff than use typescript
but thats only my biased opinion
tried and failed a lot of times trying to use it
can you use detritus in normal js
literally evie's guide is in js

also are the docs
shit u not
Documentation for Detritus Client
the docs, even though its a "pure ts lib" is in js
the docs themselves are ts tho
Meh, the one bot I made is mainly just for fun and custom stuff for friends’ servers, but I’m always down to learn other stuff, which is why I’ve been looking into swapping to detritus
i'd say its the opposite tbh
Yes
detritusjs.guide when
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
ram optimization is necessary for replit
Replit keeps killing my nextjs processes for too much ram
if u want a bot, for 4 servers, with a ping command, i'd argue either of them will work just fine
lmao, yk what Erwin. I'll do a detritus guide on our blog 
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
i'd recommend asking me quite a bit about any questions. or any of the helpers in the server. Evie accidently got a few things wrong while writting it
The way to get popular seems to be shameless ads and vote locking. Just make a 100% vote locked bot
also where are you going to host it
98% of servers use linux
and I'm sure there'll be a good amount of people seeing it. We over 40k reads a month 
then the most you'll gain from it would be typescript

Not necessarily a bad thing!
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
been learning c# off and on for a little while, haven't really taken it seriously though
The catch errors before runtime thing is awesome but the type system is very weird
there are very, very, very rare quirks of it. Most of the time, if something isnt working, its because you're doing it wrong
strong typed, easy language === "golang" always
indeed
is basically telling a shape of a thing, at its core
thats about it
HOW you do, thats what changes
i wonder how esbuild is written in golang but can be run through require("esbuild")
@umbral canyon there a ping command lmao
client.on('message', message => {
if (message.content === '!ping') {
message.channel.send("pong")
}
});
golang -> C, nodejs -> C. Can easily be compiled
for example, lets take this as example
so its basically
golang -> C -> nodejs
let prefix = "!";
CommandClient.add({
name: 'ping',
run({message}) {
message.channel.createMessage('pong')
}
})
@wheat mesa this should be a good example
just converting this good person's code
to detritus
let for prefix nice
same thing, right?
lmao
now here is where things come in handy with detritus
why not bind message and some other objects into ctx
let prefix = "!"
client.on('message', message => {
if (message.content === `${prefix}` + 'ping') {
message.channel.send("pong")
}
});
u saying this?
i would stop using detritus if it has dpy like names
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
that's discord.js
how would that be bad??
i despise python
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
the forced intendation
having it built in completely removes the need for having to write all that unecessary code they teach u with cooldowns, alieases, all that
:(
it is bind already
is that why theres braces around message
ruby has force indentation too, but its far more better than python
so it matches the example they sent
How can message be falsy?
Na ruby can be indented however you like. As it has end everywhere lol.
why does rubocop fuck me then
its never null| undefined
Also if youre using optional chaining for cc then if it is undefined the message should be undefined too right?
ignore the bad code lmao
that's like everytime, I code. " You had 4 spaces( needed 2)."
otherwise i'll go to the other repo which actually has decent code
-bots
but yeah, its redudant to check that
rubocop is pretty anal about everything.
lmao
is dart worth learning
flutter is good 🙂
not necessarily for flutter/ui
dart isn't too bad, has a small learning curve. The recent sound null safety changes are nice.
side note: trying to use dart is the reason i fucked up my linux
dart, is a bit expert friendly tho
the fact that monke
oh, almost forgot
@clear marlin https://discord.gg/gAv6TYuR
if im not online, ask there
alright
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
ookk
nice rules i can spam there
built in command handler 🤤
commando 
THIS IS A JOKE PLEASE DO NOT TAKE THIS SERIOUSLY
yes
I WILL KISS UR DOG IF U KEEP THIS UP, U LIL PUNK
screeches in detritus
I dont have a dog
I had 7 pigeons tho
i'll kiss each one of them then
They flew away tho
Hmm, who are these people using my discord client? I thought I was the only one using it lol.
@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();
Only two of em were females so
🏳️🌈:rainbow_flag:🏳️🌈
You know you can just put an || after Number(stuff) instead of using ternary
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.
That's an interesting implementation



might try 1 chunk for shits and giggles
Nah. Didn't work too well. It ended up saying that the song was -80ms long
Voltrex
What to expect from a single chunk
Ñ
Zordy
woah that's actually awesome!!
God damn, using RxJS like a chad
rxjs ❤️
@earnest phoenix my last article went fire lmao

out of the 1.6k only 966 read it 
I mean, 966 readers is still not bad
Yall should make a detritus medium
For blogs and stuff
Shrug
10 embeds + 4096 character limit in each description
such a random limit tbh 

so how many characters total can fit in an embed 
8,048 characters in each embed
I can already see mobile users (including myself) scared from this
Limit for what of embeds
titles description footer etc
🕶️
import { Embed } from "./types";
const zzz = (count: number) => [...Array(count).keys()].map(() => "z").join("");
const embed: Embed = {
title: zzz(256),
description: zzz(4096),
};
Was that kind of a joke or did you not know String.prototype.repeat() existed 
Oh nice. Didn't know that one 🙂
Is there a way to make ranges that I didn't know about? Because I actually care about that hah.
By ranges, I mean a list of numbers of x size. Most languages have this kind of syntax 0..5 etc.
so u mean like
its chooses to
5-10 etc etc?
range(0, 5) -> [0, 1, 2, 3, 4]
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)
}
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
...
???
Oh nice. fill looks good.
@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
hm
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
Fill looks pretty good though. If you only care about the length (fill makes everything undefined).
@earnest phoenix https://tryitands.ee
ok
Array.prototype.fill() doesn't make a range (example: [0, 1, 2, 3, 4]), I was talking about this
it work
As you were talking about ranges earlier

Array(rangeEnd).fill().map((x,i) => i + rangeStart);
That's slower than what I showed
Refer to this
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
Learn js before making a bot! Makes life a lot easier.
Both for you and the people trying to help you
Lol funny that. Learn to code before coding?
^^
Lol funny that. Learn to write before writing?
ok
muja samj nhi a raha kasa define kara ap indian ha to ise liya apsa pucha
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
ok

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.
Sending the same error over and over doesn't give me any more information than I already had
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
This is your connect.js file, right?
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);
}```
yes
i add this new
for catch error
how did you define Error? for your returns?
He didn't that's why
well, i would replace error by message.reply or message.channel.send
^^
also why would someone send the error object instead of error.message

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.
He says he's from India that's why he doesn't understand english
huge insult
:(
It's not
Precisely
channel.permissionsFor is also called with a user object
you should use message.guild.me inside that
However, making discord bots is probably not the best way to start out
your first project should be an html document with a button event listener that outputs hello world on click
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.
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
Depends if you like being thrown in on the deep end
But there's nothing wrong with starting out on a Discord bot imo
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
translation: aunt used to say the correct thing, there are no good people in the world
welcome back to my blocklist
not good
you cnt denfine right
This channel is for development
I am having a sudden impulse to swap to detritus because I'm bored
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?
the docs are not good, but you get usually features Day1
also it does stuff like Sharding differently
I have a 1 second interval calling setState with the new time
Yeah
bawfa ha tu bhie
????
Kids
what are you trying to do
It's probably matching the start of the string
Try using anchors
To save yourself some time on testing that- https://regex101.com
At the end too


















