#archive-library-discussion

25217 messages · Page 23 of 26

solemn oyster
#

Yes

wild flax
#

Yes

outer raven
#

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

zenith oracle
#

same for the second error

#

I'm using raw objects and haven't encountered any problem so far

outer raven
#

hmm yeah seems like the types need fixing

zenith oracle
#

does it actually allows mixed objects though?

outer raven
#

no reason why it shouldn't

zenith oracle
#

so yeah ig

dawn merlin
outer raven
#

it does because it calls this on every component

dawn merlin
#

Which line calls it in djs again?

outer raven
#

in djs?

#

this is all done in builders

dawn merlin
#

Well it’s serialized in djs

outer raven
#

it only transforms casing

#

which in the case of action rows doesn't even do anything

analog oyster
#

not the opposite

outer raven
#

huh?

analog oyster
#

you need to call .toJSON() when sending builders classes

outer raven
#

it checks if the component is already an instance of the component class

#

no you don't

#

not in djs

analog oyster
#

ah i see, but you sent a screenshot of an unrelated thing

outer raven
#

no it's not unrelated because when you call the constructor it calls this function

analog oyster
#

@dawn merlin

#

oh wait, i misread what you said initially HAhaa

tacit crypt
#

it has overrides I think? Because yes consistency baby pepeHands

outer raven
#

im not sure how to fix them because I don't know where the issue lies

analog oyster
#

yes

#

calling toJSON() fixes the issue temporarily, as siris mentioned
but you shouldnt need to

dawn merlin
#

@outer raven do you want me to fix the types or are you making a PR?

outer raven
#

I'm not sure how to fix them so feel free to

dawn merlin
#

Alright

dawn merlin
#

@outer raven I don't think I can do the PR without breaking the existing json types

#

btw this isn't the modals pr

outer raven
#

why not? Isn't it just adding the classes out of the possible types?

dawn merlin
#

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 shrug

outer raven
#

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

dawn merlin
#

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

copper laurel
#

Yeah when I did components originally the types were very loose

#

Siris was the one who improved them so I'd trust him lol

outer raven
#

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

dawn merlin
outer raven
#

A union isn’t more complex? It’s just another option for what you can pass in the constructor

dawn merlin
#

It’s not, you have to modify the *Data type itself

vernal rose
opaque vessel
#

Yes

zenith oracle
#

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")],
  })
outer raven
#

oh the data mmLol

#

that should be an easy fix

zenith oracle
#

Should I open an issue or it's not needed

analog oyster
#

cannot replicate

zenith oracle
analog oyster
#

discord.js@14.0.0-dev.1645142857.f7257f0

zenith oracle
#

Same

analog oyster
#

did you import Embed from discord.js or builders?

#

i imported from discord.js

zenith oracle
#

builders

analog oyster
#

let me see

zenith oracle
#

Oh wait a moment

analog oyster
#

works still

#

@discordjs/builders@0.13.0-dev.1645142857.f7257f0

zenith oracle
#

Uh, strange

analog oyster
#

whats your builders version

zenith oracle
#

Same, let me send a screen of the dependencies

analog oyster
#

yarn why @discordjs/builders or npm ls @discordjs/builders

zenith oracle
#

let me try to reinstall

analog oyster
#

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();

zenith oracle
#

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 😂

analog oyster
#

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

zenith oracle
#

yeah I'm using a normal Embed

zenith oracle
#

oh wait

#

I think this should be fixed with the introduction of isJSONEncodable

#

just not published I guess

analog oyster
#

in theory isJSONEncodable would only fix the issues with UnsafeEmbed ¯_(ツ)_/¯

#

i guess just wait for another dev release and see

zenith oracle
zenith oracle
woeful rain
#

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.

copper laurel
#

We don't do ETAs and everything is not done

woeful rain
#

Okay

golden mortar
# zenith oracle Well, this is weird ahahah

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

analog oyster
#

it worked with discord.js' and /builders embed for me

golden mortar
#

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

zenith oracle
#

However should be fixed now

upper echo
#

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

visual hornet
#

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

upper echo
upper echo
#

how large approx is each of those member objects?

visual hornet
#

the event in question is GUILD_MEMBERS_CHUNKS / guildMembersChunk if you want to listen to it btw

upper echo
visual hornet
upper echo
copper laurel
#

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

vernal rose
#

ig this isn't intentional. is it? it should be ActionRow right?

vernal rose
#

index.test-d.ts

