#archive-library-discussion
25217 messages · Page 23 of 26
Yes
alright that worked, thank you!
also seems like we can no longer pass action rows in the form of an object when sending messages? The error is bigger than that but I can only show that much at once
and creating an action row instance doesn't work either
from what I understand of that error it's saying that you can pass an object but components can't contain a SelectMenuComponent class object but should contain a plain object
same for the second error
I'm using raw objects and haven't encountered any problem so far
hmm yeah seems like the types need fixing
does it actually allows mixed objects though?
no reason why it shouldn't
so yeah ig
I’m pretty sure it doesn’t if you want to mix then use .toJSON
it does because it calls this on every component
Which line calls it in djs again?
Well it’s serialized in djs
this is raw -> builders
not the opposite
huh?
you need to call .toJSON() when sending builders classes
it checks if the component is already an instance of the component class
no you don't
not in djs
ah i see, but you sent a screenshot of an unrelated thing
it has overrides I think? Because yes consistency baby 
so the types are wrong right?
im not sure how to fix them because I don't know where the issue lies
yes
calling toJSON() fixes the issue temporarily, as siris mentioned
but you shouldnt need to
@outer raven do you want me to fix the types or are you making a PR?
I'm not sure how to fix them so feel free to
Alright
@outer raven I don't think I can do the PR without breaking the existing json types
btw this isn't the modals pr
why not? Isn't it just adding the classes out of the possible types?
because the component classes and json interfaces share the same properties, which means that if we union them the type constraints for them become loose. They become loose because builders hold partial data, while json objects don't
so basically we lose all of the required prop type checking for JSON
unfortunately if you want to use builders and don't care about the JSON types loosing you can use module augmentation 
well tbf component types have gotten so complex that i dont rly understand them anymore but if you add a class to a union type wouldnt typescript be able to check if you're providing an instance of that class or an object and cast the type accordingly?
I mean this was possible in v13 so it definitely is possible now, just needs some adjusting
If I'm reading the v13 branch properly it suffers for the same loose typing downfall
I rarely mix json and builders so I probably never noticed
Yeah when I did components originally the types were very loose
Siris was the one who improved them so I'd trust him lol
By “improving them” they became quite complex and often cause more issues than they solve
Iirc in v13 you do get errors for missing props when using an object in a component’s constructor, so that shouldn’t be an issue
You’re arguing about them being too complex while also suggesting to make them more complex by adding a union
A union isn’t more complex? It’s just another option for what you can pass in the constructor
It’s not, you have to modify the *Data type itself
ig after https://github.com/discordjs/discord.js/pull/7197 CommandInteraction docs don't have options property. Is it's intentional?
Yes
Not sure if I did something wrong or this is already known but with the last dev version I'm not able to send an embed using Embed builder as it gets rejected by Discord saying that a description is required (even if I added one of course)
The json data sent is in the screenshot and the Embed doesn't seem to be correctly converted to json...
A reproducible sample is quite easy like the following:
interaction
.reply({
embeds: [new Embed().setDescription("test")],
})
cannot replicate

