#archive-library-discussion
25085 messages · Page 7 of 26
yikes
and there's no way to just freeze the user object because you'll get multiple GMU / PU per user change depending on how many servers they share, so it is only successfully freezed on the first update recieved, the rest already reference an updated user object
The tag property on User is returning null for a partial user? I understand it can be partial but discord docs never mark the username/discriminator property as nullable?
yes
Because if we had the full Discord structure it wouldnt be partial
not sure if this is possible or its just "hard" to do, is it possible to manage the shards through PM2 .
Like if the library could implement it to auto shard and tell the PM2 to spawn N of processes
what benefits would what have?
apart from having to write completely new way of having shards communicate between each other, which is supplied by the fact that main process spawns child_processes (or worker threads) which in turn allows communication directly in the processes, without any external abstraction
In version 13, would you be able to give us more control over the caching? Some of the more popular bots that use discord.js use a crazy amount of memory, and most of the cache is useless because the bot doesn't use it. Even if it was just an object that said okay I want channels, roles, guilds etc etc
Then you could also ignore events where the bot doesn't want the cache for it
I believe you can achieve that already (and will be more selective naturally in v13) via intents. If you don't need a message cache, don't add the messages intent. Speaking of which, that is something that needs to be heavily considered for v13. While many people will use the built-in INTENTS.NON_PRIVILEGED (IIRC that's what it is), granted not what should be done and most likely unneeded, it is totally possible, and recommend, to only specify the intents that you think your bot needs, only to find out djs breaks because it expected cache to be present and updated
Intents are one method of controlling caching as ckohen pointed out - if you never receive the events, your bot doesn't cache them. v13 is unlikely to change the caching structures and methods themselves though - this is something we're likely to explore more in the TypeScript rewrite
Hmm okay thanks, I will look into intents and see if I can sort that out. Don't wanna have to buy a bigger server because my bot is using 200gb 
(it's not actually)
You can also manually clear caches as needed
discord.js is built to expect things like guild/channels/roles to be in cache though
The main things you can clear are users, members, maybe emojis, and presences. Those you can clear with little worry (except having to fetch members when needed)
Ah alright thanks
you have to modify the sharding manager, it is not possible without it, as Souji mentioned you would have small Benefit. But when you are so fricky on the ram usage, then there other ways to sink it...
Ghost Ping 
I think that caching is important, the biggest base of users here are js learners and this could be problematic and confusing for them. As you bot gets bigger you have to make your own library or modify it (you won't come around), to cache just things you want......
I mean, the caching can be enabled by default and more experienced developers can just disable the caches they dont need
but when the developers are so experienced, they can make their own one 
It will just bloat up the libary, you have to change every class, packethandlers.......thats so much work
discord.js does currently not support swappable cache implementations or optional caches
this is a design goal to apply when we get around to rewrite the library.
that being said, you can always clear caches you do not need on an interval, as has been said above. not receiving data in the first place can also reduce cache size.
if you want to further discuss this on a level that's got nothing to do with discord.js development please use #archive-offtopic
This statement is absolutely not true at all. A library that has no cache is for bigger bots, because then you control it yourself. A library that has no cache is way harder to use for beginners or tiny bots that most people built. Statistically speaking most bots aren’t built to be huge
lol, I builted in the not, I meant, I think...., otherwise my statement would not make sense
Yeah now that makes sense lol
a native implementation of AbortController has been released in node.js 16
should this kind of thing be delayed until a future version of djs, since node 16 is so new?
and I guess also because swapping it out doesn't achieve anything of much significance aside from removing a dependency
could polyfill it I guess
i.e check if it exists globally otherwise use the package
wait i thought it was released on node.js 15
so it was
I missed the
Some of the recently released features in Node.js 15, which will also be available in Node.js 16, include
question is still relevant though
Since master targets node 14 and I don't think there are any plans to make it target 15, this would be waiting until whatever comes next
Seems like API v9 has been released to the clients (canary only for now). Since v13 isn't finalized yet, any thoughts on jumping directly to api v9 (obviously once documentation is present)?
the issue is at this rate, by the time all changes have been done to use v9, discord will release v10 and discord.js v13 will never come out
and theres no eta ( afaik ) for v9
v9 has almost no breaking changes afaik, so switching over shouldn't take too long
v9 isn't likely to have THAT many changes
let's start worrying about API versions when they're actually documented, thanks 
I assume you mean officially documented, right? Because there was a commit yesterday for v9 https://github.com/ajpalkovic/discord-api-docs/commit/837332720fc4efc5686fa4deb96eea126fe3708d
Right, that's what I mean by "officially"
on I didn't know there was another commit
there was one a few weeks ago
We can start discussing implementations of threads once the features API is solidified and a PR on the original source repository discord/discord-api-docs, not some fork (which is already deleted)
A merge will of course require the implementation to be tested and the docs PR to be merged
Node.js v16 is out also 👀
that's also not relevant, because by far not LTS
v16 will be LTS
yes, at some point that might factor into library development. at the moment LTS is still 14.16.1
Node v16 is scheduled to become LTS near the end of October 2021. D.js v13 should hopefully be released way before that happens
i wondered how exactly a discord library like this on fetches "incoming" messages (like in this case with client.on("message", msg=>{...}))
Why would you need to fetch a message?
does it, like, fetch every latest message of each channel of a guild and compare it with the previous fetch
No, it’s an event received via the ws
ah makes more sense
woah, sorry to spark such a controversy, thanks for the opinions (Souji, of course, was looking on a grand scale, although so far it seems like going to v9 might not involve a major change for the library somehow, all speculation for now though so I'll shut up)
@ruby terrace interaction routes dont use the bot token anyway
WebhookClient is the easiest way to implement it afaik
otherwise youd have to copy all the methods
That's an error in the latest PR's that add editMessage and deleteMessage, they should be passing auth: false to the request anyways
what's the point of resolve and resolveID if they depend on cache
resolveID does not depend on cache, whereas resolve does as it is attempting to give you the cached instance
Hey. I was wondering if there is an official port of discord.js for deno. I found discordeno but I'm not sure if that is the official one
no, there isn't any
I see
Thanks :)
will v13 support slash cmds / interactions in general
Yep, they already said that
but then we can just use manager.cache.get()
so resolve is useless
no it isnt
get must be passed an ID, resolve generically supports being passed any resolvable and returning the right thing
eg GuildMemberManager#resolve works with GuildMembers, Users, IDs
oh
Hi, I'm talking about djs-next, what is tsyringe ?
?npm tsyringe
@clever crypt can you elaborate on https://github.com/discordjs/discord.js/pull/5448#discussion_r619358828 or is that resolved?
@vivid field resolved
Hey, do you know when stage channels will be supported by discord.js ?
with the next major release (v13)
if you want to test it you can install the master (development) branch:
instructions and caveats: <#djs-help-v14 message>
Why aren't the Discord embed types not sub stringed? Like this would make much more sense to substing the embed types not just trow an error saying that there are too many characters.
Why should the library be responsible for something at the fault of the user?
Its your responsibility to make sure the input is correct.
Thank you!
And, do you know if the parameter dynamic of ImageURLOptions will turned to true by default in V13?
no
There was a pr, or at least a discussion, about having it be true by default but it couldn't be done in stable because it's a breaking change
Yeah I understand, thank you
what was the reason behind this change?
Encourage the user to handle errors properly, actually checking the message still exists before they delete it etc.
You can change it to client.setTimeout(message.delete, 10000) no ?
No
why couldn't you 🤔
Many reasons that are outside the scope of this channel
If i wanted to do this issue, what git commit message would I give it like feat or chore?
feat
so
threads
docs are available and looks like lib devs will have access to test them before full release (which will be in at least 2 months)
Already working on adding them, might make a draft PR if someone doesn't beat me to it. I'm thinking to add threads into the channel cache since they are truly channels at heart, then have a #threads on text/news channels that is a ThreadManager. That way they can be accessed globally and in the guilds cache but still have references in their actual parent channels
Also, definitely need to wait until after that disclaimer about potential breaking changes is removed
Yeah we get updates from Discord Developers too. They're API v9 though which although is supposed to have basically no breaking changes, isn't what v13 has been written to so far
Could be an easy switch, but I don't know if we'd want to wait another 2 months on deploying the other features
So far (of course subject to change but hopefully not), I think switching to api v9 would be a non-breaking, non-major change for the library, its already using the PATCH method for suppress-embeds which is the only actually breaking change for v9.
But yeah I agree the release of v13 should not be delayed for it no matter what
Does a pr take 3 approvals to merge?
there isn't any specific number for that
@slate nacelle https://github.com/discordjs/discord.js/pull/5566#issuecomment-830243300 here, did you mean that first we should split by the first char in the array, and while there are any splitMessages left that are longer than the max length, split them with each other char until we achieve a length less than the max length?
When will package.lock be updated to lockfile version 2?
probably not soon
since it's not really backwards compatible, and v16 isn't LTS yet
Hey! When a client creates a shard, it emits messages to the debug event listener. One of them is IDENTIFY followed by the id of the shard over the total number of shards. However, this display method is confusing.
For example, let's say a shardManager creates 3 shards. The last IDENTIFY message sent is [WS => Shard 2] [IDENTIFY] Shard 2/3 which could mean that the 3rd shard wasn't created yet.
I think it should be changed to [WS => Shard {ID}] [IDENTIFY] Shard #{ID} ({ID+1}/{total}) where ID is the id of the created shard and total the total amount of shards to be created.
That's not happening, as shard IDs are 0-based
Think of shards like an array, the ID being the index, the count being the length
But 0/3 being the first and 2/3 being the last is really confusing and doesn't make any sense even if it's 0-based.
Could we? Yea! Should we? ehh..
The docs also show it as 0-based, and it'd stay consistent with that and how the identify payload works. We could add a (normalized ${shardID + 1}/${shardCount})
??? How so?
const arr = [0, 1, 2];
arr.length; // 3
arr[0]; // 0
arr[2]; // 2
arr[3]; // undefined
The id is a 0-based cardinal number, you're right ;
in (position/total), position is an ordinal number tho, which means by definition that it has to be between the minimum value of total and total (included).The minimum value of total cannot be 0 so position must be included in [1 ; total]. Showing (value1/value2) implies that the two values are comparable and thus have the same meaning. An ordinal and a cardinal do not have the same meaning at all... Anyway, this debug line is just a detail.
Hey guys I am making my own client and am here for some guidance (don't worry it's totally unrelated and not a discord.js competitor)
So the thing is, I am confused what to do.
My initial plan was to connect to the gateway and cache the session id. Whenever the bot connects after that, use Gateway Resume instead of making a new session.
But would this be a good idea? What does discord.js do?
this channel is for the development of discord.js, not to help develop other libraries for the discord bot API
Well then is there any other channel to ask such a question? Or is it banned D:
Making your own client is already not really ToS conform, so it will be kinda hard finding a good place to ask such a question
Why is it not TOS compliant? I'm contributing to open source and helping people.
If you mean your own library instead, the discord API server is always a place to ask in #resources
Oh yeah I mean library, sorry for the confusion
Thanks I'll take a look
Why aren't the Discord embed types not sub stringed? Like this would make much more sense to substing the embed types not just trow an error saying that there are too many characters.
It's not the library's responsibility to check your input. It also makes it harder to maintain, if discord ever changes their limits
It's better in that way to let the API throw the error like it does
to add to that there are a ton of different limits that need to be enforced. for example the "all characters in embed values can not exceed 6k"
in which of the up to 25 field bodies to you substring? why? do you just delete fields if you don't have characters left?
how do you handle the description? does it have priority over fields?
the title seems important, so maybe always use that... but what if field titles are already taking up too much space with the description, do you just show field titles? or field titles and values until that's depleted?
do you prioritise the footer over fields? or not?
etc.
Is it even possible to add possibility for bot to manage that settings?
I saw some discussion on discord support about that
https://support.discord.com/hc/en-us/community/posts/360043320632-Allow-bots-to-access-explicit-content-filter-endpoint
if its possible, function for that would be useful
No it isn't
Add event : on_bot_add
Or something linke this
what is that supposed to be
That if someone adds a bot is happening an event
Sory translator mistranslated xD
you can listen to guildMemberAdd and filter bots? I don't think a whole new event is entirely necessary
That would already be very achievable by listening to the guildMemberAdd event and checking to see whether the user is a bot
^
plus I'm sure there's a way to make your own event. Come to think of it, I should do that
But I mean that as someone will invite __ bot with this event __ something happens
And not that as the bot is already on serwer
Oh
That's what sweat
so you want to know who added the bot? I'm not sure the API handles that, correct me if I'm wrong
You need to fetch audit logs
yeah
this is 2 years ago, something may have changed
If that were the case then I'm pretty sure they would've said something by now
Sorry for the late response but on node v14 (npm v7) it automatically generates package-lock with lockfile version 2
I know
And that's why i said what i said
but v14 is LTS
Also no, node 14 does not come with npm 7
15 does
but it prompts you to update when you run npm commands
and v7 is not in beta, it's the latest release
it's what gets installed when you run npm i npm -g
Prompts you because node 14 comes with not the latest npm 6
And yes, correct, it's latest release, but it's different major, and as expected, has breaking changes
Which in this case rule out backwards compatibility
does package-lock change backwards compatibility all that much?
This change only adds things it doesn't remove anything
and I believe if you use an older npm version it converts to version 1
It doesn't convert
It warns about unknown version
it did when I was using it
it automatically changed the file and warned about the wrong version
Yeah ok. Still doesn't change the fact that lock file in such case would be constantly swinging around.
Npm 7 does not come with latest LTS, and we don't require node 16
is node 16 even a thing?
OH I thought the "Current" version was v15, was not aware of the update 
Both 16 and 15 are current rn, look at linked time table
V16 doesn't really add features anyway
It does add features, though their usefulness is questionable
It’s a new LTS regardless. It’s not about features but the long-term support it has for us in case there is bugs or whatever
Since they will be fixed in an LTS compared to v15 for example
Region changer for VCs?
like
message.member.voice.setRegion("EU") ?
VoiceChannel#setRTCRegion already exists
oh
there are multiple instances across the library where optional parameters are marked like this which does not work properly in the docs website (the name of the variable should be wrapped in []). Should I make a PR to fix all of these or is this somehow intentional?
You're confusing it with optional param, the ? here shows that it can be null
No, it's using node-fetch.
ooohhh I did not know that indeed, thanks for the info and sorry for the confusion :)
New slash commands for bots! Performing actions with bots is easier than ever. Bot developers—when they’re ready, please don’t scare them—can have a list of commands available for their bots accessible by the forwardslash key (/). You won’t have to remember bot commands anymore and get laughed at when you get the command wrong :( !help…..!help….please
Any idea when and if this going to be in Discordjs?
#5448 in discordjs/discord.js by vaporox opened 1 month ago (changes requested)
feat: interactions
📥 npm i vaporox/discord.js#feat-interactions
it is this PR iirc ^
yep it is it (cf the pinned messages)
When will djs update to v9 for threads?
Like how long after it comes out?
Hopefully it won't be like slash commands, it's been like 6 months since it released and the pr still isn't merged
as always, when it's done
The initial announcement of the developer beta wasn't even 6 months ago, let alone actual release (which has still had more changes since). It also went through a complete rewrite via a second new PR
you're welcome to contribute to the PR btw
Why can't @everyone mentions be disabled by default? It would make much more sense to make a option to enable it
this isn't channel for suggestions for discord
Ill make sure it wont be merged in the next 6 months then
Bringing the discussion here so it can get answered quicker than on GitHub.
As of now, <BitField>.has(undefined) returns true which may be problematic if you've made a typo in your code (e.g.: <Permissions>.has(<Permissions>.FLAGS.MANAGE_SERVER)).
<BitField>.constructor.resolve returns defaultBit if typeof bit === undefined.
Now, how should the library behave if undefined or [..., undefined, ...] are given to BitField#has. My first idea was to throw an error, like we did for earlier versions with string flags, but this message from Monbrey > #djs-help-v14 message kinda confused me.
- Should
<BitField>.constructor.resolvethrow an error whentypeof bit === undefined? - Should we silently ignore undefined bit(s) and do not count them ? (
<BitField>.has(undefined) === false)
Where can I suggest?
I'd personally be all for an error given that undefined is not BitFieldResolvable and the arg is required
Well that's my opinion too, updated my PR let's see what it'll give
Hi. I've noticed more than once that my server IP become temporarily banned from discord due to exceeding ratelimits, specifically due to multiple webhook clients (which are dynamically generated by user configured webhooks). I would assume this is because of a global limit of 50/sec? Does the library not handle this?
don't think that lib tracks that
it probably should given that I'm using it's WebhookClient class
Unfort. its hard to track but global rate limits are handled
Each WebhookClient uses its own #api internally, which has separate ratelimit handling
but global limits should be taken into account IIRC
which means you'll hit between 1 and N 429s for global
but N tends to be fairly small...
we ran into fairly large 'N' on our prod bot and and a while later https://github.com/discordjs/discord.js/pull/4711 was pushed and finally merged after being dusty for ages
you def shouldnt be running into this frankly
cc @tacit crypt
You got... 429d... on your bot token, by using a webhook client...?
they got the 10k ip ban
Thats on a bot token tho?
no, its ip
it's an IP ban, yes
Is it? damn
Are you sharded?
only 6 shards
And you use the same webhook on all 6 shards?
well 4711 was only merged to master, so djs 12 won't have that fix yet
oh, right
ah so it's not in stable, that explains it
might have to merge that specific branch into a fork of V12 because it's very inconvenient
sorry I missed this. No, it's based on user specified settings, so it has to be a new webhook client in each event (for a logging module)
theres a new clientoption to handle the 50/s global rl
oh i think thats what ckohen mentioned
but yeah that probably wont help u
are you getting the "you have been temporarily banned from our api for consistently exceeding our ratelimits" error?
yes
that PR would at least back off
the solution might just have to be making some queue system that runs on a cheap VPS that handles these across all shards, as those obviously make this a lot harder to handle
is there a reason u arent just sending via the bot
would it really hit 50/s?
I mean it has
when night helped me debug it the first time it happened, almost every one of the ratelimit requests occurred on webhook routes
hmm
do webhooks have ratelimit headers now
this is because I allow cross server support if the owner wishes to do so
u can still send cross server via the bot tho? 🤔
the bot isn't guaranteed to be there
ah
so the server provides the webhook url?
yes
cough didn't that go slightly offtopic?
you're right, was just asking here to find out if it was a lib thing and it turns out there was a PR for master, just obviously not on V12 yet lol. thanks for the input
can MessageType be updated to include all the new ones?
You need to be a bit more specific than that
These are the current djs ones
But the discord doc has a load more now, including ones like reply which would be very useful
Those will come with v13, for example reply and application command are already there.
The thread types will come with threads, which will still take some time and no idea what the last one is.
👍
INVITE_REMINDER is related to a system channel flag
The InteractionReplyOptions links to WebhookMessageOptions in docs, which isn't completely correct as the latter one has some extra fields. Vaporox and I had a talk about it (#djs-help-v14 message) and the problem was that making a new typdef would result in code duplication for the third time.
One potential solution that we arrived at was creating a new base typedef that will have all the common fields which MessageOptions, WebhookMessageOptions, InteractionReplyOptions, and ReplyMessageOptions (yet to be merged) can extend. This will result in no code duplication and a correct documentation.
I wanted to discuss about it first before working on it just to make sure that this is what we want.
Don't really know where to put this but is it possible to improve the embed sent with discord.js.org links so that it shows more information about that link?
Stuff like https://discord.js.org/#/docs/main/master/class/CommandInteraction could show CommandInteraction extends Interaction, maybe a list of properties and methods, the branch that it's taken from and a link to the code
Not really no. We can't really do SSR and pre-generating all the pages depending on stable/master/version/branch doesn't seem necessarily worth it.
It would also make the embed unnecessarily big, any reason why this would be particularly useful?
well you could show less info if the size is a problem. I just feel like having at least the name of the class/typedef/whatever you're linking, along with the branch would be useful and you can take those straight from the URL (although that can be unreliable)
Yeah but there isn't necessarily a big benefit in this
It would just look nice and would help people quickly understand what they're gonna find once they click the link
The benefit doesn't really outweigh the work required for it here sadly
Fair enough, I'm not sure how these docs are even generated so it might be harder than it seems, thanks for the feedback!
hey guys anything?
it's been 12 hours, give it at least another day before bumping
Question about this issue : https://github.com/discordjs/discord.js/issues/4284
Anyone knows if there is a patch or a solution?
There is still an open issue that came after that fix: https://github.com/discordjs/discord.js/issues/5063
I'm having the issue too. Seems to be an issue that comes back all the time xD
Quick question: what's happening in the options.types type in the ApplicationCommandOptionData interface? It has 2 values and 1 of them seems to link to the other and, when writing in TS, we don't get autocomplete like we do with permissions, intents, etc
ApplicationCommandOptionType are the strings that you can pass, ApplicationCommandOptionTypes their corresponding numbers
ah gotcha, why aren't they autocompleting then?
they should be
Could you try to reproduce this? Maybe I'm doing something wrong
oh, could actually replicate
but i guess that's a problem with typescript then, not with discord.js
Well I can't get to the value of ApplicationCommandOptionTypes since it's an import and for some reason my IDE doesn't let me open discord-api-types/v8 but maybe there's something wrong with that?
You could try declaring the types directly in index.d.ts instead of importing, not sure if that would fix it tho
you can open it, just ctrl+click the import
yeah I know but it doesn't work
just doesn't do anything
but it shouldnt really matter where the enum is declared
I can't find a folder called discord-api-types in my node-modules either
even tho it will have to be declared locally anyway with discord-api-types v0.19
then you didn't install it probably
I think I did tho
lemme try again
yeah just reinstalled and the import still has any value 🤔
I can ctrl click all imports except for discord-api-types/v8 and ws
I think the package isn't declared as a dependency
I was having some weird issues with ts imports too, both in master and -next (it is a dependency and is in the modules folder though)
Is it a dependency? I can't find it in my package-lock.json
dev
it's a dev dependency
well those don't show up, that might be why
They're not getting imported when installing the package
yes, you have to install discord-api-types and @types/ws separately if you don't want them to fall back to any
ooooohhhh
it works now
it was that simple huh
I'm curious on the decision for how Role#edit() is made to work, since from what I can tell reading the code for it, it always sends the permissions field to the API although the API considers it optional, so just trying to edit a role's colour or name can cause a Missing Permissions error if the bot doesn't have at least the exact same role permissions as the role it's attempting to edit, or maybe I'm just missing something/doing something wrong to cause this?
Continuing from #archive-offtopic message
@old kelp proposed merging create and edit into upsert, as it's the term for "create or edit".
However, since the edit part isn't a patch, but rather a full rewrite (override, if you will), it matches set's description, which also creates.
This also wouldn't break consistency with existing methods in the library, e.g. member.roles.set. While I don't recall upsert being used anywhere else.
What are your thoughts? @tacit crypt
what's this for? If it's for permissions, upsert makes sense, even if we've never used that term before (and that's cause we never have had a call where PUT or PATCH would yield the same)
so are we going with upsert?
cc @solemn oyster @tacit crypt
thing is, with permission overwrites, create and edit do the same
no 
Yes?
no
Souji dear
vlad dear, i broke that discussion loose 2 times, and every time i in the end saw that space was right and i was wrong, they are not the same
Look at the source code for the overwrite methods, they do 1:1 the same code??
Casein point
bump again kyra, vlad, so are we going with upsert now or..
iirc i said upsert too at some point, I can't speak for kyra or crawl tho
@unique axle could you elaborate on your point?
is it not same just for making it more verbose to users, because they internally work the same, otherwise i'm missing something?
nvm, that was GuildChannel#createOverwrite and GuildChannel#updateOverwrite (they don't do the same, hence why they still both exist)
which:
thing is, with permission overwrites, create and edit do the same
sounded like
They do do the same?
Souji dear..
no.
WDYM NO??
Look at the code
i literally argued about that for hours with space and i lost
they don't do the same
update retains other bits but the ones specified, create replaces them
Wat
OH, I see
Still, code deduplication would be ideal
<#archive-internal-lib-discussions message> (internal)
Yeah the difference is that update appends it, as space said, while create just..creates
But the end API calls and checks are the same in a way
So, those parts should be deduplicated in a private function
add an event "raw gateway response" or something
basically a way to listen for everything the api sends back to us
ah, is it undocumented?
ye exactly
thanks
so should i finally go for upsert..
No, edit and create do different things, but their end code is the same except for one line
so should edit call create then?
you should have upsert as the base func, create call it, and edit call it with the existing overwrite
Let me get you example code
Think ```js
class Example {
upsert(userOrRole, permissions, reason, old = null) {
userOrRole = this.guild.roles.resolve(userOrRole) || this.client.users.resolve(userOrRole);
if (!userOrRole) return Promise.reject(new TypeError('INVALID_TYPE', 'parameter', 'User nor a Role'));
const type = userOrRole instanceof Role ? 'role' : 'member';
const { allow, deny } = PermissionOverwrites.resolveOverwriteOptions(options, old);
return this.client.api
.channels(this.id)
.permissions[userOrRole.id].put({
data: { id: userOrRole.id, type, allow: allow.bitfield, deny: deny.bitfield },
reason,
})
.then(() => this);
}
}
class PermissionOverwrites {
update(options, reason) {
return Example.upsert(this.id, options, reason, this);
}
}``` but you'll need to make it prettier (theres a PR that makes it to where we can specify the type, so.. that might be good too)
I think this would be accurate-ish
could be cleaner, shoving everything in an object too
CC @wild flax @solemn oyster
shouldn't the base method be in PermissionOverwriteManager and make that call in PermissionOverwrites though?
oh, that's what you technically did.. i'll come up with a cleaner implementation and re-ask for review, thanks 👍
Yeah, think Example as the manager
was the code link in the docs removed?
I can't seem to find it for some reason
also in the "Links" section of the welcome page
not that, the code link in each property
this?
never knew it existed tbh, thats useful
ye I can't see that
lmao really
but I don't see that button for some reason
try hard reloading?
yep did exactly that and it worked
thats odd
ty
resize your window, something weird happens there sometimes that pushes it farther out
it was maximized ¯_(ツ)_/¯
What discord gateway link is using discord.js?
gateway link??
when you are connecting to the gateway and receiving payload with the websocket, you use a link like wss://gateway.discord.gg/?v=8&encoding=json
Yes, well that very much depends
Encoding depends on if you have zlibsync installed, but overall we are on gateway version 8
oh thank you
lol, the 2nd is not so relevant
You'd be better off just looking in the Constants or WebSocketShard
fair
Convoluted mess

one day
is discord.js master branch updated to gateway v9?
there's a PR for it
#5570 in discordjs/discord.js by ckohen created 12 days ago (review required)
feat: api v9 and threads
📥 npm i ckohen/discord.js#threads
gateway v9 is planned for the upcoming discord.js v14
There are some backwards incompatible changes with gw v9 that will be released over time, and stable doesn't even use v8 yet
oh, gateway, not api, my b
How does D.js get the GuildMember#joinedAt ?
Of course it has to be exposed by the API itself, but I'd like to hear where x)
when asking that kind of question you can often find the answer by just looking at the API docs https://discord.com/developers/docs/resources/guild#guild-member-object
joined_at ISO8601 timestamp when the user joined the guild
@solemn oyster mind jumping in a VC with me for a sec?
uh,,
Is this going to be related with the library?
yes
give me a sec, gonna restart discord
Ok
We concluded a structure called ApplicationCommandOption (as opposed to a plain object with a typedef) would be a sensible way to approach this
And it'd also refactor away ApplicationCommand.transformOption (they'd be transformed inside ApplicationCommandOption's constructor) as well as allow us to add isEqual in them for fast deep comparison
The idea behind checking for equals recursively is so we can dynamically build a framework which updates the registered application commands on Discord automatically, without us needing to write migrations or pushing all commands in every log in, which can be rather inefficient
So it would load files like a regular framework, then fetch API and compare?
yes that is pretty much the thought
Sounds reasonable for received options, but how would that approach handle options passed by the user?
Isn't that pretty much framework independent? It's not like regular users can update one bot's slash commands
I mean the users of the library
You shouldnt need a framework to create/update application commands
Need, no, but you never needed one for regular commads either
It just makes it easier
That's why I'm asking, because from what I understood, for commands.edit()/.create()/.set() you would still need a transformOption method or similar
The ApplicationCommandOption structure sounds great, but handling received interactions should be left out for the user to implement.
I assume you would then need to pass it an instantiated ApplicationCommandOption which would have a toJSON method for readying it for discord. (not sure if I'm a fan of this)
This is already separate
I guess that would work, but constructing a new class instance only to convert it back to an object right after also sounds a bit expensive
yeah, that's why I'm not exactly a fan
We're already building an object, instantiating a class is no different
That's not needed, if the properties keep using the same values, then there's no need for a toJSON
Will the BLURPLE string in
ColorResolvable be updated to match the new blurple?
Yes
Mind you, this will most likely happen in a non-backwards-compatible fashion since we are increasing the major version
So Ill have to switch my v12 bots to using the new color manually then?
No. It means we’ll switch the color and when you update you automatically have it
Usually you aren’t allowed to do that as a library, since users might still want the old color without us forcing it on them
will have to do some figuring out regarding the new default icons, they're not numbers anymore 
eh, v13 is a major anyways, might as well flip colour codes and avatars
Ah got it. thanks!
i assume the cdn images will be updated (pinged mason about it a bit ago)
the client has always used /assets instead of the cdn ones
I noticed the default avatar URL no longer works. Is this a bug with the library or discord?
By "no longer works" I mean it links to the old one(s)
you could read messages just above yours, and judge on your own why it links to old ones
oopsie, didn't notice, sorry
is this what you were talking about https://discord.com/assets/1f0bfc0865d324c2587920a7d80c609b.png ?
yes, that is /assets
Adding the bigint type for RoleManagers made things slightly more annoying for typescript devs, is it possible to remove this type for this and other managers that have this?
what
what are you talking about
Whenever I try to access a guild member's roles, the manager has those 2 types which makes it so TS always throws an error when trying to remove/add roles for example
Talking about the master branch btw
Please post the associated code with it
ok sorry I missed some context. I'm getting this when accessing a guildmember through an interaction, for which the roles object is a Snowflake type sometimes, which comes with that `${bigint}` type
the line is just this
Yes.
Is this intentional?
fairly sure it is, and it's array of snowflakes when there is no bot
How would there be no bot?
interactions don't need a bot
Interactions don't require a bot connected to the gateway or in the guild
even if it's a commandinteraction?
of course
what difference does that even make here
that we have to specify the type for the rolemanager every time we want to add or remove roles which is slightly annoying
well, it is accurate thats for sure
your code will break if you don't check first
well in my case my bot is only in 1 guild and I'm sure it will always be there and have access to interactions so I don't think any checks would be needed
Sure, whatever, but that doesn't mean we can change the typings just because you have no use for it
Yeah of course but it seems like such an edge case that will cause so much trouble for other users and isn't even documented properly on your docs website
Yeah exactly, doesn't specify any properties for that "Object" so it's hard to know
How is it an edge case? If someone invites your commands via the oauth scope without inviting your bot, you need to check.
You can do that?
Yes.

but it's an Object. it does not have any methods GuildMember would
it could be the APIInteractionGuildMember object which is what is given in TS
I dont know if this fits here, but is there a version of discord.js that doesnt use the fs module? I need to run it in the browser, which doesnt offer the fs module
webpacked versions of d.js aren't supported anymore and don't work
aw
ill write my own wrapper then, thx anyways
@untold python I don't think you can make any request to the discord api in browser now
yeah
Would it be thinkable to add an APIEvent enum containing all currently available events? That would simplify event handling implementations. Possible benefits of such an implementation (and the issue I am currently facing) are described at https://github.com/microsoft/TypeScript/issues/10570#issuecomment-769442192
I do see that solely supporting such an enum in the library itself would be a breaking change. However, one could merely provide support for using the enum for listener registrations as an alternative way to the current one.
Admittedly, this is a bit of a minor inconvenience, but it bothers me enough to propose such a feature.
I am quite new to d.js and apologize if such discussions have already taken place.
Also, I'd be happy to create a GitHub issue if need be. Thanks!
Would keyof ClientEvents not be sufficient here?
:/
I initially thought so too, but
abstract class Parent {
abstract event: keyof ClientEvents;
}
class Child extends Parent {
event = "message";
}
throws an error. TS cannot infer that event in the Child class is indeed a keyof ClientEvents, but interprets it as a string instead.
Instead, you need to assert the type manually each time:
class BetterChild extends Parent {
event: keyof ClientEvents = "message";
}
It works, but it is an inconvenience that could be avoided by using an enum that would allow for TS to automatically infer the correct type
Using event = "message" as const; seems to work.
This seems more like some "TS is not smart enough to infer that properly" than something we can do.
That's totally true, see the issue I referred to above. The enum is only a workaround to TS being incapable of figuring out the obvious on its own
Would it be possible to create a latest pre-release with the latest commit from master and publish that to NPM so that we can more easily use that version? The website I'm currently hosting my bot on doesn't seem to support installing repositories as dependencies
That's not possible but you can fork the repo and publish your own fork of djs on npm under private scope
How is it not possible? I've seen multiple packages do this
I don't know about that but publishing unstable changes doesn't sound like a good idea and it will also mess the versioning
You can have a latest release that always gets updated with every commit to master and label it as a pre-release. This wouldn't affect the stable version and thus the version that would be installed through regular npm i discord.js
which packages do that?
do they have breaking changes between commits that are published under that pre-release?
Unfortunately I can't find one anymore but I remember seeing a pretty common package with a latest release on github and npm
Found a gist on this: https://gist.github.com/schmich/d04acc4b02b45e489f329cfdf3280a3f
You may not want to make every release a rc but you can make a workflow to automate this process and publish v13 under the next tag
And here's a slightly different approach which may be more similar to what you're looking for https://gist.github.com/tfennelly/f1d573d935f4e9e9b4d1ee1b0ab6c04c
Thought about it before already, decided against it
Any reason why?
Yeah, if we ever have some sort of hotfixes because our master isnt stable, we need to think about re-releasing it constantly
It's not worth it, you are much safer just pinning a commit that works
you can automate the release process with a workflow that runs on every commit though
Yeah thats not really desirable for us
We don't want a new release on every commit
Fair enough :/
this sounds like the biggest pain in the ass right here, wtf
It's by design. Slash Commands are designed to be usable with a bot - headless functions running on CloudFlare workers for example
*without
yeah ty, without a bot
That makes sense, I just put a message in the interactions channel too, but is there a way to handle when someone adds your commands to a server even if they don't authorize the bot scope? Like a webhook, etc.? If so, can the library handle it and emit an event?
No, not in discord.js
don't think there is a way to get an event for when someone adds an interaction without a bot
...unless it emits the ws event anyway?
what ws event
well any of them
i mean, there is intehration create, not sure if it's relevant
INTERACTION_CREATE, APPLICATION_COMMAND_CREATE etc
but then again, if there is no bot, there is no ws
Yeah that I wasnt sure on, makes sense
In many cases, you may still need a bot user. If you need to receive gateway events, or need to interact with other parts of our API (like fetching a guild, or a channel, or updating permissions on a user), those actions are all still tied to having a bot token. However, if you don't need any of those things, you never have to add a bot user to your application at all.
https://discord.com/developers/docs/interactions/slash-commands
Thats not true
the WS event emits either way
well, but if you don't have the bot app, you don't get the event (unless you connect to ws on your own, obviously)
and do you get the ws event from guilds you aren't on?
Got it, makes sense. My app does still have a bot user since it needs it for some functions, but it also has commands that work perfectly fine without the bot user. What I'll just do is check each interaction, and if it needs a bot user it'll reply saying it needs additional authorization and send the oauth link for a server admin to fix it. Thanks guys!
yes you do. if sharding, it will be sent to the shard that the guild would be on
@oak quail moving discussion
TextBasedChannel handles it like this
apiMessage = APIMessage.create(this, content, options).resolveData();
if (Array.isArray(apiMessage.data.content)) {
return Promise.all(apiMessage.split().map(this.send.bind(this)));
}
So I guess reply with split would have to be
if (Array.isArray(apiMessage.data.content)) {
const split = apiMessage.split();
return Promise.all([this.reply(split[0]), ...split.slice(1).map(this.followUp.bind(this))]);
}```
Unless you can just send everything as a followup?
You have to send a reply first (or edit the deferred reply)
I think followUp edits a deferred one, but if it can't send an initial it'd be this
If it's an editReply with split data they can all be followUps
...no nvm
edits shouldn't take split options IIRC
followUp did edit a deferred one in the past, but I think that was for backwards compatibility, I think it has changed
So use case - deferring, then sending a split message
Can that be handled and if so how?
It could be handled, but you'd run up on weird situations where there are messages in between
followUp should honestly be calling .webhook.send with the created apiMessage after data and files have been resolved, and Webhook#send line 172-174 should move outside the else statement
I really have a very huge bot and it is known as well and there is play sound when it starts the result is a very large pressure on the server so if you have a solution I will not reprogram it in c ++ language I am sure that you have a problem playing sounds so always the huge bots do not use your library
discord.js voice is not designed to be the most powerful broadcast solution
If your needs are above the expected target, feel free to design your own solution or use an existing one (Lavalink for the most popular one)
There are no flaws in how discord.js handles voice features
Also, sending encrypted audio data will always require some resources (in CPU for the most) no matter if it's being made by discord.js or any other library/solution, so the issue of the pressure will stay as long as you don't split your bot logic and your audio between two machines, or if you don't upgrade your current machine resources.
Of course I know lavalink but I want to make discord.js an integrated library
Would it be possible to make an auditLogEntry event for Client?
No.
the client only has events for websocket dispatch packets that come in from Discord
there is nothing to signal audit log creation
alright, i'll try to manually make it then
Can't - the very reason I didnt do that is to support ephem. Otherwise we'd be changing WebhookMessageOptions to add ephem, which is incorrect for every other webhook
you can, if you resolve the data and files in followUp, it will use that resolved data and files in Webhook send, it doesn't re-resolve
Hmmm fair enough, I'll take another look.
Not sure if this has been brought up before, but something that would be really useful are hooks. Here is a use case:
When discord.js gets the users, you would have a $beforeUserLoad(UserManager) hook where you can inject your own data into users. Then if you have sharding, it would shard all the users with your injected data
It would be the same for guild, so $beforeGuildLoad(GuildManager)
Extendable structures are discord.js's way of doing exactly that
You can extend the structures but you cant add the data before it gets sharded afaik
Wdym when it "gets sharded". When you shard, all events and results of api calls are sent directly to the corresponding shard process
Essentially when all the discord users are cached, i would want to have a hook where i can make a request to my own api and map that data to users
The only issue I see with that is that it’s async. Constructing/caching a user wasn’t made to perform async calls
Can’t you just fetch the data on demand?
yeah i could 
I have a suggestion, regarding too the broadcastEval in the Sharding Manager, you should add a optional option, where the promise should be resolved/rejected after a certain time, bc when this does not happen --> we have to many event listeners and this could cause a memory leak
imo such timeout should be there by default
no there isnt, I can reproduce the error, go on worker mode, use a code which causes a dom expect error, broadcastEval(this.guilds.cache) --> error, no response.
Do this 10 times and voila, most of the machines will give a event listener error or crash
what that has to do with my answer
i said "should" not "is"
in response to you suggesting there being one only if you pass the timeout time as the parameter
locking you out for no real reason if you forget to pass it
Hi, how can I download the v13 version ?
there is no v13 version yet. you can however install the version from master branch, more info in #djs-help-v14
can I have slash commands on last version from master ?
check pins in #djs-help-v14
Thanks. Can you just tell me how can I install the master version ?
check pins in #djs-help-v14
Okay thanks a lot
so is there a option for the timeout? btw when will the bug on the sharding manager be fixed (https://github.com/discordjs/discord.js/pull/5559)
i didn't say anything as to if it will be there or not. it was a suggestion
okay, sorry for the misunderstanding
it already does tho.... but just on master so i dunno if that counts
the typings for PermissionOverwriteOptions seem to not match the actual js implementation
wait whoops i forgot to put the typings, sorry
there's also this function which uses a completely different type in the options parameter?
that PermissionOverwriteOptions interface is defined in typings but isn't used anywhere. Whereas the typedef PermissionOverwriteOptions (plural) is defined as PermissionOverwriteOption(singular) in typings. weird 🤔
OH
but then there's the resolveOverwriteOptions function that doesn't even make sense because when it was added ( https://github.com/discordjs/discord.js/commit/3d8207a3db2e555930d4bf809fe1bc98ec9cb348) , the parameter was PermissionOverwriteOption (which was changed to PermissionOverwriteOptions in this commit https://github.com/discordjs/discord.js/commit/2ee0f1cdc69dcd0c8f870bcecc3d36aef0e44ad1 ), lmao
actually nevermind, i didn't realize the definition was created in the same commit so it couldn't have been the parameters changing or something
it seems to have been a mistake that was added when the function was created and nobody really noticed lol
I looked through all of it and I think the current interface for PermissionOverwriteOptions (plural) should be removed from the typings (I searched it up, this interface isn't being used anywhere in the codebase) and the interface PermissionOverwriteOption (singular) should be renamed to PermissionOverwriteOptions so that it matches its jsdoc typedef. Just want to make sure that I'm not missing anything here. 🧐
https://github.com/discordjs/discord.js/commit/ca5f371f1ad0ffa6b57def34d9f50dc29c149e10
oh, resolveOverwriteOptions's options parameter has actually already been fixed but it's not yet in stable
that's fine but it doesn't solve the issue above
my bad
yeah, it seems like the interface PermissionOverwriteOptions was only used as a parameter for GuildChannel#overwritePermissions anyway, which was replaced by OverwriteResolvable (More specifically it was replaced by the interface OverwriteData, as it has the exact same properties, minus the new type property and the fact that allow and deny are now optional) so there should be no problem with it being removed, with PermissionOverwriteOption taking its place to match the documentation
Any thoughts on https://github.com/discordjs/discord.js/pull/5161#issuecomment-834991380 If not, I'll just close the PR, while its weird that the library contains the same data in old and new, that is what the raw discord event does (by not having old), so its realistic to expect the library to do the same I guess
Sounds good to me
since members might not have joined_at now, should this be changed?
i suppose they still arent "full members" but it is a member object
I was inspecting the typings when I noticed the function Permissions#serialize returned the type Record<PermissionString,boolean> and that there was an interface PermissionObject (which wasn't used anywhere in the code) with the exact same type .
After inspecting the history of the function and interface, I found out that it was in fact previously used as the return type, but was removed (along with the function) when the Permissions class extended BitField<PermissionString> and later added back with this type.
Since these are the only two instances of Record<PermissionString,boolean>, should PermissionObject be removed?
(for reference, https://github.com/discordjs/discord.js/commit/c62f01f0e4e3c24c3227b10704ac3ccf8744a6e1#diff-4f45caa500ef03d94d3c2bfa556caa1642df95d4e2b980d76b876a8fd2e8c522L731 here is when it was removed and https://github.com/discordjs/discord.js/commit/fc27ce1a1533a3c412bcdd9b1ad25ef40b11f544#diff-4f45caa500ef03d94d3c2bfa556caa1642df95d4e2b980d76b876a8fd2e8c522R1128 here is when it was added back)
Any reason for static Util#parseEmoji being private
?
https://github.com/discordjs/discord.js/blob/master/src/util/Util.js#L262
oh I just noticed, there's also Permissions#missing (which was actually added in the same commit as Permissions#serialize) using BitFieldResolvable<PermissionString>, when it could be using PermissionResolvable
What is the point of removing timeout?
Keeps it in line with other methods, also to prevent some problems that arose (eg if it was deleted before the timeout)

Would it be better as public? It's pretty user-friendly already and could serve its purpose since one of the common issues why people are coming here is how to get emotes from a message
No
The output isn't stable
And may change in the future depending on our needs
Oh okay
If you want to parse an emoji, we do expose the regex itself on the class
to at least get the id
@copper laurel do you know what the new buttons will look like? Asking bc of your draft pr
Yes
They look like other Discord branded buttons. Can be blurple, green, red or grey
https://github.com/almostSouji/discord.js/blob/dff4110758affd5849c3df135c4ff1036404b235/src/structures/Guild.js#L105
Any reason why nsfw property is assigned to Guild here instead of in #_patch? I tried to log <Guild>.nsfw and it logged undefined then I moved it inside #_patch in the source code and it logged false correctly.
Found this while working on the nsfw_level PR. Same issue there. When I move the property assignment inside #_patch it logs DEFAULT correctly otherwise it's just undefined
It should be in _patch. Must have slipped through 
Discord only sends unavailable guilds in ready, which we then patch with their relevant guild creates.
So only newly joined guilds would have that property set if it's in the constructor.
I see, I'll update the PR. Thanks 👍
I tried looking for this with no luck, do you have a link to a picture of or documentation about the clicky bois? I'm intrigued
Not that I'm supposed to share
Sorry! Should be available soon
Ah okay, I didn't know it was private info still haha
They’ll probably be “released” on Tuesday
Why does CommandInteraction#channel have a Channel type instead of a text based channel type (TextChannel, NewsChannel or DMChannel, maybe ThreadChannel idk)?
Because it's a getter for this.client.channels.cache.get(this.channelID) which is a Collection<Snowflake, Channel>
And its inherited from Interaction
Where can I post bugs?
What bugs?
.permissions doesn't work correctly
For some members
It returns bitfield 0
Even if they have certain permissions
I really need a statement on this, please
I'd say create a https://stackoverflow.com/help/minimal-reproducible-example and post it on our issue tracker:
https://github.com/discordjs/discord.js/issues/new?assignees=&labels=s%3A+unverified%2C+type%3A+bug&template=bug_report.md&title=
Ohk
Can I send a reproducible example here
sure
I have almost all permissions still the bitfield is 0
This thing worries me when I check for permissions in certain commands
All checks return false
bruh moment
can you do npm list discord.js and send the hash here
Ok
discord.js@12.5.3
This has been happening with me since months
Can't reproduce the bug on stable. You should open an issue like space said and it would be great if you can also drop a link to your bot's repo if there is one in the issue.
what's the point of this? can't we just have in ./DJSError.js's module.exports Messages = require('./Messages');?
oh
Circular references
wait
it only references DJSError.register
also is my vscode broken or is the entirety of /src/errors/ used for nothing? oh nevermind i see now
im confused
https://github.com/discordjs/discord.js/issues/5611
I am going to try to fix this. if i succeed then this will have been my first fixed issue
wish me luck
👋 Not sure if this got discussed anywhere, but it seems the lockfile in master is now v2, which is Node 15+ by default?
Node 14 still ships with npm 6 by default, and the project claims to be Node 14+, but if you actually want to develop on the project this is not the case and you need Node 15, or to manually update npm in your Node 14 install
most package managers ship the latest version (v16) and brew upgrades all packages whenever you run a command
npm 6 can work with v2 of the lockfile, and the library still works with 14
Off the top of my head, won't npm 6 overwrite the lockfile back to v1 if deps are modified?
maybe
Would it not make sense to at least define npm >= 7 in engines.npm in package.json?
maybe
Not sure where else to put this... the invite in the org's description is outdated
it still works
Yes, it just doesn't use the vanity url so it's fine if it isn't changed
Maybe refresh your browser
Bot's repo means like it's files on GitHub?
yeah
Hey, apologies if this is the incorrect channel to ask such a question, but can someone here give me an idea as to when v13 is released, as it apparently has support for the new slash commands? Thanks!
When it's ready
You can install it's in-dev version, see pins in #djs-help-v14
Oh wait, it didn't have it before?
Slash commands support has not been released yet
It will be with 13.0.0
However you can install #djs-master-branch if you want to use them right now, but it's not a stable release
Ah alright
There is support for it, that's what #archive-interactions is for
I meant that it hasn't been released in stable yet
What gateway V is using djs v12
7
Oh ok
I'd like to propose a change to the docs to make it so that the "Default" column in the parameters table displays the default value set by the discord API, even if the code itself doesn't have any default values. This way it would be easier to understand what would happen when leaving certain optional parameters out. Would this be a good idea?
no, re-documenting things is almost always a terrible idea, because upstream docs changes could very easily make the information displayed wrong
It wouldn't be re-documenting as the current docs don't link to the respective page on the Discord API docs
our docs represent our wrapper, not the discord api
what I'm saying is that currently it's quite hard to find the default value for stuff because most are left empty
so the default values are the ones in our code, not from the discord api
ye that's how it works atm, but why not change it?
if we start mix-matching it it would become quite confusing
also we would need to keep it up2date with discords docs
thats also why we don't document what perms you need for certain actions
wouldn't be too hard, I doubt they'd change values all the time and if they did it would be rarely
what about the first point
I don't see how it would be confusing
how are you going to discern what default value is ours or theirs
you're not because it doesn't really matter in the end
if you have a default value on the code, you use that on the docs, otherwise you use the one from the API
yeah it does, we have functions and methods that have default parameters that have nothing to do with discord
yeah I know that's what I'm saying
we'd prioritise the default values used in the code
so how do you document 2 default values then
you don't, you just document the one used by the library
because that one will always have priority in the code over the one the API uses
and what happens to the one the api uses (just in case they are different)
now you decide arbitrarily what to use when
it's ignored because from the moment you have a default value in the library, the default value given by the api is ignored
"oh no this isnt a default from discord, this is ours"
"oh no this is a default from us, not discord"
it doesn't matter to the user, they just need to know what value is gonna be put there if they don't specify that parameter
and we'd put the one with the highest priority
yeah, the user can just open the discord api docs too for that
which is library > api
yeah but the discord api docs are way harder to navigate than the djs ones and its easier to have it all in one place
because saying there is no default value is essentially misleading because the result you will see on discord will have a default value
its not misleading
we don't claim that the discord api doesnt have defaults
its just that we don't have any in the library
yeah but if the library is an API wrapper, it should also document what the API does in certain situations
hmm.. no
no, not really
thats what the API documentation is for
but it's easier to have everything in one place
yeah, thats fair
doesn't mean we are doing it
why not make the docs more accessible instead of telling users to go search in a million places?
:/
the docs are plenty accessible
downgrading their value simply because we don't do this one thing doesn't make them any less good
we still have, to this date, the best auto generated library documentation
that is true but there's always room for improvement
improvement is great, more things to maintain is not
If any default value changes, people will most likely hear about it quickly from the discord staff themselves and make a PR to change it
just like how interactions were released and we needed 2 PRs for it and a 6 month delay right?
I see PRs changing little things that the API changed all the time
I can't imagine that for something thats even more hidden and less important
interactions are much more complex, changing a true to a false isn't really imo
and I don't think that delay was because people didn't know about them
I say that specifically because interactions could have been done in a 2 week window
No, it was because no one was simply doing it. We don't get a lot of contributions for things the API changes
but their release was also quite weird and a lot of things changed
That was also not the reason, this discussion is pointless overall
As it stands right now we arent doing it
fair enough I guess, I'd be willing to do it if you change your mind in the future
you can technically put any type on an embed description but objects and maps will look weird and I doubt people would want to put that intentionally so would it be possible to change the embed description type to string | number | string[] | number[]? It's currently set to any
the fact that they look weird doesn't mean that they can't be passed
Yeah I'm saying they can but no one would want to put [object Object] in an embed description and it would help them identify errors if they do this accidentally (in TS of course)
This is something https://github.com/discordjs/discord.js/pull/4880 would handle
that's different because message.member.toString() exists
oh I hadn't seen that
well, so why not add all other variants like GuildMember | User | Channel to that huge type as well
you don't need to because it runs toString() automatically
but your type would mean that it cannot be passed there at all
i didn't pass a member.toString(), i passed member
but since the toString() function exists, I think ts doesn't detect that as an error
which type are you talking about
the param to setDescription?
yep
why the hell would it care about completely random properties on passed object if the object itself doesn't fit
the only reason why it throws an error is because of the number type, but it is assignable to a string type
for now :)
it won't much longer, so get used to it
wdym?
is that gonna change?
space literally linked it
I didn't see that it would require you to run the function
we aren't doing any string conversion for you anymore, you have to actually provide a proper string (once that lands)
why tho :/
you can't really do const x: string | GuildMember and use x only as a string. if x would be GuildMember, it would require you to call the toString() manually every time, it won't call it for you.
it doesn't matter that it has a function to resolve into string
it literally isn't a string
it does though
I just tested it
yeah it doesn't do that
it only conflicts with number, not string
what doesn't do that
if you have a string type and pass a GuildMember, it works
what works
passing a GuildMember object
Yes, because we forcefully resolve everything you (don't) pass into a string.
yeah and TS doesn't detect that as an error
so its all good
but it still won't work due to the number type, which is stupid
and for some reason passing a number to a string errors
am i missing something
hmm I didn't test it like that, I modified the StringResolvable type to string | string[] and it worked
the c literally isn't a string, otherwise the type would be useless
so anyway, the method works (atm) because it resolves
but you narrowing the type from any to your string | number | string[] | number would mean that you cannot pass anything that you currently can
yeah I know I believe that would be benefitial
if the change that requires strings lands, yes
right now? not really, as the method handles passing some objects (some as in literally anything that has a toString(), so pretty much everything)
technically needing to list them all in the type
since the type is literally going into the bin, i'm not sure what to improve about it and why
well yeah i wasnt aware
thanks for the explanation
I was going through the errors folder to learn how djs implemented custom errors and came across this line:
if (Error.captureStackTrace) Error.captureStackTrace(this, DiscordjsError);
at https://github.com/discordjs/discord.js/blob/b90b0c3cfa2278caa38d1ff41eef2ccf4428b99e/src/errors/DJSError.js#L18. What was the reason for checking that captureStackTrace method exists, shouldn't it be always defined in the Error class?
Looks like another remnant of the webpack build support
hmm, that's what I was suspecting too, just wanted to be sure. Thanks 👍
Any word on when library will be brought in line with button update?
Thanks sorry
It’s maybe been 24h since release. At least a little bit of patience would be appreciated
Im not trying to hurry anyone I was just wondering what the general timeframes are normally like, this is the first API change that will actually affect what I work on for the time being
The activity on that PR is nuts
Is better news than I was hoping for
I've just marked it as ready for review and testing now
Yeah i saw you are a madman
There was a lot of base structure and classes to be built - but it should make future components a lot easier
Thankyou for your service

#5674 in discordjs/discord.js by monbrey opened 2 days ago (changes requested)
[WIP] feat(Buttons): clickybois
📥 npm i monbrey/discord.js#message-components
Buttons are now ready for review and testing, but may not be stable
nice
Just pushed breaking changes to it, FYI anyone already using it
To someone who actually works in the industry, “When it’s ready” is such a cop out response. It allows Scope Creep to become a real problem which v13 is starting to show signs of. So I think many of us, who are relying on new features being implemented, would like a little more effort in that part of the department. We understand things come up and things get pushed back but no reason to set goals for your releases. Setting Target dates is important in any software lifecycle, especially when people actively use your codebase and count on these new features. Anyway, this is just some words of advice from someone who works in the industry as a Software Engineer. Take it or leave, ignore if you like.
A key thing to keep in mind is that you can still use it if you really want it. Installing from master does work and you can choose from which commit.
I think you're confusing "A community-driven open source software maintained on people's free time" with "a professional, paid team of software engineers spending 7.5 hours a day on a project" here. Community projects aren't going to hold to that level of standards of someone that's being paid $100k/year to work on a project full-time.
@sage owl have you considered using your professional experience to help move the project forward so it gets done faster? I'm sure the team would appreciate the addition of a Software Engineer helping out on the project!
Getting back to this because I found that typescript actually has this and they have a lot of releases. I don't think they publish on every commit but it seems like they publish once every day under the @next tag (and other tags too). As someone said you decided against this so, if that's still the case, feel free to ignore this
Also for the server avatar feature, should the guildmember object have a displayAvatarURL() function or just the avatarURL() and avatar properties?
What would the defaulting be
Server avatar > Global avatar > default Discord avatar?
monbrey
attaching Imge file in embed in interaction response won't work
Fairly sure it's on API on this one, someone brought that up before
@outer raven typescript also doesn't follow semver, but that's different topic
Ohk
but can i attach files on interaction reponse
Only in the edits
Dunno why
We know we have a huge community that are excited for new features to be released, but Evie is right. A lot of the staff, myself included, and particularly the maintainers are professionals, we do work in the industry - that's exactly why we don't have the time to manage this like some sort of enterprise scale product.
We don't have a dedicated testing team, we don't do sprints, and the majority of the people who use the library are, to put it bluntly, amateurs. They don't understand how to handle semver major breaking releases.
That ties into a lot of decision making around what goes into a major release, how we can be prepared to support it (eg v13 changes guide) and ultimately, when we are ready to release it.
I get that "when it's ready" might seem flippant and dismissive, but setting a date that we don't meet is pointless. Alternatively pushing out a buggy mess that hasn't been properly tested just because a date was set is even worse.
oh k so no way to attach a file nor show in embed
Also keep in mind Discord also likes to introduce breaking changes from time to time, which screws our release cycle at times
@fair yarrow you might want to use the support channels for this, this one is reserved for discussions regarding the library
when will message components be implemented?
There's a PR for it
ah
nice
?buttons
🖱️ Buttons (aka: ClickyBois):
Discord.js will support buttons in version 13.0.0!
• Buttons are being developed in PR https://github.com/discordjs/discord.js/pull/5674
• You can install and test this using npm i monbrey/discord.js#message-components
• A draft guide is available at https://deploy-preview-674--discordjs-guide.netlify.app/interactions/buttons.html
worked on there
epic
ohk sry
Correct
I made the PR meanwhile and added the display avatar url method which sends the server avatar or the user’s display avatar
What’s semver?

Major . Minor . Patch*
Major for breaking changes
Minor for features
Patch for bug fixes basically
@outer raven Question about https://github.com/discordjs/discord.js/pull/5696#issuecomment-850814155 to not pollute the GitHub feed
Will bots even be able to set a custom avatar server-side?
Very unlikely
I don't see why they wouldn't be able to
What lol
Since it's going to be restricted to their $10 Nitro apparently, I don't think they'll allow that
Can’t wait for some mods to set my image to something I don’t want
I'd find it unlikely they unlock that feature to bots
You really can’t see how this isn’t abuseable?
while those "self host" bots would love it, that type of data storage for large bots seems like a bad idea
Oh, the idea of the bot having one
Puh.
not really no ?
Not even sure that’s smart
bots have nitro features though
I can totally see someone setting a different avatar on their 300k guilds

well yeah
yeah....that
Bots can’t have animated avatars
yeah true
well ignore that comment then lol
About Nitro perks for bots, I don't think they'll grant perks from the $10 one
Not even sure if they might allow any more perk from any of both Nitros (well yes animated avatar is an example)
bots have global emojis
No other nitro features
IIRC they get upload limit based on the guild's boost level
like every other member of that guild, so irrelevant
any chance of changing CommandInteraction#options to a collection with the option name?
I dont think discord enforces uniqueness
The options are send in order as you'd expect them, so i appreciate the array here
oh it does enforce
It's much better to work with collection, so if it's possible (which it should as names are unique) I'm all in for this 👍
will we have buttons with author only funtion?
Buttons are added just like discord did. You can handle author-only buttons yourself
Is it possible to link a method in the docs by using (for example) {@link User#displayAvatarURL}?
youd use @see for that
just search the repo for it
talking about something inside a sentence
@see is a parameter in jsdoc
in a sentence probably not
oh I found it somewhere else, seems like it is possible
https://discord.js.org/#/docs/main/stable/typedef/InviteGenerationOptions this is what I needed
Why does d.js don't support editing an attachment?
I mean https://github.com/discordjs/discord.js/pull/5557 exists but it was interpreted as only deleting all message attachments
But in discord api docs it says that you can also upload new attachments https://github.com/discord/discord-api-docs/pull/2859
If your question is why we don’t support a certain feature, the answer is most likely because no one PRd it yet. This doesn’t only apply to this, but pretty much every “why doesn’t d.js support this”
But we do support it don't we? That PR was changed to allow you to edit with a new attachments array
haven't tested it, looks like it should be possible, but the jsdoc string needs edits if so
@real jetty You still haven't explained why are you confused about #5705. If you have any questions about it then ask. Your reaction just made others to react too without leaving any meaningful feedback. So, It would be really helpful if we can discuss what needs to be changed in the PR using words
Oh well it'll be hard to answer if you don't ping me
@obtuse hazel How am I supposed to know you're not using your main. Anyway, that's not the point here. So, what is it that you found to be confusing?
I removed it, as I thought it would be annoying if the order matters but you can still convert it to an array and the order will be the same. Sorry for this
const user = await message.client.users.fetch(userId)
user_id: Value "a b c" is not snowflake.
would it be an idea to provide a isSnowflake utility function when dealing with user input?
#4915 in discordjs/discord.js by TeeSeal opened 7 months ago (changes requested)
fix: handle crash when fetching members with invalid IDs
📥 npm i TeeSeal/discord.js#ws
Hm alright thanks
What do you guys think of the idea of adding a type called TextBaseChannel and VoiceBasedChannel so that we don't have to update our code so often when a new channel type is added
TextBasedChannel would be TextChannel, DMChannel, NewsChannel and (soon) ThreadChannel, while VoiceBasedChannel would be VoiceChannel and StageChannel
would only affect typescript users of course since only the typings would be changed, no actual code changes
isn't that what isText() does
that's not what I wanna do though, I wanna set the type of a channel when fetching it or something similar
instead of doing as DMChannel | TextChannel | NewsChannel I'd do as TextBasedChannel
when you fetch, you don't do the first one at all, library does it for you
and what would that TextBasedChannel even be? a type union? that still doesn't solve the problem of having to check if it's a dm or not, or if it's a specific type
not sure what would even be the use case for such thing. isText() can be used to somewhat narrow the type to channels you can for example send to. sure, there isn't stuff like isGuild or isDM but you can check that yourself with one line (and if done properly, also narrows the type further)
I don't want to check anything, I want to set the type for a channel that otherwise would have the Channel type, which is why none of those functions would work. These types I'm suggesting would be a union of all the text and voice channel types and would be updated as more are added, so that we don't have to update our code every time that happens
...and what exactly would be the benefit?
property 'guild' does not exist on type DMChannel | TextChannel | NewsChannel | ThreadChannel | WhateverElseChannel
property 'guild' does not exist on type DMChannel```
if you are fetching/getting by id, you can literally just cast to a correct type already.
if you are requiring a user input for an id, you can either assume that if you ask for "log channel" you didn't get a voice channel, or just check while you're in that form, and then just have only TextChannels anyway
there is 0 point in casting it to multiple types and then complaining that it has multiple types
and your union would be exactly that - multiple types that are just a fairly big subset of a Channel, and still need narrowing
true, there is a hassle every time new channel type is added, but there's nothing stopping us from adding the type, especially considering both how infrequently new types are added, and that it's almost sure that new channel type will have new features that would have to be added anyway
I don't see how any of the points you made are related to my suggestion at all.
Yes DMChannel causes issues often, that's not my point.
All I want is to have all text channels in one type and all voice channels in one type as well. Recently there's been the addition of one channel for both of these types and it would just be nice as Discord grows to have them all bundled into one
It's as simple as adding any new channel types to the proper type declaration and updating them as new ones are added.
and what would be the use case for such type
I still don't see how this is different to isText(), which asserts that the generic Channel is one of the three. Type guarding functions are better than casting wherever possible. If the argument is for a way to easily cast what a guard already does for you, I don't agree
Sorry for my review, I thought we used flatMap elsewhere as well, should've checked first
No worries, it was worth looking at because I forgot it existed
@remote wasp im not a huge fan of this pr
because we slowly want to migrate over to discord-api-types
how were the types imported? and what was the error?
yeah, I also don't like this fix myself but the issue can't be fixed without it.
none of the types and interfaces are showing up while importing, wait a sec let me send a ss
It's like djs doesn't even export them
This is the issue: https://i.imgur.com/zkbveg1.png
I have reloaded VSCode and have the latest commit installed (that re-exports the snowflake)
Maybe we should export all of those interfaces and everything that's actually exported then.
yeah that could be a fix that I was thinking too but I had a question in my mind too, which is:
There might be a correct way to re-export types which might fix it but one thing that I don't get is, why are we re-exporting Snowflake. We use a lot of other typings package like for node, ws and other but don't re-export anything. The end-user installs those for themselves and use it. Shouldn't they install discord-api-types and import Snowflake from it?
couldn't that be explained with the fact that snowflakes are basically the most common thing you use to interact with library?
wouldn't make sense to make a type for getting stuff from every single collection/manager and not reexport it in the lib
for the node typings, im fairly sure almost every project installs those anyway, and i think ws ones changed from being required to install manually to being installed by lib
it depends
usually yes
I would agree if it wasn't such a common type
also uh, it doesn't look like the Snowflake export is at fault here then
if we don't export those interfaces, you usually can't import them. I have no idea why it worked before lol
Because we use declare module
whens your PR making a return
I can do it now ¯_(ツ)_/¯
That'll break basically every other pr though
Or at least the ones that touch typings
yeah we prolly want buttons first then
and then your pr
Was going through actions the other day and noticed that MESSAGE_REACTION_ADD and MESSAGE_REACTION_REMOVE have sanity checks for if the event is emitted on a voice channel.
Ex: https://github.com/discordjs/discord.js/blob/master/src/client/actions/MessageReactionAdd.js#L26
Now, I know sanity checking is good and all, but has this actually happened before where the socket has emitted for a voice channel?
yeah! discord can also randomly send typing events to voice channels

That is very strange. I've never heard of that or experienced that before. (probably just lucky?)
If you use a library it won't really happen to you
But if you use the raw api it can for sure happen
and you need to handle it
Working on my own and taking inspiration from Discord.js which is why I asked. I will definitely keep these in mind, though. Very helpful to know
this is the type of thing you find out when it happens, you investigate the issue, nothing makes sense, you ask very carefully, because it's a horrendous question and then get
"oh yeah, you need to handle this" as response 
Not fun so far. Send help 
This is interesting, I did actually test that and didnt have any issues like that. I'm assuming it's because I did the {} thing, does that overwrite other exports or something?
I'm adding guildID to many of the methods in ApplicationCommandManager rn so you can manage commands on guilds that don't have a bot user / aren't cached and I was noticing something.
Would it be desirable to turn all of the manager#fetch method parameters into an object (for those applicable, still accepting resolvables as the only parameter) for consistency?
Current managers that use this structuring are ApplicationCommandManager (with my PR, and therefore GuildApplicationCommandManager), GuidBanManager, GuildManager, GuildMemberManager, ReactionUserManager
Those that do not and would be changed: ChannelManager, GuildEmojiManager, MessageManager, RoleManager, UserManager
You mean like MessageManager#fetch({ message: MessageResolvable }) or something?
Because I really hate that
No, it would still take bare MessageResolvable, but if you want to not cache or force, you need { message: MessageResolvable, force: true }
granted, it could be fetch(message: MessageResolvable, options: BaseFetchOptions )
or something
okay that I dont hate
the second one
fetch(message: MessageResolvable, options: BaseFetchOptions)
yeah, okay, need to change some of those other ones to follow that style then too, but I think that would be better for consistency
A suggestion: Allowing mailto:email@email.com urls in embeds? I could find it very useful...
Idk if suggestions are allowed here, its the most relevant channel i could find
We aren't discord.
We have no control over what is allowed and what not, or what will be.
Oh, alright. I didnt know that.
well i knew that
but i thought you had the ability to change what you could send
to an extent of course
You probably can send it, and then the API will reject it or the Discord client wont render it
I see. Thanks for clearing that up.
public on<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => Awaited<void>): this;
``` This change to use `Awaited<void>` in the Client event listeners effectively prevents you from returning anything from the function, eg
```diff
- return message.channel.send("..."); // will error
+ message.channel.send("...");
+ return;``` Is this intentional, and required for some reason? Could we not do something more generic like `Awaited<unknown>` because it doesn't matter what a listener returns (or does it)?
Hmm, EventEmitter doesn't care about return values, in fact there is no way to get them. The @types for EventEmitter define it as void, but I do think unknown would be better.
Yes, Crawl said repeated times that Awaited<void> should be the definitive return type, besides, enforcing this also helps users finding bugs
If return message.channel.send("..."); were to throw, you'd get a stack trace, but not the async part, because the caller (EventEmitter) isn't asynchronous
Okay, cool, thanks
np
Shouldn't the library prevent methods such as VoiceChannel#join to be executed if the client has not subscribed to the required intent? Or complete documentation by saying "to use this method, you will need to subscribe to that intent"?
Several people have been running into issues related to these (the example I have in mind is VoiceChannel#join throwing connection timeout).
Probably not, no.
We don't do it for anything else.
We actually do check for permissions in said method because Discord just ignores join attempts to channels you can't join
https://github.com/discordjs/discord.js/blob/master/src/client/voice/ClientVoiceManager.js#L77
Perms yeah, but we never check for explicit intents no?
No, those didn't exist back then after all.
Point is to avoid timing out, since that's a poor (and slow) error.
yeah, the error takes 15 seconds to throw. We can make it quick by checking for the required intent (GUILD_VOICE_STATES?) in the VoiceChannel#join and throw if not found. We do check for intents while logging in so I don't know why we can't do this too. Now this takes me to the question:
Why do we set ClientOptions#intents to the resolved bigint instead of an intents object?
I don't think there is a reason for that.
hmm, then we should make it an intents object, then we can easily check whether the intents user chose have an intent. Currently we will have to make a new intents object from the bigint everytime we wanna check
I'm not sure if checking for specific intents is the right path here.
Theres a fine line between good user experience and "well thats kind of your own fault, the vacuum cleaner won't put dirt into the bag if you dont have a bag"
It will still turn on however, and leave a big mess

yeah, I understand. It would have been the user's problem to fix if the error would be quick & clear but it takes 15 seconds for the error to throw and on the UI side the bot still shows in the VC. The error also doesn't help: "cannot make connection within 15 sec...something..." Which mean that the user has no idea what's causing it
Also its a bit problematic, because technically speaking we want to move away from our internal voice code anyway and mostly delegate things to @discordjs/voice