#

ig expect error is there only for empty object not for wrong class name.

analog oyster
#

yes, it should be ActionRow

quiet viper
#

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 ||

fast jacinth
#

Does anyone know if the next version will have the ability to add a banner to guild event creation?

outer raven
analog oyster
#

if you talking about guild scheduled events

fast jacinth
opaque vessel
outer raven
#

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

opaque vessel
#

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

outer raven
#

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

opaque vessel
#

Is okay [:

vernal rose
dawn merlin
vernal rose
#

lemme test all i didn't tested it

dawn merlin
vernal rose
#

lemme check it bc ig above one isn't working as expected

vernal rose
# dawn merlin Also have you looked at InteractionResponses.applyToClass? You might be able to ...

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

dawn merlin
#

ok

vernal rose
dawn merlin
vernal rose
vernal rose
#

@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)?

outer raven
vernal rose
#

how can I fix them?

outer raven
#

run yarn build to see if it completes

vernal rose
vernal rose
outer raven
#

they're not, but they don't error on dev builds because yarn resolves the other packages to their latest dev versions

vernal rose
outer raven
#

did you run build on the root directory?

vernal rose
outer raven
#

well then im not sure in that case, but as long as you can run the build script it should be all fine

dawn merlin
vernal rose
digital sun
#

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)
copper garden
digital sun
#

think that was missed in the guide walkthru

copper garden
#

It's in the guide as shown above

digital sun
#

ooo

#

well thanks!

opaque vessel
void rivet
#

i'll look into it, sure

opaque vessel
#

[: thank yous

void rivet
#

so what, this is for 13.7?

opaque vessel
#

Yea, the backport

void rivet
#

yeah i saw that making the pr, ig it was an oversight or even wasn't documented when it was made

opaque vessel
#

Yea probably

void rivet
steep zodiac
#

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

analog oyster
#

yes, it works

steep zodiac
#

Uh ...
Weird but thanks

#

I use discord.js for a few months and I never had this issue, strange

analog oyster
steep zodiac
#

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

analog oyster
#

not an issue with discord.js

steep zodiac
raven juniper
#

this is not a support channel, this is for the development of the d.js library

steep zodiac
#

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 ?

steep zodiac
#

Alright
I will stick to this server, so #other-js-questions, thanks ^^

opaque vessel
#

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...

outer raven
#

then why was there this check to begin with?

opaque vessel
#

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

outer raven
#

calm down alright

opaque vessel
#

I still think they should be added to the manager so you can edit an uncached user's suppressed state

void rivet
#

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

opaque vessel
#

If the route belongs to something there, it should be in the manager

outer raven
#

if there is a manager it should have it

opaque vessel
void rivet
#

Is that pr still up?

void rivet
outer raven
outer raven
#

(you always need to access the voice state's channel)

opaque vessel
#

You can just disable voice state caching so that seems very possible to me

outer raven
#

It’s not possible because you lose the channel link

opaque vessel
#

What do you mean

outer raven
# opaque vessel 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

opaque vessel
#

Why is that a problem

outer raven
#

what

#

how is it not a problem

opaque vessel
#

Why do you think we need it cached

outer raven
opaque vessel
#

I don't understand the confusion sorry o,o

#

Have the user provide the channel id?

outer raven
#

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

opaque vessel
#

I don't think I can see the issue still

outer raven
#

well I'm not gonna add it for now because of that, if you want you can PR it yourself later on

opaque vessel
#

I just coded it into the manager and it works fine... I still don't know what the issue is

outer raven
#

with the channel as a parameter, which I don't wanna add

#

otherwise you'd need to use resolve and not resolveId

opaque vessel
#

You should add it to expose the raw functionality

opaque vessel
outer raven
opaque vessel
#

Yes so do that where there is a cached voice state

outer raven
outer raven
#

if the manager method only works when cached

opaque vessel
#

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

outer raven
#

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

opaque vessel
#

You lost me again, why are we talking about moving members o,o

outer raven
#

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

opaque vessel
#

Providing the channel is a requirement to edit a voice state

#

Voice states don't change a member's channel

outer raven
#

yes they do

opaque vessel
#

They don't

outer raven
#

if you're on channel A then edit the voice state as channel B you moved the member

#

bro

opaque vessel
#

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

outer raven
#

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

opaque vessel
#

Their problem lol

outer raven
#

yeah no I don't think that should go in the library

#

if you do, go ahead and make it

mighty sequoia
#

sorry to bring this up again, but this doesn't work for dms since they aren't cached guilds,

copper laurel
#

Yeah this still isn't about library development either way

#

isCommand would still work

mighty sequoia
#

it doesn't

#

how would it not be about library dev if this is something missing in the lib

copper laurel
#

Because nothing is missing, as per the original discussion

#

These are typeguards

mighty sequoia
#

is a problem with the typeguards not a problem with the lib?

copper laurel
#

What do you believe is missing?

mighty sequoia
#

a way to get the original commandName of an interaction in dms?

copper laurel
#

The workaround would be to cast it directly to SelectMenuInteraction<'raw'>

#

though to typeguard it properly, I guess an .inDM() could be added

outer raven
opaque vessel
#

It's not a command

outer raven
#

context menus are commands so they have a command name

dawn merlin
#

What does this have to do with context menus?

outer raven
#

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

fervent walrus
#

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

void rivet
#

okay then making a pr

dawn merlin
loud jayBOT
#

pr_open #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

loud jayBOT
fervent walrus
alpine bough
#

is there any way to fix it?

vernal rose
alpine bough
#

thanks!

outer raven
mighty sequoia
#

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?

outer raven
#

you're better off just doing if ('threads' in channel)

#

but it could def be made and quite easily too

mighty sequoia
#

this seems like a reasonable case

mighty sequoia
outer raven
#

Huh?

#

AnyChannel is a union of types

#

If you do that you narrow it down to the channels that can have threads

outer raven
#

I also don’t know what you’d call a method like that tbh

mighty sequoia
#

.hasThreads

outer raven
#

No that’s misleading

mighty sequoia
#

.canHaveThreads

outer raven
#

Ye that’s more like it

mighty sequoia
#

or add .isNews() and then you can filter that out

outer raven
#

That is a thing my guy

mighty sequoia
#

no its not…

#

check the docs

rustic boughBOT
vernal atlas
#

what channel types can have threads

mighty sequoia
#

TextChannel thats it

inland lotus
#

.isThreadBased()? or does that sound like its a thread channel not a channel that has threads

mighty sequoia
analog oyster
#

news channels can have threads too

vernal atlas
analog oyster
#

sounds like a forum channel

vernal atlas
#

canHaveThreads sounds best tbh

analog oyster
#

while not misleading, thats not a very good name. but i cant think of anything better

vernal atlas
#

yeah its not a very pretty name but cant think of anything else either

mighty sequoia
#

just use the canHas one

mighty sequoia
#

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: [] }
}

