#archive-library-discussion
25217 messages · Page 21 of 26
so I just tested unhandledRejection and it indeed prevents the program from crashing
preventing the program from exiting and handling rejections are two very different things
const fd = fs.openSync('.'); // might throw error
// later on
fs.close(fd, ...);
although unhandledRejection prevents the program from crashing, you are still leaking file descriptors (for example)
I dont really get the difference 
idk what file descriptors are but nvm this is not the right channel
Wouldn't be good if it specified in the docs the permissions needed for both the bot and the user to run functions for example create a channel, timeout someone...
we cannot feasibly document permissions, discord can change them at will without any prior notice
they are documented upstream on discord api docs, but it's not feasible to copy these via PRs every time they're changed either
most that i can personally see happening there is a link to the upstream docs as to which endpoint is used
Node 18 is too far out for that, it won't even be in development yet
Even if listening to unhandledRejection prevents the program from crashing, that's mostly so you can log it and exit cleanly
oh alright so the method he suggested would be cleaner
it hits LTS in october this year, just like node 16 did last year
now idk how long v14 development is gonna last
that's really far out
considering the amount of features Discord is gonna add to get over the line for message intent and we've said no more v13 releases? I think you get the picture
No, far earlier than that
v14 should at least ship with modal support
Planning specific numbers on specific dates is troublesome when it comes to keeping up with Discord's release cycle
The date shouldnt matter. Just increment the version based on the changes we're making
both of these have the v14 milestone 
and at least the second one includes plenty of changes that would have to be tested
We also won't require Node.js v18 (geez, that's quite the version number) until it's near LTS or LTS, if it brings something useful
Second one is v15/TS

