#archive-library-discussion
1 messages · Page 13 of 1
In some classes we do something like```js
if (data.foo) {
this.foo = data.foo;
} else if (this.foo === null) {
this.foo = false;
}
iirc, `User#bot` is one of those cases
That could be refactored tojs } else { this.foo ??= false; }
Ok, bot is more conditional, but username is exactly like it: https://github.com/discordjs/discord.js/blob/master/src/structures/User.js#L45
The recent change to support custom user agent parameters could also use it
We could also use the new Array.prototype.at method introduced in Node 16.6.0
why
that's not available on 16.6.0 doe
it is
Any reason why repliedUser is not on ReplyMessageOptions and is instead super'd from BaseMessageOptions allowedMentions? Can you reply to a user without message#reply?
doesn't current setup of it being placed in MessageMentionOptions allow it to have different default value passed via ClientOptions?
yep it does, that's what I was missing
no, lol
Yes - TextChannel#send supports specifying a message for it to be a reply to
Why ?
fwiw, mdn is pretty useless for looking at node compat, node.green is probably the best source of truth outside trawling node release notes or docs versions: https://node.green/#ESNEXT-Stage-3--at---method-on-the-built-in-indexables-Array-prototype-at--
Apparently the Collection link was removed from the docs, which file should it go in?
gonna PR and throw it in the Client file cuz i don't see a better place for it atm
Is there any reason why ClientUser#setActivity still accepts 2 parameters instead of just 1 object?
Since v13 already changed that for sending messages, I think it would make sense to do so here too
There should be a function for hydrating objects from broadcastEval or anywhere else to a guild object, so you can access the methods and getters
So... using v8's serder?
what are you meaning lol?
lemme elaborate:
const guildobject = {id: guildid, name: guildname...}
const guild = client.guilds.hydrate(guildobject)
guild.leave()
///Functions, which can now be accessed
```Turn a plain object in a Discordjs Structure
v8's serder is able to serialize and deserialize complex types
Would guildobject be a Guild#toJSON or a raw Discord guild object
Curious, we can't use it for v12's collections
what
I proposed it in the thread, #872158099786580018
when is v13 gonna drop
when ever crawl feels like it + 1 day every time someone asks, +1 week whenever someone asks in devcorner channels
Should defer be changed to deferReply? I remember a conversation about that here the other day but a maintainer didn’t give an answer for it so I’m not sure if it’s a yes or a no
Conversation started from here #archive-library-discussion message
We kinda dont care
So like you guys wouldn’t mind if a PR is made for it to be changed to deferReply?
Cause like I don’t want to open a PR for it and then have it be rejected or whatever
I mean people will probably debate it, but you're welcome to make the PR
Why is the Emoji CDN endpoint the only one that defaults to png instead of webp?
the docs don't document that
I still don't get how the djs manages the requests
Especially the APIRouter file
A big mystery
currently <Message>.content is marked as nullable in the docs but it returns '' when no content is specified. Should it return null or be marked as a string ?
Yeah the API sends '' too, should probably be updated
That's for partial messages.
Then every property should be considered as nullable, excepted the id, in each structure which might be partial, which is not the case
The docs seem to take those into account, except for cleanContent.
@solemn oyster since you already approved https://github.com/discordjs/discord.js/pull/6278 lemme ask you this
We noticed on the upstream PR that Discord actually defaults the autoArchiveDuration to 24h and not the channel's setting. Should we try to set it to the channel's defaultAutoArchiveDuration when it exists?
That's why we don't land stuff before they land in dapi-docs
@wild flax @tacit crypt @slate nacelle wdyt?
whatever crawl says
I personally think we should not define the default, but let Discord default it
To not deviate from the behaviour from Discord
but then if discord defaults to 24h it might be counter-intuitive if people are expecting to see the setting they chose
would a "MAX" option in autoArchiveDuration based on guilds boost count be too much of a runtime check?
when replying to an intent with nothing (interaction.reply()), a better error would be nice. This one isn't very descriptive: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'fetchReply' of undefined
I spent a lot of time with this stupid mistake in my code 😅
options is documented as required
If you really want a strict language that tells you when you're not using methods correctly, you should probably switch to TypeScript
(or at least get its server running on your code)
yes yes, I know, I'm just saying that in case someone doesn't give any arguments by accident, a better error would be nice
While that could be possible, validating any possible input would take a large part of the code and create useless checks at runtime
I know nothing of the internals of djs, but wouldn't something as easy as this be enough? https://stackoverflow.com/questions/43802652/return-error-if-no-parameter-in-function
OP's idea is equivalent to a warn, you say it's wrong but don't halt it (so basically you'd still get the thrown error later in the code)
The second one would probably be the "best" one (but with throw new Error instead, and no console.error at all) - but as I said the code related to input validation would likely take like a third of the whole code, then
The last one that wraps everything into a try/catch is terrible
That's just blatantly using the method incorrectly, theres no valid use case for no arguments
@copper laurel seems like https://github.com/discordjs/discord.js/pull/6262 broke guild text channels. From my testing _patch gets never called because immediatePatch is set to false throughout the constructor chain. calling this._patch(data) at the end of the BaseGuildTextChannel seems to work, though idk if that breaks something different
I'll look soon
Yeah okay these never patch
I think I would need to add a constructor back to TextChannel which just calls super with false and then patch
And then patching starts its own super chain?
(and NewsChannel probably)
it should _patch at the end of the BaseGuildTextChannel constructor
I guess it could there too
at least until there's a constructor in its subclasses
Should I just put constructors back there I mean
What would possibly go in them
this._patch(data) 😄
lol, up to you where you put it
Nobody uses text channels anyway
@outer raven | number is a valid type for those - when you create a guild you can also create roles, set overwrites etc all at creating
You reference the roles by a referential index
these too?
Yep
Say you create a guild, and you also tell it to create 5 channels, you can reference those 5 channels by number for overwrites, and roles etc
All good, its a specific niche case that rarely gets used
But I imagine before Guild Templates were a thing template bots probably used this sort of stuff often
I don't see why a bot would own a guild tho but yeah if it's there we gotta document it lol
that is largely irrelevant, it's supported api spec
(also me, hi, i use that)
lol aight
Should https://github.com/discordjs/discord.js/pull/6027 probably be locked?
Now mostly used for completly irrelevant stuff
probably not a bad idea
just outta curiosity, why tf do you run the workflow on macos? lmao https://github.com/discordjs/discord-utils-bot/blob/main/.github/workflows/validate.yml
used to be the fastest
hmm weird i'm pretty sure it's the slowest
at least in all my cross-platform workflows, it's always the slowest
it might be by now
what r the possible text of <MessageAttachment>.contentType
@supple current https://en.wikipedia.org/wiki/Media_type
it's returned by the API, djs just passes it through
oh ok thx ill look into it
@wild flax idk if you got pinged in here but should I bring these back or is it fine to delete them? https://github.com/discordjs/discord.js/pull/6299#discussion_r683023520
Is there any chance of an embedded audio file, similar to videos, images, YouTube, etc.?
I don't think implementing that is within our power.
why 😭
Because it just was an alias to the resolve method of the member manager.
No idea why that isn't used in the second line there.
yes but it was really useful and very short way to test if the bot has certain permission
Guild#me is still there, isn't it?
oh thanks 😄
Huh? They changed the name? Is that en-us?
@outer raven
@tacit crypt should i use a temp value and assign something like maxArchiveDuration ?? data.autoArchiveDuration since they all get reassigned?
perhaps? could do it like the file above the one i reviewed
it is en-us
they changed this months ago tho
same on en-uk btw
eh, destructuring will leave a {name: (name ?? this.name).trim()} , not sure how clear this is
Is there a reason why URL isn’t capitalized when used on its own but is capitalized with other words 
Example:
MessageAttachment.url
MessageAttachment.proxyURL
I can make a PR to fix this inconsistency unless it’s like that for a specific reason
because why would you have .URL
Maybe .proxyUrl
what djs currently uses is correct and follows camelCase standards
if the name of a function/property is an acronym, it should be lowercase (MyClass.url, MyClass.http). the rules are different for constants
but it also depends on the length of the acronym. so like openURL looks descent and openHTTPConnection looks odd
v13 changed Guild.ownerID to ownerId and interaction.channelID to channelId because:
This is a more-correct casing for the camelCase used by discord.js as Id is an abbreviation of Identifier, not an acronym.
URL is an acronym
I don't think the library reflects this atm
oh i didnt see this, nvm then
@clever crypt we'll eventually replace them to Url
Because of all the reasons already listed above
so if a user was uncached when the bot was started, and they sent a message thus triggering the message event, would that cache them?
yeah
You would need to have the intent(s) to trigger the event though, I think
..yes?
wait why is the minimum node version 16.6 now
are any of its features used in the code
Not at the moment, but we will
Normally, we'd make the minimum 16.0.0, but 16.6.0 is a security release, so anything lower than that is discouraged.
16.6.0 brings Array#at in comparison to 16.0.0, which brings logical assignment operators (||=, &&=, ??=)
Since to Node.js added an AbortController (quite a long time ago), why not use it in the library instead of the abort-controller module?

I was wondering why I was able to install a module nodejs already has(abort controller), now realized its not the same...
Looks like a drop in replacement, just gotta test it (and there's a couple other PRs to merge anyways)
fake news
In index.d.ts we have :
<Role>.comparePositionTo(role: Role): number;
But in the documentation we have :
<Role>.comparePositionTo(role: RoleResolvable): number;
https://discord.js.org/#/docs/main/master/class/Role?scrollTo=comparePositionTo
Wich one is the correct ?
the latter
Why is node v16 gonna be required? Afaik there's nothing that uses node 16 in djs right?
nah you can install it but you get a warning
I really don't think you should be recommending a version of node that is not LTS
I mean sure it will be in 2 months but it isn't yet
Yeah but we also dont care
We dont want to have to release v14 in two months in order to use new Node features
When we can just make this version a v16 version
why would you release v14 just to use the new node features
like someone said the other day they're nice to have but you don't need them that urgently
But we can also set v16 now
And not need a semver major if we want anything
I don't see why it's an issue
v14 would've been a semver major anyway and when that comes out node 16 will be LTS
I think it would've been better to wait tbh
We agreed internally having a 2 month transition period where it is still "current" before it transitions into "LTS" is ok 👍
aight
(repost)
For inviteCreate
const client = this.client;
const channel = client.channels.cache.get(data.channel_id);
const guild = client.guilds.cache.get(data.guild_id);
if (!channel) return false;
const inviteData = Object.assign(data, { channel, guild });
const invite = guild.invites.add(inviteData);
``` and for inviteDelete
```js
const client = this.client;
const channel = client.channels.cache.get(data.channel_id);
const guild = client.guilds.cache.get(data.guild_id);
if (!channel) return false;
const inviteData = Object.assign(data, { channel, guild });
const invite = new Invite(client, inviteData);
guild.invites.cache.delete(invite.code);
it checks for the channel but not the guild, so if I only disable the GuildManager cache, the guild should return undefined
and since there's no check, for both this and inviteDelete, it'll cause an error
is this expected?
You REALLY should not disable the guild manager cache, and we added warnings and removed it from types so you dont
Like if there's any cache you shouldn't disable it's that one
Wasn't aware of that
came across this issue because a user disabled every cache they could
so I take it this falls in the functionality break category and there's no need to add any further checks?
Thanks to all the contributors who helped ❤️
Can a PR be made to remove the message event now that v13 is out? 
I wonder if there's a chance now to rename the master branch to main? Not sure if that would mess anything existing up
see so my thing is. I'm okay with it being node 16 but it's just that many use v14 lts because it's lts
Relevant
yes v16 goes into lts in like 2 months
It will technically still work fine on 14.6. But since we specify that people should be on 16.6, that means it's not a semver major change to use it's features, even though it would break Node 14
So if you want it to keep work if we do a minor release like v13.1, use node 16
Yep, disabling the guilds intent or guild cache is just breaking the lib
okay thanks 👍🏻
With the removal of the abort-controller dependency not anymore
iirc abort controller can be harmony flagged in on 14 if you wanted
I thought AbortController was 14 too, but nvm
oh true, it's --experimental-abortcontroller
Anyway, only talk here if discussing lib development please
re: this, to clarify I meant the deprecated client message event, not going slash cmds only 
Why not?
Wasn't sure if y'all had a planned deprecation period
its not like v14 is coming out tomorrow
damn there goes that hope 😔
New features will land as semver minor (13.1.0)
👍
Unless they're breaking in which case why v14
should structures with a .toArray() method also have a Symbol.iterator that calls it
huh i guess bitfield is the only thing with a toarray method and it already has an iterator
nvm
@oak quail can u rebase your PR (banners)
@vagrant holly unsure if was covered already - but you should also get rid of this in your PR while you're at it (or open another, I dunno)
https://github.com/discordjs/discord.js/blob/6c4d4913aac69853fd8a11cbb6366129794cf8c6/src/client/actions/InteractionCreate.js#L52-L62
Will open another to keep things clean

Slightly meta, is there a reason Gh sponsors points to Amish, and not y'all who actually maintain the lib daily?
because we get robbed

4 works
we have like 5 though lol
who am i missing
hydra, me, space, vlad, kyra
space doesnt have gh sponsors
no love for the support crew
What's hydra's username
smh

Gonna get some spicy pics of djs source on OF, soon™️
yo, I don't know where to ask because #djs-help-v14 is flooded by v13 update but i'm having an issue when I require Message structure in the Webhook structure (forked repo to edit myself some stuff), it seems to invalidate the holds and cause it to be an empty object (very weird), is there any reason behind that?
we do not provide support for forks to persist old features
oh, this is not about Structures, i see
not exactly old feature
just a quick edit on the webhook structure where I build Message instead of returning APIMessage
but when I require it on top of the file, I don't get why but it invalidate my Message hold in MessageManager
I never used Structures to extend ehe
i'll provide more context if you don't mind
Webhook file, simply require Message
what I edited, build Message instead of returning APIMessage
the issue I get
and I have verified, when I bring back the file to the lib state, I don't have any holds issue
I also tried console loggin Message in different files.
Webhook file returns the class
MessageManager file returns an empty object
so node warnings are giving me more context
Warning: Accessing non-existent property 'Symbol(nodejs.util.inspect.custom)' of module exports inside circular dependency
Circular dependency is why
Move the import to the bottom of the file or in the function
yeah got it but how could I do in my use case 🤔
alright I was trying in the function, still not done yet but i'll update
welp, here is my workaround, seems to be working
ty for helping everyone
by the way, it may be confusing the reason of doing that but its because I use the lib without the gateway for my interaction project (that runs with webhooks) and it lacks of support for uses like that.
so I am doing workarounds that aren't much reliable but works
building the Message here allows me to create interaction collector for example without having the channel in the cache
pretty useful when you don't want to fetch the channel each time
As the announcement says, it will be patched soon
#6325 in discordjs/discord.js by almostSouji opened <t:1628285607:R> (review required)
fix(Message): handle fetched messages
📥 npm i almostSouji/discord.js#fix-msg-guild
Why was Guild#owner removed?
<:_:851461195554619442> Guild#fetchOwner()
Fetches the owner of the guild. If the member object isn't needed, use Guild#ownerId instead.
Because the member object associated to the guild owner was not guaranteed to be cached - as a replacement, that method ensures you will get its member no matter what
sounds like the opposite reasoning why fetchApplication was removed lol
This would have led Guild#owner to be a partial GuildMember object (where you could <Guild>.owner.fetch()) but I don't think that was desired as the developer may not have enabled the GUILD_MEMBER partial
The application is unique, only used for the client, so I guess it can behave differently
we always get a (partial mind you) application object the moment we connect to the gateway 🙂
which never changes
It effectively just moved to Application#fetch, as you couldn't use it before logging in anyway.
Will any of the packages in discordjs/discord.js-modules be implemented into discord.js? Or should these modules only be used for interacting with the Discord API without a bot?
This is a rewrite of discord.js, so the main package will work the same as the current one, and i don’t think they’ll be implemented in the current djs because their goals is to replace the current one entirely, not implement them in the current one
Not entirely true - there's no reason parts of it like rest or ws couldnt be introduced piece-by-piece into discord.js eventually
Yes of course they could, but i mean they are mainly being built for /core right? Not to replace current djs pieces (event though if they are ready before /core, yes you don’t have any reason to not implement them)
It makes more sense to implement the modules if we want to continue enhancing them, otherwise you end up in the situation we're in now - djs v13 got enhancements that modules doesnt have, because its twice as much work
Better to enhance in one place
Yeah right
why are ya still recommending erlpack to be installed? it doesn't work with node 16 at all
theres a pr for it, but due to the lack of activity in the erlpack repo i doubt its getting merged
My plan is to implement /rest into d.js eventually
is detect invisible user possible?
no
It's invisible for a reason
i think ian (discord staff) said he'll look into in on monday
Why doesnt GuildMemberRoleManager have a method fetch()?
What if I wanted to contact API directly to check if a user has a specific role 
there is no guild member roles endpoint, is there
Oh
So djs gets the role cache based on user info endpoint or something?
the member data includes a list of role id's. we resolve them based on the roles we get from the initial guild payloads + update events
hm ok
you can fetch all guild roles, but not the ones of a specific member, including the actual role information
the association member -> role always works via the id in the member and the data in the role payload
Ok
btw @wild flax the version number pr should be good now
Why APIMessage has been deleted? To prevent developers from using additional libraries?
It has been renamed to MessagePayload.
Thanks
Hey, trying to import discord.js using ESM gives me this.
I have fixed it replacing by "import": "./src/index.js" but it shouldn't be the way
I am using ESM, so that can't be
Its probably because you run from github
The esm only gets generated on publish
I don't run from github thats weird
@tacit crypt @solemn oyster should i refactor all the iconURLs in the Emebd or to iconUrl?
no.
no
URL stays as URL
kyra is fake news-ing
calling the cancel culture police
no
okay
builders discussion
Is there any update about the issue where if you use zlib-sync, you would have increasing gc pauses over the time you use it?
how will d.js handle resolved interaction string mentions 🤔
might be useful to just expose resolved
(if you dont know what im talking about, they announced it at the q&a: https://advaith.is-in-hyper.space/d64671c2f8.png )
maybe they can also be implemented into the CommandInteractionOptionResolver
We actually talked about this (me and @ruby terrace) when we were in VC in Ian's server.. but uh i don't think we got to an "answer".. probably gonna have a Mentions of sort..who knows
It's definitely to be done
Probably like on messages
A .mentions or smth
It’s dumb
It should never have been done this way
but, when you use the CHANNEL or ROLE Type, you will get the object in the option?
why wouldn't there Permission on ApplicationCommandData
so we can just do
Name: name,
Description: description,
Options: options
Permission: Permission
so we wouldnt have to fetch the commands and adding command.permissions.add({ permissions }); manually
you can't supply permissions during creation
those are two separate api calls and shouldn't be mushed together in the library
should i ask for this call on discord api server ?
or there must be seperate api calls for a reason ?
technically yes, but they already said they're going to revamp the permission approach, so i doubt that'll do anything
Cool, i guess not gonna add a moderation command for now,
my SlashHandler will look like a mess if i do that manually
commands can be global, permissions are always per guild
what if they add a permission like MANAGE_GUILD only to use the command ?
@real jetty permissions are still per guild. you patch permissions in the guild scope, not on global, even for global command permissions
@haughty flame "what if"'s don't really use much here, you can suggest approaches in discord developers or on their github, we can just implement what's there
Are the TypeScript definitions automatically generated?
I've tried all day to see if I can bundle them up (for the monaco editor) but I haven't suceeded.
no, they're manual
@solemn oyster after some tracing, it seems that because of https://github.com/discordjs/discord.js/blob/ce9a4507b3e3fc0f1d58bf79a69bc2affa04ac98/src/util/Util.js#L467 if the color is a string, then when we get to the line that your review is on color is either a number or its NaN, so I don’t know if your review is accurate.
tho if you still want me to use Number.isNaN that’s fine, I’m sure regular isNaN is broken in more ways than I accounted for
Hey @ruby terrace @solemn oyster @tacit crypt
I am contacting you because since v13, I am having a big issue with memory usage. My bot was already using v13 before the release but using an old commit before some breaking changes.
I have updated it to v13 the same day of the release and since that, my memory never stop climbing, I tried configuring cache but it doesn't get any better.
I'll send some graphs for you
Here is past month, we can see the ram climbing normally (5-6 days to reach the limit but never uses swap or at least doesn't make other process crash)
At the end you can see past 3 days where the ram usage just climbing way faster and never stops, it causes some process to crash like database)
Also more closer look to past 2 days usage
I have tried multiple cache configurations, here is my current one
Btw, its defaultMakeCacheSettings
Thats an offtopic
and you have another typo at the Permission one
its not defaultmake
its defaultMake
as for ram usage.. do you have any heapdumps you can inspect (do NOT send them, as they can contain your bot token/auth details)?
I have tried to heapdump on a shard but it literally killed it lol
13999
sorry I don't have a list
mmh weird when I select all my intents I don't get the same number
it may have changed with new intents
but basically this
I see you're not sweeping members, is that intentional?
I wasn't before v13 too
but I could, I have no reason not to
my current config is just some testing I made fast this morning because I didn't have much time
but it can be improved I guess
and you don't happen to have v12 graphs, right?
v12 you mean?
Yes, my kb skipped a v
(after thinking about it I should have created a thread sorry)
I switched to v13 the day it was a thing
as I said I was on a previous commit before some breaking changes (like send(string, options) one)
but I always been on master branch
Then a graph from then
Is there a way you can check if a user has Discord Nitro?

Not for this channel and yes, through oauth2
yes, right there (before August 6)
I have a shard that itself use 8GB of ram, Im making a heapdump and will investiguate
the dump only ends being a 600mb file 
I am using https://www.npmjs.com/package/heapdump, maybe there are better alternatives?
fwiw im running pretty much the same intents as you and seeing ~250mb ram per shard @ 1k guilds/shard
the only major intent i see you have that i dont is voice states
I don't have music just a radio thing
and ye im seing ~1500mb per shard
and some are going wild I don't know why
I would start tracking the size of different collections to understand what's growing
with the dump I noticed one of command taking a lot, i'll find a fix
other than that 😐
I don't see anything revelant
like, TextChannels has 13% retained size
perm overwrite manager too
does setting a sweepInterval without a sweepFilter works?
No, how on earth will it know what timestamp to use to sweep by?
https://github.com/discordjs/discord.js/pull/6365 reason of my typo 
well how do I sweep users or guild members then 
Up to you
Is it bc of Threads?(New Members, which are cached on the ThreadMemberManager) btw, my bot also crashes after 2 days since v13
I have removed thread caching and it didn't get any better
My recommendation is very much to start tracking the collection size for assorted collections as well as overall mem usage, so you have a better picture of what's causing issues
It made the source of my mem issues w/ the v13 update very obvious
damn why I never thought about that before
thanks for the tip i'll monitor cache sizes
Hello sorry for bothering, you still have the opcode 5 I know it has been removed now but what was it used for when it was available ? (I'm being a bit curious I asked in the developer server but didn't get a reliable answer apparently it's for users)
@vagrant holly guild channels are automatically in channels cache too right ?
You didn't remove thread caching, that typo in ..defaultMakeCache made it not sweep archived threads from the guild and client caches, and yes, threads are in the client and guild caches too, so you'll have to write a custom Collection to enforce no thread caching (you'll get a process warning for doing so btw)
yeah I have rebooted since that typo
would you mind sending me your makeCache options? the difference is huge
Using a LimitedCollection with a limit of 0 is just inefficient, 'cause it does a lot of ops to just go "welp shit im full"
ty lmao
I should also note that lastMessageTimestamp is not a standard prop of User/GuildMember, I inject it in a listener

no it doesn't, if your limit is 0 it instant returns
Oh neato, will switch back to it then
skillz
can you guys take this into a thread?
nah jk but shouldn't I set a maxsize or sum
Koyamies caching hell
I had a question regarding copyright for async queue, I'm talking about the v12 file instead of the sapphire/async queue package. I want to add the async queue file to one of my projects, I included the copyright comments that say its the property fo Kyranet and Discord.js
Is there anything else I need to do regarding copyright stuff?
Why.. aren't you using the module from npm?
But usually if you just copied the d.js file it should be fine, iirc it had a license headee
Because I don't like adding extra dependencies, but if it solves the copyright question then ig I'll use it, thanks
You know that adding extra dependencies isn't a bad thing right?
Nonetheless, if you don't want to install the dep, make sure your local file has the license header
license header
The comments that state the MIT license?
Yes
Also what about the APIRouter, RequestHandler part? Do I need to add djs license header for that too? And sorry this will be the last question I promise
Yes, yes you do. I don't exactly know which part of it is needed, but you would need to provide the license header. Or use @discordjs/rest
I don't see why that matters, it's just code in another place
Having certain deps within your project, instead of having them as regular dependencies can harm the maintainability of your project. For starters, do you even know how async-queue's code works? Or djs/rest?
We're also adding more and more dependencies (carefully) to discord.js and related projects to improve the maintenance, like we installed ow for /builders
I know how async queue works, but not the djs/rest one. I'll try it
We plan on switching to djs/rest to some point, so yeah
oh ok, thanks a lot, I'll check it out
If you copy the code, you lose any link to the original developers maintenance and updates
It just becomes the orphaned code that you're less able to maintain yourself
When having custom cache manager and maxSize equal to 0 keepOverLimit function is ignored and it never adds anything into the cache. But if maxSize is > 0 then the keepOverLimit works just fine. I tested it with BaseGuildEmojiManager and ReactionManager
ReactionManager: {
maxSize: 0,
keepOverLimit: (reaction, key, collection) => reaction.emoji.id === config.IDs.upvote || reaction.emoji.id === config.IDs.downvote //even if this method returns true, cache is always empty
},```
Feel free to open issue on github with this (if its not intended behaviour) as I can't open issues
keepOverLimit doesnt actually go over limit, it prevents removal when adding new items. for example if your limit is 5, and you want to add something new, the oldest item by order of insertion will be removed to make space for the new one. keepOverLimit will prevent specific items from being removed, so the next in line is removed instead, but the limit never goes over 5
then it doesnt work because when I was testing it with maxSize just 1 and keepOverLimit which would permit 2 more items in the cache the total cache size was 3 and not 1 as it would have worked like you just explained
then i misinterpreted the code
so 1st item was some random collected emote and the other 2 kept over limit were the one I permitted in this cache upvote and downvote emote (total 3)
ah ok then
but yes, like you said, maxSize =0 does a hard return in the function, so it never checks for any of that
so when having maxSize it should check the keepoverlimit func
yes I see it too now just checked
but can you link me where the keepoverlimit is called? i cant find it anywhere
util/LimitedCollection.js
ah I was in different commit
got it
in my eyes it should take in account for the keepoverlimit before returning maxSize: 0 so the keepoverlimit can be used to cache only very specific objects
not like the 1 unrelated is gonna make a difference but still
yeah it should, if it doesn't then I consider that a bug
This is gonna make the convo yesterday about limitedcollection maxsize = 0 being efficient redudant/incorrect
cause suddenly ops are gonna be performed before it goes "welp shit im full"
Yeah you have to set it to 1 if you want to use keepOverLimit
typings seem to have been messed up in https://github.com/discordjs/discord.js/commit/676118ab0f5cc36cf0fdd7cb897ae68020394778 ?
freshly installed dev 13.1.0-dev.t1628337792.68c0591
hm interesting vscode seems to just have just been having trouble, very strange lol, fixed when i ctrl clicked
@wild flax
did version number not get changed at 13.0.1?
It reads from package.json
Dunno, doesn't look like it
oh it did
but its not setting it as latest @dev for some reason
oh no
its all good
you are just on an outdated release @vernal atlas
oh interesting
when #6172 gets merged will we need to specify the type for slash commands? I know it's an option but more or less asking about djs's side
Anyone else thing the Boolean option should be Yes No instead of True False? Seems a bit more use friendly and makes more sense in most scenarios
Or is this a discord api thing
We don't control that lol, just use choices
No, default will still be CHAT_INPUT (a slash command)
You can give that feedback to Discord, otherwise a String type Arg with two choices will work for you
fwiw looks like we might make it required in discord-api-types
Unless the API starts requiring it wouldnt that just be incorrect though
Add discord context menu api
is user.bannerURL gonna be available in 13.1.0?
that pr isn't going to be merged until the pr for the api documentation is merged
it was afaik
no
ic
Partial Messages for typescript
Thoughts on throwing an error in LimitedCollection if a sweepInterval is provided w/o a sweepFilter -- seems to be something that's caught multiple people out, and seems like a sensible option error to throw?
hmm, I'm not exactly opposed to that, but there was a reason I didn't do that, I just can't remember it
isnt there a default sweepFilter that checks createdTimestamp?
there is not, there was when it was SweptCollection, but since the merge there isn't
oh
couldnt if (this.maxSize === 0) return this; just be changed to if (this.maxSize === 0 && !this.keepOverLimit) return this;
It literally can’t because of the reason in the message you replied to lol
should context menus have builders? the guide uses them, so it would be more consistent
any ideas? souji said maybe deprecate slash command builders because the name is too specific. should I pr?
It should already be possible
the only thing that needs changing is allowing no description be set
and the naming needs changing
since it allows uppercase and spaces
does changing BaseGuildEmojiManager's caching do anything if client.emojis isnt accessed? since it's just created in the getter
also shouldnt GuildEmojiManager be in the Caches interface?
BaseGuildEmojiManager is a DataManager, it doesn’t have a cache (technically). probably got them backwards
@vernal atlas what? cc review
well assuming this.guild?. is handling the rare case the guild isn't present, it should be checked before adding to the collection, if not then it should just be removed and assumed present
Idgi
what does that mean
We still add to the collection though
Just the raw
You say it seems silly to add undefined, but we never do
OHH
We either resolve, or add raw
lol
facepalm moment
~~Hi hi guys, does anyone know why the typings for a WidgetMember allow for undefined, but the JSDocs says they're nullable? Is this some sort of oversight? >:
For example: If a widget member is not in voice, deaf will be undefined. The typings match up with this, but the documentation says ?boolean, but I was checking against null and was being mislead here. How come we don't default these properties to null and instead allow them to be undefined?
I would look into the pull request for more information, but I get an internal server error from viewing it >:~~
https://discord.com/developers/docs/resources/guild#list-guild-members
I didn't find a method in djs for this specifically, does it just use the request-guild-members and not this?
my use case would be that I wanted to use the after parameter
Hello - I notice the lib doesn't require a style for a MessageButton, and defaults it to null, but the API docs say that style is a required parameter... Is this mismatch intentional? I don't have any code running on d.js 13 yet, but it seems like this would be an API error waiting to happen.
References:
https://discord.com/developers/docs/interactions/message-components#button-object
https://discord.js.org/#/docs/main/stable/class/MessageButton?scrollTo=style
https://github.com/discordjs/discord.js/blob/stable/src/structures/MessageButton.js#L49
You can still set it after constructing using setStyle()
I'm aware; just concerned that the d.js lib treats it as optional when the API docs say it's required.
Especially since the lib doesn't supply it a default value under the hood
it's the same level of optional as embeds need to have a description or field, but the constructor still doesn't require any input at all
that's how these structures have generally worked, you make an instance and then set the specific attributes
do not see any reason for concern here
It's optional because as a structure, you might not have set a style on it yet. Once you do, it will be defined. If you don't, you get an API error
Context: <#archive-djs-help-v13 message>
Isn't it a better idea for the library users to define the behavior themselves rather falling back to another behavior?
define the behaviour how exactly? I'm not entirely sure what you mean by that
Like a client option?
throwIfNoGuild (bad name but)
I'm not longer familiar with Djs or Discord API anymore but I would find very hard to diagnose such issue. I would be unsure whether I'm receiving a D.js object or the raw data from the API. It's bit ambiguous and hard to test of the same function does return different structures when you call the same function with the same arguments but the library initialization parameters differs
Something like a... "inconsistency?"
I sort of agree, but theres a very specific reasons for that inconsistency, which is required to support the way slash commands work
If you have a bot user in the guild, and you provide the GUILDS intent which is essentially required to use discord.js as a bot user, it will always be a Message
If you dont have a bot user in the guild, its just the applications.commands scope, you get raw API objects
The unexpected inconsistency really only comes up when people havent fully understood intents and left out GUILDS
You can do an instanceof check if you are unsure what you're receiving
You can also construct an InteractionCollector with raw objects, you just cant use Message instance methods
I see, thus I believe it might not be a bad idea to have specific methods for each behavior rather sharing them as it would be able to report (elevate error) if there's no bot user
Making the reporting more clear
There is no methods on raw objects
That's the issue
Yes, so check what you get
How would you ensure it's a D.js object (with methods and so) or raw data from the API? It would look very ugly
instanceof
after https://github.com/discordjs/discord.js/pull/6271 we shouldn't really need to return raw objects anymore, right?
I thought of just constructing a new Message() regardless when I first implemented interactions, but the channel and guild were in the way
but now that they're getters I think it should be fine
is breaking though
v14?
yeah, personal goal for v14 is to completely separate out stuff like that, making djs far less cache dependent
So why do DM messages still need the partial to emit
Surely we can remove that now?
wait actually no
cause messages are created on the manager for the channel, we could totally remove that though and just emit with a message object lacking channel
i mean yeah, but we could emit one that wasnt if channel wasnt found
Exactly like webhook currently does?
Message#channel is a getter now but it's not marked as nullable
Why tf not
wtf
so that would be breaking too
Arent getters kinda implied always nullable gdi
¯_(ツ)_/¯
Its because our whole lib currently doesnt really work without GUILDS
I thought it was going to be nullable because people can fuck up the cache, or is that why we also did the whole "stop breaking unsupported cache modifications"
so theres no reason to mark it as nullable
Okay fair enough
and messing with channel caches isn't supported atm
welp in that case this is a dream for v14 then
any idea why default emojis will not show up on selects-menu on mobile, but will show fine on desktop?
very likely, it's the same bot code behind both interfaces. just a minor nuisance for me that some people will have emotes and some won't
Yeah definitely not library related, just a rendering issue
were there any thoughts about passing custom class type as a replacement to Structures ? ex. ```js
class ExtendedMesage extends Message {
constructor(client, data) {
super(client, data);
...
}
get property() { ... }
}
const client = new Client({
structures: { Message: ExtendedMessage }
});
client.on('messageCreate', x => { /* x instanceof ExtendedMessage */ });
typescript support might be literally impossible but i kinda fw the idea
Thats just the same thing with the same problems
because that would've been a fucking disaster
we depend on it so much that that'd have made half the library in its current state nullable
we talked about that in #archive-internal-lib-discussions and while i'm still not really a fan of it, crawl has rightly so decided to consider a non-nullable getter here
yes, consensus: no
Yeah I forgot the original issue it was resolving was just the change in type of channel
i see alright
thats what I do :)
but its tricky, some functions or properties may not work, its for my use only.
but doing that allows me to have a djs client that doesn't connect to the gateway but receive interactions via webhooks and build them like djs do. then I can use them to defer, reply etc! its just that I have no guilds, no channels in cache
so it was rendering an APIMessage (that could be a Message)
so I made a workaround for that
When is this null?
https://discord.js.org/#/docs/main/main/class/Guild?scrollTo=preferredLocale
According to https://discord.com/developers/docs/resources/guild#guild-object-guild-structure, it's always defined with a non-null value and defaults to a string
When it’s not a community I guess?
Huh
Looks like it defaults to en-US in non-community guilds yeah
Well it works as documented, apparently
I see it changed in https://github.com/discordjs/discord.js/pull/6299 but I didn't find a reason for it :thinking:, I'm thinking it should be changed back!
Oh never mind
Marked
Guild#preferredLocaleas nullable since a Guild may not have community enabled
Well this reason went untested I guess
@outer raven haiiiii, are you able to confirm the above :eyes: did you test it?
They may have changed that
(repost again)
https://discord.com/developers/docs/resources/guild#list-guild-members
I didn't find a method in djs for this specifically, does it just use the request-guild-members and not this?
my use case would be that I need to fetch a single member using the after parameter
I don't think we implement that endpoint.
What's the use case for the after parameter, out of curiosity?
probably for pagination since the response is restricted to 1k members 
Then the gateway variant, that we implement, would be more efficient.
They also mentioned a single member.
So I want to get a random member, now all the members aren't cached
I don't want to fetch every single member
let's say I'm using a giveaway command and I also need to exclude members that are new accounts, like one week or so, so my plan was, generate a random timestamp from discord's starting timestamp to last week, generate a snowflake, use that on after with limit set to 1, that way I'll only fetch a single member
that's the use case for me
I went with what the dapi docs said and they mark it as nullable, but didn’t test it no
Odd, it's not marked as nullable here. Maybe it changed?
Perhaps, I could swear it was nullable when i made that pr
use search endpoint with random letters
thats what I do but its difficult to have a good random member way without cache
Just went through all the git blames, it was never marked as nullable since implementation - I guess you should add it back x:
I could suggest to discord to add an option or sum
still need to exclude members that have new accounts
I don't get it, it's a thing in the api, so why can't I
The endpoint should probably be implemented for API coverage, but how 
Having yet another overload to GuildMemberManager#fetch is probably not wanted, so that would be in another method
Or completely break current logic by renaming fetch in request (to match with the Request Guild Members gateway command) and keep fetch for the REST endpoint
maybe have two fetchMembersOptions
I don't get what you mean by new accounts? you want to filter them?
yes, the one week example
according to which values exist, you fetch using that endpoint
Yeah it would be better to let the user choice and would fit with the current api
then yeah mine doesn't fits
That would make the method use either WS or REST depending on a property, which I'm not against but I have no idea if everyone will agree
its called list guild members. GuildMemberManager.list()
👍
wait isn't the enpoind the same
no, the one implemented uses request guild members
oh yeah right
D.js doesn't support the rest endpoint but only the websocket request, which is not the same
Sorry I can only do that on saturday, if you want you can make it yourself but it’s not that urgent since it would be semver major anyway
Yeah I guess so far they haven't seen any need for it
but since the api does allow it, why not implement it?
It would allow fetching members without a websocket connection
It's worth for some use cases
Okay so I guess the proposal right now is that this should be added as <GuildMemberManager>.list?
thats how I see it
Woud be the best, I think, to stay semver minor
Yeah that seems like a better approach than overloading the existing fetch method
tbf, the discord.js client isn't really meant to be used without a websocket connection
if you want to do that, use @discordjs/rest
but additional api support doesn't hurt
Ah don't be sorry <: I'll try to fix the regression then
Also the <GuildMemberManager>.fetch, if you choose to fetch multiple members, why is it that you don't have the ability to make it not cache the result the way you have with a singular member fetch?
I do and it works fine except few aspects that I have myself fixed on a fork
So should I work on the <GuildMemberManager>.list method?
No
<:_:874569335308431382> GuildMemberManager#search()
Searches for members in the guild based on a query.
Uses the REST endpoints
The actual list endpoint isn't very useful on it's own, we use the gateway for fetching them all
I needed it for it's after param
and since the api allows it, why not?
Eh, I guess so
So was that a yes? :D
Yeah why not
You will have to specify the type if you’re using ApplicationCommandData (with typescript) since this PR is now merged: https://github.com/discordjs/discord.js/pull/6382
yo, real quick question just out of curiosity, why does v13 now require node 16.6?
native abort controller
ah i see. cool
shouldnt the <Invite>.delete method use the proper term like <Invite>.revoke since discord mentions that you revoke invites in the invites page https://rufus.has-no-bra.in/56W2qRIME
The documentation likes to say "delete", so I guess if anything, it makes more sense on the API side
https://discord.com/developers/docs/resources/invite#delete-invite
Hm alright.
What it is ?
Oh I see, neat !
@void rivet if discord has a default, we shouldnt set one
the search one might be an oversight
yeah I was thinking that maybe that should be on a separate pr with all of the default values changed
didn't want to just change one and make it inconsistent
so what do i do?
Do I just change this, or this with the search
I am not aware of any other method that does what is being discussed right now
we cant do that sadly
since it would be semver major
but we can make sure to not repeat the mistake
and make sure your PR doesnt set one
👀
Okay 👍🏻
I'll test it first just to be sure
Should it mention that the api defaults to 1?
Guild prune does the same thing I guess, sets the default of days to 7, which is also the api default
ok you know what
that might be better for a v14 change then
lets just roll with a default then
So now I revert back to setting a default value?
😆
I'm sorry haha
I didnt think it was that big of an issue in the whole lib
Looks like well have to fix a lot on that front
Yeah np, I'm just new to github, so don't know most of the stuff, like if I can revert a commit on a pr
You can just make a new commit readding it
since we squash commits anyway
so in the end it will be 1 commit regardless
Okay but in the previous version, I didn't add a default value for after, do I just not touch it or add 0 for it too?
https://discord.com/developers/docs/resources/guild#list-guild-members
nah we can leave that
okay made a typo along the line, now it should be okay, thanks again
I'll also look for more like this where it sets the default value despite the API already having one
okay so according to my search,
prune does it for compute_prune_count too, I didn't find any more
there is ReactionUserManager.fetch
it mentions it in the docs, that it by default fetches 100 users whereas the api default is 25, why is that?
https://discord.js.org/#/docs/main/master/typedef/FetchReactionUsersOptions
https://discord.com/developers/docs/resources/channel#get-reactions
edit: i get this now, fetch() without arguments fetching as much entries as it can makes sense
I noticed that the repo uses eslint + tslint. Is there a reason why both are still user as tslint is deprecated since eslint can do all the work now?
@typescript-eslint doesn't lint declaration files from what I heard
Hmm, not enough an expert for that xD
Not necessarily an issue but why is type optional in:
export interface BaseMessageComponentOptions {
type?: MessageComponentType | MessageComponentTypes;
}
Did a big ol' refactor, bot starts just fine then boom:
TypeError [INVALID_TYPE]: Supplied data.type is not a valid MessageComponentType.
at Function.create (/BLEH/node_modules/discord.js/src/structures/BaseMessageComponent.js:86:17)
I left off type: 'ACTION_ROW' because the types didn't tell me I needed it...
Curious as to what case the MessageActionRowOptions would work without said type because of
export interface MessageActionRowOptions extends BaseMessageComponentOptions {
components: MessageActionRowComponentResolvable[];
}
Because when you use the builder classes, new MessageActionRow() etc, it internally sets type
And thats really what those options are for
But if youre not using the class and just writing an object, its required
Otherwise youd be writing new MessageActionRow({ type: 'ACTION_ROW', components: [...] })
Ah so MessageActionRowOptions should probably be export interface MessageActionRowOptions extends Required<BaseMessageComponentOptions> {?
Assuming that MessageActionRowOptions is the 'write it yourself without the class' variation (based on components?: (MessageActionRow | MessageActionRowOptions)[]; from MessageOptions)
no, MessageActionRowOptions is the parameter for the MessageActionRow constructor where it isnt required
arguably it should probably be components?: (MessageActionRow | Required<MessageActionRowOptions>)[] to make the parameters required when passing the object
and that would allow it to remain not-required in the interface for the constructor
👍 Makes sense - The impl could detect the 'object' style and run it through the new MessageActionRow automatically as well?
Nah it really shouldnt
Whats the benefit of that?
Well actually, it does do that
But it can only do that if you set the type
If you dont, it cant possibly know that it should be run through that specific constructor
So in MessageOptions['components'] you can pass things with a different type than ACTION_ROW currently?
Otherwise it should probably be doing something like rows.map((row) => row instanceof MessageActionRow ? row : new MessageActionRow(row))
Note that this is a genuine question, I don't know if there are other things you can pass currently but the types imply that you can't pass anything else at least 🤷♂️
At the very least, the type should stop me from getting the runtime error so I'd be fine with any change in that direction lol
There are instances where the lib uses the same default values as the api tho which is not good
Thats literally what I was saying
No but I remember you saying we should use the api’s defaults and never hard code them
And that’s done on some occasions
yes
Not many tho
Think about it for a bit
Well if you have the same default value as the api and remove that default from the lib its the same
Not currently. But hardcoding it to a row makes no sense if ever Discord changes that
And if discord ever changes it while we would still be on v13...
But you don’t release a new version when discord changes a default
- i doubt they’d be changing the default days to prune inactive members which is what I’m talking about
likeliness doesnt matter
and yes we dont
thats the problem
it would then be undefined behaviour
But if nothing else in the lib does this then why does this method do?
theres more
And a lot of those things are remnants
it just so happens that this was the way we did it in the past
and since the last major no one noticed or bothered
No, it can’t be changed until v14
Yeah ik
search is also one of them iirc
But it can be changed thats what im saying
GuildSearchMembersOptions?
yes the limit is by default 1
it does the same for GuildMemberManager.prune, there's default values that's the same as the API's default
https://discord.js.org/#/docs/main/master/typedef/GuildPruneMembersOptions
I guess that makes sense. Seems a bit strange to not do something 'just in case' discord changes it as they've not mentioned anything about changing it but - I'll just wrap message sends in my own function that does it instead as it's a buttload of boilerplate currently 🤷♂️
You can't just set the type of the component?
And that’s exactly what I’m saying shouldn’t happen
releasing a major version just because you made a dumb design decision in the future seems a lot more dumb
I mean, you could quite easily support something new without making it a breaking change - i.e. if no type is passed then assume its a MessageActionRow but if a type is passed then do what it currently does with the Base class.
It's far more dumb to make an API decision based on something that 'might' happen...
Also, you're aware feature flags exist? Let people opt in to 'breaking' behaviour rather than forcing major updates in 'big bang' style
I'm glad you don't design this lib
Because passing a type requires you to then use completely different syntax, completely alienating the interface
That's exactly why we removed the nested array syntax, which I liked but made way more sense to drop
I mean, the array syntax made complete sense to me because the current API onky supports Message action rows. If discord update their API to add a major new feature I wouldn't be surprised to see an update in Discord.js - but you can very easily support multiple variations without having to make breaking changes and/or adding feature flags to let people opt in in advance to allow for easier migrations.
Honestly after comments like this I'm glad I haven't tried to contribute. I asked a question and made suggestions on how you might improve your API from the perspective of someone using it. You literally called me dumb - thanks for alienating another experienced developer 👍 You do you I guess.
I'll stick to overriding your types and wrapping your broken API and types to make my life easier rather than suggesting improvements in the future.
I called it a dumb design decision, because we made it ourselves and the whole premise of locking ourselves into a corner dumb.
Stop being so offended over something that wasn't even directed at you.
And you are welcome I guess.
'Im glad you don't design this lib' hard not to take offense from that ngl. But you're right - I'll be the bigger man and clarify what I was trying to suggest.
Basically what you're doing is making your lives easier (i.e. developing d.js) and as a result making everyone else write more code.
In this particular case, it would have been very easy to retain the nested arrays API then use type checking to determine whether 'whatever new thing' discord might add in the future should do.
If that code is too complex or adds a performance overhead or is overly complex, you instead hide it behind a feature flag on the Client constructor to opt in to the behaviour to let people change things gradually rather than forcing a huge rewrite with every one of your major releases.
Obviously that's too late so we'll have to live with it but maybe at least consider the people using your APIs in the future. Discord.js has so far been one of the worst libraries I've used for upgrades because it's all or nothing. V13 is the exception of course because you basically seem to have rewritten the entire thing so I expected a rewrite but you could definitely work on making it easier to upgrade/migrate in the future.
Ignoring all the migration stuff, you should at the very least be changing the types to prevent people hitting a runtime issue by omitting the type: 'ACTION_ROW' - after all, that's what Typescript is really for
Yeah, and we decided against doing that.
Theres nothing wrong with that, as much as there might not be anything wrong with your suggestion in eyes of other people or yourself.
You now throwing insults around because I disagree with you is simply some nice /r/niceguys material
So if you have nothing constructive to say anymore, keep it out of this channel and take it to #archive-offtopic
Doesn't having different sets of features determined by a param in client options kind of make it so that lib devs have to maintain both ways? With added bonus that the usage isn't uniform anymore because it depends on an arbitrary switch?
It does indeed - It's a small amount of temporary overhead until the next major release where the 'old' way is removed along with the feature flags and the 'new' way is left as the only way.
It's standard practice in most large libraries
wait, but, if you're talking about interactions, they didn't exist at all in v12, so there is nothing really to maintain backwards compat for
Yes - and I addressed that with 'V13 is the exception ...'
I was pointing out for future changes as there's nothing that could be done to the current API without a breaking change 😉
and in terms of v13 alone, that would mean that we would have to design things fast and care about how to implement new things when they come out, instead of having a relatively clean way of adding new features later on without the need to change any usage at all
So what is your point? The what you call "feature flags", or also just referred to as deprecation of features, is something we have been doing all the time
It just so happened that interactions never existed and we went with a bit more verbose syntax.
Go listen to the message event, youll get a nice warning. It's also deprecated in the docs. Its no different to the new messageCreate event. Thats something we've been doing actively since like version 8 of this library.
feature flag = opt in to new behaviour for existing option
deprecation = existing option/behaviour going away with warning
Same principal though
I understand what you've done with the verbose syntax and why you've made those decisions. The point does still stand R.E. the runtime issue because of the type
I see no issue open about it?
Nor a reproduction case
We can't know or see bugs if no one tells us
channel.send({ components: [{ components: [aButtonComponent] }] }) = throws an error at runtime
I asked about it here because I wasn't sure if it was a bug or if I was being stupid #archive-library-discussion message
This lib isn't written in TS either, so typings being more buggy than not is a lot harder to fix and spot since we don't run through TSC
If Discord introduces some other type of row, sure its technically not breaking, but its a bad user experience to sometimes have to specify type and other times not
Ah, I haven't looked at the source and I incorrectly assumed it was written in TS - That would explain it
We were right in the first place - passing objects directly should be Require<MessageActionRowOptions> to enforce the type param, since its required
Thats the real solution here to it not asking for type when it should
Not necessarily - As long as the type information (and documentation for non-TS users) defines what the components expects to be passed it doesn't really matter if it supports n different types.
If the 'default' were ACTION_ROW for instance that would make sense as you either have ACTION_ROW or you specify the type. As said, I'm fine with the Require change - as long as the types stop me getting runtime errors we're golden 😛
Its not up to us to decide ACTION_ROW deserved a default over anything Discord might provide in future either
I get what youre saying technically speaking for types, its more about UX and expectations
Yeah, I get that - Fundamentally the issue here is just a disconnect between what the lib expects and the types. Easily fixed, ima go back to my bot now 😂👍
Yeah I think its more accurately fixed by making it required in object params for send
Not sure if I should ask about discord-api-types here but when would APIUser.bot be not provided? TS says its an optional param
I think it's only provided for bots.
ah alright
Does this new announcement of unique custom ids mean, that we have to generate evertime different ids? On each message?
I assume it's per message.
So you can reuse the same id on different messages.
Does discordjs have a way to create user commands (actions you can take from a menu when right clicking on a user)?
Yes
Could you possibly reference the relevant location in the guide docs? I haven't been able to find it.
Since it's an application command, for example, here: https://discord.js.org/#/docs/main/stable/class/ApplicationCommandManager?scrollTo=create
https://discord.js.org/#/docs/main/stable/typedef/ApplicationCommandType
Thank you space. I was trying to find it in discordjs.guide
There's some more relevant info in #archive-context-menus pins, if you have any more follow up questions pls post them there instead 
And we'll hopefully get a guide page up for it soon
Oh, I should have just linked to there. 
Thank you, will do. I have one more question, I'll ask in slash commands.
I'm just waiting for builders since the guide relies on those for interactions
nvm misread
Global commands have inherent read-repair functionality. That means that if you make an update to a global command, and a user tries to use that command before it has updated for them, Discord will do an internal version check and reject the command, and trigger a reload for that command.
https://discord.com/developers/docs/interactions/application-commands#making-a-global-command
Does that mean it's possible to artificially "force reload" a global command without having to wait the 1 hour fan-out?
well itll only update in the current guild
right
so i guess that means: from the perspective of a user who's using a global slash command, i'll never run into a scenario where i'd have to wait for the "new" version of a slash command to fan out for my guild
not really but it might fail a few times
until its updates
its not guaranteed to be fast-tracked after the first failure
i wonder how discord handles the error message in the event that the global command hasnt updated yet
oh, maybe this is one of those "interaction application command failed" screenshots that i've seen in #archive-interactions ?
yes
When I do 2 commands with the same name and different type for example slash & context menu user and use the PUT method it doesn't work and throws the error Application command types are immutable. It's an API-Side bug, right?
yes
So for now, I guess I have to solve this by using the POST method.
yes
Well thank you, because I'm adding support context menus to my package so at least I know I can't solve a better rate limit yet
any plans to move from node-fetch? maybe https://github.com/nodejs/undici? would the change be considered semver major?
Why would that be necessary?
It's official, much faster and has a nice api so why not?
What does "official" mean here?
The only "official" HTTP module in node is the native http
What might actually be worth moving to is phin - it has the exact same API as node-fetch, just a way smaller size.
We don't care about bundle sizes, node-fetch is a defacto-standard and very used package
Suggestion: Helper getter TextChannel#messagable similiar to TextChannel#viewable or TextChannel#managable
if (this.client.user.id === this.guild.ownerId) return true;
const permissions = this.permissionsFor(this.client.user);
if (!permissions) return false;
return permissions.has(Permissions.FLAGS.SEND_MESSAGES, false);
- Not limited to
TextChannelthough. A better name could also be used instead.
sendable ?
get sendable() {
if (!this.guild || this.client.user.id === this.guild.ownerId) return true;
const permissions = this.permissionsFor(this.client.user);
return permissions?.has(Permissions.FLAGS.SEND_MESSAGES, false) ?? false;
}
With a !this.guild typeguard that could fall into TextBasedChannel to be spread into all text channels (guild/non-guild)
But we still use permissions where we shouldn't, I mean it would work but it looks terribly unsatisfying to my eyes
That said, it won't even be right as I make it say true for DM channels, but we can't know before having tried whether or not we can send messages in DMs
So that would only be a prop for guild channels that are text-based, but there are no classes that represent them
Which would mean that would have to be duplicated in Text/News/etcChannel
Or just return null for dms, idk
I'm dropping this here because of the recent node-fetch talk: node-fetch is moving to become an ESM module only in version 3 (already happening in 3.0.0-beta.10) which I believe will enforce that on us if we ever upgrade to version 3. :eyes: note note
Then we'll stay v2, no biggie
Remove self bot ability
which version does the documentation show in stable? https://discord.js.org/#/docs/main/stable/class/CommandInteraction
apparently there's no .deferReply() method?
but main does show .deferReply() https://discord.js.org/#/docs/main/main/class/CommandInteraction
which doc is more reliable then? i'm assuming main points to the main branch in the repo, correct?
main and stable are branch names
main was master earlier
so main will be "newer" than stable, but also won't reflect your state if you just use stable version from npm
if i installed with npm i discord.js then that points to stable version right? so that means it's supposed to be 13.1.0 right now
yes
isn't the documentation auto generated from the codebase? how can this inconsistency happen unless it was manually updated?
it is
but source code is not auto generated, but written by humans
might be related
ah i see
so the actual method was changed to deferReply but the comment was not, so the docs wasnt generated properly
docs were generated from source code, properly
it's just that the source code was missing something
there are few places where everything has to be set, not exactly hard to miss one
usually doesn't happened, and gets fixed quickly
at this point ive encountered enough inconsistency in the docs that i'm starting to feel more inclined to reference the actual package inside node_modules/ xD
thanks for the quick replies tho
typings are usually more likely to be correct than the docs, but if you notice inconsistencies then you should open a PR or issue
Well, they're still more likely to be updated than the jsdoc. Obviously it's not a guarantee still
not really, but whatever
This particular change happened because I moved those documentation stubs to BaseCommandInteraction, but at that same time a PR to rename it landed. Because I was moving the lines it didn't get correctly reflected in my rebases
I was wondering if it was possible to represent the complex union types from typescript definitions in the jsdoc. I feel like it would improve some ambiguity.
Not sure where to post this, but it seems like it belongs in here since it has to do with what discord.js exports
There's this note in /typings/enums: ts // These are enums that are used in the typings file but do not exist as actual exported values. To prevent them from // showing up in an editor, they are imported from here instead of exporting them there directly.
Yet vscode says I can still import it. I assume that's not intentional? I'm using typescript, but I think I shouldn't import this anyways since it seems like an internal thing that could change frequently.ts import { ApplicationCommandTypes } from "discord.js/typings/enums";
It’ll cause a runtime error if you import enums like that
You need to use the exported Constants object
Ah ok
hey uh so not sure what's going on here. I know this isn't a help channel but looks like an internal error
https://github.com/discordjs/discord.js-modules/blob/main/packages/rest/src/lib/RequestManager.ts#L51 think the problem is here
I assume import { URLSearchParams } from 'url'; this would fix it
did you install @types/node
hmm ill try that
we used to have 1 interface for slash command options, who thought this would be a good idea?
I have 1 function to transform all options from all of my commands into a different thing and I can't possibly know which one of those interfaces they correspond to
can we bring back the old interface and get rid of those?
seems like it was caused by #6247, did anyone test this properly? 🤔
I think this property should only exist on BaseGuildTextChannel similar to how BaseGuildVoiceChannel#joinable exists.
npm ERR! node-pre-gyp http GET https://github.com/discordjs/opus/releases/download/v0.5.3/opus-v0.5.3-node-v93-napi-v3-win32-ia32-unknown-unknown.tar.gz
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/discordjs/opus/releases/download/v0.5.3/opus-v0.5.3-node-v93-napi-v3-win32-ia32-unknown-unknown.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for @discordjs/opus@0.5.3 and node@16.6.1 (node-v93 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/discordjs/opus/releases/download/v0.5.3/opus-v0.5.3-node-v93-napi-v3-win32-ia32-unknown-unknown.tar.gz```
checking the type actually exposes its properties. idk if this is helpful or not but I made a similar function
private _transformOptions(
options?: ApplicationCommandOptionData[],
): ApplicationCommandOptionData[] {
if (!options || !Array.isArray(options)) return [];
return options.map(option => ({
type: option.type,
name: option.name,
description: option.description,
required:
option.type === 'SUB_COMMAND' || option.type === 'SUB_COMMAND_GROUP'
? option.required
: option.required ?? false,
choices:
option.type === 'STRING' || option.type === 'NUMBER' || option.type === 'INTEGER'
? option.choices
: undefined,
options:
(option.type === 'SUB_COMMAND' || option.type === 'SUB_COMMAND_GROUP') && option.options
? this._transformOptions(option.options)
: undefined,
})) as ApplicationCommandOptionData[];
}
I have to transform 1 option at a time but this seems like a good approach, I'll try it out thanks
? This is a warning that we do not have prebuilds for opus yet, which is fine, as it'll build on your system instead
Answer is no. It's the same reason as to why -types has lots of unions. Strict typings 😃
Tho I see there's some other issues with it soo
but then we can't use these types to make interfaces of our own easily
@wild flax about my import error with ESM, it's because I use my fork but I don't build it when installing. I don't get what is the build script of the lib, prepare doesn't seem to be the one and I am still having the error after doing install in the folder
if you know how I can fix
my postinstall script for now is "postinstall": "cd ./node_modules/discord.js && mkdir -p .git && npm install"
you should make it be npx gen-esm-wrapper src/index.js src/index.mjs iirc
basically like what the prepare script it
so prepublishOnly script then?
yes
but no need to run the tests
and you need to do npx anyway
since you prolly dont have our dev-deps installed
I think ye
so gen-esm-wrapper src/index.js src/index.mjs is enough?
ok nvm I read it wrong lol
thanks i'll try it out
yay worked 
Hi, I'm re-posting this from #archive-interactions because someone suggested I asked this here, hope it's not an issue...
Question about subcommands: as of now, Discord allows you to create a subcommand and a subcommand group at the same depth level, like this:
command
|_subcommand_group
| |_subcommand
| |_subcommand
|_subcommand
|_subcommand
This is not explicitly allowed in the docs, but if you try registering a command like this it'll work, and you just receive the used command options in the interactionCreate event
Is this behavior actually allowed or is it something that works even if it's not supposed to? If it's allowed, why does the @discordjs/builders library prohibit this kind of nesting (at least through the typings)?
I'd assume Discord allowing that is a bug and not intended.
Yeah that doesn’t seem like it is intended
Got it, thanks guys
Completly forgot this class existed lol, well yeah that's definitely its best place to fit in
Opened the PR. Mon doesn't seem happy.
#6444 in discordjs/discord.js by WiseDevHelper opened <t:1629023866:R> (review required)
feat(BaseGuildTextChannel): Add BaseGuildTextChannel#sendable getter.
📥 npm i WiseDevHelper/discord.js#feat/channel-sendable
Well imo I'm completely neutral of this, I mean it's a simple permission check but it can always be useful, and considering all the existing similar getters, this one has no reason to not get implemented
Either this, or get rid of all manageable/bannable/etc getters.
There's more than a simple permissions check involved in some of those getters. I was in favor of removing a lot of them, but they're useful because they cover stuff that's more than just "do I have this one permission"
I remember a discussion with @wild flax where he said he preferred tabs over spaces, isn't it about time the whole lib is refactored to use tabs?
No
why not I mean almost everything else djs related uses tabs at this point
Because its a disastrous diff
Spaces are much worse for accessibility
ye but it will be done eventually right
Eventually
After seeing reactions to the permission helpers PR’s. I was wondering if instead of tacking these helpers onto the classes themselves, new ones would be moved to a static permissions utility class instead. I.e. ChannelUtil.isPrivate(channel)?
this is intended; the docs just don't have an example of it
builders not supporting that is an issue
Why is the ClientPresence class not documented nor present in the typings?
Because it's an implementation detail, it should probably be private in the docs too.
thing is it's not even private, it doesn't have JSDoc comments and it's not declared in the typings. Same for Client#presence
^^
well yeah it's fine for it to be private, but it's not fine for it to be undocumented
no methods are documented and it's not on the typings
It only has one method that arguably should be internal too, set
Its missing {@extends Presence}
Which is where the actual methods should be
@solemn oyster easy:
Make code clear, doing proxies and functions referring to other functions is one of the worst things you can possibly do. It's easy to get large memory footprint if near every object points to few other circular references making it's not only tough to parse but also easy place for memory leaks.
Another thing that is really annoying is how big D.js actually is. I would love to see something like from https://github.com/detritusjs/client where you have multiple packages so you download only what you need. D.js in v13 finally removed voice support from main path but it still support a buch of crap.
Next thing is memory management. I have no idea who had idea of storing everything in Collections. They are cool to use - true, but they leave huge memory footprint at scale.
D.js code looks like you would totally not care about performance at all, just make it work and leave standalone.
where you have multiple packages so you download only what you need
That's already in the works
👀
That's our first step, we'll soon work on @discordjs/ws as well, once we finish the new tests and the cache wait opt-out
Man you are the whole circus and every clown in it
Cause I care about performance while using Node?
Your constructive criticism comes from "launch some benchmarks" and "all big bots use eris"
Which are bot invalid statements right there
Barely any HUGE bot uses JS in the first place lol
And what d.js shown then?
Yea, mudae who burns crap ton of money to host it
We are this popular and this hugely used because the majority of bots are not HUGE bots, and that is simply what we focus on the most 99% of the time
I'm still not seeing any constructive suggestions for improvements, which is what you were redirected to this channel for. Continuing to make criticisms seemingly just for the sake of shitting on djs will not be tolerated here
Tatsu, Atlas, Dyno & Rythm are using Eris. Dank Memer is slowly being rewritten on Eris.
Idk about other
Mudae & Karuta used D.js
.
Biggest D.js pain is that it's pretty in cost of efficiency