vernal stratus
#

is the builders package being expanded on still?

fallow crater
#

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 😅?

copper laurel
#

It isn't stable

#

We can and still are changing it at will

outer raven
outer raven
outer raven
mighty sequoia
outer raven
#

If it tries to fetch an unknown message it should def cause a crash

mighty sequoia
unique axle
#

.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

mighty sequoia
#

I see okay

echo ginkgo
#

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?

burnt cradle
#

it has an apache 2.0 license

void rivet
vernal rose
outer raven
#

I mean that issue should've been closed when it was made because it's not an issue lol

opaque vessel
#

I think so if we wanna stay consistent? @dawn merlin^

dawn merlin
#

Yeah

#

Speaking of, I need to do everyone’s favorite consistency PR today

#

oh nvm almeida did it for me

analog oyster
real jetty
opaque vessel
golden mortar
#

can we readd addField?

unique axle
outer raven
real jetty
#

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

opaque vessel
#

Can only either be private or protected

real jetty
#

Could you do some jsdoc fuckery where you put @ private? Or would ts not prioritize that?

opaque vessel
#

Putting @private on it would work

analog oyster
#

the method is already set as protected (in ts, it has no jsdoc)

golden mortar
# unique axle no, for all the reasons listed here: <https://github.com/discordjs/discord.js/pu...

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 🤷‍♂️

outer raven
#

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

dawn merlin
#

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

unique axle
#

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

dawn merlin
#

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

unique axle
#

"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

copper laurel
#

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

icy trout
#

Are there any plans to fix (improve) the undocumented pitfalls of autocomplete interactions?

