#archive-library-discussion
25085 messages · Page 6 of 26
Inversify comes with their own helpers for JS, like a decorate method: https://github.com/inversify/InversifyJS/blob/master/wiki/basic_js_example.md
so we could either use inversify, or just write our own decorate helper
Its not nice, but i mean thats what you get when you write JS
If we stick with tsyringe we could prolly just straight up copy this: https://github.com/inversify/InversifyJS/blob/6ef0ddf76093e97fd3d302c16905daa5c418db9c/src/annotation/decorator_utils.ts
nvm we dont even have to
we can just use Reflect lmao
I mean, you dont really need the decorators
require("reflect-metadata");
const { injectable, inject, container } = require('tsyringe');
class CustomChannels {
test = 'test2';
}
container.register('CUSTOM_CHANNELS', CustomChannels);
class Channels {
test = 'test';
}
class Client {
constructor(customStructures) {
this.customStructures = customStructures;
// kinda fucky wucky idk
this.channels = container.resolve(this.customStructures.CHANNELS ? this.customStructures.CHANNELS : Channels);
}
}
const client = new Client({ CHANNELS: 'CUSTOM_CHANNELS' });
console.log(client);
wait so you dont need to mark them as injectable?
I thought that was a requirement
you do, by using register
only if they actually need to.. inject something
oh, am I misunderstanding the decorator too?
oh, and since we need users to register it anyway... I guess that makes sense
I thought @injectable did implicit resolving so you didn't have to do @inject on every parameter 
yeah nevermind, it makes sense now
uhhh yeah dd is right, but I guess as long as we dont do that?
either way you can just fall back to container.resolve in the constructor
we need to always resolve anyway for all custom structures
am I? I can't even tell anymore.
oh, that's right
@inject all the parameters.
Class decorator factory that allows the class' dependencies to be injected at runtime. TSyringe relies on several decorators in order to collect metadata about classes to be instantiated.
buut, if I'm not mistaken, you can just do
injectable(CustomChannels)
and get the same result
@wild flax whatever we use, we'll need something to auto-inject or something
is there a reason to use DI over Structures.get/extend?
Yes, Structres.get/extend is budget DI
Yeah, the current structures are ass
Client for example is something that needs to be able to resolve in all structures
what are the advantages of using "complete DI" over "budget DI"
Structures arent DI
thats why i said budget DI
We just hack together JS to make what they are right now
yeah.. it may look "clean" on the outside, but internally the current structures system is very difficult to navigate and understand
whatever they are, they seem to work fine rn. are there any major shortcomings with them?
hmm
this is similar to a lot of things in the package, for that matter
such as actions
nobody has any idea how they work anymore
Yeah, it won't be achievable like this in TypeScript without a lot of Type-hacking
And its certainly just a pain in the ass
We still need to augment modules, regardless of whether we use DI or not
what I dont get rn tho, what about the types?
lets say you extended Channels, message.channel would still have the old type, no?
thats why you have to augment
do you have to augment even with tsyringe
yes
Logically, yes
TypeScript doesn't have anything to do that automatically, types are static, not dynamic
To be honest, I hope we go for resolving the client in all structures on demand, rather than storing a reference to it as a field in all of them
that only works well in TS
We can always make our own solution if you want
So it works well for both JS and TS
You make it sounds so easy
I mean... nothing stops us from doing```ts
import { container } from 'tsyringe';
import { Tokens } from '#lib/util';
export class Base {
public get client() {
return container.resolve(Tokens.CLIENT);
}
}```
was looking at the Rest impl and have you considered making it an interface so people can use custom rest instances? https://github.com/discordjs/discord.js-next/blob/8a0f8cc547927dc5e6699c8fd9cda341b980a4a0/packages/rest/src/lib/RequestManager.ts#L126
Why would you?
big bots who microservice parts of their code would find it very useful, and i don't see a reason not to make that an option
?
You dont seem to understand -next very well
You can already use the rest package independent
It's not REST what you want to edit, Stitch, it's RequestHandler, which implements IHandler (see https://github.com/discordjs/discord.js-next/blob/8a0f8cc547927dc5e6699c8fd9cda341b980a4a0/packages/rest/src/lib/RequestManager.ts#L124)
that's not what im talking about at all...
And that
okay yeah that's a better answer
REST is just a controller, but the hard work is done in IHandler
Yeah its just that your explanation why you want it modifiable didnt make much sense
the tsyringe container would be global tho?
wouldnt we need a new container per client instance? (or what is the "defining" instance in -next)
well handler is just a request handling strategy right? as-in burst or sequential?
Generally, DI containers are global
And... what even is your use case for more than one client per process?
thats not what im talking about kyra, im talking about REST being an interface so people can use their own controllers (maybe one could proxy requests to a server that does ratelimit handling, like spectacles' proxy)
I'm talking to CHY, sorry
i was replying to this
so as soon as I use tsyringe for my own stuff I would mess with the container that d.js uses.
anyway, you probably just wrote this down quick, just wanted to notice that we need own containers for d.js (or "defining" instances? idk)
If you want to make your own REST, just do so, Stitch
Well we would generally use Symbols when registering stuff in our container, so its impossible to overwrite our stuff
If you make a class extending REST, e.g. StitchREST, RequestManager#rest would be an instance of it, per: https://github.com/discordjs/discord.js-next/blob/8a0f8cc547927dc5e6699c8fd9cda341b980a4a0/packages/rest/src/lib/REST.ts#L74
Except you use the exact same symbols
okay cool, that works
LGTM on the usage of symbols for this
SequentialHandler
I'd rather not allow that, because ratelimits are the number 1 thing that WILL get you banned temporarily or permanently from Discord if done wrong
IF we want to truly make REST extendable, the interface needs to be VERY strict
technically i can already do that extending REST, can't i?
Unless you overwrite the RequestManager's function that returns a different handler, no
that would mean going down the chain
even then
what you need is to just change api endpoint
to your proxy
and leave the rest to us

the point of the proxy is it handles ratelimits, not whatever process that is using it
yeah and?
You forward all requests to the proxy
and return some form of headers that just tell us we can keep requesting (limit 5, remaining 5, boom done)
okay fair enough i guess
const proxiedRest = new REST({ api: 'http://localhost:1234' });
proxiedRest.get('/gateway/bot');
the one proxy that im referring to returns no ratelimit info
so it wouldn't work with your proposal
we have defaults anyways
are they set to zero for everything? XD
// Update the total number of requests that can be made before the rate limit resets
this.limit = limit ? Number(limit) : Infinity;
// Update the number of remaining requests that can be made before the rate limit resets
this.remaining = remaining ? Number(remaining) : 1;
// Update the time when this rate limit resets (reset-after is in seconds)
this.reset = reset ? Number(reset) * 1000 + Date.now() + this.manager.rest.options.offset : Date.now();
Infinite limit, 1 remaining, if no headers are present
so basically
handling ratelimits in the rest manager would defeat the purpose of a proxy
it'll work just fine
Thanks
If Stitch is talking about a proxy proxy, and not a cheap "proxy", we currently don't support them if you think about it
I don't recall any place in our code taking an https.Agent instance (which iirc is required for proxies to work)
I mean there is no point
its not even how spectacles works
you dont use spectacles REST with spectacles proxy
you use only spectacles proxy and write your own quick rest handler
yes
and if i wanted my d.js bot with it, that wouldn't be possible if the d.js rest-handler is enforcing ratelimits itself
...?
Stitch
Why would you do that?
you do understand that, if no headers are present, it'll just...not..deal..with ratelimits right
A limit of Infinity and remaining of always 1 means it'll just pass through
ah is that so? nice
Thats like me saying, I have the same bot on an eris music bot, but all the other functionality on a d.js bot
Why cant I use the same proxy?
Thats such a weird request
it's not as weird as you make it out to be. kyra, for example, wants to microservice everything Moderation-related from skyra. if the new service is doing anything REST related, it's gonna need a proxy for both applications to keep track of ratelimits
Yes, but he uses libraries that are meant to work that way
You can't shoehorn this solution
Its the reason I use spectacles, and not a mix of spectacles and djs and eris
I just have a single message broker for example that makes sure all things go into the correct proxy
If we'd support every use case for this, this would mean our "unknown error" ratio would go through the roof because we can not guarantee someone doesnt mess with something we have no control over and suddenly want support for it
but wouldn't -next's rest handler being customizable be a good solution to this? it uses the proxy, and we can still use all the convenience methods d.js provides. and if vlad is right, we can do that already
I don't think you understand how this works
If you want multiple bots to proxy into a single ratelimit, you would build a server that WRAPS -next' rest handler
And then make requests to that wrapper
Not the other way around
yes, and making REST an interface would solve that?
Thats exactly how spectacles works
No?
How?
You wouldnt need any of the rest handlers logic
The proxy handles that
You just blindly fire request to the proxy, doesnt matter what it is
lets assume REST is an interface with get(), post() and put(). i implement it to send http requests to my proxy server, which then does the actual ratelimit handling.
No, crawl, what Stitch wants is to forward all requests done through -next's rest to some local endpoint, to a global "proxy" (in go or otherwise) that handles the rest
I understand that
which, as I said, is already doable
But thats unneeded
that way i can use message.channel.send() and it works with my proxy 😉
...
Yeaaaaah, thats exactly what I meant with shoehorning a solution
Y'all ignoring me intentionally? Stitch, just override the api endpoint. That's all. If your proxy runs and it catches all requests and works PROPERLY (do note its your responsibility if you fuck ratelimits up and get banned), d.js will just pass requests on
or rather, not d.js but -next's rest
IN FACT, the EXACT SAME is possible right now in v12
Same logic
yes vlad i gotcha, i did mention you said it was already possible
override the api base
You talk about microservices but say stuff like message.channel.send when you wouldnt even theoretically have a cache like that in mutliple services because its not feasible
that wasn't the point, the point is i can continue using discord.js' REST functions with my own proxy and handler
you
dont
touch
the fucking
handler
You strictly change 1 option
yes vlad i get it, don't worry
If it wasn't the point don't bring up the points of microservices
now you're just taking whatever i say out of context, im not continuing this, especially since the "issue" is already resolved anyway
If you continue to dismiss the claims that proper microservices do not rely on a monolithic library like d.js to properly function and just try to have it your way, go ahead.
You brought examples into this with skyra that have no foundation because its simply not how you would even design such a system
My opinion on this is that we shouldn't go too much overboard, -next is still very young and while many things are in the design stage, most aren't even in that step, naturally, -next will evolve with time just like any other OSS project
¯_(ツ)_/¯
if you say so, sure
I personally think that having a functional REST package that works for the typical case, is priority
We can enhance it later with things we might need in the future, but as for now, we aren't very sure about everything
Nah, its easy, just do it
Don't worry.
I'd say give the new REST a shot once it's released, and if you can find a solution (Crawl and Vlad proposed some) that works for you, then you don't have anything else to worry about
Kinda like what I want, a handler that spreads out requests evenly in the reset window (so if we can do 4 requests a second it'd spread them out as evenly as possible), but thats offtopic
doing some personal testing, exporting a class also exports the built in interface for the class
^ conversation relating to the ts recode and exporting interfaces
There are chances that we might keep Structures, mostly because it's the polar opposite of DI
The only feasible alternative a friend of mine (who's well versed in DI and many other programming patterns) was the transformer pattern, which is basically the same as Structures but less optimised and bulkier
@tacit crypt @unique axle my point with the PR is to e n f o r c e the consistency, not just change all cases into using the same bracket type (have no idea how to word this).
With the PR in place it means: route building is property access, requests are function calls, no way for it to be confusing like that.
Currently (even with the PR), you can still use .guilds(id), so if the PR gets merged and turns out I missed some changes, the library won't break.
When we're sure that all places use the correct way, we can make it error - e n f o r c ing the new style.
To be honest, I'm unsure if we'll go for that path, we can very well replace REST with -next's once Smugen's PR lands (since we need the other changes)
^
I'm more in favor of x.y.z.post(), x.y(id).z.post() or x.y(id).z(member).post() than any other variation
unenforced consistency
I think thats a pretty consistent pattern
Would it be a good idea to add some sort of error throw on GuildMemberManager#fetch if the correct intent isn't enabled?
wouldn't that be done on api side already
it'll just timeout
Could Message#authorID be added for partial messages?
hmm .. i mentioned something similar yesterday to be used with Guild#owner, suggesting it should be GuildMember | PartialGuildMember. the only 'valid' property of PartialGuildMember is id and it has a fetch function similar to GuildMember#fetch
perhaps the same thing could be applied here? PartialUser where only id is valid with a fetch function?
what's the reasoning for Message? seeing that both user and member data are included in the message payload?
does running .fetch add to its respective cache?
yes
unless you pass false to the cache parameter
@unique axle author.id is known in MESSAGE_UPDATE, so I can save an api call by using it on the partial structure and not fetch it.
all i need there is message.id, message.authorID, message.content
which I should not have to fetch
discord always sends an author object, not just an author id
so whenever djs has a message it should have an author object
so authorID would never be present if author.id isnt
It doesnt use the API, it uses the ws opcode
Huh
Oh, hm
@oak quail but it is not
when message.partial is true, message.author.id throws cannot access id of undefined
well that means that djs is constructing a message object from just an id
why though
Try enabling user partials, @snow crypt
Still (node:7640) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of null when message.partial
The docs says otherwise
Unlike [message] creates, message updates may contain only a subset of the full message object payload (but will always contain an id and channel_id)
https://discord.com/developers/docs/topics/gateway#message-update
yes, no
I have edited the literally oldest message I could find in a server (which is only 1.5 years ago, but still not very new), and MESSAGE_UPDATE (using client.ws) emitted with author
Was it a webhook message?
no
Can you show the data object?
well i can redo it in a moment

well in that case you... still wouldn't have the author id
nothing djs can do about that
yeah fml
see above the raw event with author.id and then messageUpdate where newMessage.author is non-existent
@copper garden
Apparently the author prop was left out in the client.actions.getMessage function
Looks like the method assumes that it'll either get a message object like { message: Message {...} } or just { id: "...", channel_id: "...", guild_id: "..." } (partial message)
We looked into this the other day, getMessage doesnt pass the author to getPayload
and.. is that intentional?
Probably not 😄
@ruby terrace I don’t see how that our job to maintain lol
And as I read that, several other libs decided against too
It's not something that the library should handle automatically, it should be a developer choice, but the developer currently can't make that choice
Huh
I would argue it’s discord’s fault and that’s it
We do exactly as it should work
It just so happens that discord fucks up
I can't think of one of the top of my head, but there is a point to be made for a use case where you do want to change solely allowed_mentions.
I know this is a stretch, but maybe mentioning a user, but disabling the highlight afterwards.
That seems very cosmetic at most
Which would fall into the argument of a noop IMO
Editing with allowed_mentions is always going to be cosmetic, even with content come to think of it
I’m not against a fix, but I sure wouldnt put any high priority on it
I wonder if it affects the inbox
I'll get back to you on ^ but yeah, this falls squarely on discords end as this probably wouldn't need to be used if suppressing embeds didn't reset it. Replies make it more prevalent, so it might get pushed up on their priority.
When this is approved: https://github.com/discordjs/discord.js/pull/4879 does that mean this can be approved?
Once v8 api lands, if interactions pr is done we can review it, and merge it after reviews are done
and provided discord doesn't decide to just... annihilate it with changes, because after all it is still a beta
those prs dont really have anything to do with each other
one won't be happening before the other, that is as far as "having anything to do with" goes here
We mentioned several times that interactions won’t land before the v8 upgrade
So yeah, the v8 upgrade is a blocker for a lot of PRs
finally, that delay is being removed
i thought that was denied
https://cdn.mbr.pw/SV43dgQ.png could this small fix I accidentally added to the banmanager PR stay or does it really have to go in its own PR? lol
completely out of scope of that PR
aaaight
well discord is discord
what delay?
Is there any plans to make partials per-event, not globally?
I remember someone talking about it a few months ago but don't remember what it concluded with
isnt that already a thing?
I mean, its not per event, but per Structure
I dont believe so, no
I'm a bit confused, prune method for GuildMemberManager throws on L166 (https://github.com/discordjs/discord.js/blob/master/src/managers/GuildMemberManager.js#L166) but does Promise.reject on L174 (https://github.com/discordjs/discord.js/blob/master/src/managers/GuildMemberManager.js#L174)
whats the rule here? lol
I think that should have been a reject in both cases.
3 years ago, wew
Is it possible to develop following function: When I am in an audio channel, I can invite easily someone to join my channel. Would be nice to do this by rightclicking on an user of my server in his context menu. Second would be nice, when he gets this invitation like a call, with ringing etc., and then he can join my channel by accepting this "invite-call" by accepting it with one mouseclick.
If this is not possible by rightclicking, it would be ok to use this function by text command.
This server is for the discord.js library. For Discord feedback, visit https://dis.gd/feedback
I’ve been benefiting from discord.js for a while now, so I’d love to contribute. I’ve looked through some open issues, but I’m not familiar with what’s being prioritized
Would anyone want to point me to an open issue or something you need implemented? If so, I’d be happy to submit a PR
Would it be worth changing the functionality of Guild#owner to fetch the owner if it isn't cached? The current documentation and implementation allows for Guild#owner to be null, but it feels like a nice-to-have for users, especially since it appears to be a common question in this server and on stackoverflow
The user can easily just fetch the owner themselves using Guild#ownerID, which isn't nullable
.. Guild#owner already yields a partial guild member with the guild member partial enabled, afaik
Yep. You're both right. Do those reasons still justify not doing this?
If we did this, it wouldn't be a getter anymore, but something like Guild#fetchOwner, as it'd have to fetch the member, which is also not feasible per say with intents

many things are partials for various reasons, it is what it is
auto under-the-hood fetching could be unwanted for few reasons as well
Seems like you've all thought through this and have some good reasons not to do it.
well, just like "it appears to be a common question in this server and on stackoverflow", it also happens to be brought up as to why it is that way 🤷♀️
Yeah I've seen the pattern of having lazily-loaded, memoized fetches for properties before, but it's possible that's an anti-pattern and I think with your partials param the current functionality is fine, even if it results in some people initially making a mistake because the owner isn't in the cache
In that case, I'm still happy to contribute if someone with a bit more context wants to point me to an open issue that is worth addressing. Otherwise I'll just keep my eyes out.
I wouldn’t mind if someone wanted to look over my list of getters to be removed in g#5287, maybe add some more
was djs written in ts then brought over to js?
nice
@frank turret I took a look. Caught a small mistake in the current iteration of removing VoiceChannel#editable from index.d.ts but not removing the actual method from VoiceChannel.
Looks like there is a lot of contention around whether you should actually move forward with removing these, so good luck attaining consensus
I haven’t removed voicechannel#editable at all so far
@frank turret That's why I called it out. It looks like you unintentionally removed it here 🙂
https://github.com/discordjs/discord.js/pull/5287/commits/1a04c4ee78619a582c6a66e34c380b44e721cf9a#diff-4f45caa500ef03d94d3c2bfa556caa1642df95d4e2b980d76b876a8fd2e8c522L1611
oh, good catch, yeah i'll resolve that next commit
i dont really agree with removing them
yeah there was a whole secondary discussion abt it in hydra land. Debating whether to close the PR as it seems as though the move peeps are into is expanding the amount of getters to cover all bases, instead of removing them
why exactly can you set replyTo in Message#reply 
you should probably use __Channel#send if you want to specify replyTo
It’s so you can use this feature ^ and set what message your bot is replying to.
I think the point is when you're using Message#reply, you'd be replying to that message, otherwise why reply to that message
^
I'm fully aware of what reply does lol
the replyTo is hard-coded to this, as it should be. There can be a new option type in place of MessageOptions, which won't have the replyTo field. As having option to set replyTo doesn't make sense here.
ah I see
is it not possible to just hide the option from the docs?
It was definitely intentionally added, I believe that is because the optional parameter is set to none usually, but for replies it is defaulted (by passing in the extra object) to this
also how r we gonna handle https://github.com/discord/discord-api-docs/pull/2572
I was just looking at that
I think best option is to add to MessageOptions something like forceReply (that name is not great, I'll think of something better).
Since message_reference isn't anywhere but APIMessage, that should be pretty easy to handle and easily ignorable if there isn't a replyTo specified.
I'll make a PR later if it hasn't been done already.
why is User.lastMessageId and User.lastMessageChannelId a thing when User.lastMessage returns a message object?
Because we need to store the channel and message id somewhere, so said getter can return the message
https://github.com/discordjs/discord.js/blob/master/src/structures/User.js#L136-L139
It's a getter to not keep deleted channels and guilds in memory forever (since it's likely you'll never see those users again).
ah
what's the point of having a cache system for things always cached? like guild roles, guild channels, guild emojis
what exactly are you asking about
the cache is locally, on your system
not discord's cache, they have one too, but discord.js has it's own local cache
we dont need to make requests to discord's api if we already have the resource locally (unless we think it might be outdated, in which the .fetch method exists)
does that make sense?
yeah ik djs has it's own cache, I was saying what's the point of having fetch method and a cache manager or something that's always cached?
api coverage I believe is one reason
out of the three you specified, only the RoleManager has a fetch method which would be there for what Pyro said. That and there still needs to be a manager because just cause structures are always cached doesn't mean there aren't other api methods that can be called on them.
guildemojimanager has a fetch method, and the emoji cache can be outdated so it may be needed
can't quite find a fetch method on it disregard, was looking at stable
it's always cached because you received it from api, not because you hardcode the information into your bot before you start it
it's just that unlike other data, you receive every channel, role etc upon logging in
hm yeah it isnt in stable
what?
.
oh
what does the core(*) mean in commit messages?
It's chore. It describes what kind of change the commit introduces. The * is a placeholder for scope, meaning that the changes were made in a lot of places and not just to a particular thing. This will help: https://github.com/discordjs/discord.js-next/blob/master/.github/COMMIT_CONVENTION.md
Is the <GuildMember>.id getter gonna be removed at somepoint? afaik it's just an alias for <GuildMember>.user.id.
no
Unlikely
No reason to, plus, that'd break a lot of internals
#archive-djs-v12-deprecated message
#archive-djs-v12-deprecated message
edit: this ended up being the problem however the user only reported the error in that first message link happening very occasionally. #archive-djs-v12-deprecated message
looked into that the other day, and it can't really be coming from where they claim it does.
if it were an array (doesn't look like it) it'd enter the set branch https://github.com/discordjs/discord.js/blob/stable/src/managers/GuildMemberRoleManager.js#L88 and filter dupes
if it's not an array it doesn't even call GM#edit but goes to a put route directly https://github.com/discordjs/discord.js/blob/stable/src/managers/GuildMemberRoleManager.js#L96 which can't return that error (even if the member already has it)
FaffsToday at 05:58
seems to be a library issue, not correctly checking if a value exists before adding it to the set
That is precisely the point of passing it through the set constructor - removing duplicates. The relevant code concatenates the current roles with the roles that should be added (with duplicates), passes it to the set constructor (removes duplicates) and spreads the set values back into an array.
_ _
the only point at which that might theoretically fail is if even after resolving roles (which happens in L.83) for some reason the equality check goes wrong - which i currently don't see as possible to happen, since it should at this point quite definitely be an array of strings, for which the equality op === (which uses the same comparison mechanisms as the set equality check as per es2015) quite definitely works
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#value_equality
is there a reason message references haven't been added in like a minor patch?
they're there..?
are they?
I meant as in a method
for inline replies
Oh, don't know.
I think that's available in the discord.js latest
latest as in latest release, or latest master commit
master
master already has some breaking changes, so that's not really a good suggestion
there won't be another minor release, so we decided to replace Message#reply with the new inline reply functionality for v13 instead
("minor patch" makes absolutely no sense, minor (release) is _.x._ and patch is _._.x https://semver.org/, for completions sake major is x._._)
ah gotcha
@ruby terrace mind elaborating on
but that poses the problem that the library doesn't expose message_reference whatsoever.
Message#reference is a thing
and i'm not too sure what that has to do with:
This means that MessageOpitons#failIfNotExists has no indication that it is reply specific other than the jsdoc string.
Ah, I mean on the sending side. message_reference is essentially named replyTo when passing options to APIMessage, except that parameter currently only sets the message id obviously.
And for the second part, if failIfNotExists is the parameter name in MessageOptions - instead of say, MessageOptions#reference as would follow Message#reference - then there's no indication that this parameter does absolutely nothing when replyTo isn't specified.
might be worth nesting that one further then, grouping together the reply related keys into its own reply options, which then hold failIfNotExists and messageReference/reference keys
I'd agree with that, that keeps MessageOptions much more similar to the API then
.send("...", { reply: { messageReference: <MessageResolvable>, failIfNotExists: <Boolean=True> } }) something along those lines
I like that, would we want to call reply messageReference though since the API does that? so something like this:
.send("...", { messageReference: { message: <MessageResolvable>, failIfNotExists: <Boolean=True> } })
i think "reply" is more verbose for the option, while also keeping the messageReference and fail* fields true to API naming (which are essentially shifted to top level)
That's fair, I'll go ahead and make those changes.
The MessageReplyOptions also needs to be changed now. I think it will have the new reply field with only failIfNotExists field, because messageReference gets set to this. Will wait a few days until we are okay with the changes that have been made to MessageOptions.
in the api, fail* is inside message_reference
so maybe
.send("...", { reply: { message: <MessageResolvable>, failIfNotExists: <Boolean=True> } })
or
.send("...", { reply: { to: <MessageResolvable>, failIfNotExists: <Boolean=True> } })
Shouldn't this use Promise.reject? i would PR but I don't have a computer on me
</github:805111231349653544> query: 5132
^ makes react() async so that also gets fixed
ah, gotcha
https://cdn.discordapp.com/attachments/223867697312694272/809043798008397864/unknown.png why did this behaviour change?
(channel as textchannel)
That does not do the same
And also wonder why the ChannelType enum was introduced, what channel property returns a number that maps to the right ChannelType?
this was never truly fixed iirc, but it will be in the future
Since channel types are numbers in the API, and you can use numbers in the edit function, thats why it exists
ah okay thanks
I think it would make sense to introduce a channelType property on channel so that the enum can be used
the enum is more less a misc thing defined in our current types to have a consistent type in options and such
I think it would be better if InviteScopes was an enum like ```js
exports.InviteScopes = {
ApplicationsBuildsRead: 'applications.builds.read',
ApplicationsCommands: 'applications.commands',
ApplicationsEntitlements: 'applications.entitlements',
...
};
also, documenting the uses for all of the scopes seems unnecessary on the lib side, why not just link to the Discord docs like MessageFlags.FLAGS?
that enum already exists in discord-api-types, imo it doesnt make sense to copy it, instead it could be added as a dependency (including other places in the lib)
a while ago iirc, you can use if(channel.isText()) ... however which works virtually the same
would you consider a pr whihc adds optional support for https://github.com/uNetworking/uWebSockets.js
I believe Vlad mentioned that it wouldn't be added until they follow the spec
or maybe that was a different one
Is that a client? It looks like a server and I failed to spot anything that looks like you can use it as a client (I didn't look very good tho)
uWs was removed because of it's lack of respecting the ws spec and many issues it brought up
Now, I know why they didn't respect the spec, thats how they're fast fast fast, but...
Personally, something reliable, even if slower is more welcome than something fast and unreliable
We won't go that route anymore
what makes uws so good?
Its faster. But as Vlad pointed out, its faster because it doesn't follow the websocket specifications properly.
new permission
Use Slash Commands USE_APPLICATION_COMMANDS 1n << 31n
wait was the channel partial never removed in the v8 pr?
so now bots cant get dms by default?
yeah i tested it and cant receive dms unless i enable partials: ['CHANNEL'], that should be fixed
cc @vernal atlas
personally i'd prefer it if it never dropped events due to uncached items
but it at least shouldnt do it in this situation
yea i guess the best route there is removing channels partial and having channels always be a possible partial
Are partials from the dapi per-event possible? If so, will this ever be implemented?
Discord api either gives the full object or partial. No events are ever dropped on their end
So no, there’s no per-event partials option
Damn, that would be a really nice feature if it were possible. Thank you!
Could open up a feature request (after making sure it doesn’t already exist ofc)
If I weren't already in bed, I would, but I highly doubt there isn't an issue already opened pertaining this feature.
will this and/or message type 20 be added in snek's interactions pr or should they be added in a separate pr(s)?
Why does ClientUser#setActivity has name as a separate param? Due to this, the ActivityOptions interface has the name property but the docs for it doesn't have it.
My guess would be that someone found .setActivity("name") to default to playing a more comfortable approach, and wanted to support that there
Typing wise that could be solved with omit though, afaik - question is if we want to
on message.mentions.channels the type is Collection<string, TextChannel> but it should be Collection<string, TextChannel | NewsChannel>, announcement rooms are mentionable
right, and NewsChannel extends TextChannel
yup, but text channel bind explicitly the channel.type value to text
right, also removes the possibility... to use news channel things on it
so we need to being able to check if the channel.type is news
actually, since channel mentions get parsed by the lib, it can be any channel type 👀
I'm talking about the type definitions
I know
oh noes, that's.. hmm
actually... why do we do that?
The current one is
export class MessageMentions {
public readonly channels: Collection<Snowflake, TextChannel>;
}
TextChannel rely statically on channel.type value, which is intended, but due to that the type should be
export class MessageMentions {
public readonly channels: Collection<Snowflake, TextChannel | NewsChannel>;
}
oh, i see mention_channels is only included in cross posted messages at the moment... yikes
I could fix that with a channel.isText() check in the MessageMentions constructor, if we actually see it as a bug
otherwise the type would be GuildChannel
hm, good question, actually
after all the client sort of resolves voice channels, just not clickable
mention_channels will include mentioned text channel for lurkable guilds in cross posted messages
other question being: do we even cache/handle/provide these in any way?
I would like to mention that channel mentions for voice / category channels are indeed handled strangely by the client right now. (Behave like a channel you don't have access to) However, slash commands do let you select these channels, so it is possible that the client will do something different we these mentions in the future. Therefore I'd be in favor of keeping the API emitted mention_channels and changing the types to reflect it
the api provided ones are only present under very very specific conditions and i'm not too sure we do absolutely anything with that at the moment
we resolve mentions from cache right now for messagementions#channels
can also include dm channels, so Channel, really
ah, I have misread the docs. I do see that mention_channels is stored as messagementions#crosspostedChannels
oh, so we DO handle them, yays 
oh, this is interesting, so the private _channels Collection, which messagementions#channels is a getter for, is typed differently from messagementions#channels for some reason. Also, the jsdoc strings are all GuildChannel
export class MessageMentions {
...
private _channels: Collection<Snowflake, GuildChannel> | null;
...
public readonly channels: Collection<Snowflake, TextChannel>;
...
that is wrong though, it can also have dm channels
I guess "correct" isn't the right term
It really should just be Channel everywhere
with its current behaviour? yes, def
the question becomes whether certain channels should be part of that Collection, which is arbitrary since the API doesn't give us anything
the version 12.5.0 doesn't exist right ?
nvm
great question
no it's just that I did npm install discordjs/discord.js and it gave me v12.5.0 but the intents were bug
recent release is 12.5.1 but the package.json is still 12.5.0 on master
https://github.com/discordjs/discord.js/blob/ee5bc1a5c4e218ea1f16992694a2bff86c86d2d2/package.json#L3
probably not a bug, just that the way to set intents has changed (and it’s required now) in master
tbh the version number should be changed to v13.0.0-dev
🤔 looks like there are a bunch of unmerged approved prs? https://github.com/discordjs/discord.js/pulls?q=is%3Apr+is%3Aopen+review%3Aapproved
Yes... so? 🤔
@copper laurel on #4869 u marked this as resolved but looks like u forgot to remove it? https://advaith.is-in-hyper.space/732aaeb2ef.png
</github:805111231349653544> query: 4869
Which review was that? Linking to the comment would be way more helpful than a screenshot lmao
Might have been caught up with the others in that review
tbh im kinda confused why sometimes returning the raw message object was even discussed
instead of just creating a djs msg object
Originally part of the concept was for the manager not to cache things that werent previously cached
Moved away from that
well you dont need to cache the message to create a message object
¯_(ツ)_/¯
Not relevant if we're not doing it anymore
@trim quartz will you add the new msg type (20, APPLICATION_COMMAND) and permission (1n << 31n, USE_APPLICATION_COMMANDS) in your interactions pr or should they be added in separate prs
¯_(ツ)_/¯
i can add them
I thought type 20 doesn't exist anymore
I don't know if anyone already saw this, but this dude copied you: https://www.npmjs.com/package/improved-discord.js
his link to the documentation goes to your website lol
And? The License allows it afaik, and it already happened like 30 times, forking and republishing should be fine under the Apache 2.0 License
https://tldrlegal.com/license/apache-license-2.0-(apache-2.0)
The Must sections do not seem fulfilled to me
true, but still, d.js has allowed this to happen and hasnt done anything about it since a decent amount of time so I dont see whats different with that fork
no need for more discussion, really
@fringe temple your decision 
I don't want to waste time on these forks that aren't really getting in the way of anyone
he is in violation of the license yes, but his module seems fairly inactive and hard to mistake for the original discord.js at least
Except that the readme is 100% copied and links to us
i mean, the top of it is sort of clear that this isn't the original discord.js
i mean yes i have contacted npm/repos for less than this
but honestly i am tired of chasing up every fork
They're also trying to change the LICENSE, which is.. 
i see
in that case, i'll contact the owner of this before emailing npm
Hi, because <Message>#delete({ timeout: number }) will be removed and as is it a lot used, I'm proposing <Message>#deleteIn(timeout: number), what do you think ?
The whole point of removing that was so that it forces devs to think about how they are deleting messages after a time. e.g. checking if its already deleted etc...
Its also inconsistent with the rest of the lib
https://github.com/discordjs/discord-api-types/pull/72#discussion_r579488863
@tacit crypt just to make sure i'm doing this right, are you saying you want them to each be their own interface instead of unions like they are right now?
yeah and then make a union of all the interfaces
Its being removed because internal hidden management of the timeout has issues, not because we want to move it somewhere else
Exactly like how commandOptions are done
an interface defining the type
and an union of them

Oh okay
A weird thing is happening to me, When I start my bot.. It calls guildDelete event on 2 guilds that are already deleted (means bot is kicked)
And when I run same code with token of my test bot... It runs as expected.
someone else in #archive-updating-to-v13 also had same issue
we both are on master branch.. idk much about it but wanted to make sure you saw this
I was wondering if discord.js is going to support slash commands:
</github:805111231349653544> query: 5106
ty
dependent on discord finishing their breaking changes too
That announcement is only for a Use Slash Commands permission, Slash Commands themselves are still a beta as it says
Oh yea, mb
they said the API will be stable after the announced UI changes ship
Where exactly?
in DDevs
that's not a final statement though
Where is the code that manages the queue and waits for rate limits? I just wanted to have a look but I can't see to find it. Thanks!
I see, I looked at it but wasnt too sure, thanks!
In src/rest/RequestHandler.js, why is there a +250? I looked at the issue stated in the comment but it still doesn't say why there is a +250. I have tried removing the +250, and it increases the speed that the bot can react at. Is there any reason that this is here?
Both yes and no
I think I understand now; the 250 should be the correct timeout for reactions
the react ratelimit is 1 every 250 ms, by removing that, you are likely to hit a ratelimit whenever you do many reactions at once
It's like a explicit timeout that is not based on the headers because the header parsing causes 0.25 to be parsed to 1
Is that correct?
That's a hard-coded rate limit, because is 1/0.25s and the rate limit headers used to only be in seconds, so we'd get a 0 I think, but yeah, basically because of header parsing issues
The reason reactions in particular are slowing is the ClientOption#restTimeOffset option, which defaults to 500
This option tells Discord.js how much extra it should wait when it hits a rate limit before continuing with the queue. This works pretty well for every endpoint where rate limits are 5s, 10s, 1m etc because 500ms is nothing.
Unfortunately for the Reaction endpoint, which immediately hits a rate-limit (because its 1-per) it turns a 250ms rate limit into a 750ms delay
I did set restTimeOffset to 0 for testing
If you do that, then you should definitely leave the +250 there
Wait Monbrey, are you saying the ratelimit header is in ms now?
Will the "quicker" reactions just be because of my high API ping or something?
No, they just explicitly stated that reactions = 250ms
rate limit headers used to only be in seconds
I'm talking about this
It is still in seconds even for reactions tho
That's why I was confused
Yeah "used to only be in seconds" suggests that its not in seconds anymore?
If I understand API v8 properly, then yes actually, it should be in ms.
I might do some testing with that tonight then actually, that special handling for the reactions endpoint should be removable now
Top: With +250
Bottom: +250 removed
And the pace of reactions with +250 removed is constant, so I don't see any rate limits being hit
are you on master?
I dont know exactly. It was seconds. Then it could be either and they added a precision header to tell you if it was ms or s
Now I think v8 is ms
Actually, with the +250 removed, you can see a small choke which is barely noticeable, so I guess its my ping then 🤷♂️
But still its a lot faster than with +250
Theoretically, the time it takes for 10 reactions is 2.5 seconds + your api latency + your event latency
isnt event latency like a few miliseconds?
If we're moving away from actually discussing library development, can we go #archive-offtopic or support
I do believe there is no reason to keep the line specifically for the reaction routes though, would you agree with that?
I think the headers is still in seconds
When I comment out the lines it takes 1 second for every reaction
if you are not on v8 (either by options or via using master) then its in seconds
The
X-RateLimit-Precisionheader is no longer respected.X-RateLimit-ResetandX-RateLimit-Reset-Afterare always returned at millisecond precision (e.g.123.456instead of124)
that's in the v8 changelog
I am on discord.js@12.5.1
I'm talking about in master, which has the v8 PR landed now
so that was more addressed at Monbrey
@ruby terrace yes
V8 reset-after is ms
Well
Its floating point seconds
seconds with ms precision
Is that not already changed in the v8 PR?
yeah, a little strange considering its present all the time, but 
I checked out master and It doesn't seem to be removed
But is that PR even merged
On master it is still this
oh
I checked out my master, not upstream
and yes, second to last merge
and that line is still present
Remove it and vlad or space or someone can yell at you if youre wrong
cool cool
I run through my tests anyways so I should notice if somethings wrong
Ah hah, I've found why this won't work. Server date isn't in ms, and since offset calculations are done to account for...well...offset..., you'll never get ms precision for a ratelimit unfortunately.
For example one request I had had a reset token of 1614330706.302 and my system got 1614330705260 from Date.now() after this request
(for reference the server date was 1614330706000 which would mean I'm roughly 3/4 of a second behind the server, which doesn't matter necessarily. However, given that the reset-after is 0.250, the discrepancy between reset and server date being 302 ms tipped me off)
That's not something we can change, the server sends it like this
oh I misunderstood
Guess I'll scrap this idea then (until we're all on the same atomic clock or something
)
any reason we don't have support for
https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
https://discord.com/developers/docs/resources/channel#group-dm-remove-recipient
(as far as i looked anyways)?
edit: new addition https://discord.com/developers/docs/resources/user#create-group-dm. Despite the description saying the group dm channels aren't visible to the discord client, advaith says that's outdated and has changed, making the group dm channels visible to the client.
Because the bots cant actually join group DMs iirc
The first two are really OAuth endpoints, since it requires an authorised scope to use
yes, but if we have methods for other oauth endpoints like add user to guild, why can't we have support for these?
The create group dms was intended for the GameBridge SDK, which is now deprecated. And also in the description, "DMs created with this endpoint will not be shown in the Discord client". Therefore, having group dm channel methods would be useless because bots can’t make use of them anyways
please see my edit
Is it confirmed somewhere then?
As in they actually have plans for it
i can ask for a source, hold on
So it was a recent change?
that was like last year from the timestamp
not exactly recent if you ask me
and I assume it was actually changed long before that
But in true discord fashion still not documented as such
I'm encountering a weird behavior with permissions, i don't know if DJS is broken on this part or if it's the Discord API who act weirdly. Or maybe I have not understand everything. In any cases, here is my use case to reproduce it:
1. Revoke all permissions to the role bot from the server settings
2. Grant all permissions (green) to the bot role to a category
3. Create a room in this category with synced permissions
4. Try to clone it
Due to the category permissions and the fact that the category is the parent of the room, it should be able to create a new room with same permissions no? Currently it trigger a DiscordAPIError for missing permissions. But when i'm checking those permissions before doing anything, DiscordJS seem ok with those permissions 🤔
It needs Manage Server to create channels
no? you need manage channels to create channels
but to set a permission override you need to have the permission server-wide
and to set a Manage Roles/Permissions override you need admin
however iirc they said there was an exception for cloning 🤔
why does packages/voice exist in -next if there's also a voice repo
same question for packages/collections i guess too
because the voice repo didnt exist when next/voice was created 
collection one did tho
even its TS rewrite happened around half a year earlier than -next had first commit
we need manage channels to create a channel, but i think the issue comes from the fact that the bot is allowed to manage the channels from the category permissions, and perms room are sync with the category. Maybe discord consider it's a self assignment, idk. But anyway, if it's the case the library should not return true for the permission check in this case 🤔
It appears, even if i give the permission to the bot from the server settings, if his group is explicitly granted on the category and the room, then I trigger the missing permissions error, which is really really weird. I though there was some sort of hierarchical mechanism like that: Server settings > Category settings > Channel settings
Anyway, DJS don't catch it when i'm checking for permissions while the API reject the query, which is really annoying
There isn’t, only role permissions and channel overwrites matter
Pretty sure d.js doesn’t check perms in any case before performing an api call
The same thing actually happens in the client. You can see the clone / create channel button if you have been explicitly granted manage channel for a single channel / category. However, the API will error. I think this is quite a rare case however, and you can always check your guild permissions.
And this type of permission getter is something that is trying to be avoided IIRC
the bot is granted for the category, so it should be able to perform the clone, if there's a parent, then the parent perms should apply except if there's an explicit deny no? 🤔
categories are sorta strange, they're actually just channels, and they have no hierarchical inpuit
oh damned 😅
genius idea to put hierarchical rooms on the client but not applying it to the perms 😂
idk if this is the place to put it but thought i'd share a little helper code i wrote for making message replies, since i couldn't seem to find anything else online, thought i'd share my findings
Discord.Message.prototype.reply = function({ content, embed }, mention) {
let data = {
"content": content,
"embed": embed,
"tts": false,
"message_reference": {
"message_id": this.id
},
"allowed_mentions": (!mention ? {
"parse": [],
} : undefined)
};
let reply = new Discord.APIMessage(channel);
reply.data = data;
reply.options = {};
return this.channel.send(reply);
};
pretty sure there is a pr for that (and maybe already merged in master?)
for v13 yeah but if u don't wanna have to do any merge bullshit, i didn't want to run an unstable version so i just made the function that i needed
idk how v13 does it but i just tried reverse engineering yalls library to send an api message
You should use Structures.extend, not modify the prototype directly
Are there any plans on making .send() a tad more ts friendly? Currently, I am unable to modify the method directly and the types are atrociously difficult/confusing to any new typescript programmer. It is also not following the types mentioned in the documentation and it is resulting in a lovely handful of errors from ts.
The short answer is "yes but not right now"
Typings will be improved in the future!
next ™️
its worth noting that for the send methods the typings are a bit bugged, you can't do for instance
let x: MessageOptions | string = {};
if (something) x = "hi";
channel.send(x);```
something to do with the fact that there isn't an overload that just accepts both
i was gon do a PR on it but i don't have the patience to mess with those overloads atm
will message.reply() be changed to an inline reply in v13?
Yes, it's also available in master right now
Is there a particular reason for why discord-api-types may export never types? Seems odd since void seems to be more appropriate in those contexts
technically, both are valid types for it... The never type represents the type of values that never occur vs void is a little like the opposite of any: the absence of having any type at all
In the end, they should be achieving the same thing 👀
I don't think the typescript compiler treats them the same
it's really ruining my auto-generator 
how so? Can you give me an example of the issue? What's the output with undefined vs never? Which would be the expected output 👀
You can always DM if you don't wanna clog here
yea, im not entirely sure if my thing relates to the library itself since I only use the typings for deno :v)
but yeah I'll DM
what's the point of guildMember.permissions.has() if an array of permission resolvables can be used in hasPermission
#hasPermission is removed on master and will accordingly be removed with the release of v13
simply because (see link above) it's not much shorter than <GuildMember>.permissions.has which it calls anyways
It's "private" as in you shouldn't use it, doesn't mean you can't
If you're on TS and it bitches, either shard['sessionID'] or ts-ignore it
Oh wait really? lmao does js not enforce private properties?
Or is that just a comment and I'm dumb?
well, shouldn't should be enough of a: maybe what you are planning to do with it is not that good of an idea to apply in the first place
Yeah I can access it fine lmao I'm just dumb
Dumping shard session ids to redis to then resume them on another shard with an updated version of the bot?
0 downtime updating
Bad idea ^ ?
No, absolutely valid
Okay although maybe best to do with a custom djs fork?
As it currently stands, yes
Sounds good cheers 👍
though depending on if you use TS or not
you can modify those values anyway
there is no such thing as hard privates in djs
🤔 why is it private
Do a git blame
Yeah I see now. Been doing lots of straight java recently so I forgot that @private in the comment doesn't actually make it private just invisible in docs
re: https://github.com/discordjs/discord.js/issues/5277
@opaque vessel but didn't you yourself open the issue on DAPI docs? i'm confused 
and from what I understand this would go away if fixed on discords end?
also if you know how to fix it, why not PR it?
the discord bug is different
the discord bug is that if you edit the message without setting allowed_mentions, it resets allowed_mentions
the d.js bug is that if you only send allowedMentions it doesn't send anything
...yes, .send({ allowedMentions: { parse: [] } }) or w/e is never gonna work - or am i missing the issue
OH
editing
Why is Role.comparePositions available while Role.comparePositionTo is pretty much the same
is it gonna be removed on v13?
the latter calls the former (static) with this, don't see a reason to
but they do function the same why would there be 2 methods for it
what? the static method is called in the instance method - they're not the same, one depends on the other
oh
<Role1>.comparePositionTo(<Role2>) vs Role.comparePosition(<Role1>, <Role2>) (which is called in the former with this)
https://github.com/discordjs/discord.js/blob/stable/src/structures/Role.js#L154
I thought one of them should be pointless because they both return the same result but looking at the source code and what you said I got it rn
thanks souji!
one could argue that we can shove the static functionality into the instance and remove the static, but that's just removing a layer of abstraction vs. pruning duplicate functionality
so not a fan of that, personally
oh
Yes pretty pointless in that case.
Is it intended that when you have fetchAllMembers enabled, but don't have the privileged intent the library will just wait for two minutes until a timeout occurs to start the bot? Im not sure what discord returns however seems odd to fail due to timeout
Also the timeout "error" is logged over debug, rather than the error or warn events.. is that intended? Made debugging my bot more difficult as I was logging warn/errors but not debug
yes, fixed in master by removal of the option
So I looked over the VoiceState class and .streaming is not nullable? I would assume it would be considered nullable since the rest of the properties except for id and guild are nullable.
https://github.com/discordjs/discord.js/blob/master/src/structures/VoiceState.js#L64
per the api docs: https://discord.com/developers/docs/resources/voice#voice-state-object
self_stream? boolean whether this user is streaming using "Go Live"
i guess, yea
nada, Jake told us a few months ago that any optional boolean can be safely defaulted to false if missing
so it makes sense to guarantee it
most of these properties would be changed if that were the case
"these properties"?
oh, hm
i see what you mean
i think @unique axle tackled this a while back
Oh, is that yet another instance of https://github.com/discordjs/discord.js/pull/4706 (and linked PR's)
appears so
my memory usage is increasingly indefinitely, it's in around 2.2k servers and I have sharding enabled. it's using around 700mb of memory.
I have minimal intents, messages and guilds. and message sweep is quite strict
messageCacheMaxSize: 10,
messageCacheLifetime: 60,
messageSweepInterval: 10 * 60,
messageEditHistoryMaxSize: 0
or just move it to where that pr did
to avoid any issues
just curious, how is discord.js-next doing?
typescript migration seems useful
and seems relatively simple, just adding types to existing javascript code
unless there are some non-obvious difficulties with migration?
You are misunderstanding what -next is. We're not simply adding types to existing code.
discord.js-next is going to be a full on rewrite of the library, from ground up.
types are already included with the project as it is now. (https://github.com/discordjs/discord.js/blob/master/typings/index.d.ts)
ah so like big restructuring of everything?
yes
any plans on supporting deno?
refer to
ty ty
Would there be any way to have like client.destroy return a promise containing a boolean with like if it successfully deleted the client or not
just bc like rn it doesnt return anything
so you cant really know when the client is destroyed
it's not asynchronous, it should happen more or less instantly
but why , what application does this have?
in case you want to like restart your bot
you don't wanna create a new client till the old one is made
client.destroy() isnt for restarting bots exactly, you should probably just use a process manager and restart it
oof
there's a possibility that there's leftovers which could cause unexpected behavior
destroyed clients should not be reused
I was a bit too late :snail:
loll, ty for the info tho!
Is there any point on keeping Guild.channels.cache if you have Client.channels.cache that has a property of guild for guild channels?
Well guild.channels is the actual manager with the create etc methods, so yes, it needs a cache
the cache could be based from client.channels.cache doesn't it?
But why
You want guild.channels to have to be written as a custom manager that doesn't have it's own cache, and a pseudo-cache getter for a filter on client.channels.cache? Why add that complication?
#archive-offtopic message about this, though you said its a reference, but reference to client.channels or other way around?
Neither. Collections with the same Channel objects in them
I don’t think you can have one-way object reference in js, it’s always mutual
so basically, channels in guild.channels.cache is the same reference on whats its counter part on client.channels.cache?
https://github.com/discordjs/discord.js/blob/f46940228e9f82db4af09ae2f2dad684db0d74ed/typings/index.d.ts#L991 is there any reason to not make the CollectorFilter type generic? so, in this case, you can go from
type CollectorFilter = (...args: any[]) => boolean | Promise<boolean>;
to
type CollectorFilter<T extends unknown[] = any[]> = (...args: T) => boolean | Promise<boolean>;
so that then you can add additional type data for filters like the following for the line I referenced in the link?
public awaitReactions(
filter: CollectorFilter<[MessageReaction, User]>,
options?: AwaitReactionsOptions,
): Promise<Collection<Snowflake, MessageReaction>>;
interface ClientOptions<T extends PartialTypes = PartialTypes> {
// ...
partials?: T[];
// ...
}
type ReactionType<T extends PartialTypes> = T extends 'REACTION' ? User | PartialUser : User;
interface ClientEvents<T extends PartialTypes = PartialTypes> {
// ...
messageReactionAdd: [message: MessageReaction, user: ReactionType<T>];
messageReactionRemove: [message: MessageReaction, user: ReactionType<T>];
// ...
}
class Client<T extends PartialTypes> extends BaseClient {
constructor(options: ClientOptions<T>);
// ...
public on<K extends keyof ClientEvents<T>>(event: K, listener: (...args: ClientEvents[K]) => void): this;
// ...
}
Same goes for here
Could someone shed some light on why replies are only being added in v13? It's been 4 months since the feature was introduced, shouldn't it be a priority to add new features as soon as possible?
we will not do another minor release on version 12
so we might as well introduce replies as a breaking change in the next major, 13
the usage as Message#reply is much more idiomatic than inventing another method name just for the sake of keeping it minor
Would it be such a breaking change to replace the current reply functionality with the new one that it requires a major release?
In my humble opinion I'd much rather have a new minor release with the new functionality than having to wait months on a major update, but thanks for your answer
anything that changes the publicly exposed API is a breaking change, no matter how small it is.
and changing the entire behaviour of a method is definitely a super breaking change
That's true
there is nothing about the method that stays the same but the name.
it takes different parameters
it does something else
there is no way replacing this could be framed as a minor release
I can see that, but I still feel like adding new features as soon as possible should be prioritized in some way, but I understand
I'll just use the fork for now
that is a priority, indeed, but not as much as to jeopardise semver over it, if we already have moved on with the development branch.
you can of course always install a certain commit and apply the necessary changes
in that case i'd heavily recommend pinning your dependencies to that specific commit, in order to not accidentally introduce more breaking changes when updating.
more on how that procedure works: https://docs.npmjs.com/cli/v7/configuring-npm/package-json
Thanks
I'm sorry if you guys get this asked multiple times, but I am curious and I want to try helping. I tried searching if someone asked about this in this channel before but apparently there wasn't (I could be blind though).
Has anyone got a rough idea about why discord.js is having trouble with piping Readable streams back in node v15? I know the fix is to downgrade back to node v14 but what change in v15 could've caused piping to not work, unless you do it twice.
Node.js v15 is not the stable version and has some unstable changes, so it might be having issues with the Readable Streams that are piped through discord.js's voice lib, however, the voice lib is getting a lot of changes apparently, no idea that would do anything in this case but as its not LTS, you gotta dig through Node.js's changelogs to find out what they changed between the two versions and see the difference
I dont think its worth figuring it out, use the workarounds and wait for discordjs/voice to be production ready
frankly there's not much to dig, there's very few changes that could've done this just on a quick scrim through the changelogs
[3f33d0bcda] - stream: fix pipe deadlock when starting with needDrain (Robert Nagy) #36563
being the main culprit (all though I'm not certain of the exact bug or if needDrain is used)
which is actually under the 15.5 changelogs 
so if this works on 15.4 for instance, it's probably that
With the research I did in the middle of the night. I haven't checked at which version it stops working. However I have found that this was changed between version 14.16 and the latest commit.
https://github.com/nodejs/node/blob/bd60e93357a118204ea238d94e7a9e4209d93062/lib/internal/streams/readable.js#L722L744
These lines of code in the pipe function. were changed to just pause() in the latest commit.
it stuck out since the comment said // If the user unpiped during `dest.write()`, it is possible // to get stuck in a permanently paused state if that write // also returned false.
is implementing this on DiscordAPIError feasible? https://discord.com/developers/docs/reference#error-messages
cc: @vernal atlas
We have done this..for...ages now
The MAIN reason we were on api v7 is those
yeah if im understanding right thats already implemented
the libs are broken atm, there are just random issues after the new stage channel stuff
e.g.
this is confirmed by people reporting similar in #archive-djs-v12-deprecated
and I can confirm not a single thing has changed on my bots in the past 2 weeks and this is all sudden so its def a lib or api issue with the new change
is this with one of the invite events?
they all look to be related to channel events such as channel create
also in line with the new change
can u list me all the events you listen to
but yes there is also a callback with the invite too
aight
yeah that will be fixed momentarily
nice one ty
- Does djs support slash commands?
- The new stage channels are not the same as vcs it seems so bots will say you arent in a vc how / when will there be a fix for that?
- not yet pr pending
- new channel type
Will there need to be a fix for that? Or is there a way to fix it currently
we will probably release 12.6 after all which introduces the new channel type and stage functionality
We didn't want to release anything else on v12, but things are breaking, so here we go:
• ⚠️ 12.5.2 emergency patch release to stop receiving INVITE_DELETE for stage channels from breaking the library
• 12.6.0 minor release for stage channels (might not happen because of new permission bit)
According to https://github.com/discordjs/discord.js-next/blob/master/.github/COMMIT_CONVENTION.md, (referenced in https://github.com/discordjs/discord.js/blob/master/.github/CONTRIBUTING.md ) types is a valid commit type
however commit-msg only lets me use one of [chore, build, ci, docs, feat, fix, perf, refactor, revert, style, test]
which type should I choose? the changes are only to the typings, nothing else
I would choose feat but I'm not sure whether that is reserved for actual features
sugden made a typings type commit 3 days ago but that doesnt work either
you can use feat for typings too, yes
thanks!
looks like in master PresenceData now needs activities instead of activity but docs still say activity
https://discord.js.org/#/docs/main/master/class/ClientUser?scrollTo=setPresence
did docs just not get updated?
ah so looks like it just sends the presence directly to Discord, and it changed in v8 but the typedef and interface weren't updated
why was the before option removed from ReactionUserManager#fetch ?
is it being deprecated by the API?
never worked, API docs don't get a response as to if it's a bug or just wrongly documented -> removed it
reasoning being that if it gets fixed and added back it's super easy to re-introduce in a semver minor
i see, thanks
any reason https://github.com/discordjs/discord.js/pull/5147 did not add ApplicationFlags to the Discord object? or was it just overlooked?
oh yeah, that was an oversight
is discord.js-next still being developed?
I'd be interested in contributing
Yes, see Github
last PR was in January
ran into a typings bug today
GuildMemberRoleManager extends BaseManager, which has the resolve and resolveID methods, even though they aren't implemented
I would do PR but i'm not sure how to
GuildMemberRoleManager shouldnt extend it
It doesn't directly but it extends OverridableManager which extends BaseManager
https://github.com/discordjs/discord.js/blob/6c6b1053b7a6778a5d0402941a13258ca13378f8/typings/index.d.ts#L1964
^
Interestingly GuildMemberRoleManger is the only class that extends OverridableManager
so either GuildMemberRoleManager should implement the rest of the methods of BaseManager, or not extend from it at all
either way OverridableManager seems rather useless and could probably be removed
keeping 7 as unknown is pretty 😬
maybe change to -1 or smth
although it probably wont have a real issue bc 7 was for lfg iirc (which afaik will not return/release), its pretty weird
the unknown type to existing in the first place seems to be an oversight from https://github.com/discordjs/discord.js/pull/3165 where the unknown channel approach was removed in favour of making channels of an unknown type not enter cache
Seems like this is an issue within D.JS,
where in this.connection can be null on ws open event(?)
https://github.com/discordjs/discord.js/blob/3af8179878c093985c8a94ee2fd7e99d45243bda/src/client/websocket/WebSocketShard.js#L268
Client event disconnect exists on the typings ClientEvents but its not documented in the docs 
The disconnect event is on v11, but it was replaced with shardDisconnect in v12. Strange it's not removed from the typing 
there is a very small time frame where that can happen: the shard getting disconnected/closed/destroyed before the open event is fired by ws
i believe this bug was fixed quite a while ago, strange
it rarely happens but if not dealt correctly, it will crash your bot
In my case it happened only this April 3rd
@tacit crypt ^^ seems https://github.com/discordjs/discord.js/issues/3641 has arised again 👀
how the hell...
What version?
latest master
cc @vernal atlas
was IntegrationApplication also not added to the Discord object?
i just want to ask here for better clarification
wait a sec
the fetchInviteInfo method in client couldn't pass some trolling invites
For example, i'll provide 2 working invites for examples: test and 123
Example: https://discord.gg/123/test/
DJS fetchInvite method returns the result of the server with the code 123, but Discord site automatically redirect it to discord.com/invite/test/, which is the latter
(there are actually more cases when i tested the method, will add them here later)
i don't understand your request? both are vanity invite links that are given out to two different guilds, which we retrieve correctly from the API via the GET /invites/{invite.code} endpoint and provide the data for after fitting them into discord.js structures
I mean, the only problem is that discord.gg invite links only takes the last invite code after the last slash character (if there are no characters like #? beforehand)
Just try the example invite link with by both the djs method and pasting it in the website and you'll see the difference
i really don't know what you are referring to, both https://discord.com/invite/test as well as https://discord.com/invite/123 point to different guilds, even if i enter them into the browser directly - we retrieve those guilds accordingly from the API
123/test/ is parsed as 123 by discords redirect system
But discord.gg doesn't follow the rule above
https://discord.com/invite/123/test/
https://discord.com/invite/123
both lead to the same guild, which is also the guild we return 
discord.gg/123/test
I mean this one
both discord.com and discordapp.com work well with the method
ah, so what you are saying is that discord.com, discordapp.com vs. discord.gg resolve invites differently in complete edge cases, which we don't handle on the library level, see
as i see this this is an inconsistency in discord parsing invite links with excess differently in discord.gg and discord(app).com and i personally don't see reason to specifically add code to handle this edge case
I only recognized that when there are some trollers that posted that kind of invite to my server
Fyi, I coded a bot to detect invalid invites and delete them. And it failed in those trolling invites
The trollers then dm me and asked why their valid invites got deleted, which pulls me to a tough situation as I stated there "only post invites that are valid/linked to the discord invite page"
Does Discord.js support stage channel to be created
no, not yet
was thinking of suggesting a new property for all guild channels called locked that says whether a channel has the 🔒 icon in it or not (essentially sees if the everyone role has perm to view the channel and connect (for voice channels). Do you guys think this would be a good idea?
it's just a permissions getter for CONNECT (voice) and VIEW_CHANNEL (text) permissions after overwrites and depends on the viewing member
not a fan, don't see many use cases for it either
well you can say the same thing about manageable which is already a thing right
manageable at least factors in ownership apart from just role hierarchy
well ownership wouldn't matter in this case since the lock appears to everyone and doesn't depend on anyone's permission but the everyone role
it would be almost the same as this (with different permission flags) without the first line
An example of a use case for this would be if you wanna make a command that locks a voice channel (which is what im working on for my own project) which would make this process easier (checking if the channel is locked already or not)
well, it still depends on the viewer. if you don't have connect there is a full lock, otherwise there is a small lock next to the regular voice icon i guess
but i really don't see any use case for this - even less now that you detailed you mean the small lock, which is basically completely useless information
^ Just write yourself a util that does the permission check -- its literally just a permission check, doesn't make sense to have in the core lib imo
its useless to someone that has that permission but its not for a server owner for example if they wanna easily know what channels everyone can see. To me it makes sense to have this alongside the manageable property
discord has a built in functionality to do that now, so even as a bot feature that is completely unnecessary
but bots don't have that feature and if you wanna list all the channels that are visible to everyone through a bot it would be harder
You do have that feature, it's called checking permissions? Its very simple to do, and very simple to wrap in a utility function if you don't want to write the permissions check every time?
i understand that you found a use case (which you seem to feel rather strongly about) and want to reduce your code complexity
but if we start incorporating permission getters for every small things that may or may not have a use case in someones eyes our API is going to be very, very cluttered. most permission getters that are in the library at this point either have more complicated checks under the hood or at least a broad area of use cases, where they actually make peoples lives easier
channel.permissionsFor(channel.guild.roles.everyone).has("VIEW_CHANNEL")
i really don't see why this single line and single purpose check should get its own method/getter on a library level
I completely understand that doing this for every little thing is pointless, I just suggested this because it's a built-in feature from the user's perspective and it seems like everything that the user can see is also available to a bot through the library. But it's fine if you don't wanna implement this, it was just an idea :)
well, the information is available, if you need it but "is icon displayed in desktop chat app" is not really a good criterion to develop a library based on
yeah fair enough i guess
seems like theyre adding contentType to attachments, https://github.com/discord/discord-api-docs/pull/2762
done
no
not what djs’s purpose is
I don't know if this is the right place, but I think Util.escapeMarkdown just made a mistake
That name is the same every time, fbz___
What's the input
Basically what you see except the name with the slash in it is fbz___.
want it copypasteable?
name: fbz___, displayName: fbz___, id: 29507072, creationDate: 2012-04-04T10:54:40.635Z (over ~9 years ago), type: , broadcasterType: , views: 869, description: :3
channel - name: fbz___, displayName: fbz___, id: 29507072, language: en, title: :), gameName: Path of Exile
turned into```
name: fbz___, displayName: fbz___, id: 29507072, creationDate: 2012-04-04T10:54:40.635Z (over ~9 years ago), type: , broadcasterType: , views: 869, description: :3
channel - name: fbz\_, displayName: fbz___, id: 29507072, language: en, title: :), gameName: Path of Exile
Hm
^ Reproduction fwiw: https://runkit.com/embed/sf8shw84csji, looks like escapeUnderline is somehow escaping \___ from escapeItalic to \\_\__
but only in 1 of the four times his name is there
it's interesting because it goes \___ and __\_ twice, then that becomes \_\_\_ 3 times and \\_\__ once. well I am sure my commentary isn't helpful at this point, suffice it to say I don't know how it decides what to escape
a single _ also is italics, so say you have
\_\_message\_\_ (which escapeUnderline is ran on) then run escapeItalic and you get \_\\_message\\_\_
i think thats whats happening right ?
perhaps the soloution is to escape everything else then .replace(/_/g, "\\_");
might also get similar behaviour with asterisks too but idk
I don't think it will mess up on such a common case
but clone and edit on runkit isn't working for some reason
It works fine with __message__
It works in an interesting way with ___message___, then italic really does take care of one and underline the other
Anyway. I kinda expected it to just escape everything that could possibly be markdown with zero analysis tbh
just a quick question about this is there any reason as to why VoiceChannel has 6 of these permission checks? https://discord.js.org/#/docs/main/stable/class/VoiceChannel
deletable, editable, manageable, joinable, speakable, viewable
some like joinable make sense but manageable, deletable and editable seem the same to me
yea they are a bit confusing, but ultimately, they check for different things:
super.deletable and this.manageable also perform different checks
they also all have utility for the bot itself to be able and do things
"is a channel accessible for everyone" is completely irrelevant for a bot to do stuff
Yeah I saw that but I didn't quite understand what those were doing, where can I find the code for that?
(updated the message to link to a more up-to-date version of that file specifically for the stage channel PR)
ah gotcha
thanks
seems like the url of null is happening again more frequent this time
I should really just remove that...
bringing this up again since https://github.com/discord/discord-api-docs/issues/2702 was fixed: #archive-library-discussion message
I seem to have misread the docs for X-RateLimit-Reset-After.
On v8 it is in floating point seconds, to ms precision. The value in this is not how long the reset is, but how long until the current reset, meaning it is possible to handle ratelimits better.
Basically, I would like to add handling of the x-ratelimit-reset-after header so that, if present, RequestHandler#reset gets set to Date.now() + reset-after, without relying on calculating server offset and manually adding 250 ms for reactions. Falling back to the current handling if that header is not present (in case the referenced issue ever pops up again for example).
Can anyone see a reason not to do this?
recently people are getting errors connecting to discord.com, I am not sure if it's released yet but if not shouldn't it connect to discordapp.com
no? domain change happened several months ago
I feel so outdated
how should i add msg type 22
should i add 21 to the createEnum too? or just put null for it
since 21 is in the interactions pr
why isn't 'size' documentated as a property of collection
Its a property of Map, which Collection extends
so whys that stop it from being in the documentation
Because you can view the documentation for it on the MDN docs website
No point on having duplicate docs
then how come we do that for the get, set, clear, delete, and has methods
I believe because they are implemented differently (as in there is code that makes them different from Map's equivalent)
not for get, has, and clear. We literally just return the super method
set & delete are extended but provide the caching functionality that collections has
which is being removed IIRC
I am interested in all these functions that just call super
exactly my point
couldnt joinVoiceChannel in djs/voice just take a channel object?
so instead of js const connection = joinVoiceChannel({ channelId: channel.id, guildId: channel.guild.id, adapterCreator: channel.createVoiceAdapter() }); just js const connection = joinVoiceChannel(channel);
@discordjs/voice is meant to be lib agnostic iirc
could be wrong
pretty sure that's the stated goal, yes
couldnt it work for either
then it wouldn't be agnostic, advaith
It's meant to be a standalone thing
ig 
aka you can use with a library or with pure raw data sprinkled from json files
I'm not sure so asking it here, is this endpoint covered in djs: https://discord.com/developers/docs/resources/guild#search-guild-members?
aight, thanks 👍
what do u guys think on interaction.webhook vs interaction.followup(s) ?
i feel like .webhook might be confusing since it isnt really a normal webhook
the library internally uses it for .editReply and .deleteReply but users wont need to use it for anything about the original reply
#archive-github-djs message @oak quail maybe callback would be better?
I dont think callback is correct, no
Thats definitely not what it is
I agree webhook could be a bit connfusing, however, I can't think of a better name, and it is mostly a webhook
Hey! For v13, do you think it would be possible to keep track of extended classes throughout the library? By that I mean keeping the jsdoc/types. Quick example:
Structures.extend("TextChannel", (Channel) => {
return class CustomChannel extends Channel {
constructor(...) {
super(...);
}
};
});
Structures.extend("Message", (Message) => {
return class CustomMessage extends Message {
constructor(...) {
super(...);
}
someMethod: () => {
// Now
this.channel // jsdoc/hint shows that this.channel is a TextChannel
// Better I think
this.channel // jsdoc/hint shows that this.channel is a CustomChannel
}
};
});
Maybe what im asking for already exists, in that case please make me aware of how to achieve it :D Thanks!
Btw, i'm asking that because i'm trying to work in typescript so if I want to use a method from an extended class, I have to "force" types (ex: (this.channel as CustomChannel).customChannelMethod() // would not work if type is TextChannel
I dont see this happening in v13, it might be possible in the full TypeScript rewrite
Yeah, I don't think this is an important thing rn
JSdocs definitely dont do it, but you can write your own extended typings
declare module "discord.js" {
interface Message {
client: MyExtendedClient;
}
}``` etc
Okay, thx for answering!
Util.cleanContent can be modified to take a channel instead of a message right?
...for what purpose?
Or do you just mean in general because all it accesses is message.client and message.guild
well i want to do it so it can be used for interactions
was just making sure i wasnt missing anything
Just make sure you fix the message.channel.guild line lol
are the types intentionally not imported?
looks like eslint complains that its not being used, although it helps with intellisense 
The docsgen recognizes the typings as is since it's compiled into one file anyways
ik, but the intellisense helps for developing
I don't think the docsgen supportimport("...")
well require works
other than eslint
Wouldn't that create issues with cyclic dependency?
The no-unused-vars rule can easily be fixed with the jsdocs eslint plugin (jsdoc/no-undefined-types)
@clever crypt not sure I'm a fan of your delayFor test (here https://github.com/discordjs/discord.js/blob/eeafe72d3a0d526a06d3536e9a4a85c69bd785d9/test/Util.test.js#L231-L237)
I think this approach that isn't event loop bound at all and doesn't cause the tests to take an extra 100ms to exit is much more desirable:
test('Util#delayFor', async () => {
jest.useFakeTimers();
const cb = jest.fn();
const promise = halt(100).then(cb);
jest.runAllTimers();
await promise;
expect(cb).toHaveBeenCalled();
});```
or.. something along the lines of that nevertheless.
but it's kind of redundant to "test" the ms parameter at all when it's just thrown into setTimeout
there's fairly little to test with this method overall so I can't really think of an approach that doesn't look lame
slightly confused here because lint-staged runs eslint on js files and prettier on ts files (https://github.com/discordjs/discord.js/blob/master/package.json#L85-L88)
but the prettier script runs on both js and ts (https://github.com/discordjs/discord.js/blob/master/package.json#L25)
https://github.com/discordjs/discord.js/pull/5524#issuecomment-819227769 I'm thinking of making a PR which does exactly what monbrey is suggesting here but I'm not exactly sure which managers the use of LimitedCollection can benefit from
seems like I would need to dig deep into DJS to find out which cache the lib doesn't deeply depend on
i think the biggest hint would be managers that don't have everything cached from the start
how will main branch deployments on -next be handled?
come again?
They're asking for alpha builds
how will we do them for -next
build branch? npm publish?
not anytime soon
if so, who can publish or will it be automated for canary?
see: rest module once someone reviews it and it gets merged
will be figured out when its in an actual alpha state
i've been told the reason why rest hasn't been merged is because it hasn't been texted in prod but the only way you can at the moment is by vendoring
clone, build, npm link
that and reviews
what is left to be implemented for v13?
the main features (replies and interactions) seem to be implemented already
Interactions are not implemented
interactions haven't been merged (although they are not a major change so it can release without and be a .1.0 thing). There are several semver major things that are still left (check pins in #djs-help-v14 ) Some things that aren't noted there: #5490 - Welcome screens, #5298 + #5296 - Reply options, and some other internal things that generally clean up the library
ah i see, still workin on it
best of luck contributors, thank you for all your hard work
wonder what's the API status on screening
I pinged yuugu a while ago and he didn't respond
also it would be nice to get monbrey's manager method prs in
#4872 in discordjs/discord.js by monbrey opened 6 months ago (changes requested)
feat(GuildMemberManager): extend API coverage
📥 npm i monbrey/discord.js#gmm-api-coverage
#4869 in discordjs/discord.js by monbrey opened 6 months ago (review required)
feat(MessageManager): extend API coverage
📥 npm i monbrey/discord.js#message-manager-additions
Yeah it'd be nice to get those in before 13, but they are, suprisingly, semver minor
oh there are a lot of semver major prs lol
yeah
a lot are simply internal things, and waiting on conflicts resolved / reviews
speaking of which, for https://github.com/discordjs/discord.js/pull/5161 I never got a response on if I should change it to just not emit presence / GMU if the only thing changed is the user object (still emitting userUpdate, basically the oposite of the current PR). I am aware that the PR will not get merged as is, trying to find a good solution.
wait why would it not emit presence/gmu
because oldMember and newMember are identical in those cases
as they used a referenced user object
