#archive-library-discussion
25217 messages · Page 1 of 26
@tough geode another reason would be that the id of the client user is not necessarily the id of the application.
This is only the case for very old applications however.
(Nadeko bot would be one example)
i can't seem to get TS to recognise that messages is meant to be an array?
using the normal send overloads, not from my PR
you can cast it <Channel>.send().then(msg => (msg as Message[]).length ...)
should have explained but, i made a PR to remove some duplicate types as parameters for the send overloads, but then crawl commented saying that would break it, but i can see the overloads arent even working as they should in the first place @spice lava
so, not trying to fix an issue on my end, but with the send overloads
i think i found the problem, the overloads with only options need to be defined first, i think its something to do with the fact StringResolvable is any
i pointed that out earlier
because send takes StringResolvable it would not autocomplete or type check
ah
are intents fully implemented yet?
I imagine the new cache way is to make way for the intents system instead because cache is gonna be redundant at some time
... right? cause I assume its gonna be because of the intents you're unable to really make sure that the dats you have in the cache is gonna be there so its gonna be deprecated soon?
Uhh, no?
Just specify all the intents so that we can cache stuff
Intents are available but not yet required
But there are some issues where if intents arent specified cache will be missing, yes
Even if missing, it will definitely not be redundant though. That would mean that bot doesn't cache literally anything at all, while you can just use the intent to get data for cache back again (assuming your bot will be allowed to use all intents)
No the typings are correct, they are valid types in TS
You just didn't use it correctly
What is the code you tried?
Yeah like that, now you're encountering "type widening"
You can do disableMentions: 'everyone' as 'everyone'
Ok, I just came across something, <Guild>.verificationLevel returns a VerificationLevel typedef, which has a type of String
However, when I see the typeof this thing, it says it returns a number actually
same goes for the ExplicitContentFilterLevel and so... I don't know if this was done with intention for showing the string type in the respective methods which takes a parameter as a string | number, I think it would be better if the numbers are shown along with the Level alongside in the TypeDef and make the Types as string | number
version 12 of discord.js is a poop
please don't randomly complain here. this channel is for serious discussion about the library.
@thorny cosmos oh, i think that came from a PR i made, maybe a merge conflict or smth changed it without realising
interesting
hm
@thorny cosmos i assume you are talking about
because it looks as it should to me
perhaps your version is out of date
Oh, you are right@vernal atlas , I realised i am using an older commit of v12, well, will update then
👍
I think Channel should have a partial field, since when you use client.on("channelUpdate",...) you get a Channel | PartialChannel.
I use typescript so to check if the channel is partial I either have to just channel.fetch() or do something like
(channel as PartialChannel).partial ? channel.fetch() : channel as Channel;
DMChannels have a property showing if it's a partial or not, other channels are never partials as guild channels are always cached
you can remove guild channels from cache
I think it just makes sense to put a partial property on a value that can possibly be partial. Call me crazy.. lolol
Theres already a PR in place for this
GuildChannel#partial will always return false
DMChannel#partial will do the appropriate check
Typings will be improved so directly handling the Channel class shouldnt happen, since its supposed to be abstract
https://github.com/discordjs/discord.js/blob/9c8aaf1bbcc220299e65cadb6ac54e1a7f208576/src/client/Client.js#L389 shouldn't this check for only 'all' | 'everyone' | 'none' instead of the type string?
this channel is for library discussion not support
sry
is there any reason djs doesn't use ms precision ratelimit?
you can't you don't receive milliseconds precision from the API
https://discordapp.com/developers/docs/topics/rate-limits#header-format
X-RateLimit-Reset:
Epoch time (seconds since 00:00:00 UTC on January 1, 1970) at which the rate limit resets
it's in seconds, from the Discord API
@finite rover discord.js does use ms precision
it's in s unless you tell it to give you ms
@opal mauve would you mind showing me the relevant line?
i ctrl-f ed the repo to find where the x-ratelimit-precision header was and I couldn't find it but maybe i missed smthing
@finite rover oh, my bad. it's included in @tacit crypt's REST PR which is still in draft form.
yeah exactly what i found as well
so any reason this hasn't been introduced sooner?
it shouldn't imply much change apart from sending the additional header right?
It wasn't really needed?
the PR that's adding it isn't finished yet
I mean you're not gaining SO much speed from it
that's fair, honestly I'm purely asking for information here
Maybe I'll actually finish that PR one day
After rewriting the entire bucket system...again
I was not even talking about the PR that seems to introduce much more than just ms precision
I was mostly wondering if adding ms precision would needmore changes than it seems
and that maybe I don't know about
I mean, to keep it simple
Can we use it? Absolutely
Should we? Probably?
Is it that important we use it? Not really
Is it gonna need massive changes? Nop, one liner. Testing tho... Yike
Alright
thanks for the answer
That's what I thought, I wanted confirmation thank you
Also yes I guess it doesn't matter that much 
I have been thinking. But in the message reaction remove event, when fetching cuz it's a partial. this.emoji could be a guild emoji what could trigger the error. But why does message reaction add event doesn't have that problem? 
@real jetty I'll be opening a pr today that fixes this issue with an explanation to y all this mess happens
Okie
There is a lot of text and stuff but basically you use only messageReaction.fetch() where it would also fetch the message automatically? (if the message was also partial) (In the new solution such to speak)
yh thats pretty much wat it was doing before, now it just uses Message#_patch() to end up with the same result
u would only use MessageReaction#fetch() if u care about the count prop otherwise u prolly just wanna fetch the message depending on wat ur doing
I might be stupid but why is TextChannel.members not a GuildMemberManager like Guild.members but a normal Collection instead?
because its a getter, which means it would have to be a pseudomanager, and it would also be redundant with the guild's member manager, overall its just not really worth it, at least in my opinion
I see. Thank you 
would it make sense that the 'newMessage' in messageUpdate technically couldn't be a partial?
listening to the 'raw' event, i see that the full object seems to be sent by the websocket, which is enough to construct a full message right
More of an edge edge case:
If you receive an embed update for a partial (or uncached) message, you would only have relevant ids and embeds.
ah
yo is there an API for the discordjs.org website that returns info of the docs in JSON, kind of like how NodeJS docs has a "View as JSON" format?
There is the docs branch with the relevant json files you could use: https://github.com/discordjs/discord.js/tree/docs
thanks
haiya! I was wondering how long it takes issues to be looked at and fixed.
it really depends on how complex, how big of a change it is, and if there are people who bother to fix it ¯_(ツ)_/¯
Discussing it here/general (if its a feature/change) or in support (if its not actually an issue with the lib) would speed things along
Since it gets more eyes looking at the problem
Actually, is adding information about needed permission to setChannel desription (https://github.com/discordjs/discord.js/pull/3959/files#diff-3598194ff2d32819aea8eaf51aeb1b09R157) necessary?
This would make it only method that has it mentioned.
My stand on that: either everywhere or nowhere
In the past we've always come to the conclusion that discord.js should not document upstream permissions, as they weren't even clearly documented to begin with. Discord has now fully documented permissions on the API documentation per endpoint.
However since we recently introduced the permission and hierarchy matters this might have changed.
If we really want to start documenting permissions I'd personally be in favour of adding a link to the used API endpoint rather than just the permissions as part of the method description. If that is even needed/wanted however is another point of discussion
@copper laurel It's a big issue thats causing bigger bots not to be able to start:
https://github.com/discordjs/discord.js/issues/3956
Staff have seen it
just wondering how long it will take to be fixed
as I can't keep a shard offline for too long
There is really not enough information to even figure out where its starting or coming from currently
Despite the high priority it has
Any way I can help ya get info or something
cc @slate nacelle maybe you have a better general idea where this could come from and know which information we'd need
cc @tacit crypt
I..
For one, can you get me debug logs from the shards, especially those that error?
manager.spawn(20); // Start 4 Shards
This spawns 20 shards, not 4, try changing that?
As for errors like Error: Something took too long to do I have NO idea where it's coming from. Check your code to ensure it doesn't have many hanging loops..
My thesis is that this is caused by a guild not being available (presence limit reached or discord outage, probably #1).
In detail:
Error: Something took too long to do.
This is aClient(shard) error.
Thrown on v11, once a timeout elapsed before all guilds were ready.
(Nothing you can do about this on v11 sadly.)
That was taken care of with v12 by readying the client after a (different) timeout instead of erroring.
(You'll have unavailable guild(s) then though, but that's probably not an issue, d.js-wise)
Error: Shard 1's Client took too long to become ready.
This is aShardingManagererror.
This timeout can be disabled by setting the spawnTimeout to -1 or Infinity, may not be the fanciest solution, but should work.
https://discord.js.org/#/docs/main/stable/class/ShardingManager?scrollTo=spawn
(Nothing you can do about this on v11 sadly.)
@tacit crypt Same issue with 4, used 20 to make sure that only 1/20 of the servers had the bot down
Can you check the debug log for each shard?
I tried debug, nothing was wrong
I can start it with debug and send ya the logs 1 sec
Please do
The issue persisted in v12
Sharding Manager ➜ Launched shard 1
Shard 1 ➜ Using gateway wss://gateway.discord.gg/?v=6&encoding=json
Shard 1 ➜ [ws] [connection] Connecting to wss://gateway.discord.gg/?v=6&encoding=json
Shard 1 ➜ [ws] [connection] Identifying as a new session
Shard 1 ➜ [ws] [connection] Connected to gateway wss://gateway.discord.gg/?v=6&encoding=json
Shard 1 ➜ [ws] [connection] Setting a heartbeat interval for 41250ms
o
1 sec
Hmm it seems to be working now
If I get an offline guild ill try again
owo 👍
Sorry, why was I pinged here? Is this relevant to me? I don't understand the sharding at all lol
Nope not anymore
@tacit crypt Yep it seems to work now, it just takes like a minute longer than the other shards. What could be causing this? (Nothing specifically singles this shard out in the code)
Because we wait for all guilds to come in. However, due to unavailable guilds, we wait 15 seconds. Aka
Say you have like 1000 guilds, and 5 are unavailable. We set a timer for 15s to mark the shard as ready regardless if all guilds came. We refresh that timer every time a guild comes. Once all but the last unavailable guilds came, the timeout takes over.
I keep having problems with one unavailable guild - 7100 members.
Sometimes it doesn't come through until 60 seconds after coming ready, sometimes it's perfectly fine.
and this 15s timer is present in v12 but not v11, correct?
the solution i came up with is to manually run client.ws.connection.triggerReady(), not sure if its the best workaround
I keep having problems with one unavailable guild - 7100 members.
Sometimes it doesn't come through until 60 seconds after coming ready, sometimes it's perfectly fine.
@clever crypt blame discord
^ literally nothing you can do about it
after Discord's ready event they begin sending you guilds in the form of GUILD_CREATE packets
all d.js does is process them
Thanks @fallen arrow , that workaround is working partially for me. Gonna have to work with it for now
So am I correct in thinking that the ready event is emitted when the bot connects, and the shard ready event is emitted when all of the guilds have been sent?
should be the opposite afaik
Ah ok
https://discord.js.org/#/docs/main/stable/class/User?scrollTo=toString
When concatenated with a string, this automatically returns the user's mention instead of the User object.
That's not true, when doingsomeString + user, the valueOf method is used, resulting in the userID.
https://github.com/discordjs/discord.js/blob/stable/src/structures/Base.js#L37-L39
Doingsomestring ${user}oruser.toString()does work as expected, but still, I think the word "concatenated" isn't the right word for it.
I'm having a problem understanding the version 11.6.3 and 12.00
like what are they both
and as I know, master is the version 11.6.3, right?
@wild flax wyd ya reopen?
I commented.
o
yea just saw
One of the devs above thought that there was nothing we could do about it?
nope I misread
the only thing that could be done about it is to give it the same timer that v12 uses
return { guild };
What is the point in having the above over this:
return guild;
this is #archive-library-discussion 👀
Yea that is a line in the library
that's a question about the library code, but the answer would be it returns an object (shorthand for { guild: guild }), as to why, depends on context
message.channel.bulkDelete(2, true)```
works but return this error
(node:2068) UnhandledPromiseRejectionWarning: DiscordAPIError: 405: Method Not Allowed
name: 'DiscordAPIError',
message: '405: Method Not Allowed',
path: '/api/v7/channels/%3C',
code: 0,
method: 'POST' }```
(Taken from #archive-djs-v12-deprecated )
Whats weird is from where %3C came from
Without knowing the context, that sounds like it's in a DM
%3Cis an encoded<- This method does not even hit that endpoint (
POST /channels/:id)
(It impossibly could result in that error) - Bug reports should go to our issue tracker instead
(This does not include enough info though, see point 2)
Is version 7 even available? https://discordapp.com/developers/docs/reference#api-versioning
doesnt seem to throw an error
but then again doing v9999 doesnt throw an error either

some people say v7 is "out" for multiple years now, but discord can't justify releasing it
v7 of rest is like v6 of rest but with better errors
Probably a rather nooby question, but why doesn't TextBasedChannel extend a regular Channel?
its an "interface"
and it's being implemented into whatever channels are "text based"
/\, it's never constructed, whatever it's implemented into in the lib extends Channel
in short, it's a class but its not used the "normal" way
guild.channels.create(name, options) and guild.roles.create({ data, reason }), I'd say it's better if GuildChannelManager#create would only accept one argument
Huh? It already does, the options are optional and the type defaults to a text channel
No I mean like guild.channels.create({ name: 'somevoice', type: 'voice', permissionOverwrites })
I'd say it's more consistent with other methods
The object is for optional parameters, the name is not optional for channels, it is for roles (apparently)
You see the same format in emojis.create(), first parameters are required, and then an object for optional ones
Ahh so that's the logic behind it
regarding roles, discord defaults to new role name, additionally, it's name every role you create in app had at one point, since you can rename it after you create it
I tried to update my bot to v12. It's horrible how Typescript's support has become worse than v11
Some examples:
Manager#cache is a collection, which is an extended Map.
Typings for that would be for (const [id, channel] of server.channels.cache).
If you wish to loop over just the channels suffix the .cache access with .values().
This is more of a support question that a complaint/suggestion/nit about the package.
with .values()
I did find a solution tho
(server.channels.cache.array() as GuildChannel[])
I have no problem with this code
for (const channel of <guild>.channels.cache.values()) {
console.log(channel.permissionOverwrites);
}
``` *edited for your use case
I don't think there is, but TS grabs it as a "any" type
More or less a problem with your code editor
Another fantasy
And this one is really from DJS
fetch method doesn't take any arg, right?
Correct
If you're calling fetch on the message, then yeah.
What is message?
client.on("message", (message) =>
Also wouldn't #archive-djs-v12-deprecated or #archive-updating-to-v13 be more suitable for this? 
@umbral aspen Actually I complaint more than I ask for help :x
For the collection loop, it should work fine on es6, how does your tsconfig look?
You seem to be asking questions that belong in the variety of subjects discussed / asked (about) in support center.
We have GuildMember#bannable would there be a place for a general method like GuildMember.canban(GuildMember) for example. Or is this too high level same as addBlankField was removed
Edit: or would comparing roles positions by highest roles of each member be the preferred method without a custom implementation
i really do not see a use for this
why dont you just check .bannable on the member
the last thing the lib should do is make wrappers for already kind of iffy permission getters 
As that would only count for the bot, as said this would be quite high level
you want to see if a member can ban another? lol
again, dont see a use for it
its too specific of a method to be justified to be added, especially when it has no direct correlation with things the bot is doing
That's why I asked. Alright!
Does djs use cluster module for sharding or no?
And does it scale to the number of cores available?
the node cluster module isn't particularly useful for sharding
d.js uses normal child processes
any reason why you guys wanted to go with normal child processes?
one thing i noticed about internal sharding is worker threads
would a build of several process that have several worker threads(shards) be a bad idea?
it's like a mix of internal sharding and process sharding except that you can get the most out of these processes?
we went with child processes because we didn't need the functionality of the cluster module
worker thread based sharding was merged in https://github.com/discordjs/discord.js/pull/2908
ah i see, but what about a mix between process sharding and threads sharding?
unsure what advantage that would bring
Instead of having 10 child processes with their own independent instances and their own memory being shards
We get to have 3 processes with 4 worker threads for each. These worker threads being shards (and every 4 worker threads do share the same memory)
instead of 10 child processes being shards, we get 12 workers being shards and only 3 processes
thats what i meant
@sly pollen workers don't share memory with the main thread
Does anyone know why the message event shares typings with messageDelete | messageReactionRemoveAll?
public on(
event: 'message' | 'messageDelete' | 'messageReactionRemoveAll',
listener: (message: Message | PartialMessage) => void,
): this;
When would client.on("message") emit a PartialMessage?
I can't think of a reason, so I feel like it should have its own typings
yh it should just be typed as Message. it never will be a partial within the message event, the author and content fields will always be present there so Message#partial will always be false
Haiya! I'm wondering if this is a bug or not... in djs 12.0.2, setting the position of a category to 0 puts it at the bottom of the channels, while setting it to 1 puts it under the channel in position 0
im using guild.channels.create
The position is passed to discord as-is: https://github.com/discordjs/discord.js/blob/stable/src/managers/GuildChannelManager.js#L121
Then why is setting the position to 0 having the category created at the bottom of the channel list?
guild.channels.create("Covid-19", {"type": "category", permissionOverwrites: [{id: guild.id, allow: "VIEW_CHANNEL", deny: "CONNECT"}], "position": 0})
this is not at all the place for that question
This is not a support channel
you mean client#voiceStateUpdate?
it includes a voice state which has guild info..
not the right channel for this
please use a support channel
?gotosupport
You are in #archive-library-discussion right now. Go to a support channel instead:
on stable its a VoiceState for both params and on v11 its a guildmember so im not quite sure what you are suggesting
anyways its kind of offtopic since at this point its a code issue, not a library issue
reaction.count isn't showing in docs on 12.0.2 for some reason
Possibly because // eslint-disable-next-line eqeqeq has been added between the JSDoc and the property?
I think there was a PR for that
This was fixed with https://github.com/discordjs/discord.js/pull/3980
I'm not sure the best practice on this, but instead of having a generic type like GuildChannel that's defined to extend Channel , shouldn't there be a GuildTextChannel that extends TextChannel etc.?
This way you don't have to cast everything that comes as GuildChannel to the text/voice/category/news/store equivalents
so:
GuildTextChannel ---- TextChannel ---- GuildChannel ---- Channel```? what about DmChannels, those simply extend Channel and implement TextBasedChannel, similar to TextChannel which extends GuildChannel and implements TextBasedChannel
you will still have to cast, some methods can return any channel, say grabbing a channel from the GuildChannelManager, it can be text/voice/category, etc, so i fail to see how that solves anything, it seems to just add more clutter to inheritance
Channel typings will definitely be improved in v13 with proper typescript
I think messages could implement a guild typeguard
Like the non-working channel typeguard?
I really don't know, but something to tell TS that if message.guild is present, message.channel is a TextChannel
I don't think a typeguard like that is possible with TS
But maybe a GuildMessage or something?
was about to say
That falls under what borger said right at the top there
type GuildMessage = Message & {
guild: Guild;
channel: TextChannel;
member: GuildMember;
};
type DMMessage = Message & {
guild: null;
channel: DMChannel; // can be partial(?)
member: null;
};
``` and rest
some methods can return any channel
@wild flax why would that fail for message?
oh
That part works, yes.
But breaks when attempting to use Promise#then on an union of Promises.
https://github.com/discordjs/discord.js/pull/3978
@snow crypt But if you use message.guild instead, of message.channel.type === 'text', it won't work
I know, that is why I say something like this could be used https://discordapp.com/channels/222078108977594368/682166281826598932/692703619455254579
type GuildMessage = Discord.Message & {
guild: Discord.Guild;
channel: Discord.TextChannel;
member: Discord.GuildMember;
};
type DMMessage = Discord.Message & {
guild: null;
channel: Discord.DMChannel; // can be partial(?)
member: null;
};
type AnyMessage = DMMessage | GuildMessage;
// @ts-ignore
const m : AnyMessage = get();
if (m.guild) {
m.channel.permissionsFor
}
this works
why is the return type of CategoryChannel#children marked as nullable in docs (?Collection<Snowflake, GuildChannel>)? it's not nullable in typings, and it should not be, because it just returns Collection#filter(...), which returns Collection<K, V>, not nullable.
Docs link: https://discord.js.org/#/docs/main/stable/class/CategoryChannel?scrollTo=children
I think it should be nullable since a category doesn't necessarily need to have any children channels. In other words, a category can be empty.
This perhaps should be updated to it not being marked as nullable, or updating it so it is nullable and that it returns a collection with entries present in it or null.
categories can be empty, but .children is an empty collection for empty categories, not null, therefore it's misleading in my opinion.
Yes, 1s3k3b is right, the jsdocs for .children is kind of wrong, since collections extend maps, they can give an empty collection object if no key value pair exists, here is what I just evaled on an empty category
Also the typings on Collection states that Collection#filter() returns a Collection, not ?Collection, so it makes sense for why should it not return ?Collection<Snowflake, GuildChannel>
speaking of CategoryChannel, the setParent method is documented (because of GuildChannel), but it shouldn't be there at all
it looks like they tried to document it with a warning, but it doesn't show up https://github.com/discordjs/discord.js/blob/stable/src/structures/CategoryChannel.js#L19
well, it's inherited, but it has a warning
it doesn't have
same thing for lockPermission
It can be removed by just deleting from the child's prototype (https://discordapp.com/channels/222078108977594368/222086648706498562/693752580664459295)
CategoryChannel#setParent should be there because the API technically allows it, despite throwing an error at this moment in time
Hence why instead the warning is introduced
and what would it do?
as i just said, at this moment in time you can not tier categories like a file system, however the endpoint is there, so we decided to support it
but it does practically nothing?
throwing an error at this moment in time
would not describe that as "nothing" per se
i'm talking discord
like, you can set a topic to a voice channel with djs, but it really does nothing if you look at it practically
i fail to understand what you mean, the API throws an error, the request is rejected
the api throws an error when trying to set a parent?
does the api throw or is it just the lib?
Depends on the error class you catch:
DiscordAPIError -> Discord threw it
DiscordjsError -> discord.js threw it
as said, API error, to be more precise:
DiscordAPIError: Invalid Form Body
parent_id: Categories cannot have subcategories
well isn't this going with the head in the wall?
making a request that is going to fail is very strange to me
its not worth it to specifically handle that use case or somehow remove it from the documentation despite its inheritance
but the library is there to interact with discord
could also split it to have a base GuildChannel, and a ParentedGuildChannel to have setParent on it, then have voice and text inherit from it, and categories would inherit from the base GuildChannel with no setParent
but the library is there to interact with discord
Well, it's a wrapper for Discord's API, so theoretically, if CategoryChannel#setParent is documented in API, there is no reason to not have it. It might reject today, but what if tomorrow discord will release subcategories?
It's a wrapper for whole API, not wrapper for some of its functions
It exists because the API doesn't actually have different endpoints for different channel types the way Discord.js does. There isnt even a "set parent" API endpoint. Its literally just Modify Channel, specifying a parent_id
https://discordapp.com/developers/docs/resources/channel#modify-channel
setParent() is already just a helper function around an edit call really. The most logical place to share this inheritence is GuildChannel otherwise we'd be duplicating code across Text/Voice/News/Store channels
can someone explain this change? https://github.com/discordjs/discord.js/commit/2be9ebaad2edca24f87f527397d4f2330f107a89#diff-4419bad7f25fd13106e6fe7516df7617
it doesnt play well with custom events and my event loader
i think having a [event: string]: any[] at the end of ClientEvents could potentially fix it
Makes sense to me - I think we've effectively locked it down too far
You can augment the interface adding your own events there:
declare module 'discord.js' {
interface ClientEvents {
foo: [Map<string, any[]>];
}
}
(Or that catch-all clause, too.)
I think it should be event: string | symbol in the all-catch
now how do i make a pr again
This is intentional: https://github.com/discordjs/discord.js/pull/3944#discussion_r393221258
so I guess we're not adding it back?
I'd be in favor to not do that.
I'll do a pr with that note
@slate nacelle https://github.com/discordjs/discord.js/pull/4008
This doesn't make a lot of sense
why would you not extend the interface?
Why would you want to just allow any symbol or string?
as written in the pull, i'm just waiting for feedback
You got feedback from 2 devs
why not more ¯_(ツ)_/¯
Probably more of an api question, but is there a reason why guildMemberRemove gives you a member object whereas guildBanAdd gives you a user object?
hackbans
you can ban a user by id which is not in the guild (see: Guild#members#ban())
I would not be surprised if member.ban calls member.guild.members.ban
aaand... it does
why would it not
@slate nacelle I went ahead and just made my own interface in my bot which extends ClientEvents but I guess adding it in a d.ts works too
Wish intellisense would still work if you allowed anything but yea if you allow anything now you either don't get autocompletion or you can't get the typings that are returned from each event
Also if you extend now you can easily type what's returned from your custom event instead of asserting
Would v11 break if moved to node-fetch?
otherwise it would have been done already
Would it break? No.
Would it be breaking? Yes
It wouldn't be breaking
breaking from a semver point, no?
if nothing changes on the public API then i dont see how it would be semver major
No, unless there are points where raw return values are given to a user from snekfetch/node-fetch
Changing dependencies is not a breaking change
We expose the raw errors from snekfetch when encountering 5xxs and the retry limit was reached:
https://github.com/discordjs/discord.js/blob/v11/src/client/rest/RequestHandlers/Sequential.js#L76
https://github.com/discordjs/discord.js/blob/v11/src/client/rest/RequestHandlers/Burst.js#L46
if nothing changes on the public API then i dont see how it would be semver major
that's why i'm asking
i mean, i believe there is little to be gained from switching to node fetch but a significant amount to lose if done improperly, also, v11 isnt really in development as much as v12, as long as snekfetch works i dont see a need
Would there be any way of adding in where an API call failed in the code? As in, more detailed stack traces
So instead of it coming from the library it would come from a method called from code the user had written
you mean unhandled promise rejections? not really no, as async code is run in parallel to the stack elsewhere, therefore stack traces are hard to make and would be huge
v11-dev had a way to show accurate stack traces, but afaik node always had this missery with async stack traces
then what changed between v11-dev and now that required that code to be changed?
well, ok probably a lot in all fairness but
There is a "round 2" for this in #3443.
A bit of the relevant code, but it's all over the place, really:
https://github.com/discordjs/discord.js/pull/3443/files#diff-b06340a028069dac07f7b735c4e096a5R12
https://github.com/discordjs/discord.js/pull/3443/files#diff-162f9af6d66ef5705d4310712d982f4bR85
Comment linking "round 1":
https://github.com/discordjs/discord.js/pull/3443#issuecomment-523510644
discords information on missing permissions / missing access is also lacking (like what permission is missing)
tho this is a feature request
https://github.com/discord/discord-api-docs/issues/1467
My implementation in that PR you linked @slate nacelle would only work on v8 sadly (which would be fine if we didn't have browser builds); it's to be changed
Well, yes but actually no
TypeError: timeout.refresh is not a function
at GABClient.handler (C:\Users\GAwesomeBot\Development\node_modules\discord.js\src\stores\GuildMemberStore.js:210:17)
at GABClient.emit (events.js:323:22)
at GABClient.EventEmitter.emit (domain.js:482:12)
at Object.module.exports [as GUILD_MEMBERS_CHUNK] (C:\Users\GAwesomeBot\Development\node_modules\discord.js\src\client\websocket\handlers\GUILD_MEMBERS_CHUNK.js:18:10)
at WebSocketManager.handlePacket (C:\Users\GAwesomeBot\Development\node_modules\discord.js\src\client\websocket\WebSocketManager.js:391:31)
at WebSocketShard.onPacket (C:\Users\GAwesomeBot\Development\node_modules\discord.js\src\client\websocket\WebSocketShard.js:437:22)
at WebSocketShard.onMessage (C:\Users\GAwesomeBot\Development\node_modules\discord.js\src\client\websocket\WebSocketShard.js:295:10)
at WebSocket.onMessage (C:\Users\GAwesomeBot\Development\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:311:20)
at WebSocket.EventEmitter.emit (domain.js:482:12)``` If anyone wants to have a look, I'm a bit busy 
GuildMemberStore 🤔
yes, i'm not on latest cause we're rewriting soon
what node version are u running? cause timeout.refresh was added in v10
Does djs use the Server Members Intent when using guild.members.cache.get() etc ?
No, that's just cache, it does not interact with anything outside of your ram.
ah ok thx
Just want to point out that the api seems to now show public_flags on a user object, you may want to look into that as this seems new
Once this gets documented on Discord's end (https://github.com/discord/discord-api-docs), this should be a simple thing to add.
Here we go, a PR: https://github.com/discord/discord-api-docs/pull/1490
Consider yourself PR'd 
https://github.com/discordjs/discord.js/pull/4060
Doesn't the data come in with a regular fetch? instead of needing a separate utility function couldn't users just use User#fetch
For User#fetch(), you would need the user object to call fetch() on them, and assuming you don't have any user object, in that case what will you do?
fetch from the users manager
Of course there is a method User#fetch, but it is used on Partial User Objects. Assuming you don't have that also, then how would you use? Hence you need UserManager#fetch(), i.e., a separate function exists for it @keen cosmos
I dont think that was the point being made
Are flags not included in a User payload - do they have a separate endpoint that requires User#fetchFlags() instead of just User#fetch()?
Tested - not part of the data you get about users when you identify but it is the same fetch endpoint
yeah, I meant that the data comes in from the same fetch endpoint
@thorny cosmos also you're not restricted to using fetch() on partial options
I meant that it can be used on any valid User object, it is mostly used for partial user objects but Ok
mostly used does not in any way limit it to that functionality or use case
guild.fetch() also exists, but did you ever had a need to fetch a guild? tmk you would use it only if you would at any point need maximumPresences or maximumMembers
@keen cosmos if the User isn't partial then User#fetch() will just return the cached user, so it would never end up patching the user and updating the flags
and the reason y Guild#fetch() will always patch the props mentioned above is cus it will always make the api call and call _patch() (https://github.com/discordjs/discord.js/blob/stable/src/structures/Guild.js#L588-L596)
is there a reason why bulkDelete didn't move to the MessageManager?
it was never under MessageStore
i think the question is more like why isn't it on messagemanager?
exactly, with "moving" i meant v11 -> v12 and not old v12 -> new v12
i just didnt think about moving it when implementing managers, i think its fine and its not a big deal but i do see why you would expect it to be on the manager, unfortunately the switch cannot be made as it is semver major
i kept all methods the same from dataStores to managers with the exception of renaming MessageStore#remove to MessageManager#delete for clarity
@vivid field
So v13 soon
i wouldnt exactly say soon lol, its a full rewrite and we dont even have a gateway yet, id expect the basic things like rest/gateway/ some of the core to be done by the end of 2020
the method could still be moved and leave the old one in place as a shortcut to it and deprecated
i find this useless personally
if the method would be more appropriate in the new location, it is absolutely not useless
at that point it would be more of a change just for the sake of a change
no, it'd be a change for the sake of logical consistency
is there any functional difference? no, of course not
but if that is where that method should be, then that is where it should be
no reason to hold it back in an improper place because "meh, it doesn't change anything"
meh i just think there is no need
you yourself have already essentially admitted that it makes sense to be on the manager
therefore there is a need
it does, i still dont think the change should be made
you're making that decision from a purely emotional standpoint with no logic behind it
for all we know bulkDelete could be renamed/moved somewhere else in djs-next, and managers could not exist either, i think deprecating it is not really the right move
but if it's deprecated, devs should start to look into new way, which literally does not exist now
the new way is the correct location for the method
which would exist at the time of deprecation
@real jetty that sort of question belongs in #archive-commando-deprecated not in this channel
commando is a framework for d.js it's not part of the library
you might want to read #3485 to get an idea of why things changed, its mostly to separate the API and cache methods. im not quite sure what you mean added to the client class, would you mind elaborating on that?
there are no new classes by the way, they only replaced the data store classes
while yes, they do break code significantly and many users may not see the need, which is unfortunate, the changes greatly benefitted the maintainability of the library for the future
and where would the api methods go? that would be the same as datastores but with a different name
the point of managers was to separate the cache and api, you cant quite do that without breaking users code
but what you are describing are data stores
though maybe actually extending the class into type-specific subclasses (guildcollection, channelcollection, etc) would have been a better move to avoid breaking existing code
this is essentially what was happening with stores and why we moved away from it
this would still have all of the downsides of datastores
add is an internal method to add to the cache and remove is an artifact with a pr to remove it from typings
yes
the GuildMemberRoleManager is a pseudomanager, its add/set methods call the api
no problem
Don't think it's a breaking change.
This is a breaking change tho 
at least thats what it looks like to me, im not sure if private things like the data resolver count
it is like changing the rest manager
you're not supposed to touch it
hold up, wouldn't it break things that call if it they are not also changed?
because in resolveBase64 it still checks for buffer
it seems to me that this isnt a clean change and that it could silently affect other things that call it, and that more tests need to be written
Wouldnt that just nullify the point of the pr 
technically, APIMessage doesn't document files as anything other than "Object", so I don't think this would qualify as breaking.
honestly a bit of an oversight in documentation, but i think it would serve our purposes here if we wanted to make this change
I do think a separate method for uploading local files as streams would be helpful though, I do quite a bit of sending images and my ram usage jumps up when doing so
Doesn't this entirely contradict past changes, however
with time all of the send* (e.g. sendEmbed, sendFile) methods were removed in favor of the universal send
@drowsy niche you can still make separate DataResolver methods
like, a different resolving for local / remote that will then be called accordingly
Regarding patterns in MessageMentions, can't IDs be 16-character long?
considering they are being somewhat increased, and that Discord was released in may, no snowflake from after may can be 16 characters long
so it will be 17,19 for now, and 17,20 after there can't be no more 19digit ids?
What of all of this do you actually send to discord?
@drowsy niche I messed around with your test code and it seems like the files property of the json response from httpbin is being reset when sending a stream, maybe that's the issue?
setSelfDeaf literally does not work
Not sure if I'm doing something wrong or if its because of the library itself
It shouldn't return anything
(actually it should)
the return type is documented so im not sure what the problem is
Its supposed to self deafen the bot
But its not doing that, and just returning false
well, thats not something for this channel
I thought this was a problem with the library
Which is why I posted here
Is it a problem with the docs? I'm really not sure
not sure what should I do now tho, the form-data repo is pretty dead
@drowsy niche create@discordjs/form-data?
@drowsy niche ```ts
declare const body: import('node-fetch').Body;
body.body```
Per their docs, this is totally valid
Since res.body is a Body class, it has a body property (stupid, I know)
Do you think that might fix it? (so we don't have the issue where form-data is..borked)
In this case, body.body is a NodeJS Readable Stream, instead of a WHATWG ReadableStream
Wait the hell?
Am I seeing this wrong
Oh I totally did see this wrong, fricking docs
Well this might explain why it doesn't work without that form-data PR
oh, gotcha
@drowsy niche so the issue is that form-data doesn't like anything that's not a regular Readable stream, right?
@drowsy niche if you want we can probably keep a fork and keep it up to date with upstream
well, I'd rather have a fork with the PR merged (in our fork) than rely on someone else fork, if you know what I mean
yes, but we have to fork form-data first is what im saying
have a fork that is under our control, in case the original PR author deletes his or whatever
probably
anything is better than relying on some 3rd party fork here.
Or installing a commit from a PR
Are partial guildChannels supported? This throws errors in the ChannelManager if the channel is not cached but the guild is, i was wondering if it would make sense to provide a partial channel or to simply return if either of them are not available instead: ```js
class InviteCreateAction extends Action {
handle(data) {
const client = this.client;
const channel = client.channels.cache.get(data.channel_id);
const guild = client.guilds.cache.get(data.guild_id);
if (!channel && !guild) return false;
const inviteData = Object.assign(data, { channel, guild });
const invite = new Invite(client, inviteData);
this doesn't seem quite right
normally all guilds should be cached when they are received via the GUILD_CREATE packet, which provides all channels
there should never be a case where a channel is not cached
same with roles & guilds
yes i am aware of that, the only use case for this is when the developer uncaches channels to save memory, which is more common than one would think
hence why the question if it would make sense to support such use cases since we already have partials in many other scenarios, or if this is out of the scope of the library
as stated in other places & conversations related to cache, going by
uncaches channels to save memory, which is more common than one would think
would cause a lot of changes and checks all over the place for no particular reason
The client options provide various ways of keeping cache smaller for things that are not needed by the core library.
A pretty good summary of it can be seen here: https://github.com/discordjs/discord.js/pull/3995#issuecomment-604441660
Channels are data discord.js absolutely depends on internally at the moment, not just in the situation that you pointed out just now
On top of that, I honestly doubt this is "more common than one would think", given that channels are the least of your problems when thinking about cache.
The only real place you can save actual valuable memory in is the messages cache & potentially the members.
We currently only really use or support partials whenever discord gives us partials. And channels dont fall under that category
alright thanks
@wild flax not sure if this is ping important but people have been having the issue on v12. Is there a fix on that version as well? https://github.com/discordjs/discord.js/issues/3956
@tacit crypt
do we not trigger ready even if not all guilds are ready?
Im pretty sure we do, or do we only do that on internal sharding?
we do, but the timeout waits 15 seconds before doing that
ok but what if you use the sharding manager
..same?
The default sharding manager timeout is probably too small by default
I mean the cycle is:
Bot gets Discord READY, we set a 15s timeout
For each GUILD_CREATE, we refresh the timeout
If there's still unavailable guilds, the 15s timeout will trigger, marking the client as READY
Sooo
TL;DR: increase your sharding manager timeout and it should be fine
Using a sharding manager I get the error it took to long to ready sometimes
According to what you said it should just mark as ready after the timeout with the remaining guilds being unavailable
Yes, but the default timeout is too short in the manager
Speaking of, @lofty birch do you have any of the optional deps installed? (zlib-sync, bufferutil & utf-8-validate)?
I don't believe I do
Can you try installing those and seeing if that helps?
Otherwise, try increasing the timeout on the shardingmanager to say, a minute
(manager.spawn(undefined, undefined, 60000)
Will do in a bit
Will User#Flags ever be supported in v11?
No, v11 will not receive new features
https://github.com/discordjs/discord.js/blob/master/src/structures/Guild.js#L468
get nameAcronym() { return this.name.replace(/\w+/g, name => name[0]).replace(/\s/g, ''); }
Where does the regex come from?
I am asking as it gives incorrect results, and I can't find the source for it.
probably from nowhere, as acronym is generated by client from usually first letters
so the acronym-ing is done somewhere in the client js?
by client i meant the discord app
Yeah its not an API thing
by client i meant the discord app
that's what i meant
like, in the js of the app
@opaque robin that's not how you deprecate
And you don't resolve the promise
@snow crypt tbh I searched the server for util.deprecate and afaik from what I've seen, it returns the function with the deprecation warning.
But if you say I'm incorrect, I'll take that
Currently the method returns a function
Oh, so I should be calling the function it returns
This is what we did in v11: https://github.com/discordjs/discord.js/blob/v11/src/structures/Guild.js#L1693
was about to say, do it at the bottom of the file with the prototype
yeah, thanks, space 😞
I should still be using const util = require('util') instead of directly requiring in the prototype I presume.
or destructure deprecate from it
Alright 👍
@snow crypt Wouldn't the async await mean it wouldn't be returning a promise anymore
nope, just the opposite
ah right, mb
@vernal atlas What would be the more appropriate tag to use for that?
I think <info> would be appropriate, not too sure.
No, just an actual description of the typedef
/**
* An object containing information about a guild's vanity url.
* @typedef {Object} VanityData
* @property {?string} code Vanity URL invite code, not the full url
* @property {?number} uses How many times this invite has been used, must be fetched at least once
*/
not sure what would be better (as to info or warn tag)
i think just vanity is enough
if someone would want to correct it later it's an ez pr
Might as well get everything done in the one PR tbh
so @typedef {Object} Vanity
remove URL in Vanity URL invite code
and that should be good yeah?
by client i meant the discord app
do you think ```js
t.getAcronym = function(e) {
return null != e ? e.replace(/'s /g, " ").replace(/\w+/g, (function(e) {
return e[0]
})).replace(/\s/g, "") : ""
}
I think it is
so yea, it should be name.replace(/'s /g, " ").replace(/\w+/g, e => e[0]).replace(/\s/g, "")
pr'd it
What prevents #2910 from being merged?
I'd like to know about ^ as well, left a comment two weeks ago and haven't gotten a response :P
@clever crypt I found that piece of code with the raw website, didn't need to actually download it
looked for "acronym", found uses of "getAcronym", searched its definition and got the actual one
User#flags doesn't seem to be documented, not sure if it's missing or the docgen for 12.2.0 didn't work properly or something
I'm mobile so not checking or PRing myself
on master it's there
oh, you're correct
a PR to document it was merged after 12.2.0
hey, any idea how long it takes for v12 bug fixes to get ported to v11? please let me know if this is wrong channel for this
i'm specifically looking for this bugfix: fix up WebSocketShard errors. it was released with v12.2.0 a few days back
new api feature: https://github.com/discord/discord-api-docs/pull/1528
was announced in discord dev server also
@vivid field but client.channels gives you a ChannelManager
and you can use .fetch on it
it was about djs
@vapid echo v11 is no longer maintained and will not receive further non-critical fixes. v12 is the stable branch which will receive maintenance patches and releases
Oh. I still see v11 releases though. Are you saying v11.6.4 (released 15 days ago) was the last one? @copper laurel
if there are significant bugs which can be fixed pretty easily then a quick patch to v11 may be done, but feature updates are out the window
Right, I am looking for a bugfix. Like I mentioned above, specifically this one: fix up WebSocketShard errors. it was released with v12.2.0 a few days back
Just wondering if it will make it to v11
Can you please reference the PR you're referring to
iirc that was a pretty big change, and the websocket from v11 to v12 has changed a lot, so fixes on v12 can completely break v11
Its highly unlikely because the websocket was signficantly changed in the v12 release
So these changes wouldnt even apply to v11
yeah its pretty significant
I feel like displayAvatarURL’s dynamic key should be true by default. It seems like it would be more beneficial as more people will probably be after the gif instead of the webp
Sadly thats a breaking change and wont happen
Explain breaking change. Almost everything you change will break pre-existing code?
Has anybody reported any issues with this promise hanging?
It doesn't reject, it doesn't resolve... just dies 😫
it adds listeners which either resolve or reject the Promise
I was looking for a library to write a Bot in and when looking at the discord.js Github, i've found this: https://github.com/discordjs/discord.js-next, what should anyone expect from it? Will any bot written in the current Discord.js work in next or would i have to write the my Bot again?
The next version, no, yes
I know it seems to be in a pretty early stage to say anything but you have any ETA planned? I wonder how long i could expect my bot to work using the current version.
Or you plan to support the current version in some sort of LTS?
So I found a typings issues. With the following code: ts msg.channel.delete().catch() where channel is TextChannel | DMChannel | NewsChannel fails with ```
TS2349: This expression is not callable.
Each member of the union type '(<TResult = never>(onrejected?: (reason: any) => TResult | PromiseLike<TResult>) => Promise<DMChannel | TResult>) | (<TResult = never>(onrejected?: (reason: any) => TResult | PromiseLike<...>) => Promise<...>) | (<TResult = never>(onrejected?: (reason: any) => TResult | PromiseLike<...>) => Promise<...>)' has signatures, but none of those signatures are compatible with each other.
Seems to be an issue introduced with v12 as the Channel typings changed from `public delete(): Promise<Channel>;` to `public delete(reason?: string): Promise<this>;`
Granted this would be an easy fix if you cast a type like `(msg.channel as TextChannel).delete().catch()` but I thought that this issue shouldn't appear in the first place. On the other hand I am not sure on if this should even be fixed as typings in general would be fucked if you just return `Promise<Channel>` there as this wouldnt be very detailed.
Introducing types on the top level classes like `TextChannel` would introduce the same issue. So I would like to know some comments on this one as I would say all approaches are not perfect because there are actually cases where `channel` could be both, `DMChannel` and `TextChannel`
interesting
there was something similar to this with the channel union types right?
The issue is the same with channel.fetch().catch() btw, exact same reason as above
This is the same issue as the union types, I mean it is an union type after all.
So this is a known issue/problem?
Not in this context, but I guess?
I don't think we can do much about this except using Channel instead of the union and let you assert / instanceof concrete types.
That's what I thought. Is there already a PR for it? (will look myself but maybe you know more)
I don't think so.
time to get into 2+ 2- PRs again
It doesn't reject, it doesn't resolve... just dies 😫
@fickle flare thats..impossible, theres always at least ONE event that runs
What can I do to help diagnose the problem?
or track the source
I'm not using standard Node, but until v11 it was working flawlessly
Wait, what
Yes, Its running from inside FiveM's compilation of Node
I know there was some history and people here didn't like it, but they actually solved the "window" global parameter pollution and it was working as it should
.... until I tried to update to v12 yesterday 😢
the data.embed_enabled here is deprecated, in favour of data.widget_enabled, im going to do a PR, assuming it would it be better to deprecate Guild#embedEnabled, in favour of Guild#widgetEnabled, is deprecating a property as simple as just adding the @deprecated tag?
(relevent API docs PR to show its deprecated, https://github.com/discord/discord-api-docs/pull/1536/files)
You use util.deprecate iirc, @deprecate only JSDocs it
I'm pretty sure that's only for functions
Is this a bug in the client? Whenever I deleted an uncached message but listening to it as partial, the .system property is always true, but that's not correct?
Suggestion to add field inline limiter, so you can use two values each line if you want to
That's quite easy to implement, but really not a feature for D.JS imo
Especially since .addBlankField has also been removed

addBlankField was just a shortcut for addField('\u200b', '\u200b'), that's why it was removed. You can still do it on your own, adding that as 3rd inline field will "fill" the 3rd inline space
However, that will render badly on devices that do not have ability to render any form of inline fields inline. Additionally, embed rendering is purely up to discord - as example can be not-that-recent embed update that allowed to have 3 inline fields and a thumbnail.
so i was actually looking around trying to figure out why user#flags can be undefined, found this, kinda odd? how the API sends it but its not picked up?
Seems that the API only gives information about public_flags for some users on startup for some reason, manually fetching the user will return the property
I don't think the library can do anything about this
https://github.com/discord/discord-api-docs/pull/1490#issuecomment-613546566
There is still User#fetchFlags
ah, assumed that it was just being lost somewhere
Message#suppressEmbeds seems to be broken when using the allowedMentions client option
(suppressEmbeds calls Message#edit, which uses APIMessage.resolveData and adds in the allowedMentions default option)
would the best way be to just call the endpoint directly in suppressEmbeds rather than calling this.edit?
i feel like theres a better way but maybe thats just because its 2:30am and i haven't slept 
broken in that it will unintentionally also edit the allowedMentions?
Reminder: message edits do not ping the user/role(s)
would ids be bigints in djs@next?
possibly, not much is set in stone yet for djs 13
broken as in the API returns an error (if said message is authored by another user)
(i thought i mentioned that but must've slipped my mind lul) @copper laurel
Ahh right, makes sense
As for BigInt - why? I don't see any value in them being handled as integers, strings works perfectly well.
tbf most sensible languages handle them as a numbers
there isnt any particular reason why we couldnt
Except we have the constant conversion between BigInt<->String for REST
Not sure if I should make a new issue for this so I am just gonna try asking here first.
https://github.com/discordjs/discord.js/pull/4087#issuecomment-619242608
I didn't get a response from any of the lib devs on this besides a reaction which doesn't help clarify to me what you guys plan on doing for this? Should TS developers expect breaking changes without warning in the future on what should be a stable branch?
No, updating typings is not a breaking change
if it breaks projects it is a breaking change, and this broke projects aka breaking change
If DJS doesn't want to properly support TS devs then thats different, but any TS dev using TS properly the way it was intended broke from this PR
All im asking is to just give a proper bump to the semver, im fine with the change ill make the changes to my code but dont implement a change that can break projects in a minor bump plz
npm i on the vps and projects breaks RIP!
You don't bump major because you want to, you bump it because it should be bumped. Typings are non-code changes
When a PR breaks a project it should be bumped
the question is whether or not DJS is wanting to properly support TS developers
If DJS wants to properly support TS, then it should enforce proper warnings of breaking changes that DO break TS projects. If it doesnt then thats the devs choice and right to choose and myself to live with
But come one folks, this is a pretty simple ask to not introducing breaking changes for TS devs in a non-major bump 🙏
This is not how things work
This is not a breaking change. If you're extending the functionality of D.js, that's on you
You don't bump the major version because X gets messed up by it
I highly advise you read this webpage: https://semver.org/
correct, yet the API wasn't changed.
this is incompatible with the previous commit aka breaking
just typings behaivour
yes it was
this does not fall under semver major
@timid pewter How was this a breaking change
no parameters were moved/removed, no methods were removed
The API was clearly changed, it prevents a lot of behavior
it prevents emitting events that arent listed in those types
anyone that was using that behavior which was supported by DJS broke
Api didn't change. It was typings file that changed, it's not exactly part of library source code
this, typings changes alone will never fall under anything that isnt semver patch
the typings are what provide the api to ts
It doesn't prevent anything. tsc now tells you types don't match
aka the api did change for ts devs
It doesn't prevent anything. tsc now tells you types don't match
No it prevents it. Bots wont start
once again, this is not how semver works, also see what Daro said
TBH daro i was just hoping for a answer from a lib dev and then ill be on my way
You can launch compiled code anyway, so nothing broke
I don't think you guys understand how working on a TS project works and how massively this PR effected end users
Hey, I'm implementing support for chunk_count, chunk_index and nonce properties in GUILD_MEMBERS_CHUNK on discord.js. In the event emit, should I better put count and index into an object or leave them as two separate parameters?
Like... (members, guild, { count, index }, nonce) or (members, guild, count, index, nonce) ?
I think one single object would be good, in case they add more props.
^
id also be on board with that
generally more in support of objects in all cases almost
One single object containing the three properties so?
yup
Fine 👌
as for the bigints, i just wanted to know if they'll be used as they exist now, not insisting they should / must be used, but just showing the possibility
for snowflakes? there is no real reason to
the library has functions for extracting data out of snowflakes without using a bigint, and dapi gives snowflakes as strings
@rigid trail read above (like, really)
that conversion everytime seems unnecessary when thinking about it, but wouldn't it actually fit it better?
i agree with monbrey in saying its a useless conversion, most users dont have to do any integer things on ids, and if they do its an easy construction of a bigint
this is true
i also see no need to do math on ids
but the data type exists now, why not use it?
just because something exists doesnt mean its a good idea to use it
BigInt may also confuse begineers (it's already complicated sometimes as strings so I don't imagine...)
all the math you have to do on snowflakes theres a deconstruct method for it
there really is not much math u can do on snowflakes
(should there even be in the first place?)
what
forget it
the deconstruct is used internally too
timestamps, right?
making it a bigint is quite frankly, pretty useless for most if not all users, and detrimental, as it will be a pretty gigantic change
also inconsistent with dapi as snowflakes are strings when sent, not integers
aren't they strings to support languages that dont have support for 64b ints?
which now, js isn't
yes, but the support isnt as seamless as other languages like python, it really serves no purpose yielding a bigint, instead of a string which can easily be converted to a bigint if somebody needs it, which again, 99% of users wont need bigint snowflakes
actually, yeah probably
so this change would be:
- Gigantic (most bots rely on the id property)
- Pretty useless
- Mostly just an annoyance
Thats my take on it
well yeah, useless - probably
anyway, v13 would be a gigantic change on its own, so bigint snowflakes shouldn't be the thing we're afraid is going to break alot
just because other breaking changes will happen doesnt mean we should break things just because
realistically, what use will this bring, for most users, absolutely nothing lol, it will just be annoying
and unlike something like managers, it doesnt really have a purpose for the library itself either
again, just a possibility ¯\_(ツ)_/¯
There's absolutely no point to use bigints here, it's like making a change for the point of making a change which is really rather stupid
aren't they strings to support languages that dont have support for 64b ints?
which now, js isn't
Note that BigInt wasn't "merged" into nativenumber
number is still a primitive, and it still has the same size, bigint is a specialty object if you need to deal with large numbers
I mean people accidentally use numbers for ids already and it's causing them errors everywhere... and while you could argue that that's a beginner level problem, you can't deny that it will just bring more errors when people are trying to handle them like number, forgetting that yes, bigints are sth different
The fact that the language has BigInts does not make them a good or well supported option and it will do nothing to address people who use IDs as numbers. There is no use case I can think of for making the switch, and as Vlad pointed out, they need to be sent as strings to the API anyway
I mean can we use BigInts? Totally! Should we? nah
Monbrey that's not what I meant. Messing up Bigints and numbers is even easier than Strings and numbers. And using bigints is also needlessly complicated judging by this mdn doc. So the few places where you'd want to have ids as numbers (which I can't think of rn) wouldn't benefit from it in the slightest anyways
Yeah I know, I was agreeing with you, or I meant to be. BigInts are not a useful implementation for us to be using
This is a snippet from the discord.js sharding manager. Can someone tell me why the await statement is not outside the for loop? (github link: https://github.com/discordjs/discord.js/blob/026691702da7d1fcf9a959f00082f07f1e14b13d/src/sharding/ShardingManager.js#L209)
because the promises array is defined in the for loop?
if you look at it, there are delays getting pushed into the promises array to delay the next loop run
I get that. But this way the shards would spawn serially. I'm just wondering if it would be better if they spawn async?
Or am I missing something?
There is a 1/5 rate limit for identifying, this avoid failing attempts at such.
Got it. Thanks!
i wanted to know if the owner of a guild is always cached or not, because intents are giving me an headache with this
no, also a question for support channels not here @tawny warren
guild owners are guildmembers same as any other member and are subject to cache, use guild.ownerID instead
Wouldn't it be logical for the GuildDelete action to use a typing method in it's condition (for example, ClientUser#typingIn()) to return a value to determine whether or not the client user is typing in the provided channel to not call TextChannel#stopTyping redundantly? Or am I missing the point here?
TextChannel#stopTyping() already has a check for this https://github.com/discordjs/discord.js/blob/stable/src/structures/interfaces/TextBasedChannel.js#L234 (which is pretty much the same to how ClientUser#typingIn() does it)
Hey, hope it's the good channel to ask. I'm wondering if the fetch function is of any use in the RoleManager. As of my understanding, the cache should basically always be up-to-date, so is there a reason the method exist?
Source of what I'm talking about is there: https://github.com/discordjs/discord.js/blob/stable/src/managers/RoleManager.js#L48
Not everyone keeps everything cached and there's no issues having a fetch method just in case
What do you mean by "not everyone keeps everything cached"? Is the cache opt-out? And so, would you recommend using fetch() over cache.get()? That was my understanding that is was the preferred approach but wanted to be sure.
No, the cache isn't "opt-out" but some people might manually clear the cache
Alright. But either way, the best practice would be to use fetch, right?
not unless you modify cache. cache should always be up-to-date, as you said earlier, too.
I know I'm exaggerating, but is there any way that the cache would somehow miss roles? Packet loss, problem with the Discord API, or whatever? A very rare occurrence, but still possible?
not really no
So fetch is only there as a short-hand and if we manually remove entries from the cache, then. Got it, thank y'all
its also there for api coverage
just like guild manager and channel manager's fetch, its not much use to most people but some people may use it and the library should allow users to be able to use the whole api
Ah, I didn't notice that. Thanks for informing me, @real jetty. \👍
what is the reason for dynamic in image options being false by default?
breaking changes most likely
thought of that, but why wouldn't it be true by default in the first place?
When was discord.js made?
This isn't a question exactly appropriate for this channel, but the first commit of discord.js was Aug 9, 2015
If you have more questions about the history of discord.js please ask in #archive-offtopic
@snow crypt well, because it would be breaking. before dynamic you would always get an image in format you wanted ({ format: 'png' }). Since png is not gif, you get png.
To get a gif when person has it, and a png when person doesn't have it, you would have to check if avatar hash starts with a_ and pass format appropiatelly. That's exactly what dynamic does.
if it would be true by default, you would have exactly 0 idea why the hell you pass { format: 'png' } and get a gif, but only for few people.
didn't know dynamic didn't exist when the initial switch to functions was done, makes sense
discord.js-next/pull/24 is just updating a lockfile and adding 2 empty typescript files
It's a WIP PR. It's to track changes by that contributor
Draft PRs exist, and this one isn't marked as one. is your #25 also wip for tracking, or is it somewhat ready?
there isnt even much you can do with the pr when there is no rest, no client, and no gateway lol
I should also point out that any PRs which are nothing more than a copy-pasting or port of existing code with some type annotation slapped on are unlikely to be accepted
@ornate topaz It's for tracking. @copper laurel I know it might not be accepted
@surreal geode If it's for tracking, why is it not marked as draft? Draft PRs are unmergable until marked as ready
Oops sorry. It's marked as draft now
Should docstrings for Collection mention that sort and sorted are stable starting with Node 12?
Shouldn't there be a clone method for MessageEmbeds?
also freeze
more like permissions handle it
that would also prevent actual embeds from actual message be changed
You can already do new MessageEmbed(embedToClone)
I've seen this, and seen that the default method is process, just wondering what would be better about using process vs worker? https://discord.js.org/#/docs/main/stable/typedef/ShardingManagerMode
Also, worker threads are not experimental anymore since Node 12.x
@topaz mango i know, but you can also do new Permissions(permissionsToClone), but as they can be frozen, the methods check for it and operate on clone if frozen
shouldn't this be done with embeds too?
also, it's non-breaking to update
What's the use case?
same as for permissions
making Message#embeds array elements to be frozen
see as GuildChannel#permissionsFor returns a Readonly<Permissions>, because both memberPermissions and rolePermissions (internal) call .freeze() on the permission before returning
Making Message#embeds contain frozen elements is breaking.
As much as I'd like them to be frozen.
@slate nacelle how is it?
the interface would be the same
but MessageEmbed methods would check if it is frozen, and if it is - return a modified clone
again, like bitfields do
They'd no longer return this but a new embed, changing it's behaviour in a non backwards compatible way.
Does https://github.com/discordjs/collection have a minimum Node requirement?
Context for the question: I want to either clarify (if Node below 12 is supported) or remove the mention of sort being not necessarily stable.
Because in Node 12+ it should be stable.
That's v13, aka next
but next is gonna be ts
and unit tested
and more
i mean a branch parallel to master, but that accepts breaking changes
but semantically that would be v13, which is djs next
So no further breaking changes are expected to the current codebase? Even if Discord does something unexpected to the API that needs them?
it is highly unlikely discord will make unexpected breaking changes to the api and require people to bump to the new api version
but no, v12 will not have breaking changes
By definition, yes. My question is "can there be a v13 before d.js-next gets ready".
im no dev but for that to happen djs-next would have to be made v14, @slate nacelle would that be acceptable in the unlikely event discord required breaking changes
No clue, we'll see it if it comes.
@rigid trail can't it just be pre-v13-dev or something?
still feels like it should exist
If there is a need for a breaking change, then PR it to master and a v13 will have to be released
The one being discussed here however is really not worth a semver major bump on its own
I saw, by doing a mistake in my code, that GuildMember.hasPermission(permission) doesn't throw any error when the permission isn't in the good format (for example, a typo in the permission flags).
The execution just stop silently.
I wonder if it's useful to open a PR to fix that or if it's just done on purpose? I hope it's the good channel for, if not, really sorry (don't hesitate to @ me)
doesn't occur for me
(owner and admins will always return true unless you specify to discount that)
My precise mistake was :
message.guild.me.hasPermission("VIEW_AUDIT_LOG,MANAGE_WEBHOOKS", {checkAdmin : true})```
In guild where the bot didn't get admin permission, the execution just silently stopped without any message error (don't ask my why I did add it this way...)
Probably you're eating exceptions somehow without displaying
I log all unhandledRejection, but I will take a better look. Happy to see it's not due to d.js, and my bad 
Thanks and sorry 
I don't think that's how bitfields work
Pass in an array ['VIEW_AUDIT_LOG', 'MANAGE_WEBHOOKS'] instead
Are Discord API endpoint changes going to be added to v11?
Oct 7th: intents are required - will not be happening for v11
Nov 7th: domain changes are required - doesn't really matter as v11 is already not usable anymore
in djs 12 Manager#fetch is typed as Promise<Thing>, where Thing could be a user/channel/whatever. this is assuming that the fetch operation always succeeds and finds something. is this by design or a mistake?
its not assuming that, the promise could reject
does the promise reject when the snowflake isn't found
looking at source code, no
god i can't wait until djs next is released and i can bathe in first class ts support
not sure what specific manager you're referring to, but at least the channel manager seems to have the appropriate logic
Yeah not seeing the issue, most will include a call like this: const data = await this.client.api.users(id).get()
That handles and throws DiscordAPIErrors, so the fetch call, which is just an async function, would reject
Shouldn't channel type group be removed?
bots can't be added to group dms, so kinda seems like a weird choice to keep it
They could be added to group dms before iirc, so some still may be there
Bots can fetch invites to group dms, which yields you such a channel.
oh, ok
@slate nacelle continuing the embed discussion, what if we added .clone() that just returns a new this.constructor(this)
or add freezing, but not freeze current non-frozen stuff
.clone() would be redundant, just construct it normally. The whole thing is currently non-frozen so you can't add freezing to it
Why is https://github.com/discordjs/discord.js/pull/2910 not being merged?
@slate nacelle why do you check if the max listeners are not zero?
Because 0 is used as "no limit", incrementing would set the limit to 1, decrementing it would throw.
and what about #2910?
Would a pr that set the default id of fetch to 0 be useful ? I say that because when you do not provide anything it returns a 404 instead of 'uknown user'
it would be a breaking change
Why ? 🤔
it changes the response
yes I see 🤔
@opaque robin could you add what space requested in #4103? I really wanna see it merged
also, the d.js error is not imported
Why doesn't it throw an argument error if you call fetch without passing an user object instead of doing a bad request?
This seems more like a support question, but you'd really need to be more specific about which fetch endpoint at least, there are a lot
that would be breaking btw, so that could not be changed either ways
I was replying to the thing above
https://github.com/discordjs/discord.js/issues/4151 any ideas on the situation with this?
Causing major problems with one of my shards right now, sending 3 messages per command
There's an open PR aiming to fix it
Alright ^ ty
@snow crypt k I’ve just been busy with other stuff
i have a suggestion for a future version: a user/guildmember hybrid object without an user property
my reasoning: intents can get messy and sometimes member.user can return undefined and everything goes downhill
There's a few issues with that. First of all, the User and GuildMember objects/endpoints are completely different in the Discord API - they aren't a hybrid and as an API wrapper, it wouldn't be a correct implementation.
Second, while in theory a GuildMember object could extend User and include those properties, its not a good design pattern. It means we'd have to update every GuildMember hybrid object whenever a shared User property changes, instead of just the single User object which is referenced by member.user
In a broader sense about your concern with intents - I agree. The way discord.js is currently built does rely a lot on its internal caches for a lot of things, and those need specific intents in order to be filled and for that functionality to work. Making any changes to that behaviour would be huge, and almost definitely breaking. It'll be considered as part of the discord.js-next / v13 rewrite
@slate nacelle how is it cached?
isn't it there a way to iterate through getters/setters and peoperties and attach them to an object so the references are kept? or i just understand the core of references wrong?
you could use what is called delegation
so when you access member.tag it will actually be member.user.tag
?npm delegates
but there's really no reason for that
i was going to write up some TS enums with pretty comments for gateway opcodes, where would those files belong in the ideal djs@next repo?
@drifting knot i guess it will be the types package
would this affect d.js https://github.com/npm/rfcs/blob/latest/accepted/0025-install-peer-deps.md
npm v7 looks like it will install peerdeps automatically
and I know d.js has peerdeps which might conflict like sodium and libsodium
there are some solutions in the file, I guess we would need to do some of those
are private props in WebSocketShard intentionally not shown in the docs?
what props are you referring to?
Probably not
pr incoming 
All of those are private props you don't need access to
I guess they're missing an @name although then again; you won't need those variables ever
@snow crypt i think both would be the better option
the fix i suggested also fixes another issue i mentioned here a couple days ago
which one?
to where calling suppressEmbeds throws an API Error if you have the allowedMentions client option enabled, and said message is authored by another user
well, i tested passing undefined, but that removed the mentions
instead of keeping them
That sounds like an API bug
could be
aka test it and report tbh
ah, no i was mistaken before, both null and undefined do the same
I don't know if it's already been asked, but it'd be awesome to have a property User#nitroType which returns either 0, 1 or 2, as API returns, or <null>, NITRO_CLASSIC or NITRO
nitroType requires an authenticated request (through oauth2, with the identify scope). As we do not provide any utility for oauth2 requests having such a field would not bring much if any benefit
All the information a API request from a bot for a user returns:
{
id: '83886770768314368',
username: 'Souji',
avatar: 'c97d04911a8bc6f059900e913649fd1b',
discriminator: '0001',
public_flags: 640
}
ref(oauth2): https://discord.com/developers/docs/topics/oauth2
GET /users/{user.id} doesn't require oath. Otherwise, how could you return User#locale?
That endpoint doesn't, but when requested by a bot token, it does not return information such as locale and nitroType. Retrieving that data does require full OAuth, as Souji said
Then how do you return User#locale?
the full return from that endpoint is in my initial response.
we also can not provide the locale, despite it being documented it will always be null, there used to be a dummy value for bots which was provided, however this is no longer true
the property still existing in the library is an oversight
Sad :c
Thanks
Can we hope that, one day, we can have support for oauth2 requests?
That requires a web server, which is not the purpose of djs.
unlikely, discord.js is a wrapper for the Discord bot API
the purpose of oauth2 is to grant a token to do requests as the user, which is no longer part of the bot API
the request also requires an endpoint for the redirect
ok, thanks
maybe opening an issue would raise more attention
@snow crypt i'll open an issue when npm v7 is close to release as rn the latest seems to be 6.14.5
@digital hawk open it now so we can fix it ahead of time
ok
Hey, quick question regarding one of the library dependencies
The choice of node-fetch for > 12.x has any particular reason beside snekfetch being deprecated?
Okay, thanks 👌
Either way one that works some of the time would be better than none at all
A fix really isn't that hard, it just seems like they made a mistake while implementing
I can PR one, I just wanted to know the reason why it got removed before I open one
There will be proper rest stack traces once I get to actually re-doing my REST PR
space pls
Ahh great! Then I won't open a PR
It's nice that you can, but please don't be overconfident and think we didn't have internal discussions and trials before reverting it.
It wasn't "just" a silly mistake. Also theres performance implications with async stacktraces on top.
could be nice to have an option to use async stacktraces then, so it's off by default, but can be enabled
No such thing without a working implementation
why have a feature that doesn't work all the time? you would explicitly enable async traces, just to get that [object Object] when you least expect it
Altering the stack trace isn't the solution
And it only works in v8 and not in any browsers that don't run v8b(like Mozilla or Safari)
The solution is implementing something that doesn't mess with the stack
In which case there can be multiple activities to a presence ? (=> Why is it an array (GuildMember.presence.activities) ?)
Custom Status + Other presence
many more cases actually, discord just sends all activities, no matter which are displayed in the client GUI
spotify, games, code editors, custom status, etc.
this used to not be the case, but was added as feature (by discord) around the time when v12 neared end of development
oh ok thanks... ^^
maybe that should be written in the docs, because it is not really clear when this can happen ^^
Simplest example would be rich presence and spotify
has something been done about this, bots can ping roles now
i'm in a bit of a panic since this is going to lead to some serious abuse
disabledmentions doesnt seem to have anything to stop role pings right now
other then not formatting them at all
or maybe i'm just stupid
Shouldn't that mean it's off by default?
I updated discord.js quite recently so something seems off
So should I just set allowedMentions to 'none' in the client
Docs said it's the default value but maybe I'm just reading it wrong
I tested and other bots seem to be able to ping as well
Oh - I figured it out. Sorry to bother 
Hi there, I was wondering about support for the new js runtime, deno. It hasn't hit its 1.0 release yet, so i understand if development hasn't started yet, but I think it would be interesting to see a d.js module for deno
If not, i'd be happy to help when deno gets released. good learning opportunity for me :P
regarding the issue #4284, this seems to be the problem, https://github.com/discordjs/discord.js/blob/2583ad5da7db5ab92dfa357909f9c713db0a2981/src/structures/Message.js#L479-L484, but why was that even done in the first place? seeing as it causes the event to be emitted twice
or at least, done in a way that emits the event
g#4121
@vernal atlas methods that cause an event to be emitted called the handler itself as a fallback (for cases when the ws wasn't connected or w/e), the handler then has some logic that checks if its alr been handled but that seems to be missing on MessageReactionAdd. there was a discussion a while ago about always assuming the ws event would come thru and not call the handler itself but instead handle the response within the method itself to avoid double emissions (which was done on Message#delete() / TextBasedChannel#bulkDelete() a couple of months ago iirc) so #4285's approach seems fine except it needs to call MessageReaction#_add

Hi hi! Would I be right in stating this thrown TypeError is improper?
https://github.com/discordjs/discord.js/blob/master/src/managers/GuildMemberRoleManager.js#L93
It has a grammatical error: TypeError [INVALID_TYPE]: Supplied roles is not an Role, Snowflake or Array or Collection of Roles or Snowflakes..
The other TypeError just above on line 85 seems fine though! In comparison, the latter TypeError includes all possiblities of the accepted types, but the former TypeError doesn't include them all which I'm not sure is intentional 😅


its still v13