[
  { 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 :)

copper laurel
#

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

unique axle
#

@icy trout if this is not yet an issue on GitHub, please make it one, so we can track completion

icy trout
simple pagoda
#

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!" });
dawn merlin
simple pagoda
#

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

dawn merlin
#

Not interactions but the builders

#

Interactions are only created internally

simple pagoda
#

yeah thats what i mean, things like SlashCommandBuilder

dawn merlin
#

Oh yeah they don’t

simple pagoda
#

is there a reason why they wouldnt, or just wasn't added/overlooked?

dawn merlin
#

Probably overlooked

tacit crypt
#

Not overlooked

idle cypress
#

Now that modal pr had been merged can we expect 13.7 tonight?

analog oyster
#

the modals pr for v13 was not merged

idle cypress
loud jayBOT
#

pr_open #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

analog oyster
#

that was targeted at the main branch

#

aka v14-dev

opaque vessel
void rivet
#

Sure I'll look into it when I'm back home

outer raven
#

seems like the method internally calls ChannelManager#fetch which can't return null, which is what I find odd

opaque vessel
#

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

outer raven
opaque vessel
#

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

outer raven
#

Shouldn’t it return a Channel instance of type unknown?

#

And tbh no other fetch method has null as a possible return value afaik

ruby terrace
#

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)

outer raven
#

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

ruby terrace
#

its not supposed to be an edge case, and you can't just yank out a valid type

outer raven
ruby terrace
#

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

outer raven
#

Yeah that’s true

#

Maybe it should reject the promise whenever a non thread channel is fetched

outer raven
#

The documentation workflow should probably pull before pushing to avoid CI failing when many commits are made at once

outer raven
#

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

analog oyster
#

pulling at that stage is probably just going to cause conflicts

vernal rose
sand thunder
#

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.

visual hornet
#

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?

sand thunder
visual hornet
#

probably, it's maintained by djs contributors

sand thunder
#

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!

visual hornet
#

probably just took a while to get added

copper laurel
#

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

tacit crypt
mighty sequoia
#

in my testing, lastmessage is always null for threads in 13 latest

dawn merlin
mighty sequoia
#

yes

#

doing const msg = await threadChannel.messages.fetch({limit: 1}) works

opaque vessel
#

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

vernal rose
#

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(); 
 } 
wicked bronze
#

Am I allowed to send suggestions for D.js in here?

unique axle
#

feature suggestions generally go on the github in the form of issues so they can be tracked

outer raven
#

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?

outer raven
#

@wild flax since you’re the one who manages that, what do you think about this ^^

outer raven
#

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?

void rivet
#

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

copper laurel
void rivet
#

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

copper laurel
#

I don't think so but I'm not certain

void rivet
#

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

vernal rose
void rivet
vernal rose
void rivet
#

that is how djs caches all the guilds to begin with

void rivet
#

even according to types memberCount isn't documented to be null

visual hornet
#

make sure you have the proper intents as well?

visual hornet
#

0 + null should just be 0 though

vernal rose
#

Idk how it's giving null lol

analog oyster
#

I had that issue too when sharding, unsure how it happened so I just added || 0 to the memberCount and forgot about it

visual hornet
#

could you maybe try changing the reduce function to (a, b) => (console.log(b.memberCount), a + b)

analog oyster
#

Yeah

vernal rose
#

Lemme try

analog oyster
#

Might just be because of unavailable/ghost guilds

void rivet
#

perhaps you can add a filter for it beforehand?

mighty pebble
#

How do you view the name of subcommand that was run

visual hornet
mighty pebble
#

oh god wrong chat sofry

void rivet
analog oyster
#

thats not even the right type for it

#

it doesnt have any of those methods

void rivet
#

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

analog oyster
#

the components class in djs and createXBuilder methods in builders serve different purposes

void rivet
#

so the types should change to createComponent, right?

analog oyster
#

yes

#

or removed entirely, depends on which path you want to take

#

since its not actually exported

void rivet
#

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

analog oyster
#

no me, and it shouldnt use that

#

above your comment in rodrys pr

void rivet
#

i'm talking about builders though

analog oyster
#

wdym, builders uses ts, that wouldnt happen there

#

createComponent is just being used incorrectly in that one file i mentioned

void rivet
#

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?

analog oyster
#

it doesn't have a @private thing in the jsdoc so i dont see why not

void rivet
#

yeah but i'll confirm it and let rodry make a pr

flint ledge
#

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

tacit crypt
#

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

outer raven
unique axle
#

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)

outer raven
#

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

unique axle
#

i think i agree, not a fan of functions with side effects, really

outer raven
#

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?

unique axle
#

i would personally probably go with the most straight-forward and least ambiguous, which is "collected" vs. "not collected"

