#archive-library-discussion
25217 messages · Page 18 of 26
That’d be best case scenario then
And if there’s issues, we could just send a pr or 2 to them too
Since it’s a very specific lib too, so it’s not like we need to hammer through some bureaucracy because it does too much
I’m sure we’ll get someone who tries to copy the dep and make a pr and say “one less dep, here you go” but we can just deny those, wouldn’t be the first time
Lol
I just don’t wanna maintain more code that doesn’t really concern us or rather shouldn’t be maintained by us unnecessarily
What would you need to maintain?
If it works atm there’s no reason for it to break later on
It’s just not beneficial
Look at the code I posted above from the ts lib
Shoving all that into a Util file and let it rot there
At this point you might as well just install the dep lol
It’s not just that it “won’t” break, it also needs to be updated when any new ts type features come out. The TS devs have shown interest in expanding the template literal types
Yeah the one you linked seems fine since it doesn’t case converting only, but the one siris suggested doesnt seem right imo because we’re only using a very small portion of it, and some people, including myself, really care about package sizes
but why?
But that’d only need to be done on a major release, which would probably come with other breaking changes
Yeah but it shouldn't be our priority or task to upkeep such a util function as a "discord" lib
if theres bigger issues at hand in that case
My bot is currently 430mb ish because of dependencies mainly and it cannot cross the 500mb because of the host I use. Crossing that would mean having to find a new one which would be a pain. This is my case tho, idk about others
it just fragments our focus
You could look into bundling?
tsup for example could very well be used to bundle your node_modules too into a single minified file with a sourcemap
so you also get proper line counts in the source files in case an error occurs
I could look into that but most of that size is a dependency that is on the host only which is needed for a specific package (puppeteer) to work
The lib is like 2kb
Anyway that’s not really the topic of this channel, point is that yeah that could reduce size but it wouldn’t be a lot and I think it’s still possible to avoid deps when we can
mb*
I’m talking about type-fest which is 155kb (ik, not a lot, but still)
What is the djs’s size?
I would really like you look into bundling your application honestly
you can ignore puppeteer, but youd drastically reduce the size of your application
I can maybe write up a guide for the guide page for this
But we really shouldn't be "too" careful here
I'd appreciate that, but I'll look into tsup like you suggested 
I can maybe also look into bundling d.js itself, so our sourcefiles are minified
since they can take up quite some space
I agree it’s a server module not a browser module
wouldn't that make it harder to navigate? Also there were some issues with using fs recently I didn't really look into those too much I just saw a PR about it
Harder to navigate how?
Nah it was injecting an "import" into a cjs file, nothing to do with fs or path
Well duh, it comes bundled with an instance of chromium..
like when we get errors that link to a djs line instead of an error message, I usually open it to see where it came from and then check other files, if it's all in 1 it could be harder to do this
Please no.. it's something I dislike heavily when we did in sapphire, it makes exploring the code locally a nightmare without opening up the repository
^^ this
yep that's the issue kek
well that shouldn't be a main concern, sorry lol
The stack traces aren't an issue, source maps deal with that
I disagree with bundling stuff built for servers
if im on a server env, I don't go looking into my node_modules to fix something
But like our lib is pretty small either way so I don't see how we'd benefit from minifying it further
what if you're in a dev env
Don't bundlers minify our source either way? You want small, use a bundler?
Sure, that'd be on the user then
I don't see why we should minify our source, I'm sorry
But why does this matter on the server? For websites that’s a concerning number, but 1.19 should be palatable
I mean at the end of the day, once we switch to TS, we will bundle and minify anyway...
We're what.
So I am not sure how keeping that equilibrium is important
Why are we minifying .w.
well didn't voice already get minified
Well the output .mjs and .cjs gives is a lot of crap anyway
So traversing that is already painful
Even without minification
Yeah our voice lib is only around 450kb
Also don't forget our code does fs calls now so careful with minifications and bundling..
Well that will obviously change
nothing wrong with hardcoding them
its a pain to maintain
we switched to the fs approach because at the time I thought it was a somewhat good idea, but I don't really think so anymore honestly
since we had to introduce this webpack hack
its ok for now
I mean yeah but they're also touched once a century soo
but I would rather not keep it for the long term
actions yeah, but I've personally always thought we should do this for index.js
I still strongly dislike the idea that we'll minify/bundle our sources in the future... There's like..no reason to outside of this size..
Quick question, are we going to use deno for the TS rewrite with npm exports?
deno*?
Yeah
Not sure I want to commit to deno and node at the same time
I doubt our lib will be deno compatible?
Deno usage is very low
would also mean refactoring -modules, /voice and /collection
Thats... a lot of work lol
Tru
I mean for -types it was dumb easy to do, but for d.js.. the path changes ALONE would be a chore, so I doubt it'll happen soon
I mean collections should be deno compatible tbh
I don't think we'd need to change anything?
you can add those to an array, it's much easier to specify the ones you don't want than the ones you do
I'd rather use a multi index.ts approach
and call export * from 'x/'
so youd only need to add the export to the specific sub-index.ts
and it will expose itself
yeah but you still gotta go there and manually add the line
thats fine
whereas with an fs read you simply don't have to worry about that
yeah but I don't see the benefit here
How often are you gonna add new classes/files and have to add an export
every time a new discord feature comes out
Isn’t that what most TS libs do tho
They don’t expose everything by default
yeah, using fs to export your files is quite the anti-pattern
I'm not sure what most TS libs do tbh, but we're still js and im proposing this for the js lib still
And I’m not comfortable enough to pioneer a different way here lol
I always see the reexport pattern used in ts libs
Relying on IO shouldn’t be something we do in the lib
Just my 2 cents
Save those cpu cycles
I'm not comfortable reading all our directories to do an index.js/ts/mjs/tjs/whatever file either
but on discord-api-types you have all the v9 stuff in 1 file, so you only export 1 file
That would be the same for nested index.ts’s they reexport and then the root index.ts re-exports them again
but in djs you have multiple files so even if you have multiple indexes, in the sub indexes you'd have to be require()'ing all of them
Ideally every directory has an index.ts, all you would need to do in the root index.ts file would be reexporting each directory (on the same level).
yeah that's fine, but it doesn't solve the issue, just spreads it across multiple files
"issue" imo ofc
I honestly don't wanna get too hung up on this whole thing
I am pretty dead set on this
Sorry
We're not using fs to generate an index.anything file
Reexports?
Multi-index file approach
Ah ok
and using fs on index?
What if there’s files/symbols you don’t want to include in your exports?
you put them in an array, like was done for actions
was at some point, idk if it still is
Yeah I def wanna move away from that
:/ aight
I'm +1 on that
I wasn’t aware of this, but this is … gross
was added in https://github.com/discordjs/discord.js/pull/6709 but why? And why was it merged if it's so bad
Because we I merged the fs pr, which I shouldn't have in hindsight
but 20/20
If anything the less complex code #6102 made things a lot more complex
But hey, I was young and dumb
_how is it complex tho
_
Live and learn
people often think less lines = faster/cleaner/better/etc
I'm saying because of that PR, we had to introduce a more complex method for webpack, since we broke support for it
golfing in a nutshell
So "less complex" ended up being "way more complex"
but wasn't support for webpack removed in v12?
I see
So like the dom lib essentially?
No no, we had specific builds so you can run your bot on a website lol
Hmm ok
Or the chrome console or whatever
But since discord doesnt support that anymore, we removed those builds
Doesn't mean we should break bundling overall
@tender field are you able to continue working on https://github.com/discordjs/discord.js/pull/6647? You have requested changes from Space
I think that's the wrong PR
Fixed 😅
can you rebase this @dawn merlin https://github.com/discordjs/discord.js/pull/6950
Will do
It’d be amazing if GitHub notified you whenever your pr has new merge conflicts
you can use an extension
it doesn't notify you, but it shows you on the pr list
for example this has a merge conflict and it has the icon
yes i'll do it asap! thanks for reminding me, i forgot about it 😅
uh-oh i think i failed my rebase
can some gitmaster help me fix my rebase fail here please ? https://github.com/discordjs/discord.js/pull/6647
ah shoot 😅 well thanks, i'll redo it.
@opaque vessel your PR will be the last blocker for a 13.4 release 👍
so whenever you get to updating it with the feedback, we can move forward with that
Could try if you invite me to the repo
invitation sent ✅ thanks for your time!
Aight will take a look
thanks ! i'll be back in half an hour fyi
Fixed ^^
Ooh okay, just done that - allowed null to be passed which'll clear the author object (:
Also @tacit crypt, I removed the default value on the first parameter (which was an empty object). This shouldn't be optional because calling .setAuthor() with no parameters will yield an error when undefined is checked to be a non-empty string.
That should be all
Is the plan to port stuff like MessageButton and MessageSelectMenu to builders?
And if so, how far does that extend? Would it include something like MessageAttachment?
I did start a Button PR but I didnt like the design and never went back to it
Thing is, components basically already are builders in discord.js
Yeah that's why I'm asking
i pushed commits that added tests and resolved Space's comment, ready for review 😄
https://github.com/discordjs/discord.js/pull/6887/files#r736720877 does anyone have a better suggestion for this description? @opaque vessel I know you usually like docs stuff so maybe you have an idea?
tbh I think it's good as it is. It mentions the API and client names just like we do in other properties
in fact, maybe it should only mention the client name (since the api name can be deduced by the property name) which has also been done on others like GuildMember#premiumSince
ops @tacit crypt?
Hey library people. Please let me know if this is intended:
With the bot having the "View" permissions in channel 1, I am able to access interaction.channel (as a ThreadChannel) when a command is used in channel 2 (the thread).
If the bot is denied the "View" permission is channel 1 and a command is used in channel 2 (the thread), interaction.channel returns null. The <interaction> itself is a basic object format.
interaction.channel is always available in channel 1. Permission doesn't matter. Is there a reason why the thread acts differently?
what method are you using to check viewability?
No checks in code currently if that's what you mean
But Slash commands don't care about channel perms, no?
It seems to be cache-related. I can get it it work, but then if I then deny all perms and restart the bot, the interaction.channel returns null again
This is all beyond my skill level, but might it be because the bot isn't actually inside the thread?
In the client, this is the description. So, maybe this:
Whether this guild has its premium (Boost) progress bar enabled
Just one word in a bracket extra
with a lower case b but yes that sounds great, will change
I don't think you need to state its whereabouts in the description
At Discord we tend to capitalise the word Boost everywhere
Because it's a part of "Server Boost"
When I said "At Discord" I didn't mean discord.js, I mean literally at Discord
well but we follow the d.js standard
True, though there's my suggestion nonetheless (:
yep, committed :D
Not sure if you saw this @dawn merlin
yeah I did, haven't fully looked into it yet
djs-modules/core will be using djs-modules/rest and djs-modules/ws instead of internally implementing it for the most part, right?
wait, what will core do? I assumed it was going to be the djs ts rewrite
core just houses functions or classes that multiple modules use
Ah i see
Hi, do you think it would be possible to add some type hint of the expected interaction type in command data interfaces?
export interface UserApplicationCommandData extends BaseApplicationCommandData {
type: 'USER' | ApplicationCommandTypes.USER;
__interaction: ContextMenuInteraction; // Like this
}
The issue I'm running in to is that the union type causes issues when attempting to extract the correct properties because you can't get the properties by only referencing either value of the union, and providing both tends to become verbose, after some workaround I managed to reference either union member to get the correct ApplicationCommandData properties but now I essentially have no way to statically determine what interaction type I'm dealing with based on the inferred type
Hi, are you able provide a code sample of this issue? I'm just having a hard time trying to visualize it
Well simply said, it would be nice to be able to do execute(interaction: ApplicationCommandData[T]["__interaction"])
Where T is where I reference ApplicationCommandData["type"]
so bascially in your command handler you want the specific interaction type to be inferred?
Exactly
Currently it's not possible because ContextMenuInteraction is completely separated
I can share some code I use in mine to get it to work
I'm scared now but I'm interested 😅
export type CommandRunner<T extends Interaction> = ({ interaction }: { interaction: T; }) => Promise<void> | void;
export type CommandBase<T extends BaseCommandInteraction> = ApplicationCommandData & {
run: CommandRunner<T>;
};
export type ContextMenuCommand = CommandBase<ContextMenuInteraction<'cached'>> & (UserApplicationCommandData | MessageApplicationCommandData);
export type SlashCommand = CommandBase<CommandInteraction<'cached'>> & ChatInputApplicationCommandData;
export type Command = ContextMenuCommand | SlashCommand;
// Usage:
const command: Command = {
type: 'USER',
async run({ interaction }) {
interaction // Inferred to `ContextMenuInteraction`
}
}
basically the command kind is inferred based on the type passed into Command
Why is ContextMenuInteraction different from the others? Oh wait I see now
This is what I managed to create
import type { ApplicationCommandData } from "discord.js"
interface LegacyCommandData {
type: "LEGACY"
name: string
description: string
}
type InteractionCommandData = ApplicationCommandData | LegacyCommandData
type InteractionCommandProps<T extends InteractionCommandData["type"]> =
InteractionCommandData extends infer U
? U extends unknown
? T extends InteractionCommandData["type"]
? U
: never
: never
: never
type Command<T extends InteractionCommandData["type"]> =
InteractionCommandProps<T>
```In this case it would be solved with `InteractionCommandProps<T> & Record<"execute", (interaction: InteractionCommandProps<T>["__interaction"])>`
You don't need a conditional type to get this to work. A union of ChatInputCommandData | UserApplicationCommandData | MessageApplicationCommandData is a discriminated union. It's discriminated on the type prop. As as long as the type prop is provided typescript can figure out which constituent to use. So adding a branded type to the interface wouldn't add much value.
I see, ty for the example, honestly the guide screams for a TS version now but that's more of a #archive-guide-discussion thing 😅
It's too hard to navigate the types
I agree lol, someday
RESTManager class does not have JSDoc comments?
It doesn’t indeed
This is intentional
I see
this is intentionally how Discord works, it isn't a library thing
Discord gives users data for all non-thread channels in the guild, but thread data is locked to users who can access the parent channel (if the thread is private, membership in the thread or the Manage Threads permission is also needed)
the only channel data Discord currently sends in interactions is the channel id (which you can access in d.js with interaction.channelId); interaction.channel is loaded from cache
Is there an official place on djs's github to work on the ts rewrite? Can't tell if im missing something
Well it hasn’t started so not really, but the modules it uses will be under -modules
ah, alright. thank ya
And is the rest module as powerful as the one djs is currently using? Like does it respect ratelimits everywhere it can and such like djs does?
Yeah it keeps track of bucket hashes so it can keep track of rate limits, it’s almost if not as powerful as the djs rest client
Alright sounds good, thank ya once again!
Thanks, I guess that makes sense
Well, since the only open PR on collection was closed, can we get a release 
https://github.com/discordjs/discord.js/pull/6968's upstream pull request was intentionally closed
Why does Util.discordSort sort by id if the rawPosition is the same?
It seems to maybe have some issues, as channels with the same rawPosition have the position in the wrong order
2 channels with the same rawPosition of 0 will have the first channel's position as 1 then 0, for example
the rawPosition is linear with some repeats, but where the rawPosition has repeats, the position goes backwards
rawPos 0 0 1 2 3 3 4 4 5 6
pos 1 0 2 3 5 4 7 6 8 9
Positions are quite a problematic thing so I think that was done as a way to be able to tell them apart. Since Discord doesn’t send the proper position fields, it’s hard to know where stuff is right
well it's consistently wrong when the rawPosition is the same, so maybe the a and b could be swapped when checking ids to make it correct?
that would fix your use case specifically, but break others where that position is correct
I don't think you can have a 100% success rate
with the other scenarios where the rawPosition is incorrect and the position corrects it, what's going on there?
the channels i have here are from cloning
which makes the new channel higher up since it's replacing the position of the cloned channel
when you create a channel, discord messes up positions and sets two channels to the same pos, which is why there's rawPosition and position, so just like you had a scenario where the order was reversed, others might have a scenario where it is correct
pain
I think threads are incorrect either way
They sort alphabetically I think in the client
Which is an accident
so, it's an issue upstream that's attempted to be fixed with the position getter?
Our discord sort should be exactly what the client does
well, it clearly isn't, but i guess that's not really an option
You mean it isn’t for channels either?
nope, this is the result im getting
the repeated rawPos seems to sort by id ascending, but the discordSort method actually seems to sorts descending
@outer raven can you reproduce a scenario where rawPosition is the same and the position is correct between 2 channels? i can't seem to get any cases where it's correct with create either
TextChannels
GUILD_TEXT
Is the <ClientUser>.setPresence() thing buggy for activities? Because there were multiple people in #djs-help-v14 now already whos code didnt work with it, but it worked with <ClientUser>.setActivity()
@trim quartz can u just copy the client code for positions on channels and threads and give it to us 
setActivity calls setPresence so there's no reason for it not to work
well, why wouldnt it work then? I have no idea tbh because it works with the same code for my bots but it seems not to work for theirs (and setActivity works for all of us)
could be an issue in their code, I'm not sure
do you have a reproducible code sample?
no.. unfortunately not.. i was just wondering because their exact code worked for me..
Can possibly be unknown rate limits if they set at start-up
well i'll just draft a pull request for now, if there's more inconsistencies then... idrk
and im not touching threads, they don't seem to even have a position
Does the api not give a position for threads?
iirc no because threads aren't always present
Hey, (not sure if its good channel, sorry if its not), does anybody know if the new Discord event scheduling feature will be included into the Discord API? And following question is - if it will be, will it be implemented to discord.js library?
the first one isn't really a question to djs, but if it's added to the api it'll be added to djs
it probably will be added though
for discord api implementation you should see in the discord api server, #useful-servers
Afterwards, anything open to bots does end up on djs, someone just needs to make the PR
#6493 in discordjs/discord.js by iShibi created <t:1629573546:R> (review required)
feat: add support for GuildEvent
📥 npm i iShibi/discord.js#feat-guild-event
okay, thank you for the info, have a nice day 
Will discord.js include a thing for server events? Like create, edit, delete, etc...
yes
was just discussed lol
discord.js supports everything the API does, so those questions always have an obvious answer.
Thing is the API doesn’t currently support events yet, so we’ll have to wait until next week
Ok? I'm aware as stated at the start of this conversation. Not sure why it's being repeated
then why the reaction 
Misleading phrasing
Ok, then let me be clearer. Your phrasing was terrible
The API does support it but bots cannot use it
yeah so the part that concerns discord.js supporting events isn't supported yet
is mostly because "why repeat things already said to just be less precise"
Isn't this exactly why it is, in fact, not an "obvious answer" as you put it? Because the API endpoints for this feature are not yet available to bots, thus it's a Discord feature discord.js is not yet able to support
wh
@opaque vessel for issue #6905, could ThreadChannel#parentId be used?
Sorry, can you elaborate?
On this part of the issue ticket:
However, this condition is always false. this.channelId is the id of a ThreadChannel, but the deleted channel is a GuildChannel. Therefore, the interaction collector is not stopped.
Couldn't you use the parent id against the deleted guild channel id?
I'm kind of lost sorry
The parent id of the deleted guild channel would always be a category channel (if one), and this.channelId is the id of a thread channel
This issue could be partially resolved if one were to not store ids and instead store the structures. But, that would remove the ability to use the interaction collector on guilds the client is not in
another alternative would be to find a way to directly associate collectors with their respective channels, some kind of tree-like structure. When a parent node is eliminated it's children should be as well
I think the infrastructure issue has to deal with the fact that threads are more than one layer deep
The thing is, both solutions will not work in guilds the client is not in. The client won't detect if the thread is deleted or if the parent channel is deleted
There will always be a possible leak because discord.js supports those types of guilds for the collectors
The only real fix is to require a time, then it won't be discord.js's fault (':
Then comes the handling of the thread channel shenanigans
so this leak affects collectors in guild channels too?
If you mean a discord.js structure, then currently, yes. But that's fixable
It's just not fixable for guilds the client isn't in
ah ok
So you can see the real pressing issue here >:
hmm maybe it's worth it to throw an error if you're not in the guild and create limitless collector
after all collectors are djs constructs
How would you detect that in the typings o,o
I mean you wouldn't, lol, it's possible but painful
Ya, but this specific collector is alienated from the others due to its unique ability to work on fancy guilds
I think the/a fix would ultimately be for the next major version though
For sure
Idk but a suggestion that the docs give a note saying CommandInteraction#guild and CommandInteraction#guildId will return null if the client user isn't in the guild / used the command in dms
Isn't that... obvious?
well, Message would have to have that as well? and also Typing? and then it would have to be on the base Interaction to let it be shown for the other interactions?
yeah i don't think it's really worth documenting, as jiralite said, it's kinda obvious
hmm okay then
well since noone has brought up anything conflicting with this, ill just mark my pr ready for review, since im free to respond to any feedback or comments now
Has it been tested against guild roles?
oh shit, it hasn't, i forgot about those.
well there's where the positions are correct as is, since the positions are reversed, so ids are sorted descending instead
so i guess there'd have to be some extra option or check for that?
discordSort is only being used for those 2 (channels and roles) though, so that should be everything left
so this can be resolved but i don't know what would be the best way to go about it.
you could add an option for the sorting order ¯_(ツ)_/¯
i did mention that but im not sure what the best way to go about it would be
by the way, is there a specific reason parseInt is used instead of, say, Number in discordSort?
Maybe it should be BigInt(a.id) - BigInt(b.id). That code is from several years ago... won't have to slice
alright ill include that in my pr
Noo that won't work
was typing a question, got answered before i finished 
Number(BigInt("858851038236901377")) - Number(BigInt("858851038236901376")); evaluates to 0 and that's not true
make them strings
the ids.
Thats not even the issue (well, it is, but not the issue I'm poking at)
If the return type won't accept big integers then there's no point doing it in the first place then
oh whoops
there is, for doing the math
Jiralite pls
Heck what
Do you see me calling Number twice? 
also as a side note, im not sure if i set something incorrectly in my dev env, but uh,
i haven't modified this or anything, just cloned the repo
eslint is complaining that this should be under node-fetch, but nothing about it shows up with npm test
doesn't hurt to run an npm ci, restart the eslint server and also re-run the test script
Apparently that's a false positive
#archive-library-discussion message
aight ill try looking into that, thanks
As long as npm test works fine then all should be good I guess
yeah i understand that, just want to make sure eslint is working fine in the ide since the changes im planning are more than just swapping a and b like i initially planned lol
Should https://github.com/discordjs/discord.js-modules/pull/45 be closed? Seems like the changes are no longer accurate/true
i got to this, but it feels kinda clunky, im not sure if this could be improved in some way?
Number(a instanceof GuildChannel ? BigInt(a.id) - BigInt(b.id) : BigInt(b.id) - BigInt(a.id))
Suppose you should use variables to make it less clunky? Shrugs
as an iife? or just make it a block and return the result?
Yeah it looks like a block would be more readable
Like so?
const aId = BigInt(a.id);
const bId = BigInt(b.id);
return Number(a instanceof GuildChannel ? aId - bId : bId - aId);
aight
return collection.sorted((a, b) => {
const aId = BigInt(a.id);
const bId = BigInt(b.id);
return a.rawPosition - b.rawPosition || Number(a instanceof GuildChannel ? aId - bId : bId - aId);
});
so this is what i've got now, anything else to be desired here?
@dawn merlin your question you just asked isn't for me, that's for Discord
ok, I just wanted to verify that this currently how discord is sending events
I don't really know how ddevs and that all works (not in there), but you should probably ask in there. If you don't want to, I can get an answer for you during working hours
i'll just make an issue ticket on the dapi-docs github, someone from ddevs will probably answer
alright i have an issue with my pr that i cannot figure out for the life of me,
in the latest djs pr these lines were added https://github.com/KhafraDev/discord.js/blob/main/src/structures/MessagePayload.js#L181-L189 that cause some issue in my pr https://github.com/discordjs/discord.js/pull/6586 and prevents attachments from being sent. without these lines, i can send an attachment just fine, anyone got a clue?
here's what attachments is ```js
attachments: [ { id: '0', description: undefined } ],
aren't you supposed to use files to send them initially
and attachments is mainly for editing?
no clue, these were just added as the result of a rebase
removing those lines makes everything work fine once again
still have no idea what attachments are really for :/
neither do I but i'm wondering if that's a bug, extraneous code that can be removed, or if i need to implement a fix on my pr
the naming scheme is kinda weird, files is the array that is processed into the attachments array, the attachments array in MessagePayload is the thing actually processed into formdata.
There is also the attachments key in Messages, which is JSON data and completely separate.
so any reason sending the attachments array would cause a 400 status from discord's side?
i have no idea how to fix the issue i'm having minus just removing that section of code linked above
the exact error:
DiscordAPIError: Invalid Form Body
attachments[0]: Attachment data not found
code 50035
- if (file?.file) body.append(file.key ?? `files[${index}]`, file.file, file.name);
+ if (file?.file) body.append(file.key ?? file.name ?? `files[${index}]`, file.file, file.name);
You made this change to the formdata appending, which I believe causes that error. Take a look at the new attachment uploading stuff in the api docs, seems that was missed in the rebase
that fixed it! but that brings up a second question:
the issue is that file.name wasn't und/null so the name would default to that.. but if file.key was a valid name, wouldn't it throw an error there as well?
the key is used for stickers only, because the formData key needs to be "file" for that
the stickers endpoint uses formdata but is more json styled
interesting 🙂 thanks for the insight & the help
np, its all kinda confusing, I wouldn't know about that stickers stuff if I hadn't just implemented that in /rest
(unrelated to the current discussion)
i think im doing something wrong with testing
i only added a require and changed discordSort, but when testing im getting Util.setPosition and Util.idToBinary not being functions, logging Util gives an empty object
i tried requiring the index through a filepath, and also by npm pack then npm i, and they're yielding the same results
requiring the index where?
in testing code, i just did require('../../discord.js/src/index.js')
well actually it was esm that i already had from earlier
circular requiring index is generally very very bad, any chance thats happening?
oh it wasn't inside djs
i had a test file inside a different project in the same directory
Is there any package that can perform automated tests for bots using slash commands?
pls ping if answering
this isn't really a question for this channel, you can just write tests yourself
@tacit crypt has there been any discussion/decision on the issue of replacing ow in builders? Sorry for the bump but esm support being broken feels kinda high priority
ow, my validation...
Discord.js seems to lack some API fields according to the Discord API Documentation here:
https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure
The attributes min_value and max_value is not present in the type ApplicationCommandOptionChoice and also not set in transformOption().
See:
https://discord.js.org/#/docs/main/stable/typedef/ApplicationCommandOptionData
https://github.com/discordjs/discord.js/blob/stable/src/structures/ApplicationCommand.js#L330
I see that an PR is being merged 4 days ago. Let me use the github master version then
It's just not in stable
Because of the way dynamic works, shouldn't gif be excluded from the format type here as it'll already use gif when possible if you specify the dynamic flag?
Possibly, but iirc providing both isn’t technically incorrect
What if you don't know if the user has an animated avatar icon? Providing your desired format there is a fallback
Feels like the default for dynamic should be true
the defaults for images should be changed a bit imo
but yeah it's a bit risky to provide a gif format
Im pretty sure the defaults we have now exist for a good reason, this discussion comes up every so often
It feels a bit odd imo to specify a dynamic property to get the actual avatar icon that is being used by the user in the right format... wouldn't it be more desirable to replace that with a static property where you decide whether you want to receive their URL in a non-animated format?
So { static: false, format: "jpg" } would get the .gif and fallback to .jpg if it's not animated
{ static: true, format: "jpg" } would get the .jpg always
I'm not sure where this can falter tbh
And whats the default, static: false?
I just dont really see what benefit this has over setting a format, and a property which will override that for animated avatars
Yep yep, static: false is the default. If anything, this seems more like a helper property by discord.js shrugs
If you think about it, fetching the avatar's hash will return it in a format starting with a_ if it's animated. discord.js converts every image received to static by default, though that's not necessarily what should be happening? It should be returned as-is, and the user can specify if they want to enforce the image to be static
Not exactly? The default format is webp
So what you'd be suggesting is this: https://github.com/discordjs/discord.js/blob/5ec04e077bbbb9799f3ef135cade84b77346ef20/src/util/Constants.js#L50
- if (dynamic && hash.startsWith('a_')) format = 'gif';
+ if (!static && hash.startsWith('a_')) format = 'gif';```
Yeah but currently, you have to specify if you want it to be dynamic
Yes I know
Sorry didn't see the code block with the huge thing being collapsed x_X but yes!
Tbh at that point the property becomes useless, if you want a static image, just supply "png" or "jpg" or something
uhh.... no? Because it will default to gif?
Can you elaborate
Supplying "png" would be for deciding the format if it is not animated
Unless you also provided static: true
Or the reverse with dynamic: supply "png" to always get a png, or supply "dynamic: true" to get a gif if its animated
What I'm saying is that if we flip the logic to ensure all the URLs made are dynamic by default, you wouldn't need the static property. Since all animated avatars on Discord are of a .gif format, then the other formats .webp, .png, .jpg and .jpeg are all for static images so... they would never attach themselves onto animated avatars
Supplying one of them implies you want them to be static
No it doesnt
That's breaking the existing functionality of being able to specify the static image format while also resolving an animated one if applicable
Currently:
() - webp
({ dynamic: true }) - gif > webp
({ dynamic: true, format: "png" }) - gif > png
({ format: "png" }) - always png
With your proposed static: false default:
() - gif > webp
({ static: true }) - webp
({ format: "png" }) - gif > png
({ static: true, format: "png" }) - always png
If you remove static/dynamic entirely, you lose that gif > png use case
The fallback scenario is gone
I got you yeah just at the last moment, thank you for being concise there haha
Otherwise the change is literally just swapping the logic on the first two outputs
Yeah exactly, I'm pretty sure everyone everywhere is favouring always using dynamic: true, so... we should probably change that
Not true, I dont
Well, mostly, at least, but the logic I follow is if the user object logs the avatar's hash as "a_..." and you run .avatarURL(), one new user would likely think they're going to receive the animated avatar
Uh anyway... I guess that's a change for version 14?
Would definitely be breaking yes
Cool, alright, thank you for this lil' conversation (':
On that note, I believe there’s no good reason to use webp as the default is there? Discord doesn’t have a default, the client used png and webp doesn’t even support transparency
Webp does have transparency
It does not
If you try to set something’s icon or avatar to a webp image it loses the transparency, I’ve tried it
Well the format does dunno why it doesn’t work for discord
¯_(ツ)_/¯ but supplying png for that works as intended
So maybe that default could also be changed for v14?
Actually now that I look into it, webp is supposed to provide quality images with less size but it’s made mostly for browsers, and djs doesn’t work on a browser, so maybe that was forgotten when that was removed ¯_(ツ)_/¯
Is this via the client gui?
the client gui doesn't even allow you to upload webp
We did not write our code with browsers in mind past the parsing res.stuff from node-fetch.
If discord cannot process webp's that's an issue on their end not ours
Also the client uses webp whenever possible
If a platform doesn't support it, then it defaults to png
Thats because you didn't press "skip" in the selector
You cropped it with discords internal crop tool, which gets rid of any transparency
As for our methods, the problem exists most likely with their image microservice
I didn’t crop anything
So why don’t we default to png
This is why
Because the client is based on web so it needs smaller images, but if webp doesn’t work properly with djs I don’t think we should use it right?
You do realize that it's not discord.js's fault that Discord's media whatever the hell it's called breaks webp transparency, right?
And also, we already default to jpegs for uploads
if you send discord a webp image thats on you
I don't see why we should change internals for this
Maybe we have a bug that we send the image wrong to discord when using an URL
My point is that if you don’t specify a format, discord.js sends webp which then breaks the image. I understand this may not be the library’s fault, but it’s something that can be fixed by changing the default, and then if the user decides to specify webp it’s their own fault
in this case it is the libs fault because of what vlad said
we just assume its a certain extension
which could potentially mean gifs break too, except if we check only for gifs
But where’s the code that’s defaulting to jpeg?
@outer raven the regex you gave for INVITES_PATTERN doesn't work for events, need some help with Client#fetchInvite
which PR? I don't remember touching that one 😅
yeah so the idea was for it not to match events, and for a new regex to be used for those
I remember that now
not sure if you agree but I feel like it would make sense for an event not to match with the invites pattern
so that regex does work for events only (not sure if the https should be matched or not)
Client#fetchInvite uses that pattern to resolve the invite code, so we need something that matches event's link too
but if you wanna fetch an event shouldn't there be a sort of Client#fetchEvent?
clicking an event link does make you join the server, so I guess you can leave the invites pattern unchanged, but that method could be interesting if there is an endpoint for that (not sure, haven't really looked at the documentation properly)
actually, since you wanna capture the event ID and not the invite id, lemme update that comment
fwiw they also use discord.com/events/snowflake/snowflake
android client share does at least, and I'm not entirely sure
one of them is obviously the event ID
an example if it helps: https://discord.com/events/613425648685547541/908867166378553345
oh guild ID and event ID
on iOS I get missing permissions 
oops sorry for all the confusion, I got confused by the guild_scheduled_event_id field in https://discord.com/developers/docs/resources/invite#get-invite-query-string-params and thought we need to somehow resolve the invite link to a code for Client#fetchInvite to work.
We don't, the invite code is of the channel and that query is just for fetching event data if there is one in the channel
Now, the issue is that how to add a way to let users pass an event id to Client#fetchInvite without a breaking change, because it only takes invite resolvable as argument
well make it a second arg
but it's really annoying that you cannot resolve an event from an invite, maybe we could add the method and warn users that it would make 2 api calls?
that's gonna be controversial though since every other method in djs uses 1 unless given certain options
btw this link only works if you're on the guild, it doesn't work as an invite
that's weird
anyways, I just wanted to point it out because I've seen that form a few times
honestly not sure what to do with it
add an options object (since thats how we do optional args) with eventId
yup, that's what I decided too. Had to go with ClientFetchInviteOptions because FetchInviteOptions is taken. Could change that to FetchGuildInviteOptions in v14 👀
#archive-library-discussion message
Anyone got any suggestions for what i did wrong with testing here?
Forgive me if this isn't the right place to ask, but there's a fix for an upstream CVE that can now be pulled into @discordjs/node-pre-gyp: https://github.com/discordjs/node-pre-gyp/issues/5. Is this the right place to draw attention to this?
Yes, Ill be handling that in a few days time
Thank you for figuring that chain of deps out and making it to the source to get it fixed 🙏
Ok cool, and then @discordjs/opus will also need to be updated downstream. Thanks.
Lol i've been chasing it all the way down from the top.
also prism-media will need to start referencing whatever updated version of @discordjs/opus that integrates the fix but i'll bug them about it once that happens
desktop has a copy link button too
that was not the point. the point is that the link that is copied on android is different than the one on the other platforms
Has there been chat about creating a general .send() method on interactions that will send a message no matter if a reply was already sent (by calling .followUp()) or deferred (by calling .editReply())?
Apparently I was the only one who disliked that but the issue was closed, so I'm not sure what that means
Usually djs doesn't like utility methods that have other workarounds iirc, but it's a matter of opening a PR and seeing the feedback ig
Yeah it's an abstraction that is misleading
Crawl never really agreed to it, looks like it was summarised by my comment
None of the reactions on the initial post are from maintainers
Crawl did disagree to my comment, along with 6 other people
not sure why
but yeah I assumed it wasn't something ppl wanted
Usually djs doesn't like utility methods that have other workarounds iirc, but it's a matter of opening a PR and seeing the feedback ig
I've got a question regarding this since it's true to my knowledge: why does the lib includeFormatters? It simply exports some functions from builders but they're not used in the code whatsoever. Plus it adds1211 dependencies to the main lib
Hi @dawn merlin - thank you for letting me know about deprecated usage of ThreadMemberManager#fetch() <:
Looking at it closely, how come the second parameter is an object and not the first? If one wanted to fetch all members in a thread but not cache them, the method would have to be called as fetch(undefined, { cache: false }). Why not fetch({ cache: false })? I may have missed something x:
Mainly because if the first was an object, it would be a breaking change, since Snowflake would now be an object
Sorry, I don't follow. Before this commit, there was no Snowflake type?
oh sorry it was a boolean before
Ya! Exactly haha
So imo, I thought it would be better if a boolean was passed, it would be internally converted to { member: undefined, cache: boolean, force: false }
yeah I think that's what it's doing
The member to fetch. If
undefined, all members
- in the thread are fetched, and will be cached based on
options.cache. If boolean, this serves- the purpose of
options.cache.
So ig maybe a deprecation warning isn't needed
You're willing to keep the boolean property?
That does look like it'll also solve the issue
So I guess, either make a change to keep the boolean property, or convert the first parameter into an object shrugs
well for v14 just an object but to prevent breaking changes im pretty sure it needs to be a union
Ya
honestly if you don't mind it can probably be an addendum to your PR, but if you'd rather not I can make a PR
Would you pretty please mind making one <3
for sure (as in I wouldn't mind)
(:
is there a way to destructure and have a named parameter on a function? ie:
function foo(options { a, b })
for the same parameter? i don't think so
but you could just destructure out afterwards since you'd need to check for the boolean first
yeahhhh, I also have to deal with default values as well but I think thats the only way
i think the default value should be fine, since it would only trigger if neither the object nor the boolean were given
oh wait I just realized you can get the first argument via arguments[0]
this will be changed with a breaking change in v14, right
yeah
We never really cared about dep count
It’s a metric that is rather bad to go by. You obviously shouldn’t add all kinds of junk, but at some point it gets rather silly
I agree in some cases but adding 11 deps just so people can import formatters from discord.js and not builders is rather strange imo
especially since in v13 dev a bunch of old methods that weren't used in the codebase got removed as well
just wondering what benefit having Formatters in the lib gives over importing djs builders instead?
iirc
/**
* @param {SomeType} options
*/
function foo({ a, b, ...options }) {
}```
*more of a js question but you asked it in here so*
in that case options will not have the a and b fields
the best you can get is ```ts
function foo(options) {
const { a, b } = options;
}
i mean yes but thats just kind of silly IMO, at least for making a function in djs
@copper laurel ban
what
There was a nitro scam someone deleted it
@opaque vessel looks like I need to improve those type guards 😅
Is this regarding issue #7001? o,o
Yeah
Sweeping the channel manager isn't actually supported so... dunno if you want to do that shrugs
Hmm it isn’t? I thought sweeping any cache was valid
Ik extending caches isn’t supported
https://discord.js.org/#/docs/main/main/typedef/ClientOptions
The sole warning block on that page says so, right? As far as I know, that's the only way to sweep channels out
oh yeah I'm just being dumb, I literally said extending isn't supported, but thats the only way to change the sweep settings anyways.
I could've sworn it throws if you do that, so im not sure how the person in 7001 got around that
oh it just emits a warning...
#7002 in discordjs/discord.js by That-Guy977 opened <t:1637212129:R> (review required)
fix(Util): fix sorting for GuildChannels
📥 npm i That-Guy977/discord.js#main
could i request for someone to check if putting those changes in breaks Util in the same way mine did?
#7001 in discordjs/discord.js by ElectrifyPro closed <t:1637206940:R>
Interaction.reply() with the fetchReply option returns a message object with no Message prototype
For CommandInteractionOptionResolver#getChannel, where does the Option.channel come from? Discord does not list this as a valid property from Application Command Interaction Data Option.
From what I can see, minimal transforming is done, but I've only looked at the AutocompleteInteraction#transformOption
Ah wait. That's coming from resolved. However, I don't think resolved is properly being passed to that properly. I've been looking at AutocompleteInteraction#constructor at https://github.com/discordjs/discord.js/blob/main/src/structures/AutocompleteInteraction.js#L45
and the signature for transformOption only has 1 param which does not include the resolved
Im not sure what you think the problem is here?
I got really confused because the signature didn't have a resolved param, but it will still being passed anyways. Type safety is the issue
The autocomplete interaction doesn't, so it is useless here
But autocomplete is only for string types anyway
Its a JS library there is no type safety lmao
This is the full one
Trying to fix that 
So yeah, it probably shouldnt pass resolved in the autocomplete interaction
That was my problem because my brain is melting trying to make things type safe
sorry for confusion
Documentation suggestion for @dusk loom:
Interaction#type
The interaction's type
you mean this?
but that does exactly the same as the typeguards, except without type safety. If that's not it then I'm not sure what you're looking for
determining if it's a select menu, button, command or context menu requires 2 checks, which are done by the typeguards, so why not just use those?
the only alternative to the typeguards is doing the checks they run yourself, which is less clean imo. There are all sorts of typeguards both for specific interaction types and more generalist ones so idk why you can't just use those
and by that I mean isApplicationCommand and isCommand for example
Yeah I really don't understand this question. It's the "how do I do <thing> without doing <correct existing way to do thing>"
What's wrong with the methods
- public on<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => Awaitable<void>): this;
+ public on<K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => Awaitable<unknown>): this;
```Do you think this would be possible?
Makes sense to me, return type shouldn’t matter here.
cc @dawn merlin
I'm not sure what this would be used for 😅, the return type is intentionally void because you don't return values from a client event, you only consume what's given to you
If you make a event handler it's nice to be able to do early returns when calling methods that don't return void
Yeah in the end it doesn’t really matter what the listener returns, so I’d say any would be fine too
export function createEvent<T extends keyof ClientEvents>(
cb: (
...args: [...args: ClientEvents[T], prisma: PrismaClient]
) => Awaitable<void>
) {
return cb
}
export default createEvent<"messageCreate">(async (message, prisma) => {
if (x) {
return message.channel.send(...) // Promise<Message> not assignable to void
}
})
```If you do change to unknown in your handler, you can't dynamically pass it to client.on
just return on the line after the send
Yeah but that makes the code unnecessarily more bulky when it doesn’t make a difference if you return a message
any is fine too
return void await x
return void x
The ending type of the function doesn’t matter though. unknown/any feels more representative of the node typings (this is just a better typed alias of EventEmitter.on)
yeah, i was just suggesting an alternative soloution to their problem, at least until if/when its changed
You'll just have to return after the method executes
if you make the return type a promise of unknown it's misleading because it implies that return value is used somewhere else which it isn't
What about any? Or a type alias that represents something with the value of any
It just adds extra noise atm, especially with
padding-line-between-statements:
[error, { blankLine: "always", prev: "*", next: "return" }]
```I get it's my issue but the return type doesn't matter
This applies to anything non-void
I need more context on what this means
eslint rule to always add a new line before a return statement (separation of concerns preference)
ig disable it then? lol
What about passing a type parameter to specify the return type, or will that not work
it would but I don't really see what justifies it?
Shenanigans
I think it would be nice to support as many JS patterns as possible, generic return type would be fine too
I just don’t get the issue with having it return any
For semantic reasons, but generic return type fixes that
What would that generic type look like
public on<TReturn = void, K extends keyof ClientEvents>(event: K, listener: (...args: ClientEvents[K]) => Awaitable<TReturn>): this;
TReturn should probably come first so you can specify it easily
True, edited
Why not default it to any?
My issue is that it enables code to be written with unclear intentions, it's unclear if the return value is consumed by the client or not. Also from a documentation standpoint when the return type is Promise<unknown> or Promise<any> it seems like you need to return something, and may confuse people.
IMO, it's just confusing to add a return type of any/unknown as users may think that a value should be returned or that it can be used somewhere
^
I mean isn't Awaitable confusing for the exact same reason?
I read it as oh I can await this and it might return something
No awaitable just means it can be await'd that doesn't imply anything is returning a value
Could endlessly discuss those being different, anyway just something I faced today, I'll stick to ts-ignore
or just put return on another line
Why is that confusing? Any is literally any type, including void. Something that can return any type to me means that it doesn’t matter what it returns, not that you have to return something because the return type would be more specific if that was the case
It's confusing because any could be a value
This is not an option due to the eslint rule they showed above
But it could also be void, and if the return value mattered it wouldn’t be any nor unknown
the return value doesn't matter because it's never used, when I see a return type of any I honestly assume something needs to be returned
You can't tho..
I don't see a reason why it should be any/unknown too.
I mean, yeah, in a command handler having a return type of any would be more comfortable but also lead to unexpected issues, like we may return a string because we think that it'll be sent as a reply for example, so it's always a good practice to put your return statements outside any expression.
Also iirc the return type of that function in the built-in EventEmitter is void...
That’s a wrong assumption then because if something had to be return, that type would not be any
Doesn't matter it's still not as clear as void
void is always going to be more explicit and less of a gray area
built-in EventEmitter is void
void, not Awaitable<void>, if djs uses it, it's not following standards anyway
Iirc it was changed to Awaitable because of an eslint rule that didn't allow the use of an async function in that case.
It's however really different from any/unknown
it doesn't matter it's a callback, Promise<void> | void are void once resolved
eslint didn't allow the use of async functions
ts doesn't allow me to return methods early while it's still technically valid, just like you're able to await
I honestly see both cases as supporting JS patterns, I do get where you're coming from
Awaitable isn't needed, it's just an alias from Promise<T> | T
You can also return void x and have it all in one line
Just a bit upsetting as most ts features that are being added are to be able to type JS patterns
Yea I know I can work around it
honestly imo returning a value for a method that's supposed to return void isn't a great pattern anyways
🤷♂️
speaking of TS, they themselves don't even recommend that pattern: https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#return-types-of-callbacks
its technically not correct, yes
since whatever you return, if its fails, is unhandled
so what we do is fine and correct
Correct me if im wrong about this behavior but shouldn't this always be a guildmember because of the typeguard?
try inCachedGuild instead of inGuild
Yeah that did it, forgot about that one 😅
inGuild() there refers to just a guild, whether it be cached or not yeah
Is there a set in stone idea for what djs-modules/ws would be responsible for? Is it a general powerful websocket module that's capable at handling any url type, or one that's specific to discord only and can do all of the stuff that the current djs one can do?
Are there any plans to move util functions to their own package like a @discordjs/util of sorts? Some of these functions are quite useful and people don't always need the full library to work with them
like?
SnowflakeUtil for example
That’s the one that sparked this idea, could look into the others too
SnowflakeUtil is likely superseded by @sapphire/snowflake, which @discordjs/rest uses
Yeah snowflake Util isn’t super useful honestly
is there a reason Shard#eval can't have a context passed into it? (like why wasnt that implemented)
Ah I didn’t know about that sapphire package, will take a look ty
I'd say that's an oversight that could easily be implemented (just not the "must be a function" part, since that's breaking)
You can work around this by passing (${function})(this, ${JSON.stringify(context)}) as script to the method.
ig so but i added it into the src of the pkg should i pr it?
Gladly
Can we get a way to specify the type of the components in an action row, through something like new MessageActionRow<"SELECT_MENU">() like was done for collectors?
cc @dawn merlin 👀
I’m guessing this is just for enforcing that everything in the row is the same type?
yeah since you can't really mix component types and it would make doing this easier
you might be able to mix component types in the future though, so that type could support multiple component types
Even if this was implemented wouldn’t you still have to cast?
Because the array of rows isn’t guaranteed to have the same component types
I'm talking about individual rows through
so in that case I wouldn't if I just created the action row with the type like we do with collectors
But if you access the the row by index how it know the type? Because the array of rows is a less specific type
idk about you but I never access a message's rows, I just store the row in a variable and modify it later on
and that's the use case I'm talking about, since you can't get more specific when accessing a message's components array (and perhaps you shouldn't)
what if the first component you add to a messageactionrow changes the class or something
But isn’t that what you did in that screenshot?
oh wait no that wouldn't work
in that screenshot I have a row constant that was created by me, not retrieved from a message
like this
and the idea was to do this
So addcomps would only take select menu components?
could you maybe add a typeguard based on the type like how you do it with Interaction
yeah, and then the components array would be an array of select menus
Ok I see
that wouldn't make sense here
...yeah.
i shouldn't be here
No worries, it happens
This is what I did:
declare const selectMenuRow: MessageActionRow<MessageSelectMenu>;
// @ts-expect-error
selectMenuRow.addComponents(new MessageButton());
assertType<MessageSelectMenu[]>(selectMenuRow.components);
yeah sounds good
make sure to also test with spliceComponents and setComponents (and maybe resetting the components array ?)
those both seem to work, I'm assuming by reset you mean setting the components to [] and splice should only take components of the correct type
I meant re-setting, aka doing row.components = [new MessageButton()] which should error
hmm idk if I can type check that without creating a setter in the typings, shouldn't that be readonly anyways, because setComponents should be used instead
well yeah it should be used but there's nothing stopping you from doing that either. I thought that if the type of components is set to MessageSelectMenu[] and you try to overwrite it with a MessageButton[] it would error out wouldn't it?
oh wait I'm dumb, yeah it's doable
This works as expected
// @ts-expect-error
selectMenuRow.components = [new MessageButton()];
ready for the PR? I'd be glad to test it
wait can you send stickers with interaction.reply?
i didn't find it on the api docs but the typings for the method tells you you can since it extends BaseMessageOptions
Yeah that seems to be an issue on the typings. You cannot add stickers with interactions and the typings for editReply seem to be correct. Feel free to PR if you know how to fix, otherwise I can look into it
you do it 🙃

#7012 in discordjs/discord.js by ImRodry opened <t:1637436949:R> (review required)
types(WebhookMessageOptions): disallow stickers
📥 npm i ImRodry/discord.js#types-webhook-stickers
@void rivet ^^
👍
In what scenarios can Invite#uses not be null? I already fetched an invite and I didn't get that data
I'd assume when obtained through Client#fetchInvite.
that's what I did though and didn't get the uses, same thing when looking at the raw data from the API
the uses property appears in an "invite metadata object" in the discord docs that is supposed to be extra info that may be present, but they don't mention when that can be present
it's mentioned at https://discord.com/developers/docs/resources/guild#get-guild-invites
oh so we only get that data when fetching the invite on the guild? 
I think the Invite class could use some improvements on its documentation to specify these quirks
the docs are open source ¯_(ツ)_/¯
I'll give it a shot with a PR, let's see how that goes
Audit log documentation needs some updating as well, seeing that the description of <GuildAuditLogsEntry> is literally just "Audit logs entry."
I just thought of this, but why not use a type guard to prevent casting here?
I feel like a typeguard would make less sense since you're the one constructing your action row, you usually don't receive it without knowing what it will hold
you could add the typeguard as well to make it work when you receive it too ig
Hmm
Why are API objects not exapanded upon? For instance i don't see why we couldn't provide support for APIMessage#edit() (you could get an api message when you followup an interaction)
I don't see the purpose of just dumping the api obj on them when we're supposed to be wrapping around said api object
Api objects are usually returned when you’re client isn’t a bot in the guild. The api* objects are just the raw data returned from the api. The reason we don’t wrap them in a class is because the cache cannot be properly updated because it doesn’t receive guild events. In fact in the case of the message, you can’t edit a message purely based on the message recieved it needs to be done via the interaction (since the bot isn’t present in the guild)
I see, makes sense.
You can edit any message as long as you have its id and its channel id using the manager
But yeah if it’s an interaction you should be using the interaction methods instead
discord.js\src\util\Util.js:413
if (typeof data !== 'string') throw new error(errorMessage);```
Couldn't the data be tried to convert to a string first?
interaction.reply(client.ws.ping) will crash the process because it is a number
this used to be done, but was changed in v13 to allow for more strict typings and less [object Object] strings. You can easily convert that to a string by wrapping it around template strings
oh yeah I remember this working in previous versions
Are we still doing consistency with the api with types?
message type 20 is listed as CHAT_INPUT_COMMAND in the api docs, but it's APPLICATION_COMMAND in djs, which i guess could be somewhat confusing since CONTEXT_MENU_COMMAND is a seperate type, type 23
when that was introduced the discord docs called it APPLICATION_COMMAND
something for v14
didn't see any issue/pr for it
i guess this would need some type updates, which i don't know how to do, so... unless someone's free to do it, i'll make an issue in a bit
all you gotta do is change the value in constants
and then change the typings accordingly
but it's a semver major so ¯_(ツ)_/¯
which i don't know how to do lol
eh it could be left for later
go ahead
also for reference, this is the PR that changed it: https://github.com/discord/discord-api-docs/pull/3651
client.users.cache.size has only ever been cached users
Never ever has this property been populated with all users in all your bots guilds
Fetching all members is absolutely not recommended at all
Please go back to support, this is not a library discussion issue
@copper laurel
ty
Hello
About the presence update
I think game activity presence should be separated
No idea what you are asking
to know if there is a game u a member is playing
coz when i use presenceupdate
while playing a game then i have set a custom status or some other activity like listening to spotfy, it will give my undefined or the latest activity for that
what do you mean? what are you suggesting? could you give a better understandable example?
I have this bot that gives role when a member is playing then remove the role when he is not, then when he have set a custom status then removed it, it will remove the playing role coz, i get an undefined precense activity
but he is still playing
So the playing role shouldn't get removed to him
so what do you suggest we do?
i don't know if the issue is from the presence update or my code
i guess your code
members can have multiple activities, right? your code probably wasn't made to deal with that
but would it be possible to retain the array no. from the oldpresence to newpresence
you do know that you can just see what an activity is, and then check any other one that is present? it doesn't end on [0] or [1]
you have multiple tools in javascript to do that
you can find it by it's type, which for you would be playing
yeah but the problem is i am comparing same array number from new and old but the new don't now have that last array numbers so it gave me undefined
then don't do that.
Okay okay i'll be trying ur suggestion
yeah it's not really an issue with the library, it is your code
how you dealt with presenceUpdate
i think it's my code
I just compre new from old
Thanks @void rivet I now have an idea
Why does MessageEmbed has .video property if you can not embed a video?
received embeds can have them, you can just not send them from bots
hence why there is access to it but no means to set it
Is there a specific reason to why the Client constructor doesn't default to no intents?
Like, this just seems like unnecessary:
const client = new Client({
intents: []
})
I'd much rather just do this:
const client = new Client()
Because intents are mandatory
So basically because people NEED to know they aren't enabling any intents?
Because people NEED to provide intents to connect*
EDIT: They need to specify that they either want no intents or some intents so users know about them
You don't need any intents to run the bot, though?
I don't know if Discord lets you connect if you specify intents 0, but our lib does require at least GUILDS intent to work most of the time (iirc with interactions that's less the case)
The fine line here is omitting the intents and providing no intents. You should explicitly specify your intents and discord.js shouldn't shortcut it
Yeah, 0 will connect
TIL (and it makes sense I suppose)
for the sake of explicity, we make intents mandatory
Alright, thanks guys.
This is probably better for the majority, as they wouldn't understand why is working, before realizing they were missing intents.
Glad to clear up, that it was done for a reason.
isnt it supposed to be true by the default?
More of a #djs-help-v14 question but since you're providing allowedMentions in your client thats what we use when it's missing from your reply calls
Still, they didn’t specify repliedUser so shouldn’t it mention them?
thats more of an API question but no, it shouldn't, because if you specify allowed_mentions at all Discord just disables it by default
Ah I see
That's some weird behavior on Discord's end.
Probs an API bug then
I think if you do not send allowed_mentions, all mentions are parsed (and replied user is true), but if you specify it, replied user defaults to false.
I wouldn't say its an API bug but an annoyance personally
so the API should see which values were sent, and use the defaults for the other ones instead of reading them as false when set to undefined
but probably not worth the bug report
@outer raven hey sorry to bother you, i fcked up my rebase again 😬 i'm sorry, can you help me ? I still have no idea how to fix those 😅 thanks
https://github.com/discordjs/discord.js/pull/6647/commits
Sorry bro just shut down for the day, I can only do it tomorrow but I can help you do it in dms
no it's intentionally weird
That just sounds like bad code tbh but aight
The api has a lot of “intentionally weird” things
well it was discussed with multiple staff back then
i dont know if this is the right place to ask but do we know if we will be able to insert any of the current message components into the new modal feature coming?
modal feature..?
at launch only text input; select menus will be added later but not buttons, also ddevs is the correct place to ask, not here
https://devsnek.notion.site/Modal-aka-Form-Interactions-e839b3dd8c214eb08f950764a8328e36 announced at the ddevs event
thanks, i tried finding the correct place to ask in their server but was just as confused
api-questions would be the best for now
so the default of repliedUser in the docs should be false, right?
nope
if you pass no allowedMentions then the default is true
only if you do pass them you overwrite that default
ah i see
its actually marked as default false in discord's docs (which was confirmed in the discussion with staff), because it is in the object
it doesnt exist at all if the object doesn't exist
and d.js doesnt seem to modify it so... shouldnt it be the same as Discord and say false?
allowed mentions itself is optional too and that missing defaults too "all mentions"
At least that's my explanation
Should default to Discord’s default but they should enable repliedUser since that’s the default on the client
the client doesnt send allowed mentions by default
When you click reply on a message, the replied user is pinged by default
That’s what I’m saying
Its really not as complicated as this discussion would suggest
allowed_mentions not provided - all mentions are enabled, including replied_user
allowed_mentions is provided - only those mentions listed are enabled, which mean replied_user only if provided
Theres no reason to think of it as some separate default, its just an allowed_mentions property
Discussing the fact that the desktop client has a toggle in a default state is irrelevant, this is the bot API, not a desktop client
This seems more like support than a discussion for this channel
still it would be nice for them to be consistent, and if you provide allowed_mentions and only pass an array of users, all roles will still be mentioned, so your argument doesn't make much sense
I wish this was the case for interactions as well
Just tried and I'm not able to replicate this. Provided users array with no parse, did not mention roles
At least, not in djs
Thought this worked before but yeah you're right. That's quite annoying but I can see it's not something looking to be improved on
I dunno, I think the design is fine. parse is mutually exclusive to the arrays. You can:
- parse all users and/or roles and/or everyone
- array of users and parse all roles
- array of roles and parse all users
- array of roles/users
And add replied_user to any of the above
yeah but if you don't specify any of those values, they should use the default that is used when the object isn't passed at all
so allowedMentions with a roles array and nothing else, repliedUser would be true for example
because I think that's what the average user would assume would happen
and the current behavior is also inconsistent with the docs, which say repliedUser defaults to true
Eh, I disagree that they would or should assume it, thats their fault for making assumptions
I do agree on the docs though, its just annoying to accurate represent both
You overwrite the default, so the default doesn't apply anymore
I don't understand how that concept is so hard to grasp
I dont think it should be marked as defaulting to true though, since doesnt that imply the code sets it to true if not provided?
you're not overwriting the default if you don't specify it
Yes you do
You're making the same mistake I originally called out
We don't merge with our defaults
If you pass ANYTHING into allowedMentions it will overwrite our default
If you change allowed_mentions you have overriden the default
There are no sublevels
lets say you do:
allowedMentions: { parse: ['users'] } }
now that means our default which includes repliedUser will be overwritten with JUST what is above
so if you wanted repliedUser to still be true, you have to manually include it
So having said that, shouldnt the docs specify the default as none rather than true, because we do NOT default that property if not provided
I cant find where we do
but it would be really easy to apply these defaults by deconstructing the object. I was trying to test it but idk where this is parsed if it is at all
But we dont want to because Discord doesnt
we can do things that Discord doesn't tho
I cant find anywhere that we actually set a default for allowedMentions or repliedUser
yeah me neither
I know we can, but if you refer to the first half of that sentence I also said we dont want to
aight ig ¯_(ツ)_/¯
Ah, its on the message options for it
Well the problem with that is that it probably used to be the behaviour when that PR was made
and it was documented as a discord default
Which is something we indeed usually don't do
Probably yeah
Where as now, at no point do we apply a function default parameter for that, so it should probably have the default removed from the JSdoc too
Because I do read that as implying that if repliedUser is not supplied in allowedMentions, discord.js sets it to true
(and we dont)
but we could, since it's been documented like that
Well in case I havent been clear, I do not think we should have a different default behaviour to Discord
I believe it wouldn't be the first time we fix little quirks of the discord API to make them more logical
of course this "logical" is very subjective, but I think it's what the users would assume the default behavior to be
default being not passing the parameter, regardless of the object being passed
because whether you pass allowedMentions or not, the properties you don't specify are set to undefined, which should always be replaced by a default value
Its a bit scary defaulting to discords defaults
Since they could change, and preferably we want to too, but thatd require a new major
well in this case we'd be defaulting to a default that isn't always used and if it does change we can handle that in a semver major, without the behavior simply changing without any version bumps (although this is unusual, discord usually doesn't ship a lot of breaking changes without version bumps)
so if we set defaults on the library's side, we can change those defaults without relying on what Discord does, and follow semver properly
@visual hornet have you tried moving the require to below module.exports?
At the very bottom
which require? the GuildChannel one i added in Util?
Yeah
yeah that.. solved it...
what changed here?
CommonJS considers a module "loaded" when at least one export or when module.exports is defined, so by moving the import to the bottom, you're requiring that file from a loaded module, so when it's required back, it works as intended
hm i see it's also used in TextBasedChannel with a comment, I'll copy that comment and commit that
thanks
Is there any reason why UserManager#send doesn't exist so you can send a message to a user without fetching them first?
I noticed MessageManager#delete where you can delete a message without fetching it so I feel like UserManager#send would also be rly useful
Can probably be done
how will you get the dm channel?
That's not relevant, when one is created it'll return the existing item
let me rephrase: how will you achieve that in a single request
Don't believe you can
Oh, I didn't realize that :( nvm
I guess the current User#send method already does 2 requests if the dm channel isn't cached
Yea that's right, so you'll essentially be doing nothing under-the-hood, just refactoring
Anyway on that topic, I suppose you can move .createDM() and .deleteDM() there

there are a lot of methods that could be moved to managers honestly
just like the message manager has
I tried to do some of those at some point but there were just too many
so that'd be a good way to start
I feel like there aren't too many methods that couldn't be moved to managers
Just out of curiosity, what’s blocking the GuildScheduledEvent PR and the release of 13.4?
Every time you ask the it gets delayed by two weeks
I really hope that’s not the case cuz I think a lot of people, including me, could use it on a dev release at least :/
But it’s the first time I ask about this PR
I don’t make the rules 
Yeah ik, just saying it would be nice
We need a few bugfixes in, at very least, and to start with
@outer raven are you looking for to do a PR?
I had one in mind but it takes some time, what you thinking of?
Adapt the new component stuff for builders
Are those reviews on the PR? I didn’t see any
Last time I touched builders it was painful cuz of the validation and all that
I have no clue how that works tbf
What I was thinking was the PR to add methods to managers
CC @burnt cradle
Which methods?
You might want to wait on any major builders prs until after the validation lib gets changed so you won't have to rewrite ur pr halfway thru
This is tru
Also adding the new components would be bigger than you think cuz there's currently no component infrastructure so you'd have to write it completely from scratch
A lot of methods that are currently handled by classes and not in managers, similarly to the guildmember and message managers. I don’t know which can be moved which is why I gotta look into it better, but there were some ideas above about dms for example
Not everything floats on the same PRs, there are more
rn there's a critical bugfix PR pending for review, among a few more
But on djs?
I saw the dapi types pr was merged which I thought was the only blocker
Yes, Rodry. Check the list of pull requests, and you'll see
I can't find anything that could be related to scheduled events, can you give me the PR id?
It's not related to scheduled events