discord.js@14.0.0-dev.1645142857.f7257f0
Same
builders
let me see
Oh wait a moment
Uh, strange
whats your builders version
Same, let me send a screen of the dependencies
yarn why @discordjs/builders or npm ls @discordjs/builders
this is what i used ```js
const { Client } = require('discord.js')
const { Embed } = require('@discordjs/builders');
const client = new Client({ intents: 1 });
client.on('ready', () => console.log('ready'));
client.on('interactionCreate', async interaction => {
if (interaction.isChatInputCommand()) {
await interaction.reply({
embeds: [new Embed().setDescription("test")],
})
}
})
client.login();
I'm deferring the reply actually but I tried it with reply and still
Reinstalled and used a normal reply, error is still there, I'm really confused now 😂
what does your src/structures/MessagePayload.js line 196 look like
discord.js folder in node_modules
btw, are you sure you're not using unsafeembeds? because there was a bug with them not being serialized and the fix is not on @dev yet
yeah I'm using a normal Embed
embeds: this.options.embeds?.map(embed =>
embed instanceof Embed ? embed.toJSON() : this.target.client.options.jsonTransformer(embed),
),
oh wait
I think this should be fixed with the introduction of isJSONEncodable
just not published I guess
same as mine
in theory isJSONEncodable would only fix the issues with UnsafeEmbed ¯_(ツ)_/¯
i guess just wait for another dev release and see
Well, this is weird ahahah
Yeah but the fact that the embed is nested in data can only happen if the toJSON method is not called, which happens only if embed instanceof Embed is false, and it shouldn't actually, but isJSONEncodable checks for the existence of toJSON directly without using instanceof so I guess it should work.
Still not sure why it isn't instanceof Embed but... not such a big problem actually
I know, you don't like eta questions but... When will the new version of the djs be released (v13)? I see that everything (probably) is about done on the modals PR.
We don't do ETAs and everything is not done
Okay
I'm guessing one of u is using djs' Embed and another is using builders? Then the instanceof Embed would fail for one of you (whichever one djs uses). Either way problem is fixed next dev release
it worked with discord.js' and /builders embed for me
I think I had issues with builders as well although I didn't look into it much because siris made a pr almost instantly to fix it
Yeah it was weird because the djs' code seems to import Embed from /builders, which I was using...
However should be fixed now
Hey guys, was wondering if anyone could give me a run down on guild.members.fetch() and just how we are retrieving info at scale in general in discord.js before I dive into the code myself? I just ran that function in a very larger server and was shocked by how performant it was
major shout out to the contributors
it's event based, it tells discord that it wants members and then discord sends the members as gateway events in 1k member chunks until either it's done or it times out
yeah it blasted through 100k with very little effort
thanks for the high level explanation!
how large approx is each of those member objects?
the event in question is GUILD_MEMBERS_CHUNKS / guildMembersChunk if you want to listen to it btw
tysm, so appreciate these breakdowns cuz it saves so much time while I am looking through it myself
i don't really know off the top of my head, but the full structure that discord sends is available on the discord docs if you want to see how much data it's sending
https://discord.com/developers/docs/resources/guild#guild-member-object
yeah just put together something and shipped it really fast, now need to bridge the gap between understanding how this lib works to ensure it's performant
If you're fetching all members of a large guild, its never going to be particularly performant. However yeah as the others have said, rather than use a REST API to do this, discord.js sends a opcode to the gateway requesting members
Discord then sends back several guildMembersChunk events which the library collects until it has them all, matching guild.memberCount
ig this isn't intentional. is it? it should be ActionRow right?
index.test-d.ts
ig expect error is there only for empty object not for wrong class name.
yes, it should be ActionRow
Are any kind of ratelimit issues known, which causes a local limit on a specific route/resource?
Did not found any issue on github and others can not reproduce it.
Ik, wrong channel, its not a Discord bug, raw requests works with status 200
The new rest manager has the same issue...
|| #944920036471111680 ||
Does anyone know if the next version will have the ability to add a banner to guild event creation?
that's not possible in discord assuming you mean creating a guild with a banner because you need boosts to do that
the dev version has it
if you talking about guild scheduled events
yep, awesome thank you
@outer raven how are you managing https://github.com/discordjs/discord.js/pull/7529? What code gave you a union of all channels?
like I said in the description, an options object with no type specified
turns out the test with an empty object was seen as an undefined value somehow
so TS didnt pick up on that
if you specify one of the properties you get the bug
I'm not able to reproduce that
I'm not sure how that comes to be because the type is required in options, so that overload should be skipped and head on over to the last one, right?
And wouldn't these tests pick it up? O_o
well this is awkward, because I can't reproduce what just happened to be 10 minutes ago
I think I know what happened here give me a second
yep, so I had a channel with an incorrect type set as the parent, which messed with the types
guess I'll close that because that should never happen in normal conditions, my bad
Is okay [:
@dawn merlin
function copyProperties(target, source) {
for (let key of Reflect.ownKeys(source)) {
if (key !== "constructor" && key !== "prototype" && key !== "name") {
let desc = Object.getOwnPropertyDescriptor(source, key);
Object.defineProperty(target, key, desc);
}
}
}
https://github.com/discordjs/discord.js/issues/7517#issuecomment-1048262707
will this work?
Sure but would it copy the setters? Because the setters shouldn’t be copied
lemme test all i didn't tested it
Also have you looked at InteractionResponses.applyToClass? You might be able to take some inspiration from there
lemme check it bc ig above one isn't working as expected
I was testing with few functions and found this one helpful but it includes creating instances but I can't find any other good way to do this i'll try later
function cloneClass(target, source) {
for (let key in source) {
if (source.hasOwnProperty(key)) {
target[key] = source[key];
}
}
return target.constructor;
}
const B = cloneClass(new A(), {});
console.log(new B().b);
copying properties and gatters only
edit: above approach was wrong
ok
In your case ig something like this will work
nice, if you don't mind you can make a PR. Probably easier since its ur idea
okay sure. I'll try some other if I can find any simple alternative or i'll use this one
@dawn merlin I've found another workaround which is working fine. But how can I update typings? Should I create a new interface for components coming from api (ButtonInteraction.component)?
@dawn merlin did you test the code sample you sent on https://github.com/discordjs/discord.js/pull/7531 on main?
how can I fix them?
if the CI doesn't error you can ignore that
run yarn build to see if it completes
yeah that's why I was ignoring but as no was reporting so I thought these errors are coming to only me
lemme try
they're not, but they don't error on dev builds because yarn resolves the other packages to their latest dev versions
oh btw build worked and now only rest have error
did you run build on the root directory?
yeah
well then im not sure in that case, but as long as you can run the build script it should be all fine
@vernal rose have you tried looking to see if mixins work:https://www.typescriptlang.org/docs/handbook/mixins.html
tbh I don't know how mixin works. I'll check it and will see if I can use it.
Found a bug when following the official discord js guide and I had to hack to get to work. Sub commands are not assigning the type when using SlashCommandBuilder.addSubcommand and the API throws this error options[0].type: This field is required
What I had to do to get it to accept commands with sub commands was to manually add it:
or (const file of commandFiles) {
const command = require(`./commands/${file}`);
if (command.data.name === 'assign') {
command.data.options[0] = {...command.data.options[0], type: ApplicationCommandOptionTypes.SUB_COMMAND}
commandModules.push(command.data);
}
}
commands.set(commandModules)
You have to call .toJSON() on the builder before using it in the api call
ahh
think that was missed in the guide walkthru
It's in the guide as shown above
Hello @void rivet, do you think you can backport https://github.com/discordjs/discord.js/pull/7436 to the v13 branch? [:
i'll look into it, sure
[: thank yous
so what, this is for 13.7?
Yea, the backport
https://github.com/discordjs/discord.js/pull/7337/files this looks to be the other half of this feature :thinking:
yeah i saw that making the pr, ig it was an oversight or even wasn't documented when it was made
Yea probably
Howdy
Can anyone confirm `npm i discord.js" works ?
I can install other modules, but with discord.js it throws an error, so I wanted to know if the issue comes from me
yes, it works
Uh ...
Weird but thanks
I use discord.js for a few months and I never had this issue, strange
In the log file it ends up telling
"Invalid response body while trying to fetch https://registry.npm.org/@types%2Fnode: EIO: i/o error, read
Idk, it's the error I get when I try to install discord.js
Never got this before so it's weird
I searched for this package on the npmjs registry, it exists, but I cannot install it with "npm i @types/node"
I was about to check djs packages.jsos dependencieson github
not an issue with discord.js
its trying to download @types/node from a random website instead of registry.npmjs.com
Any explanation ? 😭
I tried "npm i https://registry.npmjs.com/@types/node", but I got a lot of "checksum failure" 🤔
this is not a support channel, this is for the development of the d.js library
Oh sorry
I tough it should be discussed here because it's not really related to the use of the library and I just wanted to know if I'm alone
So it's one of #djs-help-v14 channels to go further ?
Alright
I will stick to this server, so #other-js-questions, thanks ^^
Because you can only edit the logged in user's voice state, not any other one, so I don't think it would belong there
@outer raven I don't wanna say this on GitHub but this isn't true...
then why was there this check to begin with?
Why are you just looking at one method
You've grouped up a method for only the client user and everyone else into one method for just the client user, removing functionality
If we could only edit the voice state for the client user... why would this class exist in a cache lol
calm down alright
I still think they should be added to the manager so you can edit an uncached user's suppressed state
Speaking of this
What really plays into whether or not a method should or shouldn't be on the manager?
Like let's say messagereactionmanager.fetchUser
If the route belongs to something there, it should be in the manager
i mean i made a PR to add every method to it's manager where applicable
if there is a manager it should have it
This is on the ReactionUserManager
Is that pr still up?
Yeah but you need a specific reaction
been merged already
could be on both
editing an uncached voice state will never be possible, should this still be on the manager?
(you always need to access the voice state's channel)
You can just disable voice state caching so that seems very possible to me
But if you do you won’t be able to edit them
It’s not possible because you lose the channel link
What do you mean
when you send the request you need to send the id of the channel the voice state belongs to. If the voice state isn't cached you can't know what channel it's on
Why is that a problem
Why do you think we need it cached
I literally just explained what
that's not gonna happen obviously
the voice state is already on a channel
and this method requires you to be on a stage channel
I don't think I can see the issue still
well I'm not gonna add it for now because of that, if you want you can PR it yourself later on
I just coded it into the manager and it works fine... I still don't know what the issue is
with the channel as a parameter, which I don't wanna add
otherwise you'd need to use resolve and not resolveId
You should add it to expose the raw functionality
Then do that and do the cache checks where there is definitely a channel
if you use resolve then you can't use it with uncached voice states 
Yes so do that where there is a cached voice state
no because then you'd be moving the user too which is not the point
so whats the point?
if the manager method only works when cached
I genuinely don't understand the confusion here
Just move the method to the manager, anything that requires a cache check keep it in the voice state and keep things raw in the manager
it's not a cache check
you literally need the whole class to make the request
it's not a check
and im not gonna add the channel as a parameter
because moving users is a method for the guildmember class and its manager
You lost me again, why are we talking about moving members o,o
if you provide the channel id as a parameter you're adding the possibility to move the member
which is not what this method is about
it's simply about editing those 2 props
Providing the channel is a requirement to edit a voice state
Voice states don't change a member's channel
They don't
if you're on channel A then edit the voice state as channel B you moved the member
bro
That's not from the voice state's endpoint
That's editing a guild member
There is only two things you can do with a voice state: edit a suppressed state & set your request to speak
Everything else you see in there goes to the guild member endpoint
then that's even worse: you're providing a parameter that can only be 1 thing and cannot be used for anything else
the error if you provide a different channel ID is "Unknown Voice State" which would sound like a library error
Their problem lol
sorry to bring this up again, but this doesn't work for dms since they aren't cached guilds,
Yeah this still isn't about library development either way
isCommand would still work
it doesn't
how would it not be about library dev if this is something missing in the lib
is a problem with the typeguards not a problem with the lib?
What do you believe is missing?
a way to get the original commandName of an interaction in dms?
The workaround would be to cast it directly to SelectMenuInteraction<'raw'>
though to typeguard it properly, I guess an .inDM() could be added
Why can’t you just access Interaction#commandName
It's not a command
context menus are commands so they have a command name
What does this have to do with context menus?
Nvm
But there should be a typeguard for asserting something cannot be the api type but can also be null
Which I think would help here
any reason why onClose is not being invoked which result in shard not resuming after a zombie connection[4009]?
Ive been trying to debug WebSocketShard.js to find why the shard is alive but isnt responsive ie zombie connection due to 4009. I am failing to understand why it wont invoke onClose method. when 4009 occurs randomly
But when I try to recreate a zombie connection it does invoke onClose which later on reconnects from the WebSocketManager.js
https://github.com/discordjs/discord.js/pull/7384 shouldn't this be backported as well?
okay then making a pr
7576 can be backported as well
#7576 in discordjs/discord.js by suneettipirneni opened <t:1646018618:R> (review required)
feat(StageInstance): Add support for associated guild event
📥 npm i suneettipirneni/discord.js#discord.js/feat/stage-instance-events
#7384 in discordjs/discord.js by fowlerro merged <t:1644664130:R>
fix(guildmember): check if member has administrator permission
I am trying to fix websockets https://github.com/discordjs/discord.js/issues/7450
Can someone help?
is there any way to fix it?
No I had created an issue in eslint/import you can check here
https://github.com/import-js/eslint-plugin-import/issues/2354
thanks!
Yeah there is that isn’t an issue with the plugin 🤔
I don't think It's possible to coerce an AnyChannel to a Textchannel that can have threads in it, since isText() allows for NewsChannel too, so I still can't use the threads object?
a typeguard could be made but honestly that sounds like a bit of an edge case
you're better off just doing if ('threads' in channel)
but it could def be made and quite easily too
how so?
this seems like a reasonable case
cant since anychannel has threads in it
Huh?
AnyChannel is a union of types
If you do that you narrow it down to the channels that can have threads
Make a PR, see how it goes
I also don’t know what you’d call a method like that tbh
.hasThreads
No that’s misleading
.canHaveThreads
Ye that’s more like it
or add .isNews() and then you can filter that out
That is a thing my guy
Documentation suggestion from @void rivet:
Channel#isNews()
Indicates whether this channel is a [NewsChannel](<https://discord.js.org/#/docs/discord.js/main/class/NewsChannel>).
what channel types can have threads
TextChannel thats it
.isThreadBased()? or does that sound like its a thread channel not a channel that has threads
its on main not on release
news channels can have threads too
sounds like a thread channel
sounds like a forum channel
canHaveThreads sounds best tbh
while not misleading, thats not a very good name. but i cant think of anything better
yeah its not a very pretty name but cant think of anything else either
just use the canHas one
Unrelated, but this seems like with djs too:
is there a reason that ```js
const channel = await client.channels.fetch(config.THREAD_HELP_CHANNEL)
if (channel === null) return true
if (channel.isText()) {
const { threads } = await channel.threads.fetchActive()
for (const [, thread] of threads) {
const msg = await thread.fetchStarterMessage()
throws at the `const msg = await ...`.:
DiscordAPIError: Unknown Message
at RequestHandler.execute (C:\Users\12156\Documents\git\prismarine-bot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\12156\Documents\git\prismarine-bot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
at async MessageManager._fetchId (C:\Users\12156\Documents\git\prismarine-bot\node_modules\discord.js\src\managers\MessageManager.js:219:18)
at async userAlreadyHasOpenThread (C:\Users\12156\Documents\git\prismarine-bot\src\threads\index.js:14:23)
at async Client.<anonymous> (C:\Users\12156\Documents\git\prismarine-bot\src\threads\index.js:29:59) {
method: 'get',
path: '/channels/----/messages/----',
code: 10008,
httpStatus: 404,
requestData: { json: undefined, files: [] }
}
is the builders package being expanded on still?
How stable is v14 right now? I know it's still in dev so there can be breaking changes, but is it worth already using it in prod 😅?
Yes its on dev because it was a breaking change, it won’t be on v13
Some things don’t work at all atm so I wouldn’t recommend it just yet
The reason is probably that the message was deleted
It isn’t and I checked, besides that shouldn’t cause a crash anyway that should just return null
If it tries to fetch an unknown message it should def cause a crash
that's not desirable behavior at all, it should just return null
.fetch* is making an API call and subsequently returns a promise
if anything goes wrong (the API errors) that will cause the promise to reject
that is desirable behaviour.
handle your promise rejections gracefully and if you really don't want it, wrap it in a function that resolves the promise with null instead
I see okay
Just a quick question as I'm looking to use discord.js for a project at polytech, is the node module free to use for non-commercial projects like this, and are there any licenses I need to make note of and comply with?
it has an apache 2.0 license
could https://github.com/discordjs/discord.js/pull/7292/ be backported as well?
issues like https://github.com/discordjs/discord.js/issues/7192 can be closed right? there are no response since 2 month. If anyone still have the issue they can create a new issue.
I mean that issue should've been closed when it was made because it's not an issue lol
shouldnt the /builders addChannelTypes() accept rest parameters instead of an array?
https://github.com/discordjs/discord.js/blob/53defb82e36108468e35077b887ee28b811891ab/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts#L51
I think so if we wanna stay consistent? @dawn merlin^
Yeah
Speaking of, I need to do everyone’s favorite consistency PR today
oh nvm almeida did it for me

I think I found a bug? this method is already called internally on toJSON and has no docstrings https://github.com/discordjs/discord.js/blob/main/packages/builders/src/interactions/slashCommands/mixins/ApplicationCommandOptionBase.ts
It's not hidden because it's not a private method
can we readd addField?
no, for all the reasons listed here: https://github.com/discordjs/discord.js/pull/7533
I tried to keep it relevant but guess they didn't feel like it
Shouldn't it be though?
It seems like an internal method considering its already called on toJSON and i don't see why any user would want to run it twice
Can only either be private or protected
Could you do some jsdoc fuckery where you put @ private? Or would ts not prioritize that?
Putting @private on it would work
the method is already set as protected (in ts, it has no jsdoc)
That PR fails to mention the burden of moving from v13 to v14 or developer experience completely, and it got closed too fast for any real argument to be made for or against it. I don't even care much about bringing back the v13 syntax, I'm against removing it entirely
It's a simple utility method that has existed for probably well over 5 years now that has (a) no maintenance burden, it was a 1 line utility; (b) had no memory footprint/ performance implications whatsoever; (c) is widely used (unlike a certain equals method recently added 🤭 ); and (4) is another deterrent from switching over from v13 -> v14.
In the original PR, I hardly see any argument for removing it, if we distinguish opinions from actual arguments. I didn't actually expect the addField removal PR to be accepted so I never got to make these comments on it.
- "redundancy" from advaith's argument:
If the goal is to remove redundancy then imo addFields should be removed instead of addField, which is probably used a lot more.You replied that addFields "makes much more sense, you can add multiple, but adding one is fine too.". Now you can probably see the issue... it all comes down to an opinion. In my opinion, adding 1 field using addFields doesn't make sense, whereas adding multiple fields with addField does make more sense. Therefore I don't consider this point valid... - advaith also brought up another point: popularity. A quick search on github shows that addField is used 444,000 times. On the other hand, addFields is only used 85,000 times (https://github.com/search?l=JavaScript&q=addField(&type=Code vs. https://github.com/search?l=JavaScript&q=addFields(&type=Code). In other words, addField is used 5x more than addFields. I searched through a few pages of addField and every usage was from djs.
p.s.: im not gonna reply to this or really view it as I already made my point and have nothing much else to say, plus you probably couldn't change my mind anyways 🤷♂️
I don’t understand how or why you prefer to add multiple fields by calling addField every time as opposed to simply passing all of them as arguments to addFields but ok 🤔
Imagine trying to add 25 unique fields manually through that method… wouldn’t be fun at all
Looking at the search results I can confidently say that there's much better ways to do this:
calling the same method over and over again doesn't make sense
and even in instances where that's not the case it's preferred due to how people use builders - adding single fields based on conditionals
bringing up "popularity" of method use is not something i'd deem considerable in the discussion of keeping singular or plural at all
In addition addField will always have an advantage in terms of usage since you'll most likely have to call it multiple times as to opposed to once (which is the case for addFields), which again is a poor approach
"makes much more sense" is much less of a personal opinion than you make it out to be, that point is about grammatical implication through how language works.
"This method allows you to add multiple fields" is implying that a single field is also okay, that is just how plurals work, you can say "we need more developers" and just getting a single one is also fine for now
"This method allows you to add a field" is implying that it only takes a single field, you cannot say "we need one more developer" and possibly think that implies there is enough space for more than one in the team
p.s.: im not gonna reply to this or really view it as I already made my point and have nothing much else to say, plus you probably couldn't change my mind anyways 🤷♂️
is always a lovely stance to bring, when you went through the effort of sharing your stance, ngl
I dont know why any of you are bothering to respond to someone who criticised the current arguments as being opinions, then gave an entirely opinion based argument, then openly stated they weren't going to listen to anything that might change their opinion
Are there any plans to fix (improve) the undocumented pitfalls of autocomplete interactions?
-
CommandInteractionOptionResolver.resolvedcan be nullish (per discord docs https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure , seeresolved) -
Fetching an option using
getUsergetMembergetChanneletc on an autocomplete interaction does not behave as expected,
[
{ name: 'for', type: 'USER', value: '163646957783482370' }, // does not behave as expected as 'user' is missing from the object
{ name: 'action', type: 'STRING', value: 'add' }, // behaves as expected
{ name: 'product_code', type: 'STRING', value: '', focused: true } // behaves as expected
]
Although the USER type is present, getUser does not return the expected output b/c it it missing the resolved user field.
(this should really be documented, I had to look at d.js source to find out why it was returning null)
https://github.com/discordjs/discord.js/blob/stable/src/structures/CommandInteractionOptionResolver.js#L193
I had assumed that d.js would resolve the user id into a user under the hood when resolved was not present.
A lot of the head scratchers here could be resolved (pun intended) by updating the documentation to reflect reality :)
Yeah it sounds like these issues are an oversight as a result of re-using the CommandInteractionOptionResolver and assuming the types would be the same
@icy trout if this is not yet an issue on GitHub, please make it one, so we can track completion
with the #7584 builders PR changes, would it be better for all builders to have a constructor where you can pass a raw object into it, for consistency? currently, only the EmbedBuilder and UnsafeEmbedBuilder support using new Embed(rawEmbedData), however the other builders lack such a method. would it be better to have these on all, or remove it from embed, just to keep builders consistent.
just for clarity, some examples:
- let mySlashCommand = new SlashCommandBuilder().setName("mycommand").setDescription("example command");
+ let mySlashCommand = new SlashCommandBuilder({ name: "mycommand", description: "example command" });
- let myButton = new ButtonComponentBuilder().setCustomId("testbutton").setStyle(ButtonStyle.Primary).setLabel("Click me!");
+ let myButton = new ButtonComponentBuilder({ customId: "testbutton", style: ButtonStyle.Primary, label: "Click me!" });
All message component builders support raw data as well
oh do they? must've missed that, apologies
i did double check interactions and they don't appear to have it, unless im mistaken again
yeah thats what i mean, things like SlashCommandBuilder
Oh yeah they don’t
is there a reason why they wouldnt, or just wasn't added/overlooked?
Probably overlooked
Not overlooked
Now that modal pr had been merged can we expect 13.7 tonight?
the modals pr for v13 was not merged
It's the v14 one?
#7431 in discordjs/discord.js by monbrey opened <t:1644395181:R> (changes requested)
feat(modals): modals, input text components and modal submits, v13 style
📥 npm i monbrey/discord.js#modals
ed92015 in discordjs/discord.js by suneettipirneni committed <t:1646380429:R>
feat: Add Modals and Text Inputs (#7023)
@void rivet do you mind doing this one too? I don't think it's in version 13 as well
#archive-library-discussion message
Sure I'll look into it when I'm back home
In v13 ThreadManager#fetch with a ThreadChannelResolvable can return a Promise of a ThreadChannel or null (https://github.com/discordjs/discord.js/blob/stable/typings/index.d.ts#L3240), is this correct? How can it return null?
seems like the method internally calls ChannelManager#fetch which can't return null, which is what I find odd
I may be missing something but I'm not sure why it calls ChannelManager#fetch()... and it looks like the parameter calls there are incorrect - second parameter is an object
Why wouldn’t it call the channel manager? It’s a channel after all
It looks like we future-proof channel types such that if you fetch a new channel type and we don't have support for it yet, the fetching returns null
So I guess in this case, it cannot return null... also @ruby terrace maybe you can look into that too^
Although when forum channels come out and we don't have support for it yet & it's being fetched, it will return null in that instance it seems
Shouldn’t it return a Channel instance of type unknown?
And tbh no other fetch method has null as a possible return value afaik
ChannelManager#fetch returns null when the channel type isn't known (unknown is only used if you construct a Channel directly, not through .create) OR when the guild is not in cache (with a notable exception that doesn't apply here)
That should probably be changed though right? It’s such an edge case that having it typed as null solely for that is a bit annoying
its not supposed to be an edge case, and you can't just yank out a valid type
But you could return a channel instance with type unknown. Either way fetching a thread through the thread manager should always return a thread
if you want to take it to that, you need to check the type of the returned channel because you can technically fetch any channel via the thread manager
Yeah that’s true
Maybe it should reject the promise whenever a non thread channel is fetched
The documentation workflow should probably pull before pushing to avoid CI failing when many commits are made at once
I believe that merge queues (whenever they come out) are meant to fix situations like these: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/using-a-merge-queue
Ah I hadn’t heard about that, sounds like it’ll fix it yeah
But still, it’s a small thing that can prevent issues for now
And it shouldn’t create other issues
pulling at that stage is probably just going to cause conflicts
you can also do hard reset with main branch so it won't cause any conflict. but ig queue is a better option.
I sincerely apologize if this is better suited for issues, but... has there ever been plans to work on a built-in framework/command handler for discord.js like discord.py has?
One of the main issues I have when creating new bots with discord.js is having to spend hours creating a framework for handling commands and events.
If there was a framework like Akairo built-in and updated/maintained, or even just a template that could be linked to something like npx create-discord.js-app, I think that would really improve the library.
isn't that just sapphire (#useful-servers)
haven't really used nor looked into it so not sure if that's what you're looking for, but iirc it's a v13 commando which i think i recall was a framework for commands?
Is that actively updated to support the newest discord.js features like slash commands though?
probably, it's maintained by djs contributors
Huh, I used to ask here pretty frequently if Sapphire supported slash commands and people said no, so I assumed that it wasn't actively updated. Now that I look at it again though, it looks like it does support them.
My bad, sorry for wasting your time!
probably just took a while to get added
We don't want to "build in" a command handler in the same way that discord.py did. We're a much more foundational API wrapper, while discord.py includes a lot of abstraction and additional features. That's not the approach we take.
Sapphire is our recommended framework - while it may not always be perfectly in sync with Discord/discord.js it is the actively maintained framework, by discord.js contributors, and is the only one that properly supports v13
Regarding your final suggestion, you can always keep your own private boilerplate repo of your template/framework and fork it into new bots or similar
You can check in our server 
Application command support has been available for a few months in the @next version, and a few bots are already using it in prod too (so it works
)
in my testing, lastmessage is always null for threads in 13 latest
Do you have the message intents?
Not able to reproduce that
You need the proper intents and must ensure that the thread actually has a last message id. If there is a last message id & the message isn't deleted & the message is cached, make an issue
https://github.com/discordjs/discord.js/pull/5367
ig this pr should be recreated because of these 2 issues. The first one was opened recently
https://github.com/discordjs/discord.js/issues/7571
https://github.com/discordjs/discord.js/issues/5350
#950042305702817842
But I'm not sure what space said.
is this is what he said?
if (this.status === Status.WAITING_FOR_GUILDS && [WSEvents.GUILD_DELETE, WSEvents.GUILD_CREATE].includes(packet.t)) {
this.expectedGuilds.delete(packet.d.id);
this.checkReady();
}
Am I allowed to send suggestions for D.js in here?
feature suggestions generally go on the github in the form of issues so they can be tracked
I know there haven't been a lot of PR merges lately but I've noticed that when there are, they are usually shortly after 12pm GMT (the time at which a dev release is published) so I was thinking that maybe it would be useful to change the schedule to try to make a dev release at 4 or 5 pm/am since that's usually after PRs are merged so that more features could be shipped faster, what do you think?
@wild flax since you’re the one who manages that, what do you think about this ^^
the collector filter function emits with a collection of all the collected items so far but the typings don't seem to represent this, is this a bug?
could we use an array instead of a collection on collectors' end events?
since (for reaction collectors) emoji ids/names are used as collection keys, for multiple collections on the same reaction, the collector would only hold one of them since the keys are the same
But reaction.users would have both in it
what if it's not a completely new emoji and other users who reacted to it are cached
wouldn't reaction.users return all the cached users and not just the collected ones? is that what's really intended?
and yes now that i think of it an array of MessageReactions doesn't fix it either,it's not that simple
i don't know what would be ideal
I don't think so but I'm not certain
well i'll test it when i can then
it should be pretty simple, just need to check on the collection, one of the .users contains the bot who should be filtered out
https://discord.com/developers/docs/resources/guild#guild-object
Based on this info member_count is only sent in GUILD_CREATE event then how djs can give the memberCount. Also it's returning null in my case so I'm investigating the cause before creating issue
GUILD_CREATE is emitted to the bot when it connects and you receive the memberCount and you cache it
and on GUILD_MEMBER_ADD the memberCount increments and the opposite happens on the remove event
Ic. In our case how it's returning null?
that is how djs caches all the guilds to begin with
could you show your reproduceable code?
even according to types memberCount isn't documented to be null
make sure you have the proper intents as well?
I've and I'm getting memberCount for 1 shard
https://media.discordapp.net/attachments/869839643850473472/952549369717092412/unknown.png
https://media.discordapp.net/attachments/869839643850473472/952549469520527360/unknown.png
9 is giving memberCount
0 + null should just be 0 though
Idk how it's giving null lol
I had that issue too when sharding, unsure how it happened so I just added || 0 to the memberCount and forgot about it
could you maybe try changing the reduce function to (a, b) => (console.log(b.memberCount), a + b)
memberCount || 0?
Yeah
Lemme try
Might just be because of unavailable/ghost guilds
perhaps you can add a filter for it beforehand?
How do you view the name of subcommand that was run
by getting it, #djs-help-v14 #archive-djs-help-v13
oh god wrong chat sofry
the types say that Components is exported by djs but in reality it's not
https://github.com/discordjs/discord.js/blob/87a6b8445bfbf3981cd39813fe961dfa1c7f2bce/packages/discord.js/typings/index.d.ts#L2526
logging it returns undefined
should this file be reexported on the library as well?
there is a Components class in ./util/Components that has a createComponent method
i think it was an oversight since createComponent got renamed to createComponentBuilder i am unsure which one you want to stick with since it is the djs package
the components class in djs and createXBuilder methods in builders serve different purposes
so the types should change to createComponent, right?
yes
or removed entirely, depends on which path you want to take
since its not actually exported
yeah i'm not sure on that either on whether or not they want it exported
it didn't make sense to me to use the word Builder in the djs package
but all this aside, there are still bugs with builders
in builders, there are cases where the createComponent -> createComponentBuilder change hasn't been dealt with, i mentioned that in rodry's pr
i'm talking about builders though
wdym, builders uses ts, that wouldnt happen there
createComponent is just being used incorrectly in that one file i mentioned
okay no i think i was checking outdated code on phone 🤔
so in the end the question is just
should the Components class from util be exported from djs?
it doesn't have a @private thing in the jsdoc so i dont see why not
yeah but i'll confirm it and let rodry make a pr
how even does the user detection work? like if u put a user token, and what doesnt the other libraries do that allow ppl to use user tokens? for example eris
No library is allowed to support user tokens anymore
And they haven't been for years
Eris is removing it too
And as for how user detection works...we don't know. It's Discords secret
Also not related to d.js
https://github.com/discordjs/discord.js/pull/7644#issuecomment-1066181908 so @unique axle are you suggesting I should use "ignore" or is that not a great option either, I got confused
that'd be my proposal, should we go with an event at all
(arguably this can easily be done right now by having a filter with side effects)
it can but like I said in the PR, a filter's purpose should be to simply return a boolean and not do other tasks and this would make people's code more organized
well I like that idea, but idk if I should commit it or wait for others to give feedback on it
i think i agree, not a fan of functions with side effects, really
ill wait until tomorrow at least to let other people give their opinions or react to your comment
also about the descriptions of the event and collection on the docs, should I keep filtered out or change to ignored?
i would personally probably go with the most straight-forward and least ambiguous, which is "collected" vs. "not collected"
alright, I have the commit ready for tomorrow then
on "notCollect" is a super shit event name though, unfortunately
lmao yeah
Is this worth fixing?
Current: <Collection>.first(-1) => <Collection>.last(1) => ["returnValue"]
Current: <Collection>.first(1) => ["returnValue"]
<Collection>.first(1) === <Collection>.first()
But: <Collection>.first() => "returnValue"
Should .first(1) or .last(1) not return a string?
Fixed: <Collection>.first(-1) => <Collection>.last(1) => "returnValue"
Fixed: <Collection>.first(1) => "returnValue"
I would say that is intended behaviour. You could be passing a dynamic number which may be 1 and still expect an array result. This breaks that behaviour
testing the bot is hard you've to do it in discord in real app is there a way i can do fake bot ? in discord.js like emiting fake events but in easy way ?
You make a good point 😄
you can always emit your own events through client.emit. Either way not something for this channel
I’ve been thinking of making a mock gateway server for testing djs
any plans to ditch commonjs and just use es modules?
... hopefully not
No, terrible idea
https://github.com/discordjs/discord.js/blob/87a6b8445bfbf3981cd39813fe961dfa1c7f2bce/packages/discord.js/src/structures/Embed.js#L203 i think setColor was missed here should i open a PR that removes this?
Sure
okay then, removing Embed.setColor
#7662 in discordjs/discord.js by BenjammingKirby opened <t:1647253905:R> (review required)
feat(embed): remove Embed.setColor
📥 npm i BenjammingKirby/discord.js#removeEmbedSetColor
Why missed?
That function is clearly adding functionality on top of the builder function
setColor is a method that shouldn't exist on Embed, it should exist on the builder
none of the embed modifying methods exist on Embed other than this
what you've sent in the pr @outer raven is outdated, the Embed class no longer extends EmbedBuilders check https://github.com/discordjs/discord.js/pull/7584
if anything the setColor method should be added to the djs exported EmbedBuilder.js
https://github.com/discordjs/discord.js/blob/main/packages/discord.js/src/structures/EmbedBuilder.js
this one
but not Embed
Ah right, not confusing at all
okay so let's make it less confusing,
setters should be on EmbedBuilder, not on Embed, that's the whole point of 7584
Got it
In GuildMemberManager#_fetchMany, it has this line for fetching with shards: this.guild.shard.send({
When I try to fetch guild members from a guild that isn't on the same shard, this line errors because this.guild.shard is undefined.
Would it be better to change this line to this.client.shard.send({ instead, or would that break something I'm not aware of?
if no one explains exactly why i'm wrong within 2 hours imma make the pr
Here are some steps to reproduce the issue:
- Make a bot with members intent enabled and add it to 2 guilds
- Shard the bot with a ShardingManager and set the totalShards to 2 (This is so each guild can be on a different shard, in reality my issue takes place on a bot that will have ≥2 shards anyway)
- On ready, try fetching one of the guilds by its id and then fetch the members.
client.guilds.fetch("insert_guild_id_here").then(guild => guild.members.fetch().then(console.log))
It should be able to fetch with no problems on both shards. However, on the shard that does not include the guild, it will throw an error because this.guilds.shard is not defined because the guild is on the other shard.
You don't have the GUILDS intent?
yes i do
['GUILDS', 'GUILD_EMOJIS_AND_STICKERS', 'GUILD_MEMBERS', 'GUILD_MESSAGES', 'GUILD_MESSAGE_REACTIONS', 'DIRECT_MESSAGES', 'DIRECT_MESSAGE_REACTIONS']
My intents
(yes, my bot is verified/whitelisted for the members intent)
the error stack:
TypeError: Cannot read properties of undefined (reading 'send')
at /Users/myname/Documents/Projects/Bots/node_modules/discord.js/src/managers/GuildMemberManager.js:422:24
at new Promise (<anonymous>)
at GuildMemberManager._fetchMany (/Users/myname/Documents/Projects/Bots/node_modules/discord.js/src/managers/GuildMemberManager.js:419:12)
at GuildMemberManager.fetch (/Users/myname/Documents/Projects/Bots/node_modules/discord.js/src/managers/GuildMemberManager.js:177:31)
at module.exports (/Users/myname/Documents/Projects/Bots/bots/Cinnamon_Beta/events/ready.js:49:67)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
gtg
nevermind, replace this.guild.shard.send({ with this.client.ws.shards.get(process.env.SHARDS).send({ because this.client.shard is not the same type as this.guild.shard
and however you'd get the shard id in other sharding types
As far as I am aware will Discord just discard those requests.
interesting. Is there any other way to fetch guild members from the wrong shard?
or do I have to fetch on one shard and then cache them in the main process (which would be an absolute pain)?
what is the reason for you to actually be fetching the members?
i need to verify that the member has a specific role in the bot's support server for their server to have a specific value stored in the database, it's part of the premium perk system
then there should be absolutely 0 problem to just use a broadcastEval for that. no need to move caches between anything
ok
what if the shard that manages the guild isn't ready yet?
or does it wait until all shards are ready to trigger the ready event
if you are doing it in ready, you could just wait until all shards spawn. you should be able to access total shard count and id of current shard. if it's last shard, call the broadcastEval
no this eval needs to happen on every shard to get the member info to all shards
i'll just do the complicated caching system that i know will work
broadcastEval, in case you didn't play around yet, runs code on every shard.
yes but it won't give info to code current file
?
it will if you write proper code https://sucks-to-b.eu/XEU1Qp.png
anyway, this doesn't really fit this channel anymore. you should probably move to #archive-sharding if you want help with broadcastEval
thanks for the help but i already know how broadcasteval works and why it won't work in my scenario and that it would take too much typing to explain it and i'm on mobile rn
@tacit crypt gonna be honest with you, I have no clue how to make tests https://github.com/discordjs/discord.js/pull/7649#pullrequestreview-908667046
so to answer your question literally, no I can't 😅
Bumping this PR on /rpc https://github.com/discordjs/RPC/pull/167
@dawn merlin i wrongly believed that EmbedBuilder.setColor had the new implementation, could you redo https://github.com/discordjs/discord.js/pull/7593
but instead of for the Embed class, do it for EmbedBuilder on djs's exported EmbedBuilder specifically?
or should i do it later?
Depends, there's no rush so if you feel up to it feel free
yeah i can do it a few hours later, it'd just be a clone of your pr just for a different class
#7673 in discordjs/discord.js by BenjammingKirby opened <t:1647358099:R> (review required)
refactor(EmbedBuilder): allow hex strings in setColor
📥 npm i BenjammingKirby/discord.js#addSetColorEmbedBuilder
Is there an interface in the djs docs for this type?
currently, the EmbedBuilder class in index.d.ts has this error in setColor method
is it worth opening a PR do just remove overrive keyword?
there's no error you just installed your deps wrong
try reinstalling them
true, thanks 👍
since the re-exported djs EmbedBuilder's setColor now takes in multiple types of input
are there any plans for the djs exported builders to use the Util methods and allow multiple input types like how it used to before?
like perhaps the setEmoji methods 👀
There’s a PR for this
#7616 in discordjs/discord.js by suneettipirneni opened <t:1646667379:R> (approved)
refactor: allow builders to accept emoji strings
📥 npm i suneettipirneni/discord.js#discord.js/refactor/allow-emoji-strings
are there no other builder methods that used to use Util internally to resolve a data?
The only other places it’s used is for verifying input and resolving a string to an enum type (which we purposely don’t support)
yeah i know, that's why i mentioned resolve a data specifically
but i'll take that as after the setEmoijs are done, there aren't any similar cases
Discord is rolling out Text-in-Voice. Since the voice channel type will stay the same, won't it have a effect on the messageCreate Event?
It would affect the Message class most likely, mainly its channel property type
I heard from some users that their bot crashed. Let me gather more info.
Stable should be fine. v12 and v11 won't though.
it does
const mess = await (client.channels.cache.get("id") ).send("mess");
await mess.react("😂");
await mess.react("🤣");
const collector = mess.createReactionCollector({"filter": (reac, usr) => !usr.bot && ["😂", "🤣"].includes(reac.emoji.name ), max: 1});
collector.on("end", (collected) => console.log(collected.map((e) => e.users.cache)));
```it does include the bot's initial reaction, i don't think there's any way to get only the collected data, it gives you all the cached users, not just the collected ones, which i don't think would be intended
i again don't know what would be the ideal solution
i don't think you want to start with an empty clone of the MessageReaction
i don't know how you even only get the collected reactions and just the collected reactions
what's with this "typescript rewrite" milestone? https://github.com/discordjs/discord.js/milestone/13
there are just 5 seemingly unrelated issues on there 
all opened by the same guy
*gal
and this "same gal" is one of the core maintainers :p
the issues are related though since the ts rewrite is.. a full rewrite, and those are desirable things to have but that are difficult to accomplish as the library is right now, if I had to guess why those 5 right now
o well i figured the latter at least
yea that would take... a while
and it would really only benefit the maintainers i guess
Yes and no
Proper typescript rewrite should create much more robust experience for all TS users of the lib
And all contributors, not just maintainers
And even for the JS users, as typings would be always up to date and accurate with the code
Not sure if this is known or not but the seems like the publish dev workflow is not working. The last commit was done 3 days ago and the last release was 4 days ago
its stuck in this commit
I know it takes time, but is the modals (v13) pr still being worked on or awaiting review/merge
I'm on holiday
That's why I haven't rebased it lol
I'll be back home on the 25th
alright, have fun
¯\_(ツ)_/¯
https://github.com/discordjs/discord.js/blob/72577c4bfd02524a27afb6ff4aebba9301a690d3/packages/discord.js/src/util/DataResolver.js#L120 should probably handle bad status code
how do you see this "handled"
throw an error
I'm curious for the new 13.7 update, especially I'm in need of the native stable release for modals. Would it be the last minor update so bot developers can move on with the major update soon?
its the last minor planned currently, yeah
Shouldn't interaction.options.data hold the options of the subcommand whenever there is one? It's a bit annoying to have to first find the subcommand when it's the only option and only then be able to get its options
Then it wouldnt be the raw data though
Or is it already promoted up... I honestly cant remember anymore
okay no it isnt
Seems like only the private _hoistedOptions property gets that but what’s the point of having the subcommand in the data? Is there a use case for that that can’t be covered by getSubcommand()?
I mean... technically no, I agree. But that's the "not raw data" use case
So you want to get the subcommand via a resolver method, then access the raw data in a hoisted fashion only for that subcommand instead of resolver methods?
Yes because I have a command with like 8 options that are the same and having to call getString on all isn’t practical
8 options from which only 2 are required
@unique axle in v13, colors are typed in UPPER_CASE, the Colors object you linked in https://github.com/discordjs/discord.js/issues/7695#issuecomment-1073218771 is from v14
so the color BLUE should resolve correctly
did you even read what i said?
I did read it all
you said it's not found because of the casing difference
but there is no casing difference
i said i can reproduce that the color does not resolve with that code on the dev version
with an explanation as to why that may be the case
but the bug report is from v13 
...
I cannot reproduce this on either the linked stable version (you should probably update to 13.6.0, by the way, minor releases are non-breaking) or 2297c2b (if adapted accordingly).
It was there at the end
doesn't make much sense to talk about v14 code if the bug report is from v13
you.. clearly didn't read
souji simply explained why such an issue would arise on 2297c2b and that he could
somewhat reproduce
and even mentioned
I cannot reproduce this on either the linked stable version [...]
So couldn't you just getSubcommand, then hoist those options yourself from the raw data
yeah but that extra step seems unnecessary since you won't need the full option data for a subcommand, you will likely always need the options within that subcommand
I mean I generally agree with you except I don't think we should ever be modifying that property since it's the raw data
So leave it alone
I'd just suggest making hoistedOptions public read-only
having both data and hoisted options as public props seems redundant but sure that could work ig
is it intentional that the discord.js/typings/ folder is not exported in the main index file?
yeah
ah okay
When will v12 be completely finished?
Answer is: in about a year
v12? That ones deprecated to the moon and back
v14? 
its deprecated but it will work for a year
according to discord
Is there anyway to run cleanup code after an interaction has timed out?
what sort of interaction timeout are you referring to?
maybe interaction isnt the right word, maybe command timeout? So when you issue a command and it listens for an interaction there is a timeout (not sure what the default is) but you can defer this.
basically im wondering if there is a way to hook into this timeout, maybe with a callback? does that make sense?
you mean when the interaction fails?
you have 3 seconds to respond to an interaction
you can defer this and then have a valid token to update it for up to 15 minutes to resolve the "thinking..." state
There isn't a djs exported ModalBuilder that accepts camelCase properties
is this intended?
we should be able to do guild.channels.resolve(channelMention)
Would rather the user parse the input, not a fan
Yeah that's not what resolve is for, does not do regex parsing of ids. Expensive operation
what do you mean by "expensive"?
Slow. Not very performant
hi, quick question: is there a roadmap for specific releases so users & contribs can know what needs to be done and when to expect a new release?
Nope not really, new prs get added to a milestone which u can follow tho
Is there anything holding this PR back? Hasn’t been reviewed by any of the maintainers https://github.com/discordjs/discord.js/pull/7649
good to know, thanks!
the first screenshot includes your bots token in case you're not aware
@hollow stirrup ^
shiiiit
also might not want to show session IDs either
people can resume with it but without your token
and just start listening to that shard's events
even gives room for grabbing your token
imo versions earlier than 13.3.1 should be deprecated due to the TiV crash
no they can't
you need the session id and the token
why doesn't djs type Events even though it exports it?
I see it here... am I misinterpreting what you're saying? x:
no you're not, i reached the wrong conclusion based on a question a user asked
[:
Apparently you can't construct a link button in an object and send it in a message but I can't quite figure out why, does anyone know the cause for this? You can make non link buttons just fine btw and the error is the one attached and I also attached the button object I'm working with
found this while adding the tests you asked for @tacit crypt, I'll commit with this line commented out as this seems to be an issue in discord-api-types so I'll leave that up for someone else to figure out
Looks like clashing versions of -types
hmm my deps are up to date though
I could update to 0.30.0 tho
updating it didn't fix it unfortunately
Has it worked before? If not, add an as const maybe?
don't know if it has because I've never had that case in my code and no, as const doesn't work
The inferred type is not narrowed all the way down
Oh, as const on the button style directly maybe ?
Don’t remember if the buttonstyles enum is const or not
there are no const enums thankfully
oh that does it ye
but we shouldnt need to do that
Yeah, then that cast should
because it works for non link buttons
Sounds like a type is only accepting a subset of valid button styles hence why link doesn’t work directly
Well, yeah that is narrowed to link only
Also don’t think it’s a Dapi types issue most likely djs types since we made changes to ActionRowData recently
but the types for raw button objects come from discord-api-types
They don’t they come from ButtonData
which is this, looks like it should work
Probably something small causing the issue
What happens if you put style in the BaseButtonComponentData
as a type generic or a property
Just as a style: ButtonStyle
do you know why there is only 5 styles of buttons?
Bc that’s what the api allows
doesnt work and type generic doesnt either
why they don't make custome color😅
That's not a discussion for this channel
ok
Hmm I wonder if the v13 types are doing anything different
cant test on v13 rn but I think they'd be fine because the issue might be because we use numbers
and TS isn't good with excluding numbers from enums
or so I've heard
We’re not using enums as values here we’re using their types
What happens when you don’t use exclude and manually list the interaction button styles
same thing happens
Now im really interested if this works on v13
can you test it?
Yeah when I get home
alright
I'm not able to reproduce this on v14:
const row = new ActionRowBuilder<MessageActionRowComponentBuilder>({
components: [
{ type: ComponentType.Button, style: ButtonStyle.Primary, customId: 'test', label: 'test' },
{ type: ComponentType.Button, style: ButtonStyle.Link, url: 'test', label: 'test' }
]
})
if (channel.isText()) {
channel.send({ components: [row] })
}
It wasn’t an action row builder, it was an object with the actionrow type
Hello guys how do i test my bot any library?
http://npmjs.com/discord-mock-server seems to be the closest to any such things
thanks
this still works for me:
channel.send({ components: [{
type: ComponentType.ActionRow,
components: [
{ type: ComponentType.Button, style: ButtonStyle.Primary, customId: 'test', label: 'test' },
{ type: ComponentType.Button, style: ButtonStyle.Link, url: 'test', label: 'test' },
],
}]});
it doesn't for me tho 
i mean that exact code snippet works but the second I put it in a variable it doesn't
can you try that?
it works in a variable as long as I explicitly set the type to (Required<BaseComponentData> & ActionRowData<MessageActionRowComponentData | MessageActionRowComponent>)
which is the same thing you have to do for v13
but thats not ideal
you shouldn't have to explicitly type it
specially not that monstrous type
well yeah the type name can definitely be reduced, but there's no avoiding not typing it at all. TS can't infer the type prop enough by itself
in v13 it's reduced to string
and in v14 it's reduced to ButtonStyle
both aren't specific enough
hm aight then
Why doesn't GuildScheduledEvent#fetchSubscribers() include member data by default when other endpoints with optional data always include it unless the user specifies they don't want it?
Also is there a reason why those users aren't cached? They're sent through the events
Any idea on how to make a warn command? Would it be better to have a database which have a general array that includes elements, that elements also include the user id and the quantity of warns
or is a better idea to have an individual array for every user
wrong channel and not djs related.
Have individual arrays per user
So https://github.com/discordjs/discord.js/pull/7616 didn't add the ability to parse emojis from strings in the constructor, however this was available in v13, should a new PR be made to support this?
i assume so, basically the same as the setEmoji method but on the constructor
Then probably yes, the constructor should behave the same
alright, will PR
Hey folks where is the best place to get updates on v13.7?
Thanks!
not sure if it goes here but the last message in #769862166131245066 is a bit outdated since you can edit your bot profile picture and name in the dev portal again
Proposal - revert PR 7584
hey, i've been told something about a new sharding client being worked on. is that still being worked on? if it is, i have some ideas to bring to the table about some perf things
I mean there's https://github.com/discordjs/discord.js/pull/7204 but it hasn't been touched in a while
right, because i saw something called discord-hybrid-sharding that implements some theoretically pretty cool ways of saving memory wehn sharding
thats none of our business
im not saying use their package, im saying use the same technology / the way they have implemented it into djs
nvm then
When in doubt, if you see opportunities for improvements, bring them up in the PR.
For instance some brought up ws related improvements already
such as?
just curious :p
which one
.
the shard one that was linked above?
ah right
last commit a month ago 
should we thread up about something regarding clusterning shards? @tacit crypt - i think it would be a good fit for your pr potentially
hmm?
i'll take that as a yes
well
there is some prior art
lets just make a thread
clustering shards
Is the reason for why something like a MessageEditCollector doesn't exist a lack of practical use cases, or would it not be advised to use such a collector for some other reasons?
Most likely a lack of practical use case, even before the message content intent was a thing
on top of that, i believe it also isn't that hard to implement using just messageUpdate event and checking for message id to warrant it being a Collector
At the moment I don't see enough warranting to include this in the library, would be great if you could provide some.
If you have a rather specific use case you can always implement https://discord.js.org/#/docs/discord.js/stable/class/Collector on "messageUpdate"
(see the MessageCollector or MessageReactionCollector classes to understand what you need to do)
Most probably a niche use case, but was midway between making one when I started wondering if there was another reason for why it doesn't exist
Technically, collecting messages or reactions manually in messageCreate or messageReactionAdd isn't particularly hard. You just need to check relevant ids (channel id and message id, respectively). There's also countless ways on how you would manage the handling of multiple things to track, and adding/removing things you track dynamically.
The reason as to why MessageCollector and MessageReactionCollector exist is that the commonness of wanting to get some additional data from user in the simplest forms of sending another message or having user react to a message "outweighs" the relative ease of own implementation. And it also comes with few things that would make it tricky or convoluted to implement, especially if you don't necessarily know how to perform such stuff manually (like dispose, max or any time related param)
Edits however are quite rare form of giving your bot more data. Hypothetical MessageEditCollector would most likely be also scoped to only a single message, so it wouldn't be useful for stuff like command edits, where you would have to create collector for each and every message your bot receives. There's also the fact that edits are limited compared to just sending new message - think attachments or getting outside of character limit. And you can only press up arrow so much without resorting to having to constantly right click -> edit.
(Also, despite MessageCollector and MessageReactionCollector being a thing, you still should just use events instead of long-running or endless collectors for stuff like reaction roles or "send message here to verify" things 🤷♀️)
would it be possible to override all of discord.js's collection based cache for redis without needing to fork and change the lib?
The only issue I am thinking will incur is redis is async collections are !.
Trying to create a centralized cache solution for a project.
the cache methods are currently all synchronous. There has been talk about such a cache upgrade before though. You may be interested in https://github.com/discordjs/discord.js/issues/6539#issuecomment-907736748
thankyou >-<
Hm interesting, I may very well take the partial packages and just contruct my own wrapper at this point.
Very interesting issue though 👌
@slate nacelle a lot of people are waiting on https://github.com/discordjs/discord.js/pull/7649, could you please review 
@copper laurel actually it seems like those methods don't allow null in their types 🤔
Well it wasn't necessary prior to your change (though arguably should have been possible to remove the author entirely with null)
you can remove the entire object but not specific props within it
And .setAuthor({ ...embed.author, iconURL: <new URL> }) will work after the getters PR right?
There are so many PRs touching builders I don't even have enough courage to submit a PR that makes builders consistent with interaction builders
djs should get rid of builders and make it an optional package for ppl to install and use
ie. message.embeds would return an array of APIEmbed and a user would do something like ```js
const embeds = message.embeds.map(e => new UnsafeEmbed(e));
if they wanted the structure
rather than the library constructing builders for people, it should just return the direct api data and have the user construct the builder themselves.
cool 👍
Might be wrong but outside of the extended builders re-exported by djs. It doesn’t use builder code anywhere for serialization anymore
i asked this before but i don't believe i got a response
For
XCollector.endReason, why aremax[X]options treated as[X]limit?
Shouldn't they bemax[X]just for consistency with the option that triggered them? Or at least be documented?
https://github.com/discordjs/discord.js/blob/main/packages/discord.js/src/structures/MessageCollector.js#L103
https://github.com/discordjs/discord.js/blob/main/packages/discord.js/src/structures/ReactionCollector.js#L164
https://github.com/discordjs/discord.js/blob/main/packages/discord.js/src/structures/InteractionCollector.js#L182
also why doesn'tendReasonseem to acknowledge thetimeandidleend reasons
I can't seem to find the documentation for the send() method in the Channel object. It works though :/
should I do it differently?
it's on the TextBasedChannel, which DMChannel, ThreadChannel, and BaseGuildTextChannel implement, and TextChannel and NewsChannel extend BaseGuildTextChannel
you can't really send a message in category or stage channels. (or a voice channel but that's soon to change i think)
❤️ (for some reason I can't react on your message)
does anyone know
a maintained version of djs/commando right now
like a fork
i need to support this legacy bot but cannot get rid of some of the commands
sapphire
No, commando is not maintained
alright thanks
how does djs get to know if <GuildMember> is bannable, moderatable,kickable etc
you can look at the source code, it's a chain of permission and highest role position/owner checks
ty
any chance #7731 can get reviewed soon? it has been sitting there for 11 days with no reviews from maintainers
Hey, I have a simple question, since the v14 is coming soon. It’s true that the v12 will definitely end this month if?
apparently discord pushed back the update so i guess not
v11 and v12 dying are not in our control
After it doesn’t matter if it ends, but it’s so sudden
because I still have my site that is under v12 and if it ends this month if it is hot to pass in v13
v12 will die in early 2023
Was it really announced or is it a guess?
it was really announced
discord developers server #useful-servers
thanks, message links please
scroll in api announcements and you will find it
yes
but how do we know which api and used on the versions of discrdjs?
read source code on github
well I already looked before but it gives the api 10
Thats the main branch
v11 is api v6 and v12 is api v7
both v11 and v12 use rest v7
Ah ye nvm
thx
https://github.com/discordjs/discord.js/blob/e1cdcfa9a6baed1d373cc5474630d32ce38db31e/src/structures/MessagePayload.js#L114 Shouldn't the end of this line be true?
Is it worth making a PR?
probably not, since if you want to unset the content you set it to null iirc
Well if it's false it seems you get an error saying "Message content must be a non-empty string." even though it can
Also just above it content is defined to be an empty string so empty strings can still be returned from that function
Tbh can't believe I'm the first person to encounter this bug lol. You should be able to send a message with embed data and an empty string. Works if you make a raw api req
well, most of the time you just do { content: null, embeds: [embed], ... }
But why can't you do { content: '', embeds: [embed], ... }?
Still valid but it errors
imagine you have a string variable and in some case its an empty string, you're unintentionally removing the content of the message which results in the error.
while if you pass null, you're explicitly telling it that the content must be removed.
thats my opinion, ill leave the rest to the maintainers
I mean I agree that in terms of practice it's probably better to make it explicit
I'm not 100% sure what this libraries policy is for API compliance but it would make more sense from a "will this work" stand point to allow empty strings as a raw api call will allow it? Both are falsy values anyway and in terms of just that function it literally just converts it to an empty string if the content is null but then doesn't allow just an empty string to be passed in? Seems a little counter intuative imo
Do you think it's worth a PR to let people discuss on github?
sure
would it be possible in the future to have client.channels.send(id, message) similar to client.users.send(id, message)? is there something in the REST api that would prevent that?
What the function does internally might come out purely from how API works. Does the API allow you to pass null instead of empty string to achieve same effect?
Also, note that discord.js isn't a thin API wrapper that merely exports functions calling some endpoints. This is a library and we have some design across the board regarding its usage
i don't see why not, as having channels cached isn't a requirement for bot commands now. previously this would have been redundant as channels wouldve been cached while a user would have to be fetched.
Pretty sure this is added in v14 and the v13 branch, not yet released tho
v14 docs don't seem to have ChannelManager.send()
Actually it seems like it wasn’t ?
Weird, that should’ve gone in the manager methods pr
You can PR it if you wish, probably missed it by mistake
#7300 did not add UserManager.send(); that was done separately during move of createDM() to the manager in #7087, which in turn allowed sending DMs without need to fetch users.
And personally not sure about the fact that while every user has a send method, not every channel is able to have messages being sent to it, and library itself clearly defines that in code
and weren't channels defined as always cached for discord.js?
there should be a way to do it independent of shard though
True
You could always have the method and let discord error if it cant receive messages
hacky, but await new TextChannel(undefined, {id}, client).send(message) seems to do what i want
you can use /rest and manually send a request to post a message -> https://discord.com/developers/docs/resources/channel#create-message
ah cool, i will check it out
Does @discordjs/rest handle rate limits?
Yes
I always forget this is a problem too. djs is still quite dependent on channel + guild cache, but for sharding it doesn't need to have them on shards that don't handle their respective gateway events (duh), however it would be nice to be able to fire off a rest based request on any such thing from any shard
Just tested and the API does allow you to pass null and undefined as well as an empty string to the content field. However it seems ( do correct me if I'm wrong ) that when sending an embed when content is set to null an empty string will actually be sent to the api? Surely this is not intended? If so could you explain why as it doesn't make sense to me
Thanks for the clarification about how the discord.js project operates
any hopes on throws being documented in the near future with js/tsdoc?
Discord has said that they want bots to add support for text-in-voice and forums so they are ready when they release; does discord.js plan on adding and merging those features accordingly?
Did they already gave api info for the txt-voice feature?
well the draft tiv pr hasnt been edited since january
they just unblocked some endpoints in voice channels
But there is no official info as of now.
they announced it to large bot devs and library devs in october, with access to the testing server
Yey
Of course we intend to. I'm not sure how else to respond to that.
But like always, we require some form of documentation to base it on
Discord has been giving us confusing information recently, they don’t want us to implement undocumented stuff yet they want us to implement undocumented stuff. Seems we need some updated guidance
Yeah, if we get preview docs we can at least have a draft PR ready
tiv doesn't really need docs changes
since the docs don't say voice channels can't have messages
I think the only change needed is to the permissions page and is irrelevant to djs
and the draft pr being stagnant for months seems to indicate a lack of interest in adding it soon
Or it means it’s been basically ready for months pending a release
shouldnt it be merged if it's ready
No because it’s not documented
There's nothing to document about it really other than "hey look you can send messages in voice channels now neat"
Makes me wonder if there even is supposed to be a pull request to document it
Or they were trying to tell us to implement it all those months ago
the work many of you did to update clients was essential because we wanted to make sure bots could be updated well ahead of launch.
yeah, "documented" means nothing for this as I said multiple times so idk why people keep claiming it's "not documented"
the docs don't say that voice channels dont support messages
wouldn't that also mean that you can send messages to categories?
well, there's several things that need updating (granted some that need updating from news channels and threads too lol) https://discord.com/developers/docs/resources/channel#modify-channel-json-params-guild-channel and https://discord.com/developers/docs/resources/channel#create-message are great examples, suspect here is this line in particular (very outdated unless guild text is suddenly a group of channel types instead of a channel type). I also suspect a larger rework of the channel page is necessary here but that's not relevant
if we just implemented and merged TIV when we saw "oh hey, messages can be sent in voice channels now" only for discord to not ship the feature, we'd have some big issues
what issues?
Probably the same issues that came when djs released threads ahead of time 🤔
is there a reason for one being named ChannelType and one being named ChannelTypes?
Historically yes, one being a string literal type, the other being djs constants enum
read the channel topic
this is not a support channel.
#djs-help-v14 #archive-djs-help-v13 (and please learn js, r2)
Does REST Client djs has respect rate limits and queue requests?
that's a requirement to be on the discord documentation list of libraries, so yes
also #769862166131245066 has a note about rate limits
is this a good way to simplify handlers's index?
first image is before and the second is what i could do to simplify this massive thing
this is not a support channel.
#djs-help-v14 #archive-djs-help-v13
read the channel topic
literally 3 messages above yours lol
that is library-related, i'm editing library's code (the path is literally above the code)
so uh, no i guess
ah my bad, i (incorrectly) assumed the handler you were referring to was an event handler.
not sure if having just that filter would be a good idea though, as that could get tripped up if someone makes an unrelated file there for some other reason
there is no problem :)
the filter is there only because of index.js file, that is the only one that isn't a handler
The script should be as bare as it is, removing anything may result on lower performance, lower code readability, or a change in behaviour
Doesn't the actual code also use sort to ensure the generated files have the same order regardless of the OS?
I assume you're talking about this? https://github.com/discordjs/discord.js/blob/main/packages/discord.js/scripts/generateRequires.mjs
I'm saying that if another non-handler file were to be added for any reason, the filter would have to be updated, and I think that could be easily missed.
If what you're showing me is that you're making the thing dynamic, you'll break webpack or whatever tools some people use, which has caused us some headaches. That's why it's generated and not dynamic
ah ok, now i understood
thanks for the explanation :)
fair
this was done and quickly reverted because of people who want to compile their code with stuff like webpack where fs isn't viable
sad 😢
@ruby terrace node-fetch does cloning here https://github.com/node-fetch/node-fetch/blob/6875205c1a6eff1ce89ae762b1636cf3cd9fb957/src/body.js#L260 but I feel like it's better to remove the event & use diagnostics_channel instead
Diagnostics channels are indeed nice
@outer raven regarding https://github.com/discordjs/discord.js/pull/7718
is there any chance you could do a pr for SelectMenuOptionBuilder with the same idea?
dunno if its an oversight but you cant provide a string for emoji with it
is there a djs version of that builder?
cuz iirc that was done only for djs not builders
yes
export class SelectMenuOptionBuilder extends BuildersSelectMenuOption {
public setEmoji(emoji: ComponentEmojiResolvable): this;
}
then yeah i can do that
thanks 😄 👍
will do that for addOptions too cuz it doesnt seem to have been done
my PR's CI is failing because of this test despite me not touching rest, does anyone know how to fix this?
already tried forcing it to rerun but it still failed
thats odd, I didnt have that issue doing my builders PR this morning
yeah i made 2 prs and only one has this issue, no idea why
and it's passing locally which is also weird
can you try rerunning the CI one more time?
I'm not a maintainer on Github
ah I thought you were
push an empty commit
yeah those timing tests are like flipping a coin, i just removed them in my undici pr
I was getting some weird results like the 2nd time being newer than the first (getting negative diff), occasionally being 0.00000ms different, etc.
Can we get a quicker merge on https://github.com/discordjs/discord.js/pull/7788 since it's crashing some bots?
How long should I expect to wait for https://github.com/discordjs/discord.js/pull/7768 to be merged?
It needs reviews of the 4 core maintainers before being merged
why
Because that’s how the process works
On this page https://discord.com/developers/docs/interactions/application-commands#retrieving-localized-commands Discord says that nameLocalized and descriptionLocalized is only present when a user requests a bot's commands and thus that endpoint will return the relevant name to that user, however, this is irrelevant to bots as they cannot change their locale so why was this added to djs? We could change the methods to provide with_localizations as true internally and we won't need this field as it might cause confusion
in fact there seems to be no way to pass with_localizations as true at the moment (correct me if im wrong tho)
Aren't those based on the locale of the user, though? Not of the bot? misread, mb
You can
It’s part of the fetch options
I looked at the code and it didn’t seem to be
Must’ve forgotten to switch branches then
And that isn’t documented
The docs make it seem like you must always pass an id
Either way, can we remove that option and default it to true? It seems useless because of this
no if the API provides the option, it should be configurable from djs. By default it doesn't provide localizations, so by default djs doesn't do the same
The API provides that option for users only, storing nameLocalized and descriptionLocalized is simply useless for bots
And those fields aren’t even documented on their docs, only on the endpoint
that's what the API returns by default for fetching all commands so that how it's used in djs.
And those fields aren’t even documented on their docs, only on the endpoint
That's documented
The API will never send those values to a bot. If you read the description closely it says those are the names and descriptions in the user’s locale. Since this is always en_US for bots it will always be null/absent
Well name_localization and description_localization aren't applicable to bots anyways so those being returned or not doesn't really make a difference. However the localization maps are still only sent when a given option is provided and aren't provided when the option isn't present. Djs should be following API defaults here.
If you think they should always return the localization objects by default that's more of something to be brought up in the ddevs server and/or github
those don't exist?
what are you talking about
sorry description_localized and name_localized
well then that's why djs should just ignore those 2 props
it does unless provided
and there's many other methods where djs hardcodes a query option