outer raven
#

alright, I have the commit ready for tomorrow then

unique axle
#

on "notCollect" is a super shit event name though, unfortunately

outer raven
#

lmao yeah

minor venture
#

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"

opaque vessel
#

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

real jetty
#

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 ?

outer raven
dawn merlin
#

I’ve been thinking of making a mock gateway server for testing djs

patent halo
#

any plans to ditch commonjs and just use es modules?

golden mortar
#

... hopefully not

copper laurel
void rivet
dawn merlin
#

Sure

void rivet
#

okay then, removing Embed.setColor

loud jayBOT
outer raven
#

That function is clearly adding functionality on top of the builder function

void rivet
#

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

outer raven
void rivet
#

okay so let's make it less confusing,
setters should be on EmbedBuilder, not on Embed, that's the whole point of 7584

outer raven
#

Got it

hot echo
#

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:

  1. Make a bot with members intent enabled and add it to 2 guilds
  2. 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)
  3. 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.

opaque vessel
#

You don't have the GUILDS intent?

hot echo
#
['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

hot echo
#

and however you'd get the shard id in other sharding types

slate nacelle
#

As far as I am aware will Discord just discard those requests.

hot echo
#

or do I have to fetch on one shard and then cache them in the main process (which would be an absolute pain)?

ornate topaz
#

what is the reason for you to actually be fetching the members?

hot echo
#

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

ornate topaz
#

then there should be absolutely 0 problem to just use a broadcastEval for that. no need to move caches between anything

hot echo
#

ok

hot echo
#

or does it wait until all shards are ready to trigger the ready event

ornate topaz
#

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

hot echo
#

i'll just do the complicated caching system that i know will work

ornate topaz
#

broadcastEval, in case you didn't play around yet, runs code on every shard.

hot echo
ornate topaz
#

?

#

anyway, this doesn't really fit this channel anymore. you should probably move to #archive-sharding if you want help with broadcastEval

hot echo
#

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

outer raven
#

so to answer your question literally, no I can't 😅

real jetty
void rivet
#

@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?

dawn merlin
#

Depends, there's no rush so if you feel up to it feel free

void rivet
#

yeah i can do it a few hours later, it'd just be a clone of your pr just for a different class

loud jayBOT
outer raven
#

Is there an interface in the djs docs for this type?

alpine bough
#

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?

outer raven
#

try reinstalling them

alpine bough
#

true, thanks 👍

void rivet
#

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 👀

loud jayBOT
void rivet
#

are there no other builder methods that used to use Util internally to resolve a data?

dawn merlin
#

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)

void rivet
#

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

quiet viper
#

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?

copper garden
#

It would affect the Message class most likely, mainly its channel property type

quiet viper
#

I heard from some users that their bot crashed. Let me gather more info.

slate nacelle
#

Stable should be fine. v12 and v11 won't though.

void rivet
# copper laurel I don't think so but I'm not certain

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

stark wolf
#

there are just 5 seemingly unrelated issues on there Thinkeng

#

all opened by the same guy

warped crater
#

*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

stark wolf
stark wolf
#

and it would really only benefit the maintainers i guess

copper laurel
#

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

tacit crypt
#

And even for the JS users, as typings would be always up to date and accurate with the code

analog oyster
#

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

copper laurel
#

So can we blame Rodry? (jk)

#

We know, I assume someone will look at it soon

inland lotus
#

I know it takes time, but is the modals (v13) pr still being worked on or awaiting review/merge

copper laurel
#

I'm on holiday

#

That's why I haven't rebased it lol

#

I'll be back home on the 25th

inland lotus
#

alright, have fun

warped crater
#

how do you see this "handled"

rough roost
#

throw an error

dim crown
#

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?

real jetty
#

its the last minor planned currently, yeah

outer raven
#

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

copper laurel
#

Then it wouldnt be the raw data though

#

Or is it already promoted up... I honestly cant remember anymore

#

okay no it isnt

outer raven
copper laurel
#

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?

outer raven
#

8 options from which only 2 are required

outer raven
#

so the color BLUE should resolve correctly

unique axle
#

did you even read what i said?

outer raven
#

I did read it all

#

you said it's not found because of the casing difference

#

but there is no casing difference

unique axle
#

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

outer raven
#

but the bug report is from v13 what

unique axle
#

...

vernal rose
outer raven
#

doesn't make much sense to talk about v14 code if the bug report is from v13