yeah we should probably...migrate that to a v15 milestone now
Yeah, whenever Crawl makes it
I wanted to get that in too, but there's already a lot of big stuff in v14, and its not the ts rewrite
The issue tracker doesn’t show everything, we want to make more internal changes like using /rest within djs
We don't want the v14 update to be as breaking as v13 was, as simple as that
Nope, it's hell to do that change without TypeScript
And there's still stuff to discuss
oh alright
more...incremental, most of the breaking changes are removals of deprecated v13 things
Because we want raw data storage to be beneficial, not a burden for those who are trying to scale their bots
Yup, we basically want to do major releases more frequently, as opposed to making large major releases every year or so
That way it's a lot easier to update between versions
just don't pull a dotenv who releases 3 major versions in a weekend
lol no
I think we want to do 2-3 majors a year, depending on how much stuff we want to do during that year
that's nice
And ofc also depending on what Discord releases
with a few patch & minor versions in between
yeah lol
rodry4contrib
This should also alleviate some of the pressure on people to upgrade major versions if its less likely v13 is going to break while we work on v14, v15 etc
Not relevant to this channel, thanks
this is what I'm really looking forward to, we're ahead of the curve on api versions now, so v13 isn't in imminent demise like v12 is
I'm not sure where to post this, and it doesn't feel important enough to go make an issue on the github.
But I feel like it'd be worth while to put a comment in the https://github.com/discordjs/builders readme that says it has been moved into a monorepo of the main repository. Cause right now it looks like it was archived for no reason and archived generally means "not supported anymore"
I'd make a PR but it's archived so 🤷♂️
Something like this at the top of the file
## @discordjs/builders has been moved into the main Discord.JS GitHub repo. New link: https://github.com/discordjs/discord.js/tree/main/packages/builders
Especially because the guide still links to the builders repository.
Yeah the other packages should say the same, not sure if one can commit to archived repos though
I recently came across that djs v14 uses discord-api-types which is cool. I was just a bit puzzled by the Subcommand thing, why is it Subcommand and not SubCommand when in UPPER_CASE it is SUB_COMMAND so in PascalCase it should be SubCommand
I think dapi-types has it correct because it’s one word in the docs: https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups
Will the event messageCreate disappear after April? Or still accessible?
accessible
but if you want to see content, you need have message intent
People are lazy.. Starting a / command takes them too long 😅
okay, because i saw this
Slash commands are really good
Yeah think it’s a mistake in djs
Also, why did you choose PascalCase when discord uses UPPER_CASE in their documentation?
I mean, a user already has to upload an image (and the bot read out its content). That step often is already too much 😂. < In my case
It’s TS convention to use PascalCase enums
why do GuildEmojiRoleManager and GuildMemberRoleManager extend DataManager, when most of the other managers extend CachedManager?
is this a mistake?
It's intentional, since they don't store data but rather point to it
interesting
what exactly is the difference?
between datamanager/cachedmanager
don't they both have a cache
If you take a look at the source code you can notice the cache getter actually hides a redirection to another collection that's external, rather than an internal cache (which is what CachedManager offers)
DataManager does indeed not have a cache, and the getter just throws an error if you try to access it
CachedManager does have one and its cache getter points to it
ahh ok ty
in what situation would this.holds be falsy?? https://github.com/discordjs/discord.js/blob/12ffa069aa8b247e945fef16a543f41c2c391bf1/packages/discord.js/src/managers/CachedManager.js#L44
(i think this is a permalink for what you are referring to? i couldn't find a .d.ts) https://github.com/discordjs/discord-api-types/blob/03b8d3fee032fb77213389019baa2b80377dcfdc/rest/v9/index.ts#L756
Only guild commands can have permissions on them, so there's only one thing it can ever be
(source? where???)
If you realise that then the distinction isn't needed
Not our problem? They should read up on the routes they're going to use lol
can someone explain to me where this d.ts file comes from
i thought github was the source already
does that show up after installing and building the package?
When it's compiled d.ts are made
ahhh ok
Depends it can be hand-written or generated
Route names for the method are usually build from what the route says (guildMembers, guildBans, invite, channelMessages) etc. Annoying? Yes. Consistent? Also yes
yea I'm just curious where this particular one comes from, cuz he said "there's a d.ts in the 'source'"
but apparently they meant in the output
ALTHOUGH to be fair, it should've been applicationGuildCommandPermissions
who did this
Yeah in most TS projects it’s generated
does anyone happen to know the reasoning behind this check 
const entry = this.holds ? new this.holds(this.client, data, ...extras) : data;
wondering if there is any situation where data would actually be returned 
are components fixed in the latest dev release?
Likely not
They might be since they got replaced with builders but you can test them out
I'll try then
So components are but interaction.options.getSubcommand() isn't, I guess that will be fixed by the enums PR
That's not true anyways, global commands can have permissions, it is just scoped to a guild
here isNaN is used and isNaN don't check that is the input is a string or number. Is this intentional?
there's a typecheck right before it
Could change it to use Number.isNaN, which does both
yeah
Or actually no, we need it to return true if it’s not a number type
Number.isNaN only checks for NaN
you would still need the type check yeah, Number.isNaN is more specific to NaN
just seems unnecessary to me.
Number.isNaN checks for number type as well as NaN or probably Number.isFinite can be used
I think some of them can take Infinity tho
it gives false for strings which can't replace the typecheck, so why bother
It would also give false for NaN, which is correct
meant Number.isNaN
yeah just checked it + Number.isFinite also can't be used bcz of the infinity so current implementation is correct
All it does is v !== v, it doesn't check for the type
The global isNaN does Number.isNaN(Number(v)), which parses values to a number
yeah got it
Publish Dev has been failing sometimes recently, could you try rerunning it? https://github.com/discordjs/discord.js/runs/4867272929?check_suite_focus=true
I submitted a PR to address that.
Thank you!
Can we get a manual run of publish dev pls 
Done
Thank you!
On the latest dev the component constructors are exported from builders but they don't exist there yet do they?
It seems like there hasn't been a builders release since that was added so that won't work
would you guys recommend using enum resolver or importing types or just putting the raw number in code
I recommend using the enum, ie ChannelType.GuildText
djs ships with the dapi-types enums included
Import enum. If you use TypeScript and you needed to use the square bracket notation (Type[0] or Type['TYPE']) use resolver.
aight, I'm not familiar with enums so I don't want to start editing hundred lindes of codes and realizing it wasn't the best way
I was more hesitating with importing types and just put raw number like Button.setStyle(1)
but importing is more reliable I guess
yeah you should avoid magic numbers if possible
gotcha
boop Can we get a builders release? 
damn I was wondering what I was doing wrong
can confirm that builders doesn't exist lol
builders does exist 
Why is Collection archived?
because monorepo
Oh I see
is there some sort of workflow set up for edit-build-test loop for contributors? i.e. i am making some changes and would like to test them with a sample bot while I work, is there an easy way to do this in place?
Usually you'll just do tests manually with your own bot
besides running npm pack, moving the tarball to a testing folder, installing from the tarball, every single time i change something
I use npm link for this
creates a symlink between your testing project and the djs code
is that reliable? I think I read somewhere that npm pack is the only way to ensure that nothing breaks
b/c some sort of weirdness with the linkage
I mean I've had no problems with npm link, it's worked as expected
no problems with path resolution or anything?
nope
hmm, okay, thank you 
npm linkis designed to install a development package and see the changes in real time without having to keep re-installing it. (You do need to either re-link ornpm rebuild -gto update compiled packages, of course.)
what do you do to update the package after making changes?
this is the point of using symlinks
oh, the npm docs seems to think you need to "re-link" it for some reason
unless I'm misunderstanding it
what they're saying in the docs is if you have code that's compiled/transpiled that needs to be run
then you'd have to re-link each time? 😵💫
discord.js is javascript without any compilation step so it doesn't need to build
you'll only need to link once and just edit the package like normal
ah ok, tyty
There won't be any releases until 2 upstream issues are solved from git cliff
oh I've been running into issues with git cliff myself, can you link me those?
Or rather 1, the second isn't so important
Thats the one we need to wait on:
https://github.com/orhun/git-cliff/issues/48
This one is a nice-to-have:
https://github.com/orhun/git-cliff/issues/47
Both are supposedly possible, so they are most likely just bugs and not working correctly
Thank you! Will check those out
@dawn merlin why would this be nullable? in the class itself it only relies on the message id
because of polymorhism, if a child class can be nullable then the parent class also must be nullable
well, do we really have to only rely on the thread_metadata.create_timestamp thing, why cant we just use the ids to get the timestamps on threads too
thats why ts only allows it this way
uhh idk, lemme see
The id of a thread is the message's id, so it's not the creation time
Ah ok
ah okay, makes sense why they are sending it then
if that's the case then this is not correct
Yup
Wanna point out it won’t really affect that much anyways bc there’s separate events for thread creation and channel creation and they’re typed properly. So it’ll never be nullable on “channelCreate”
why button interaction don't have style property?
https://discord.com/developers/docs/interactions/message-components#button-object-button-structure seems like APIMessageButton have it
I dont understand why you think the interaction would have it
ButtonInteraction#component
The component which was interacted with
You can access the button and get style from there if you really need to know for some reason
oh ty
never got around to ask this, but out of curiosity, what was the reason behind the removal of timeout on Message#delete?
The timeout being internal to the method meant it was out of the users control, couldnt be error handled, couldnt be cancelled etc
Using setTimeout yourself is just far more adaptable
I wish to contribute to discord.js, but the codebase is massive. Where do I start digging in?
I'd start with the issues I guess, or follow discussions in this channel - you dont just "dig in" and changing/writing stuff
Really depends on what sort of change you intend to make
You can also watch for new Discord API features, but we have such a big community that its almost a race to contribute to that sometimes
is there a list of deprecated things that are going to be removed in the next major version so i can prepare early?
Not yet
a good way to find them is to search for process.emitWarning on the stable branch of the repo
@outer raven Is v14 working for you now?
Oh yeah
btw why isn't the CI failing because of that?
Because it's using the local builders code, not the npm code
Wouldn’t it be possible to change that so we know when it’s fixed?
thats not really desirable lol
I think it would because then you’d be able to see errors that pop up when using the package externally which should be the point of those tests right
🤔
that'd make development unnecessary hard
you couldn't change something in /rest or /collection anymore and then test it in discord.js without a release
also this is one of the reason why people make monorepo to test all package compatibility with other without installing
that makes sense. perfect. thanks for the answer!
Are xDelete events deprecated or not recommended for use? (in v14)
#7092 in discordjs/discord.js by kyranet merged <t:1641642095:R>
refactor: remove deleted field
They aren't deprecated. Deleted property is removed from all the classes read linked issue to know more.
These 2 things aren't related ig
Is there a recap on what features and changes are planned for v14?
Not yet
how are breaking changes detected by the changelog generator? Do we need to add something to the commit description?
I only see this in the config file which doesn't tell me much
not sure if this is how it picks it up, but there's a piece about breaking changes in the conventional commit guide https://github.com/discordjs/discord.js/blob/main/.github/COMMIT_CONVENTION.md
yeah I added that to my commit description but tbh I haven't seen anyone else do that so it probably doesn't matter too much
oh I'll do that then
So all other breaking changes won't be in changelog? Which don't have breaking in description or ! Before subject
They will be there but not as [breaking]
But that doesn’t matter because there’s always a converting guide
No
We're using ^2.6.1, as you can see in https://github.com/discordjs/discord.js/blob/stable/package.json#L60. Package managers resolve to the latest minor and patch within the v2 range, so they'll resolve that version as 2.6.7
You can see the semver compatibility here: https://jubianchi.github.io/semver-check/#/^2.6.1/2.6.7
https://github.com/advisories/GHSA-r683-j2x4-v87g
You may need to update node-fetch to 3.11
No we don't, read the message above
Cookie header leaked
We don't use cookies
well ok
anyway it's always good to do updates
but you tell me that it's not urgent ok 🙃
You are aware that 3.x is ESM only right?
It wouldn’t even work if we updated
Not for anyone using CJS
oh yeah i didnt know
also iirc node-fetch is releasing security updates for v2 still
#7324 in discordjs/discord.js by YodaLightsabr closed <t:1642879503:R>
fix: update node-fetch to 2.6.7
nice, came here to ask about the CVE and you guys are on it
There's nothing to do though
I see, just finished reading through that gh issue
lol same here, glad it's a false positive after all
@wild flax My https://github.com/discordjs/discord.js/pull/6782 PR is one of the only PRs without a milestone, was this forgotten or is this intentional?
Const enums vs regular enums and possible switch
looks like this is fixed
reinstalled pkgs
shows no vulnerabilities
Yeah so do i
is there any ETA for V14? I can't wait to run it and start my new djs series....
not anytime soon
but arent the prs all ready?
There is a lot more to be done
the PR's aren't a representation of the progress overall
How can I look at the progress, and maybe work on contributing?
look at the open PRs
look at the current issues on github?
also you can already use v14 by installing dev versions
ok thx, I'll take a look into what I can do
speaking of which, now that they're somewhat fixed, can we get #djs-at-dev back?
I have noticed that uploading emoji to a server has a high ratelimit when it's hit, the issue is that the rest handler is queuing a request that can take up to 15 minutes to be retried, I would like to avoid that and warn my users about the ratelimit instead of just having a request pending (can cause issues with interactions because it expires after 15 mins and the editReply function will fail).
Any way to do that?
Something like that has been implemented already:
https://discord.js.org/#/docs/discord.js/stable/typedef/ClientOptions -> rejectOnRateLimit
thank you, exactly what I need 
function is very powerful
rejectOnRateLimit: (data) => {
return (
(data.method === 'POST') &&
/\/guilds\/\d{16,19}\/emojis/.test(data.path) &&
(data.timeout > 30_000)
);
},```
made something like this 😁
I'm a bit confused by route & path difference tho, if anyone is down explaining
Route is used to group rate limits (strip out non major ids and group all reaction endpoints together).
Path is the actual path being used for HTTP.
aight, path is good for my use then
@solemn oyster I guess this went unnoticed, what's your opinion on this? https://github.com/discordjs/discord.js/pull/7067#pullrequestreview-860259281
We're not doing that for /collection anymore, so I don't see why should we for /builders's Embed
we're not doing it for collection because it became obsolete, but I was told an equals method wouldn't make sense on builders so that's why I think we should have it on djs
and the use cases for the equals function are perfectly valid and I don't think it should be removed without a reasonable alternative
i'd rather it be on the json the builder produces rather than on the builder class directly
how would you have a method on an object?
it wouldn't be on an object it would be a pure function
but would that belong in builders? It feels weird
doesn't have to
Well then where would it go?
either djs or builders
I'll make a PR to add it to djs Util then, but I feel like yall should start thinking twice before removing perfectly valid features and actually listening to feedback. v14 so far seems like it's just a bunch of removed features for the sake of it with no replacement for them
Im judging what I’ve seen so far. This alternative I’m suggesting could’ve shipped with kyra’s PR but it didn’t because it seemed like it was disregarded. Also #Const enums vs regular enums and possible switch got negative feedback once again and for no reason from what I saw, and that one doesn’t have an alternative other than the one proposed (to my knowledge at least, correct me if I’m wrong)
I expected the embed pr to go through either way, so I implemented my own Embed class that works fine with typescript. You can do something similar and include your own utility methods (equals, etc) if it makes a difference
But the point of a library is to help with those utility methods unless it’s something very very specific to your bot. Of course we can all go and make our own functions but then we should also just not have a library at all
I don't care much about stuff getting removed as I don't expect the lib to hold my hand and keep in technical debt so i can use unneeded utility methods that aren't being used elsewhere in the library
although I do agree that MessageEmbed should have remained
I'm honestly still really on-the-fence about const enums
There won't be any more enums or const enums. 🙂
Just objects
Tbh as much as I want to keep them, holy fuck do they cause headaches
What would those objects look like? And typings? Would it be similar to how we defined things in the djs Constants.js file, and then with things like keyof typeof TheConstantObject
https://github.com/tc39/proposal-record-tuple could potentially be used in the future when/if it becomes a thing
will that be live before that PR I mentioned is merged so that the methods don't have to be removed?
the style of the Permissions object is what they'd be aiming for I believe
-types is not tied to d.js at all, for all I know those methods will still vanish, idk 
I know it isn't tied but many types are used by djs and in this case in particular those methods are being removed because of the eventual TS rewrite
so if there's a plan to change that and if that won't be an issue by the time the TS rewrite arrives, I believe we could keep those @dawn merlin?
why not though?
what else should it return
I think it would be harder to convert them all back to upper case
SaRcAsMcAsE
hm?
I honestly just wanna understand the issue, because I think people couldn't care less how it's displayed, as long as it is displayed in some way other than magic numbers, so if you tell me what the issue is maybe we can work out other ideas that aren't a pain to maintain?
It was a meme I dont think we should use that casing
it's what the maintainers decided to go with for the enums, not saying I prefer it either, but any other casing option seems to be a pain
although it would be fairly easy to convert with regex
Could you give a usecase, where the casing will take place and how it will look like?
You could easily have your own resolver from those numbers
¯_(ツ)_/¯
What?
It involves bit shifting which is not easy to make and even harder to read which is why I’d rather have that in the library
You get a..class..with .has on it
All you'd do is go through each bit and figure out if it's present
I know but the point of toArray is to display the flags to a user and yes I know we can make that but so can the library
If it has supported this method for ages there is literally no reason to stop now when it can be perfectly avoided
Once again it seems like you’re breaking stuff for the sake of breaking
Its rather for the sake of not having to keep updating and releasing stuff to get an accurate representation of permissions
If a new perm is added, wed have to add it and release a new version otherwise you won't see it or get it listed
While now, its a bit different
But this point can be argued back and forth
Not to mention renamed permissions
You will always have to add it to discord-api-types no matter what and will need a new version for it to be usable, I don’t think this would change any of that
And if we transform the permission name with regex you don’t even need to add it to discord.js itself
Doesn’t change the latter part
We’ve had that like 2 times by now where we had duplicate keys because of renames too
And now we dip into territory that seems really like some weird solution for the names
I understand wanting readable names to a degree, but your strong input on changes that are not final are just a bit discouraging to keep discussing
I don’t know if I like this better, but it’s better for maintenance for now, that’s why it’s merged
If I update to -dev and use it for a while, I (or other maintainers too) might realize that it would indeed be beneficial or awkward not to have it
And it can always be added later in the dev flow
I can remove whole classes for a while, only to realize they are kinda handy to have and add them back like 3 weeks later
The current state of development does not reflect anything really
In software development there is this awfully annoying pitfall where you keep adding stuff, but never think about how to refactor or move forward from a structure you really dislike keeping.
By completely removing certain features or parts and later reimplementing it, you get around that and bring in some new ideas on how to handle things and freshen / lighten your overhead
So yes, some things are also simply for the sake of breaking stuff. Will it stay broken like this? God knows. V14 is far from finished by now
And while I appreciate getting instant feedback from a community on changes and the development process, it gets a bit far expecting us to always have a 100% foolproof solution and working main/dev branch that people run “production” bots on
I understand that and there’s still a long way to go, my reaction stems from the responses I’ve been seeing on this channel because for me personally that method is important and I’ve even considered making a small package purely for handling bitfields in djs and converting them to readable strings. I also know the dev versions aren’t supposed to be used on production but I like to make breaking changes to my bot as they come out instead of making all of them at once when v14 officially releases
My main concern here is the lack of plans to reintroduce this as almost every other thing that was removed had an alternative, when this doesn’t yet
Also about this, I know -types doesn’t follow the same version scheme as djs but if -types makes a breaking change to the name of a value in an enum and djs is exporting that enum, that will inevitably be a breaking change so you’d end up with the exact same problem, right?
I have a problem installing discordjs/opus on wsl2
is that a bug or it doesn't support wsl2?
Are you on node 17?
There is no such thing as "not supporting wsl2"
Would it be fine to change ThreadChannel#setLocked to set both locked and archived to the provided value? Having a thread with locked set to true and archived to false does nothing and the thread needs to be archived for it to show up as locked in the client. Either that or I think we should add a note to the docs mentioning this somewhat odd behavior
Literally an actual Linux kernel
I thought of setLocked as a way to lock threads for when they auto archive, not lock and archive
you can't do that though
you have to unarchive it and then archive it again
and there's no such thing as locking without archiving
@ruby terrace so op on this?
You don’t need to ping me to get a response, I’ll respond when I have time.
When I added threads you could lock and it stayed locked when it auto archived.
Test it again, if locked doesn’t apply without archiving at the same time, make a pr
my bad
Well at the moment you can lock a thread which won't do anything visibly, and will only lock the thread when it is archived or autoarchived. If you have an archived thread you have to unarchive it to then lock it later, so I believe this isn't the behavior you're describing right?
The first part is what I was explaining
I mean it does get saved in the API but has no effect until the thread is archived, which makes it a bit useless in my eyes
but if that's the intended behavior then I won't touch it
#7345 in discordjs/discord.js by Raiden-Ei opened <t:1643169109:R>
Can't start bot with CHANNEL partial
Hi all, quick question. Reading the Discord API docs, there is a note that Membership Screening has been removed from the documentation. Does that mean the endpoints for getting/setting the server rules in the membership screening page are also removed? Or are they just undocumented? Main point of my question: does Discord JS have functions to get/set membership screening settings just like it currently has for the welcome screen?
There was a PR in the past (https://github.com/discordjs/discord.js/pull/5144) but we can't implement things we don't have documentation for so we're still waiting on discord
The upstream pr was merged tho?
re-read that PR
Which part
the upstream one
Thanks all. Shame its a year later and still no update from discord
Is it intentional that the EnumResolvers class has no jsdoc? It would be nice to have it show up on the docs
Why errors thrown by functions are not documented? i.e. MessageManager.delete(id) throws a DiscordAPIError if no message with that id is found, but how am I supposed to know as it is not mentioned in the documentation for that function?
I'm trying to look on the documentation for the official Discord API, but there are no mentions about errors that can occur there
So it is just trial and error?
That error can be actually thrown by every function that calls the API so I think it's useless to add a warning in every function that says "Hey, this function may throw a DiscordAPIError as it calls the API"
Pretty much all promises can reject and you should handle that
Which I would categorize as a general understanding when it comes to using JavaScript
I am coming from Java, so that was not obvious, thank you
Oh yeah I forgot you have to handle all possible exceptions in java
Yes, it is good practice to declare all possible exception in method signature so that the compiler won't let you not handle it
The functions on DJSError.js all have JSDocs but they're not inside a class so they're not displayed on the docs. Should they be removed?
No? Surely if you want to solve something here the better option would be if they are displayed. Even then at the very least having documented source code is better than undocumented
the docs could have another section for standalone functions
the only way to do that would be to make DJSError a class (could do, lmk if that's a good idea), otherwise the docs don't support lonely functions atm
I don't know what the best/right solution is but I'm against removing the jsdoc just because it isn't parsed - documented source code is still good
Intellisense probably still picks it up
meh there doesn't seem to be an easy way to document this so I'll leave it be
CI has been failing on every commit now, I keep having to force push for it to run again and work, did something break?
Why do we manually have to call .toString() on numbers for message embed fields
input validation, you can also put it in a template string
But I feel like if u passa number it should automatically parce it to a string
You should always be explicit with your types. If it’s a number and a method expects a string you should explicitly convert it. Implicit conversion of function arguments is just asking for unexpected behaviors and takes control away from the user
Congrats on passing the 6000 commits on main branch
https://discord.com/developers/docs/resources/channel#delete-message
This endpoint supports the X-Audit-Log-Reason header.
curious as to why
https://discord.js.org/#/docs/discord.js/main/class/Message?scrollTo=delete doesn't have a reason parameter
Doesn't appear in audit logs, at least didn't the last time I chcked.
So I'd say that box is wrong. (Or the behavior changed)
okay then sure, i'll test again to make sure
do it
I'm pretty sure bots deleting a message doesn't show up in audit logs lol
a few other actions are labelled as supporting the reason but don't show it as well iirc
yeah i couldn't get it on the audit log
thanks
That can be true for any other type but numbers could be allowed since those will never have unexpected behavior
Won't happen
mb
When shards are spawning and you try to perform an operation (broadcastEval or fetchClientValues), the manager throws the error SHARDING_IN_PROCESS
In my opinion, the ShardingManager should either perform the eval on the shards that are spawned and ready or we should have an event that emits when all shards are spawned are ready so users can perform the operations without any errors
Just my thoughts 🤷♂️
perform the eval on the shards that are spawned and ready
👎 this is just outright unpredictable behavior - it isn't guaranteed to be the same on every start up
an error is the correct behavior even if an event were to be added for this usecase
Ah true
Why?
I see your point. I mean we’ve had full string conversion and now we have no conversion at all. I think a balance between those two could be to support numbers and strings since those are the only two types that can be safely converted to strings. In this case it would just be an if statement since all the others have the possibility of breaking
not a fan
the argument of "cannot have unexpected behavior" doesn't really bring much when the idea is that implicit conversions shouldn't be made period
But a number converted into a string will always be that exact same number
No matter what
If a string is expected you cannot pass a number. If an object should be rejected so a number should be too... If you really want to pass just a number then it's quite easy to stringify it
I know it is but there’s a difference between displaying [object Object] and 5
So let’s assume this is added, someone comes up and says “hey how come the method accepts numbers but not bigints, I mean if it supports numbers it might as well!” Ok we add support for bigints since numbers are in fact supported. Then someone else comes and says “hey your library accepts numbers bigints and strings, why not accept a Boolean as well, it’s a primitive too!” Ok makes sense we add support for booleans to be passed in. Finally someone comes and says “you support all primitive types in this method except objects, why not just add that in for completeness” we support for it completeness. Now we’ve ended up with a function that’s a black box in terms of input and has to do five different checks for its input. TLDR; You need to stick to an parameter type and keep it.
Well it makes sense for numbers and bigints because, when stringified, they keep their exact value, which does not happen with objects like I said since no one wants to display [object Object] just like no one wants to display true or false without any context, even though those would be stringified cleanly too
So why can’t people just do .toString() then? Why does it need to be done for them? Furthermore why is it our responsibility?
just like no one wants to display
trueorfalsewithout any context, even though those would be stringified cleanly too
field values for yes/no states
It would result in cleaner code on the user’s end because what you put in the field is what gets put in the embed on Discord, no messing around
That’s not user-friendly
If you want yes or no, you pass yes or no
As someone who doesn't see much of this from internals, this just sounds like the usual "I want djs to friendly guessthings for me" which djs has moved away from in the last year or two
Yeah, if someone wants a string pass a string
the goal for djs has been to give specific things to get specific outs
What do you have to guess when converting a number to a string?
but it's not an [object Object], so an argument could be made that it's useful. not saying it is, but someone could say that with a similar argument to the "number to string is the same thing" argument
There’s literally no risk with that
It’s not the same thing. A number is a number and can be displayed, true and false are technical terms that should not be displayed without context to the end user
name: "Is this statement true or false"
value: true | false
yes it's arbitrary, but still, that argument could be made
Not doing String(…) or x.toString() or using template literals does not make your code cleaner
What is “clean” even at this point
to me it's code as straightforward as possible, without unneeded visible modifications, so imo that would make it slightly less clean, although it's def not the end of the world
And if we go into detail here, “1” is not the same as 1
when you put it in a field in discord it will look exactly the same
because the quotes are removed
But it’s always a string in the embed that’s the point
It doesn’t change that this would be one of the only places in the lib where we start to transform and coerce user input
Just because someone thinks it’s “clean”, whatever that means
Please don’t impose some weird concepts that don’t exist
Read some actual language concept books
I'm not imposing anything, it's a simple suggestion being discussed on a discussion channel. After all, isn't that what this is for? I told you what looks clean to me, that's all. It may make no difference for you, and I'm not extremely bothered by it either, just a nice QOL thing, just like string types were. But thanks, you're super nice as usual
Idk, I don’t care mostly
It’s like we say reasons why and all that comes back is “but X and Y and Z”
And then we say some more reasons and it’s “but A and B and C” lol
No offense but we already answered the “why” I’m unsure why we need to explain further and further and looks like it’s not something that gets accepted as a reason, while we should accept whatever comes in as feedback lol
to every argument there's a counter-argument, and that's how discussions work. I understand you may not want that for X Y and Z, but some people might and in most of these topics we're just discussing QOL, which has been getting reduced over time in djs but I don't wanna get into that again
For every QoL change so far we’ve introduced some alternative
That is almost as equal
Minus the Embeds
We even ended up keeping the permission stuff
The clean argument is really dumb either way
If it makes your code "cleaner" by not having to include .toString(), then it has made discord.js's code "dirtier" because we do have to include toString()
Its not like the conversion doesn't still need to happen, the so-called "dirty" code has just moved
Which means it isn't actually clean or dirty at all, its a necessary conversion step. And as per the inversion of control principles, that step belongs in your code
think so
and now we can't pass camelCase properties to the builder constructors
could we make classes extending the builder classes that convert camelCase to snake_case and send it over?
along with other stuff that might be needed
you could
It seems like a really odd pattern to even pass a manually created object to the embed constructor
Why get an instance if you already have the object?
I think it's mainly used for serialization when djs receives api data
I construct my embeds like this because I feel like it's unnecessary to construct an empty embed and call subsequent functions on it when I can simply save some performance and do it all at once
🤔
since, with the setAuthor and setFooter deprecations, the functions no longer have any advantage when compared to the raw object, so might as well just pass it like that
At this point why even use a builder
because of the functions
I don't use them on declaration
I use them later on in the code
when actually modifying a value
I find that to be cleaner than an assignment
and it also allows me to do this (different builder, same issue)
I had this conversation with rodry already 🙃
yes we did
how about the types?
Generics I guess
cuz I did try that, but some types were a mess because of unions
like the button type is a union of a bunch of other types and you can't simply replace a property
I mean allowing both will mess up your expectations instead of types
What takes priority
Snake or camel? And why?
Arbitrarily decided?
just like it was already happening with djs embeds, it's the type that comes first until you add a property exclusive to one of the types
then it starts expecting all properties to be either snake or camel cased
So what exactly wouldn’t work with a toSnakeCase function
the function works, but button types are a union of link and customId button interfaces, so we have to re-type them all
I tried to avoid that with a type generic that replaced props but it didn't quite work due to that
and also ended up finding this issue which was another pain for the same reason https://github.com/discordjs/discord.js/issues/7342
at least to me, if anyone knows how to fix that please be my guest
but I tried with Omit and it didn't work
I dont see why the types need to be changed. If there are utility functions to convert casing, the constructors can stay as they are and you just convert your object to suit the accepted input
new Embed(toSnakeCase(rawCamelCaseEmbedObject))
I was thinking of a class in djs that would extend builders and run that there
and either way if djs or builders provides the function, you need the types for that function
As in MessageEmbed.toSnakeCase() with types for that output?
A standalone utility function would have generic types
Going to be fun when we'll have to pass iconUrl because it snake-cases to icon_url, since iconURL would snake-case to icon_u_r_l, which of course leads to inconsistencies since we use URL (avatarURL, displayAvatarURL...)
Though I do find that amusing wouldn't it be relatively simple to ensure the capital letter is followed by a lowercase one before inserting an underscore?
In the case of consecutive capitals, underscore then lowercase until an already lowercase is following
Of course that'll probably break some other parsing instead
The issue is that you’d have to make exceptions for anything that’s considered an acronym.
Sort of?
If you target capitals specifically yes, if you target changes in casing its sort of manageable
I havent done any technical feasibility of course lol
Just a rough unfinished thought
Well, I'm surely not writing the type hell for that
We used a package for that, and the type hell it had to strict type the conversions was already enough bad as it was
customURLFormat has changes at mU and again at Fo
And at those spots specifically, an underscore is required before the capital letter
Then toLowerCase the lot
I know that phrase isnt in djs I just wanted one where it was in the middle
I just found a bug in MessageEmbed#length in djs v13 but it's not present in Embed#length in builder so should i create a pr to fix it in MessageEmbed as people will still use v13 after v14 release?
what's the bug?
If use
Embed.setFooter(null)
It sets this.footer={}
So here footer is defined but footer.text isn't so when using MessageEmbed#length it checks
this.footer?.text.length here text is undefined so it'll throw error
In builder it sets footer to undefined so it's not throwing err
ok so it's fine now?
In v14 it'll be fine but it'll throw error in v13
Oh I mean we don’t usually take prs to stable releases soo it’ll probably have to stay
v14 will be a lot less breaking than previous majors
Yeah that's why asking
Probably not necessary, people will be able to upgrade easily
I don't think there will be much need to maintain a 13.6.1 alongside it, but there's no harm in opening a simple PR like that I guess
Yeah ig ppl rarely uses MessageEmbed#length
Ok I'll do it then
So this should be Flags, right? https://github.com/discordjs/discord.js/blob/main/packages/discord.js/typings/index.d.ts#L1269
yeah
aight that's a 1 character PR
Shouldn't the first one work? How are we supposed to add intents now?
GatewayIntentBits.Guilds
but that should work too, right?
doesn't look like it'll work, but we'll probably make flags private anyways for the TS rewrite so you should use the enum directly
why was it kept then?
could just be removed
because the classes use it internally via inheritance
yeah
also I figured out why it doesn't work, I have to use typeof Enum not just Enum
go ahead an add that in as well, since it doesn't hurt
will do but I don't think private works
you have to make the base class prop private
i see the issue, mark them as protected
@wild flax do you know if @protected tags render correctly on the docs (with the private toggle too) or should we use @private instead? re: https://github.com/discordjs/discord.js/pull/7363#discussion_r794959391
Why make it private?
Discussion above
I don't see any, just some assumption that I have no idea where it came from.
@slate nacelle I just made it private because of this, and also because people can use the enums directly
That's the assumption I meant.
How are people supposed to know which flags belong to this bitfield now?
Read the source?
I don't know, I seem to be the only one with any concerns here.
that is a valid concern tho, I didn't think of that
maybe @dawn merlin
My reasoning for wanting them private was that BitFields used to serve both the purpose of an enum and a BitField class. Now that we’re using -types it no longer needs to act as an enum. The enum values only need to be used internally now to make sure certain methods work. As for knowing what enums to use, I think it’s relatively intuitive to find the analogous -types enum, and if you’re using typescript the enum types are defined via generics.
I'm honestly fine with both approaches, although I'm more tempted to make them public again, but I'll go with whatever the maintainers prefer
I'm ok with making them public so they can use it over importing a package they most likely did not install
they don't have to import from -types, they're re-exported from djs
Does anyone know the release cycle of discord-api-types & discord.js - waiting for a merged bug fix to be released
which bug fix was it?
when I say bug I mean change not necessarily bug but:
discord-api-types: https://github.com/discordjs/discord-api-types/pull/306
discord.js - https://github.com/discordjs/discord.js/issues/7270#event-5949161400
well since it's not a bug you'll have to wait for whenever v14 comes out, but if you're just using -types they're probably be a release sooner
but no schedule
Why is the ApplicationCommandPermissionsManager#set method called set and not edit? The endpoints it calls are either edit or batch edit so I feel like that would make more sense?
yes it is
There we go then
so if we call batch edit and only provide some command ids, do the commands that get left out get their permissions reset?
Same with commands yes
More of a technical question rather than a discussion, but when is manager cache actually used internally? Every event sends along all the user data necessary to construct a djs structure (right?) and from what I've seen in the codebase I think it just overwrites the cache when that happens. (Might be wrong there). So when is it being used, apart from explicitly getting a value from a manager?
Every event sends along all the user data necessary to construct a djs structure (right?)
No. If this was true partials would be irrelevant, off the top of my head messageDelete doesn’t send the full message, message edit doesn’t send the before message, some things can be missing from guildmemberleave, and there’s more im definitely forgetting
Oh yeah also guilds, discord doesn’t send that again after startup (obviously except for guildCreate)
Yeah forgot about partials, however I'm not currently listening to any events that send partials, in that case cache would be minimally used right? (apart from guilds like you said) Asking mostly because we currently have a sponsored vps with minimal memory, so as long as most of the events send along the necessary data to create a djs structure we can make a relatively small limited cache.
That's a dangerous proposal, Darkerink
The cache is used way more often than you might think
The most common examples I can think of are Interaction.channel / Message.channel - both of those are getters that retrieve the channel from the cache
Manager#fetch will check cache first
i'm super late to this but okay what about this now? the issue was that the library sets default values which are already api default values
Yeah sure
well i haven't kept up with any of the changes
i'll go look for some now
limit_defaulted_to_max
https://discord.js.org/#/docs/discord.js/main/typedef/FetchReactionUsersOptions's limit
redundant_default_values
https://discord.js.org/#/docs/discord.js/main/class/GuildManager?scrollTo=fetch's limit
https://discord.js.org/#/docs/discord.js/main/typedef/GuildListMembersOptions's limit
https://discord.js.org/#/docs/discord.js/main/typedef/GuildSearchMembersOptions's limit
https://discord.js.org/#/docs/discord.js/main/typedef/GuildPruneMembersOptions's days and count
https://discord.com/developers/docs/resources/channel#create-channel-invite
https://discord.js.org/#/docs/discord.js/main/typedef/CreateInviteOptions's maxAge maxUses unique and temporary
https://discord.js.org/#/docs/discord.js/main/typedef/ChannelLogsQueryOptions's limit
https://discord.js.org/#/docs/discord.js/main/typedef/ReplyOptions's failIfNotExists
I've had a message that's edited every 10 seconds to update an embed in it for a couple years now I think, and recently the embed started to not update after a while, even though the message itself gets "edited". any insight on this?
There’s a rate limit now for messages older than 1h
It might be 3/15 I think
So 3 edits every 15 seconds max
these are all i could find
also curious as to why MessageManager.fetch fetches 50 messages and not 100 like some other methods like <Client>.guilds.fetch() and <MessageReaction>.users.fetch()
I was under the impression they'd fetch all they could by default
If you don't supply a message limit, the API defaults to 50 for messages
I am aware
but as i've mentioned, in cases like <MessageReaction>.users.fetch() the limit is by default 100, which is the max
whereas the api default is 25 https://discord.com/developers/docs/resources/channel#get-reactions
I am aware
Then... that's why
I don't think we should be setting default values if the API has a default value though
Imo if we set default values when the API has defaults already, we should remove them and leave that to the API
I don't think we should get the max just cause
I don't think we should be setting default values if the API has a default value though
that's what this whole thing is
a list for the ones that set the default value even when the api does it
that is the plan
but just to confirm what you're saying, even the methods like <MessageReaction>.users.fetch() shouldn't by default fetch with the limit set to max?
Yea, I would say leave that to Discord
If a user wants max, they can specify it, it's no big deal
trying to find more default values i came across something elsejs const newData = await this.client.rest.patch(Routes.channel(this.id), { body: { ... lock_permissions: data.lockPermissions, rate_limit_per_user: data.rateLimitPerUser, default_auto_archive_duration: data.defaultAutoArchiveDuration, permission_overwrites, }, how come https://discord.com/developers/docs/resources/channel#modify-channel-json-params-guild-channel doesn't mention a lock_permissions field?
has it been removed?
Not looked into it but changing a channel's position has a lock_permissions JSON parameter to sync with the new parent. Maybe it works but just isn't documented?
these are all i could find, surprisingly, the only method where the limit by default was fetching the max (and wasn't already the api default) was the one listed, some existing methods like <Guild>.fetchAuditLogs never set a default value
https://discord.js.org/#/docs/discord.js/main/class/GuildManager?scrollTo=fetch some of the methods just lists the api default on the documentation even though it's not hardcoded
Hey, can anyone fill me up with the future of bot prefixs? I have a bot that only runs on my server, should I be worried and rewrite my bot in order to support slash commands? Or is this something that noone knows until time comes (april)?
⚠️If your Bot is operating in 100 servers or less, this change doesn't impact you.
https://support.discord.com/hc/en-us/articles/4410940809111-Message-Content-Intent-Review-Policy
Thanks for the info and link 🙂
Slash Commands are generally better anyway, and you should probably be rewriting to make benefit of the ongoing new features that will be released for them
Wait but, doesn't the reaction.users.fetch fetch all users who reacted?
Cc @opaque vessel
I agree, but I’m still not really in fond with having to press tab everytime i fill in a parameter, felt like I could execute command way faster using bot prefixes.. or am i missing something?
The command being correct?
Sure typing messages might be slightly quicker for power users, but having an integrated UI, tab completion of options, choices, autocomplete suggestions, user/channel/role resolution handled by Discord
All far more powerful
Yeah i agree, any idea if slash command scale and run faster than bot prefixes? Or is it the same.
I wouldnt expect there to be any difference though newer versions of discord.js have becoming increasingly lighter in terms of memory footprint and performance
Alright, ill take that into consideration. Cheers for the info!
Iirc no, it fetches the first 100? Then if you want to fetch another 100, you gotta use the after parameter to get the next batch and so on
well, then description for it seems to be incorrect?
since it implies similar behavior to passing no parameters to other fetch() methods, that do end up fetching everything, more so as the options are optional
Oh yeah, that's incorrect
I could have sworn I made a PR that clarified that
why does the -types UserFlags have a None = 0? I know its listed in https://discord.com/developers/docs/resources/user#user-object-user-flags but i fail to understand why its there too
its causing this https://github.com/discordjs/discord.js/issues/7374
yeah I think it's safe to assume that 0 is no flags, that doesn't need to be in -types
...Thats an interesting find
And yeah makes no sense for it to be in the enum
although it doesn't hurt to have
it does hurt because otherwise that will have to be accounted for in discord.js
sorry for interrupt the discussion, but if https://github.com/discord/discord-api-docs/pull/4405 get merged, will it be necessary change the default parameter in OverwriteData? as well in RawOverwriteData and PartialOverwriteData
or it has nothing to do? lol
I think our intention is to not document api defaults (although I think that slipped in on some occurences), but our own defaults.
alright, thanks :)
uhm @wild flax i was about to push something to that PR that jiralite mentioned
oops
if you still want changes, make sure to put it in draft mode then
and they were most likely unrelated anyway
sorry it was a small thing, I was gonna get it done when I got home
they weren't actually
what about adding them in optionalDependencies in package.json?
atleast butterutil and utf-8-validate as they don't need visual studio installed
That still gets installed automatically I believe
It does
why do errors look like this now?
Source maps or something
that's what happens when code is minified. [variable] names are also minified
source maps have nothing to do with this
I didn't change my code tho, so something changed on the lib
yes, /rest is being minified
Can we remove that?
turning minify off does fix it
minify saves a total of 15kb, from 34kb with minify off to 19kb with minify on. I mean it is a reduction but if these errors are supposed to be shown I think we should have better names and 15kb never made a difference anyway
managed to get the same size while keeping the names, the only thing that keeps weird names is the error stack, is this preferred or can I PR with a slightly bigger file size that keeps all function and class names
It makes no sense for djs to care about size, it should be turned off completely
I mean there must be a reason why they added minify
Tsup supports a preserveNames options, which is also used in /collection
Maybe it should be used here too?
@zenith oracle thats what this is
I don't think that's enough
because if we wanna trace back an error, the source code is an absolute pain to look at
i dont understand why theres a sudden urge to minify stuff 🤔
I mean, there's literally a stack trace with a .ts file, what's the problem?
at C.runRequest
is the problem, i guess
Tbh, if you want to look at the source code for that, you probably should already be familiar with the lib and know exactly where those functions are. Unless you are In the unlikely scenario it’s a lib issue, that part of the stack trace is practically irrelevant.
Being familiar with the lib doesn’t make it any less difficult to read the source code with that option
Not in every library, for /rest it does though, there aren’t that many functions. I can read that error just fine
this is getting fixed by keeping the names of the classes
Fwiw I don’t care about minification, I think some people will though
also i'm 90% sure the sourcemaps fix the errors in your console so you can go on github and see it
Yeah that’s kinda the point of sourcemaps
Just enable source maps in node
js errors will always be a pain to look at when the code base is in ts
It won’t really match up either way
But if you use source maps the problem is easily solved
How can you read it if it gets compressed to 8 lines?
Just enable source maps in node
also I do use source-map-support and I still get this
I have it enabled
otherwise that error wouldn't be pointing to a ts file
all I can say is that it should work, otherwise everyone creating ts libraries wouldn't be able to see the source when they debug
when I click the linked file and line yes it does, but it still says C.runRequest 🤔
node --enable-source-maps . or similarly set the NODE_OPTIONS env to --enable-source-maps
do I have to include that in the start command every time I start my bot
ill try the env
If you use Docker, you can also add ENV NODE_OPTIONS="--enable-source-maps" before your CMD and you're all set, although I'd argue this solution is less useful for most
alright thanks! Does that mean I don't need source-map-support?
That's right ^^
I have been using that flag myself for almost as long as it's been out (of experimental) in v15, works pretty well
alright, thank you
@outer raven people are whining about the performance impact of validation, if we add extra properties, it'd cause an even bigger performance impact.
Also, we'd need to hide that property somehow because it'd get serialised if it's left enumerable
1 single property is less performant?
didnt know that then sorry
the name unsafe sounds scary tho lol
It's meant to be scary
I'm open to names that are synonyms to unsafe
Rust uses unsafe to give you raw power and performance, while it also discourages developers from using it
If you want it less scary but accurate you could use Unvalidated
But I think unsafe is fine
or it could have the normal naming and validated components could be prefixed with safe
either way good job siris 😄
That would encourage people to use the unsafe ones by default, probably not what's intended
that's what i'm suggesting more or less
While I personally would probably use the unsafe ones (or not builders at all tbh) they're intentionally presented as validation being normal, unsafe being the alternative. I don't believe anyone wants to flip that
Is there any possibility for the PR https://github.com/discordjs/discord.js/pull/7200 to be merged into discord.js stable, so still up to v13 version? A lot of people would surely appreciate it, since it's coming out any minute now and some people don't want to wait a year for news (djs major version comes out mostly every year) and don't want to use the unstable dev version either.
(djs major version comes out mostly every year)
v14 is coming v soon
If I use inGuild() in a partial message it makes it Message<true> but acc to src it doesn't checks for cached message it just checks for in guildId. So ig this typeguerd is wrong. Is it's intentional or a mistake?
Yeah, because the name if it is misleading
It's called "cached" but it is more of a "inGuild"
Hey, would be nice to have a djs-rest channel for futur help and suggestions
I was wondering if it would be possible to add a "default format" option for the CDN, I don't like the webp one and having the format option in every cdn function of my code is meh. (I know format was renamed but I forgot the new name)
Not a huge fan of global settings
well it could be added to the rest options ?
While debug turned on my bot stopped sending heartbeats after 15 - 20 mins and went offline while the process is still online. Anyone know what can be a reason for that
Then it’s global on rest
Doesn’t change my view
Ill do it on my fork then but im having issues compiling the rest package, can I share it here to get some help?
will do when I get home ty
is it possible to keep the packages updated whenever i start the bot?
like for example something like in package.json
"dependencies": {
"packageName": "latest"
}
read the channel topic
Thats a bad way handling this. On breaking changes, you can recieve type errors and unexpected behaviour.
You can do it with the npm start script.
Btw wrong channel
here is my issue, seems like it get the tsup config right but the tsconfig isn't being read in the correct folder
Thanks, btw where is the right channel for this question?
#resources since its a general question
How are you building this?
When installing or something?
Guess youll have to also change this command here
And supply -p with the correct location of the tsconfig
yeah, I do npm run build on postinstall
aight lemme try
i'm having difficulties using the -p flag, it always return an error with Cannot read file '/home/koyamie/koya.gg/binteractions/node_modules/tsconfig.json'.
i've even tried to specify the full path from root
How do you use it
I'm installing the package and with my postinstall script I do npm run build (which I changed to "build": "tsup && tsc --emitDeclarationOnly --incremental --project tsconfig.json",)
but the project option doesn't work, I have tested changing path or providing the full path it always return this path: node_modules/tsconfig.json
because /rests tsconfig.json uses the root tsconfig.json in the monorepo
oh
make sense
damn yeah the extends props
thank you, sorry for the mess that was my issue
If you want to do this create a higher order function for the cdn functions
So like my myprofile = applyOptions(rest.cdn.profile)
The you can reuse that function anywhere
I'm not sure to understand sorry
So with the recent switch to /builders, embeds and components no longer get transformed from snake_case to camelCase when receiving them through the API and this is the only place in the library where this seems to happen. Can we make a class on discord.js that extends /builders and implements that? I'd be willing to open a PR for this with the types as well
on builders
<Embed>.setFields
takes a rest parameter
/**
* Sets the embed's fields (max 25).
* @param fields The fields to set
*/
public setFields(...fields: APIEmbedField[]) {
this.spliceFields(0, this.fields.length, ...fields);
return this;
}
while for some reason <ActionRow>.setComponents takes an array
/**
* Sets the components in this action row
* @param components The components to set this row to
*/
public setComponents(components: T[]) {
Reflect.set(this, 'components', [...components]);
return this;
}
``` shouldn't these be consistent?
should be yeah
setChoices is a weird one
public setChoices<Input extends [name: string, value: T][]>(
choices: Input,
): Input extends []
``` it takes an array of arrays
instead of objects like setFields
yeah that should probably be an object too
okay but a rest parameter too, right?
we're trying to make these methods all have arrays or rest parameters?
so what, just make a new type for this?
i don't know if APIApplicationCommandOptionChoice can be used since APIApplicationCommandOptionChoice["value"] is typed as string | number
that is fine since it can be a string or number
these methods are called on string/integer/number options specifically
yeah which is why value can be a string or a number
the point i was making was that why would SlashCommandStringOption.setChoices take a number as it's value?
other methods like addChoice lets you use the type based on what type of option it is
it uses the generic
then follow that ig
okay so..
make a pr which changes all these methods to now take rest parameters and make setChoices take objects to be consistent with setFields, sounds good?
I don't see why not
okay then, i'll make that shortly 🤠
meanwhile let's bump this back
Perhaps the ability to use color strings in Embed.setColor() could also be readded with this? 🤔
@wild flax anything regarding this? Would still love to see this get merged xDDD
okay i am done
i have tested it and they seem fine, before i push, what do i name this object? i'm calling it ChoiceData for now
yes!
no that won't be added, if you want colors you'll need to use the Colors enum or a hex literal ie 0xffffff
The latest turbo update works fine to me on Windows 11, have you tried reinstalling node_modules?
yeah did that and it seems to work now, weird
@outer raven did you want me to actually get rid of the generic or will it stay?
I found it to be redundant but if it solves an edge case in TS it can stay
okay then
you actually can remove the generic, we found out recently that the cases where setChoices couldn't be used are still show up in TS regardless of input
just have it return this as well
wait what cases?
ahhh
public setAutocomplete<U extends boolean>(
autocomplete: U,
): U extends true
? Omit<this, 'addChoice' | 'addChoices'>
: this & Pick<ApplicationCommandOptionWithChoicesAndAutocompleteMixin<T>, 'addChoice' | 'addChoices'> {
``` that's because `setChoices` was never used on Omit
no, like for example your current code won't allow setAutocomplete after setChoices, but if you do something like setName after setChoices, it still allows setAutocomplete
oh yeah that makes sense
probably gonna PR those conditional types out since they aren't reliable anyways
so it's a separate pr or do i do it here?
you can do that one method if you want
hmm, then i think it'd be better if it were a separate pr where both are removed at once
ok
thanks again both of you 🙂
also this is unrelated to this particular pr but i had a few questions
about the setEmoji methods, following up on this conversation now only taking an object instead of an EmojiResolvable, is that intended behavior?
should the documentation for the methods list the API defaults as it's own default value?
like https://discord.js.org/#/docs/discord.js/stable/typedef/FetchGuildsOptions this lists limit's default as 200, in the code it doesn't set a default value, it's actually the api default that's mentioned here
and aren't the builder methods like addFields, addComponents dropping support for arrays to be passed and are only supporting rest parameters to be passed?
Discord.js v15 will already be in TypeScript?
we do not give version numbers to milestones that are on the roadmap
Can you clarify the benefit of this?
I'm not sure why this is necessary
Just for property consistency?
Everyone assumed v14 would be TypeScript rewrite too - TS rewrite will be whatever the next major version number happens to be when its ready to release
Consistency with property names (everything in djs is camelCased except for stuff imported from builders)
Ability to use types and utility function from djs in these classes (e.g. Util.resolveColor)
Ability to pass an object to the constructor of these classes with its properties in camelCase, just like we could in v13
This would all be easier if we just didn’t use builders at all, but since that change was made we’re gonna need dirty fixes for these issues
I tend to agree, I personally think the way builders have replaced discord.js components is a mess. Property consistency would be nice, I'm assuming the child class constructor would just convert the incoming object to snake_case and pass to super()?
The color thing, couldnt care less either way tbh. Hex literal numbers exist
I thought we were sticking to snake case json payloads, I closed my pr bc it was suggested that decamelization would be handled by the user
It would also allow us to use -types directly
This is where I get very confused. If:
- the API sends snake case
- the constructor accepts a snake payload
- and the builder properties are all snake case
- and the toJSON method on the builder produces snake case
When is there ever a camel case object to be decamelised?
Anywhere snake case is accepted
But it isnt camel case in those situations
Where is the camelCase object coming from - are we suggesting the user is going to write it in the wrong case just to pass it through a decamelize function for the constructor?
Theres no reason to do that
Rodry is making the opposite point, and I agree with him, that builders are completely inconsistent with the rest of discord.js because there is never any camelCase involved
Well, it made me happy to rewrite discord.js to TS. Just one more thing. Are you planning to use minify the same way as with the other modules? It doesn't make any sense, at most it will increase the package size by a bit.
Dont know, minify wasn't my decision nor was I involved in any discussion around it, and I also think its dumb
That and the properties on the class would be camelCased too
Yeah but constant colors are nice, specially random and official discord colors like blurple
Well I personally don’t know what hex blurple is and it changed recently so having just “BLURPLE” in the code is much more helpful as we can be sure we’re sticking to Discord’s branding
Also about this, since there is a toJSON method already we could simply store data in builders as camelCase and then convert it, since people have to run the method anyway to send it to the API
I disagree that embeds should accept strings to address that, but I'd agree with keeping the colors constant or enum, whatever that was
Would you rather check that every time or literally just type the name of the color? Cuz I’d pick the second option
See this is the problem, /builders were originally designed to be for the /rest package. Having camelCase properties in /builders would have made absolutely no sense since in that ecosystem its a waste of time converting them
making 0 difference in usage apart from where it comes from
And here we go back to the good old “let’s remove every single utility from DJS since the users should be doing that themselves anyway”
It just doesn’t make sense. It’s a library, it’s meant to help
But now they're in discord.js too, where their casing doesnt align
yes, that's suggestion because the alternative is performing a transformation regardless if it was snake case or camel cased input. There's no good way to tell them apart in a function so they'll both be transformed
Every other method in djs does camelCase to snake_case convertion, why is that a problem in builders?
not anymore
This is why
Or at least this is the reason it originally made no sense for them to be doing that conversion
Well yeah but now that they’re in djs, it should follow the same rules
Originally it was fine because it was even mentioned that builders should not be used with djs
Huh?
which methods are you referring to?
@copper laurel this is about a quite nice use case anyway
Literally every method that calls the API
Every property you pass is in camelCase, every property in a structure is in camelCase
It’s about supplying a camelcase object in the constructor of a builder, to then use the methods on it
Instead of constructing it solely via an object, or use the builder methods solely
Why would you write that object in camelCase knowing that the constructor doesn't accept camelCase
but we're not supporting camelCase payload either right?
By using a raw object you lose the utility functions, by using the class with subsequent methods you lose some performance, even when using the unsafe classes
I agree that's a niche, but also agree that the design of builders is inconsistent with the rest of discord.js
Not incoming, because that’s not a real word scenario. Every private constructor accepts snake case, every public constructor should accept camel case
I think the monorepo and cross-package dependencies is overall a far worse experience for the user
Yeah that’s for sure
Not sure how the mono repo is related to that now
I think the docs link issue has been resolved
I mean yes, it wasn’t meant to be a permanent issue
Installing individual dependencies from GitHub is still difficult. Is there a plan to have an @amber obsidian release for every package?
ahh damnit sorry
@dev
Unlikely, maybe
Monorepo has been sorta tied to all the changes to builders and all, but to me the only issue is the CI not reporting errors for subpackage dependencies, as it makes them go unnoticed
Our package is pretty unique in people even wanting to install via GitHub
Like you never see that anywhere else really lol
That’s only true when there aren’t prereleases
also kinda sad that there was no mention at all about stuff moving to monorepo on separate repos

:thonk: curious actually, does npm link work if you run it from the correct package subdirectory?
Thinking of forks
It does, I’ve used it
seems weird to also not mention the fact that it's a monorepo in the monorepo readme as well, but i suppose there is only a single dir that isn't dotdir now, so eh
If people care about the development of a package they will. Heck some people even install node from their master branch and it appears on their release cycle graph
No, really not. It rarely happens
You can die on that hill if you want, but 99% of TS written packages out there simply don’t support that use case at all
Neither do they dev releases or pre-releases
TS itself does dev releases
ts isn't a monorepo?
Not the point anymore
And also a dependency
No
There’s been prs on djs to fix bugs from ts pre-releases
It’s a cli tool
It’s not a library
Need a rust tool to run on a dev version? Clone it, build it, run it
You can’t easily do that with libraries, that’s just a fact
Sure you could do the same approach and npm link it, but then you might as well just do that
It has nothing to do with dev or pre-releases
even if ts wasn't a cli tool, they do specific manual beta releases, something we've never done
like it's feature complete, it just is getting tested by the community
nom link only works locally, you can’t have your app run off of an npm link on a VPS
Ye thats true, but it could be done
? anything could be done, that's not much of a point
We’ve kinda drifted away from the main point which was the /builders integration with djs and how that’s caused a hot mess of issues and inconsistencies
So… you clone the repo on your vps
🤨
Do you realize how complicated that is when we could just install stuff directly before?
And you realize that we already do things that others wouldn’t even attempt to?
And just because our setup isn’t 100% ready yet, it’s like everyone acts like it is lol
I’m the only one that does organizational stuff here, esp repo setups and all
And I don’t care about v14 to be stable, so yes CI doesn’t “throw” errors, because it doesn’t need to
The packages “in development” work with each other.
v14 being the only one with constant dev releases, not working with not released changes of the other packages is a given here
A good way to have people not complain about a product in development would be to have a public roadmap of features that you want to add to v14 before releasing, instead of just discussing that internally. People also wanna help so having that would help them pick a feature to work on and PR, and you could direct them to that list if they complain about something that is there
The main complaint here is purely organizational + builders discrepancy
And no one can really help with dev releases because of npm access restricted to maintainers
I swear there's so many topics going on, please thread them because I see concerns about the whole camelCase vs snake_case and now @dev releases and something else about them
Everyone can always make a PR
Yeah sorry, lemme make a thread
How’s that help if it can’t even be properly tested and would potentially need a lot of follow up prs instead of just someone doing it that has actual control over it to actually fix it
I didn't say you do it, but if that topic is planned to be discussed further pls thread it 🙏
Builders discrepancies with DJS
Someone that has control can review the PR and tell the person to add whatever they feel is missing. If that roadmap also has a bunch of goals that must be met for each feature that would make the review process faster too
Yeah and that’s nonsense
There’s things that I don’t want to teach people and them doing it wrong or me having to correct them over and over, or worse them not responding for days
I might as well do it myself
That's.. irrelevant? By that point Crawl can just do it himself without needing a middleman for it
I’ve never seen someone call a roadmap “nonsense”, that’s def one I wasn’t expecting lol
I wasn’t responding to a roadmap at all
Crawl never called the roadmap ^
That’s assuming everyone is stupid and will make incomplete PRs, which isn’t true and there are many smart contributors that don’t have the shiny green role and I’m sure would love to work on such a thing
But letting others do prs that are of organizational nature, or generally PRing things we rather handle ourselves
The first interaction PR set us back MONTHS
For having support for them
I’d rather not run into this again
I’m not saying the community should be doing prs like the monorepo one, but minor features are harmless
And since then I personally haven’t seen any situation like that
It was a bad experience, sure, but those are the quirks of open source
Most of the time people making PRs in djs know what they’re doing
You're missing the experience factor, besides, I think I said this already, but we communicate a lot in internal channels, and those who aren't part of the proficient+ team just don't have access to those, so there isn't much of a coordination either
🤨
Sorry but
I’m not sure if you make it sound like you know better or… undermine however we are involved in OSS
I know you do, and not having an official way for people to try to get the role also prevents a lot of good contributors from reaching that and being able to contribute in a more positive way.
notice how I never said my name and I'm not even thinking about my case in particular. I could name a few people who have contributed to djs recently who are actual good contributors and would take a lot of advantage from a public roadmap. I haven't talked to any of them privately, but I believe they would
It's also not like our roadmap is private or something, it's public, and I also did not want to imply that most/all communication is internal, in fact most of the time it just mirrors the discussions that take place here to get to a better conclusion or just give a better answer
the only roadmap we have is made off of PRs that are already open, us outside collaborators have no idea what's planned to happen in the future before the release
Then check issues
I don't know why are you looking for stuff to do while checking stuff that's basically done
I have a few issues open that have a lot of thumbs up but so far almost no feedback in them, even though they improve performance and memory usage *drastically*
some of your issues have already been set back to v15
You can still provide design ideas
there was never an issue about converting everything to discord-api-types enums
they're good as-is IMO, that's probably why they don't have replies
Thats often not a good idea.
New Features should be correctly designed, inorder to prevent future breaking changes, bc the code has to be refactored/changed
New features should also not get merged until they’re done properly
Says who
Common sense idk
It's not like things get merged intentionally unfinished