warped crater
#

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 [...]

copper laurel
outer raven
copper laurel
#

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

outer raven
#

having both data and hoisted options as public props seems redundant but sure that could work ig

real jetty
#

is it intentional that the discord.js/typings/ folder is not exported in the main index file?

wild flax
#

yeah

real jetty
#

ah okay

latent idol
#

When will v12 be completely finished?

cursive jackal
outer raven
#

Answer is: in about a year

tacit crypt
#

v12? That ones deprecated to the moon and back
v14? Eventuallytm_new

outer raven
#

according to discord

short cairn
#

Is there anyway to run cleanup code after an interaction has timed out?

unique axle
#

what sort of interaction timeout are you referring to?

short cairn
#

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?

unique axle
#

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

void rivet
#

There isn't a djs exported ModalBuilder that accepts camelCase properties
is this intended?

mighty bough
#

we should be able to do guild.channels.resolve(channelMention)

opaque vessel
#

Would rather the user parse the input, not a fan

copper laurel
#

Yeah that's not what resolve is for, does not do regex parsing of ids. Expensive operation

mighty bough
copper laurel
#

Slow. Not very performant

wet spruce
#

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?

outer raven
#

Nope not really, new prs get added to a milestone which u can follow tho

outer raven
hollow stirrup
#

@tacit crypt

#

I only have these 2 left

#

I deleted those logs

analog oyster
#

the first screenshot includes your bots token in case you're not aware

solemn oyster
#

@hollow stirrup ^

hollow stirrup
#

shiiiit

warped crater
#

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

hollow stirrup
#

@warped crater now it doesn't matter all are invalid now

#

Token, session id

oak quail
#

imo versions earlier than 13.3.1 should be deprecated due to the TiV crash

tacit crypt
#

you need the session id and the token

warped crater
#

oh

#

memory trolled me

void rivet
#

why doesn't djs type Events even though it exports it?

opaque vessel
void rivet
#

no you're not, i reached the wrong conclusion based on a question a user asked

opaque vessel
#

[:

outer raven
#

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

tacit crypt
#

Looks like clashing versions of -types

outer raven
#

hmm my deps are up to date though

#

I could update to 0.30.0 tho

#

updating it didn't fix it unfortunately

ruby terrace
outer raven
ruby terrace
#

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

dawn merlin
#

It’s not

#

But that shouldn’t affect types anyways

outer raven
#

there are no const enums thankfully

outer raven
#

but we shouldnt need to do that

ruby terrace
#

Yeah, then that cast should

outer raven
#

because it works for non link buttons

dawn merlin
#

Sounds like a type is only accepting a subset of valid button styles hence why link doesn’t work directly

ruby terrace
#

Well, yeah that is narrowed to link only

dawn merlin
#

Also don’t think it’s a Dapi types issue most likely djs types since we made changes to ActionRowData recently

outer raven
#

but the types for raw button objects come from discord-api-types

dawn merlin
#

They don’t they come from ButtonData

outer raven
#

which is this, looks like it should work

dawn merlin
#

Probably something small causing the issue

#

What happens if you put style in the BaseButtonComponentData

outer raven
#

as a type generic or a property

dawn merlin
#

Just as a style: ButtonStyle

errant basin
#

do you know why there is only 5 styles of buttons?

dawn merlin
#

Bc that’s what the api allows

outer raven
errant basin
raven juniper
#

That's not a discussion for this channel

errant basin
#

ok

dawn merlin
#

Hmm I wonder if the v13 types are doing anything different

outer raven
#

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

dawn merlin
#

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

dawn merlin
#

Now im really interested if this works on v13

outer raven
#

can you test it?

dawn merlin
#

Yeah when I get home

outer raven
#

alright

dawn merlin
#

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] })
  }
outer raven
vital wind
#

Hello guys how do i test my bot any library?

real jetty
vital wind
#

thanks

dawn merlin
outer raven
#

it doesn't for me tho Thonk

#

i mean that exact code snippet works but the second I put it in a variable it doesn't

#

can you try that?

dawn merlin
#

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

outer raven
#

but thats not ideal

#

you shouldn't have to explicitly type it

#

specially not that monstrous type

dawn merlin
#

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

outer raven
#

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

rocky owl
#

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

ripe gate
runic bear
outer raven
copper laurel
analog oyster
#

i assume so, basically the same as the setEmoji method but on the constructor

copper laurel
#

Then probably yes, the constructor should behave the same

outer raven
#

alright, will PR

short cairn
#

Hey folks where is the best place to get updates on v13.7?

ornate topaz
lament shoal
#

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

outer raven
#

Proposal - revert PR 7584

lofty beacon
#

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

lofty beacon
#

right, because i saw something called discord-hybrid-sharding that implements some theoretically pretty cool ways of saving memory wehn sharding

outer raven
#

thats none of our business

lofty beacon
#

nvm then

tacit crypt
#

When in doubt, if you see opportunities for improvements, bring them up in the PR.

#

For instance some brought up ws related improvements already

lofty beacon
#

just curious :p

tacit crypt
#

check the PR

#

:P

lofty beacon
lofty beacon
#

the shard one that was linked above?

#

ah right

#

last commit a month ago dead

#

should we thread up about something regarding clusterning shards? @tacit crypt - i think it would be a good fit for your pr potentially

tacit crypt
#

hmm?

lofty beacon
#

well

#

there is some prior art

#

lets just make a thread

#

clustering shards

inland panther
#

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?

copper garden
#

Most likely a lack of practical use case, even before the message content intent was a thing

ornate topaz
#

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

unique axle
inland panther
ornate topaz
#

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 🤷‍♀️)

real jetty
#

Thonk 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.

ruby terrace
real jetty
#

Hm interesting, I may very well take the partial packages and just contruct my own wrapper at this point.

Very interesting issue though 👌

outer raven
outer raven
#

@copper laurel actually it seems like those methods don't allow null in their types 🤔

copper laurel
#

Well it wasn't necessary prior to your change (though arguably should have been possible to remove the author entirely with null)

outer raven
#

you can remove the entire object but not specific props within it

copper laurel
#

And .setAuthor({ ...embed.author, iconURL: <new URL> }) will work after the getters PR right?

tacit crypt
#

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

golden mortar
#

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.

dawn merlin
#

It doesn’t return builders anymore

#

It’s a class that just holds data now

golden mortar
#

cool 👍

dawn merlin
#

Might be wrong but outside of the extended builders re-exported by djs. It doesn’t use builder code anywhere for serialization anymore

visual hornet
#

i asked this before but i don't believe i got a response

For XCollector.endReason, why are max[X] options treated as [X]limit?
Shouldn't they be max[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't endReason seem to acknowledge the time and idle end reasons

earnest sedge
#

I can't seem to find the documentation for the send() method in the Channel object. It works though :/

#

should I do it differently?

visual hornet
earnest sedge
#

❤️ (for some reason I can't react on your message)

real jetty
#

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

inland lotus
#

sapphire

copper laurel
#

No, commando is not maintained

real jetty
#

alright thanks

wild osprey
#

how does djs get to know if <GuildMember> is bannable, moderatable,kickable etc

unique axle
#

you can look at the source code, it's a chain of permission and highest role position/owner checks

wild osprey
#

ty

honest barn
#

any chance #7731 can get reviewed soon? it has been sitting there for 11 days with no reviews from maintainers

calm urchin
#

Hey, I have a simple question, since the v14 is coming soon. It’s true that the v12 will definitely end this month if?

visual hornet
#

apparently discord pushed back the update so i guess not
v11 and v12 dying are not in our control

calm urchin
#

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

ember steeple
#

v12 will die in early 2023

calm urchin
ember steeple
#

it was really announced

calm urchin
#

do you know where the ad is?

#

please

ember steeple
calm urchin
inland lotus
#

scroll in api announcements and you will find it

calm urchin
ember steeple
#

yes

calm urchin
#

but how do we know which api and used on the versions of discrdjs?

ember steeple
#

read source code on github

calm urchin
#

well I already looked before but it gives the api 10

outer raven
#

v11 is api v6 and v12 is api v7

analog oyster
#

both v11 and v12 use rest v7

outer raven
#

Ah ye nvm

calm urchin
molten jungle
#

Is it worth making a PR?

inland lotus
#

probably not, since if you want to unset the content you set it to null iirc

molten jungle
#

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

inland lotus
#

well, most of the time you just do { content: null, embeds: [embed], ... }

molten jungle
#

But why can't you do { content: '', embeds: [embed], ... }?

#

Still valid but it errors

inland lotus
#

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

molten jungle
#

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?

inland lotus
#

sure

molten jungle
crisp thicket
#

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?

ornate topaz
visual hornet
outer raven
ornate topaz
#

v14 docs don't seem to have ChannelManager.send()

outer raven
#

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

ornate topaz
#

#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?

crisp thicket
#

there should be a way to do it independent of shard though

ornate topaz
#

True

outer raven
#

You could always have the method and let discord error if it cant receive messages

crisp thicket
#

hacky, but await new TextChannel(undefined, {id}, client).send(message) seems to do what i want

golden mortar
candid crest
#

Does @discordjs/rest handle rate limits?

dawn merlin
#

Yes

ruby terrace
# crisp thicket there should be a way to do it independent of shard though

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

molten jungle
# ornate topaz What the function does internally might come out purely from how API works. Does...

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

blazing palm
#

any hopes on throws being documented in the near future with js/tsdoc?

oak quail
#

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?

quiet viper
oak quail
#

well the draft tiv pr hasnt been edited since january

oak quail
quiet viper
#

But there is no official info as of now.

oak quail
#

they announced it to large bot devs and library devs in october, with access to the testing server

copper laurel
#

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

ruby terrace
#

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

copper laurel
#

Yeah, if we get preview docs we can at least have a draft PR ready

oak quail
#

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

ruby terrace
#

Or it means it’s been basically ready for months pending a release

oak quail
#

shouldnt it be merged if it's ready

ruby terrace
#

No because it’s not documented

tacit crypt
#

There's nothing to document about it really other than "hey look you can send messages in voice channels now neat"

opaque vessel
#

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

oak quail
#

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.

oak quail
#

the docs don't say that voice channels dont support messages

ornate topaz
#

wouldn't that also mean that you can send messages to categories?

ruby terrace
# oak quail yeah, "documented" means nothing for this as I said multiple times so idk why pe...

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

oak quail
#

what issues?

outer raven
#

Probably the same issues that came when djs released threads ahead of time 🤔

mighty bough
#

is there a reason for one being named ChannelType and one being named ChannelTypes?

copper laurel
#

Historically yes, one being a string literal type, the other being djs constants enum

outer raven
#

read the channel topic

visual hornet
solemn flower
#

Does REST Client djs has respect rate limits and queue requests?

outer raven
#

that's a requirement to be on the discord documentation list of libraries, so yes

alpine bough
#

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

visual hornet
alpine bough
#

that is library-related, i'm editing library's code (the path is literally above the code)
so uh, no i guess

visual hornet
#

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

alpine bough
#

there is no problem :)
the filter is there only because of index.js file, that is the only one that isn't a handler

solemn oyster
#

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?

visual hornet
solemn oyster
#

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

alpine bough
#

ah ok, now i understood
thanks for the explanation :)

outer raven
alpine bough
#

sad 😢

golden mortar
wild flax
#

Oh damn diagnostics channel is nice

#

Is this an observable

slate nacelle
#

Diagnostics channels are indeed nice

sinful citrus
outer raven
#

is there a djs version of that builder?

#

cuz iirc that was done only for djs not builders

sinful citrus
#

yes

#
export class SelectMenuOptionBuilder extends BuildersSelectMenuOption {
  public setEmoji(emoji: ComponentEmojiResolvable): this;
}
outer raven
#

then yeah i can do that

sinful citrus
#

thanks 😄 👍

outer raven
#

will do that for addOptions too cuz it doesnt seem to have been done

outer raven
#

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

copper laurel
#

thats odd, I didnt have that issue doing my builders PR this morning

outer raven
#

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?

copper laurel
#

I'm not a maintainer on Github

outer raven
#

ah I thought you were

outer raven
#

did twice already

#

actually

#

second time seems to have fixed it

#

first time didnt

golden mortar
#

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.

outer raven
brisk remnant
real jetty
dawn merlin
outer raven
#

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)

visual hornet
#

Aren't those based on the locale of the user, though? Not of the bot? misread, mb

dawn merlin
#

It’s part of the fetch options

outer raven
#

I looked at the code and it didn’t seem to be

outer raven
#

Must’ve forgotten to switch branches then

#

And that isn’t documented

#

The docs make it seem like you must always pass an id

outer raven
dawn merlin
outer raven
#

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

dawn merlin
outer raven
#

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

dawn merlin
#

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

outer raven
#

what are you talking about

dawn merlin
#

sorry description_localized and name_localized

outer raven
#

well then that's why djs should just ignore those 2 props

dawn merlin
#

it does unless provided

outer raven
#

and there's many other methods where djs hardcodes a query option