This should have been fixed by Discord in the last API version (which actually djs supports).
Are still there any problems?
#archive-github-djs
1 messages ยท Page 3 of 1
Please describe the changes this PR makes and why it should be merged:
This PR adds conditional typings to the Client class, allowing for TypeScript to infer the ready state of the client and provide access to properties that are initialized at login, such as Client#application and Client#user. This also adds a client parameter to the Client.on("ready") event, defined in typings as a ready client.
This will be a major quality-of-life improvement for users of TypeScript and t...
Only to me this line seems too long ๐ ? Did you try to run prettier?
It's the same length as the line above, which wasn't modified.
I think transforming Client in a generic type is a too big change which will make a lot of problems to TS users... Why not just using something like Partials? Like, create an interface called LoggedClient and pass it in events (where we're sure the client is logged)
7322547 types: fixed unreachable overloads (#6062) - kyranet
e2f9b79 Docs build for branch master: 7322547172e2d34bd... - iCrawl
I think transforming Client in a generic type is a too big change which will make a lot of problems to TS users...
https://github.com/discordjs/discord.js/pull/6073/commits/ef0714832df6a62a7852be4cbb4d4ca99d0c6e1d#diff-4f45caa500ef03d94d3c2bfa556caa1642df95d4e2b980d76b876a8fd2e8c522R283
It defaults tobooleanwhich will result in the same typing as before and thus no changes required to existing TypeScript projects (unless they want to).
Why not just using something like Partials? Li...
Why not just the isReady function? Having ready and isReady doesn't make much sense imo and ready isn't in the typings
Ah right, I'll combine those two into just isReady.
Defaulting to boolean if the generic isn't specified so as to not break existing typings.
Are these typing changes suitable? If so, will add them to PR.
https://github.com/shinotheshino/discord.js/commit/d3addcaa5d76b46e7a629330f5a2189332644c2e
I would say so although you missed quite a lot of Base<true> extensions
I was leaving the others alone as I thought they could reasonably exist on a client that wasn't logged in
I'll fix last thing tomorrow.
Please describe the changes this PR makes and why it should be merged:
Currently in InteractionResponses#update, the description and example refers to a button interaction, so this also gets displayed in e.g. SelectMenuInteraction#update on the docs. This is not done by any other methods on the interface. This PR generalizes the wording to a general component interaction, also probably making it future proof in case more component interactions will be added in the future.
Also chan...
I'm not sure I fully understand the benefit of this. If the TS user has to manually define it as Client<true>, how is that any different to non-null asserting the properties? It's just a shortcut that does them all at once?
TypeScript isn't "inferring" anything if I'm the one casting it to an interface where the properties aren't null, because manual casts can still be done incorrectly.
The way I see this is that the classes extend a Base class that is already logged in so it knows the properties in client are not null, the user would not have to do any non-null asserting.
That sounds even more incorrect. Though uncommon, I don't see anything guaranteeing that an instance of a class extending base has a logged in client.
These are forced types, not inferred ones.
You canโt really interact with Discord if youโre not logged in so anything the client receives has to be with a logged in client
If the TS user has to manually define it as Client<true>, how is that any different to non-null asserting the properties? It's just a shortcut that does them all at once?
This PR adds the Client#isReady(): this is Client<true> method, which provides a type-safe way to assert that the client is a Client<true>. Additionally, the ready client is emitted from the ready event, allowing for type-safe initialization logic.
A potential use pattern would be:
- Use
Client(with no gene...
Please describe the problem you are having in as much detail as possible:
I was testing the new makeCache option introduced in #6013 and the client crashed after disabling the presences cache (PresenceManager: 0) and listening to the presenceUpdate event. I was expecting it to be emitted with some data or partial data.
Log:
/media/vicente/Secundario/Desktop/Proyectos/djs-limited-caching/node_modules/discord.js/src/client/actions/PresenceUpdate.js:30
if (this.client.li...
The problem is that from what I can see, you're not defining it as logged in only on the Client events - you're defining it as always true on the base class itself. This simply isn't true 100% of the time.
As much as I hate myself for writing terrible discord.js usage like this:
const client = new Client({ intents: ["GUILDS"] });
client.token = "<token>";
const guild = await client.guilds.fetch("412130302958239745");
This code is functional, and will return a horribly usele...
As much as I hate myself for writing terrible discord.js usage like this:
const client = new Client({ intents: ["GUILDS"] }); client.token = "<token>"; const guild = await client.guilds.fetch("412130302958239745");This code is functional, and will return a horribly useless partial Guild object. But it does work.
I don't know of any projects using such methods for fetching data without logging in. However, if this is something that some users do, we could remo...
True, the main problem is the advantage of that. In some places we're sure that the client is logged or that, however, some properties are not null, but we still need to use an assertion like isReady(), which is really annoying... Anyway, I think this at least add an easy way to let TS know that some properties are not nullable without using non null assertions or difficult typecast.
If there exists cases where it is wrong, then it is wrong. Not a fan of this unless those edge cases can be fixed.
And removing things that make it wrong is a bad approach.
28b5ffb docs(ClientUser): fix shardId nullable (#6072) - DTrombett
fb8bc2e Docs build for branch master: 28b5ffb4d67d9b8ba... - iCrawl
The underlying issue seems to me to be that there is no single well-defined state in which the client is logged in aside from client events.
With this in mind, universally generalizing the Base class doesn't make sense currently. I can see a few potential solutions for this:
- Keep
Basegeneric and set classes that could be retrieved without a logged-in client to extendBase<boolean>instead ofBase<true>. This doesn't really offer a benefit, overall, though, since for example `Gu...
It seems to me actually that Base is outside the scope of the PR. I'll revert back to 4bdf25a, before Base was generified.
Yea, I can no longer reproduce the bug. Closing issue
Please describe the changes this PR makes and why it should be merged:
This PR fixes the jsdocs and typings for GuildInviteManager's FetchInvitesOptions, since #6036 the fetch methods channelID param was changed to channelId which the casing wasn't fixed in the type declarations file, and channelId was missing completely from the JSDoc. The JSDoc was also inconsistent with what was in the typings file.
Status and versioning classification:
- Code changes have been tested against ...
Please describe the changes this PR makes and why it should be merged:
This PR fixes #6075 by using the presence returned from PresenceManager#add.
The cause for this is a combined effort of #6013 and #6055:
The first would discard the presence on insertion (as intended when not caching them), causing the getter to return a default presence here.
With the second the default presence was removed, causing the getter to now return null, causing this crash.
~~I should have spotte...
Should be done! LMK if there's something to change.
Mmh, no? channelId is a Snowflake, not a resolvable. It's a good idea to change this to a GuildChannelResolvable but this means that the name should be changed to channel and resolveId should be changed to resolve in the function.
9cd5e7e refactor(Managers): rename add to _add (#6060) - 1Computer1
6b73e85 Docs build for branch master: 9cd5e7ed6104e40c0... - iCrawl
@almostSouji what would the cooldown time be?
Please describe the changes this PR makes and why it should be merged:
This PR reverts const enum to enum so that TS users can use index access with variables without receiving the error A const enum member can only be accessed using a string literal.
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't need updating
- This PR **on...
Please describe the changes this PR makes and why it should be merged:
The reply method returns Promise, so .then(console.log) is pointless. This replaces the log with a simple string to acknowledge success. I left other methods that potentially resolve into void (defer, followUp, etc) alone.
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't need updating
- This PR *...
This will throw a big error...
* .then(() => console.log('Reply sent.'))
if (this.client.listenerCount(Events.PRESENCE_UPDATE) && !newPresence.equals(oldPresence)) {
Probably got removed on accident
Shouldn't at least the example at line 71 be changed too?
Doing this brings back this issue: https://github.com/discordjs/discord.js/pull/6065#discussion_r664458288
Those enums should either be objects in the declarations or enum equivalents in the constants file (would require a small modification to the createEnum function)
Mmh should we change them to interfaces or types?
There are a few more logs like these in this file, if you want to include them. :eyes:
c1eaa78 typings(GuildInviteManager): FetchInvitesOption... - BannerBomb
67e9ce4 docs(InteractionResponses): generalize wording ... - BaumianerNiklas
751326f Docs build for branch master: c1eaa78ab7cef55f2... - iCrawl
d205e70 Docs build for branch master: 67e9ce46933c6471f... - iCrawl
Isn't this set in the constructor, and is independent on the client logging in?
This feels wrong... I can set the token as a string even without calling login and it's technically a string even if the client isn't ready, and can be used (Mon's example of using it just for rest actions is a perfectly valid example)
Right. I'll change it to If<Ready, string, string | null> then
I think that creating an interface ConnectedClient extends Client where you override the relevant properties as non-nullable is a more elegant approach, something like Client<true> can be confusing at first sight and the If type also won't work if we decide to have optional properties at some point in the future.
As per an earlier comment on that:
Why not just using something like Partials? Like, create an interface called LoggedClient and pass it in events (where we're sure the client is logged).
That's another approach that could work; I settled on a generic type as it results in minimal overhead for existing users. i.e. just change
ClienttoClient<true>and it works, no need to import another type.
Well in an event (that is not in our index file) we'll need to import Client probably, as we don't need to declare them but use with a function parameter or with the .client property
This seems to be errored logic in the original as well, I'll replace 0 with this.flags
It is, just not in the diff since I didn't need to change it
https://github.com/discordjs/discord.js/pull/6071/files#R178
Nope, I wrote it wrong, supposed to be !data.attachments ๐คฆ
No, the only way this could cause errors is if the _patch call in the constructor sets partial to true, so don't do that!
Well you would still need to do casting either way since we can't count on event clients being logged in except for in the ready event
Yeah, that's why it's the same... Maybe creating another type will be useful for people who are asking why is there a generic, but, at the same time, we still need to use the isReady / a typecast to let TS know that the client is logged.
b170fb5 docs(InteractionResponses): reply docs example ... - anandre
7945d34 Docs build for branch master: b170fb5ce8a487c38... - iCrawl
6301728 refactor(Channel): change channel types to UPPE... - ImRodry
e250ddf Docs build for branch master: 6301728d35cfdc8b3... - iCrawl
637c8e0 fix(PresenceUpdate): use added presence over nu... - SpaceEEC
bcf2192 Docs build for branch master: 637c8e0fdfb4ce153... - iCrawl
5b6be0c types(Test): fix overloads for channel create - iCrawl
55ff7ad Docs build for branch master: 5b6be0cebc4aefd93... - iCrawl
Please describe the problem you are having in as much detail as possible:
interaction.options.get('optionname') returns undefined, but when I do console.log(interaction.options) it is perfectly printed out, name, value, type...
Include a reproducible code sample here, if possible:
client.on('interactionCreate', async (interaction) => {
if (!client.application?.owner) await client.application?.fetch();
if ( message.content.toLowerCase() === '!deploy' &...
The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue โ you will get redirected there anyway.
This needs a rebase, btw.
As nice as this was for the user interface, as per internal discussion it was considered not future proof should there ever be a different type of Row component.
This removes support for sending a nested array of components, e.g. message.channel.send({ content, components: [[button]] })
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't need ...
With the removal of skipValidation, I believe the @param for this should also go on line 56, right?
Yeah thanks, I always miss docs stuff
But the MessageUpdateAction literally may create a new Message object and call _patch with partial=true...so, are you sure this isn't an issue?
If we go with space's suggestion, I'm more leaning towards the latter
You can't call _patch(data, true) on an uninstantiated message. In creating the new Message object via _add, it calls _patch(data), not partial, then patches as partial later.
Please describe the problem you are having in as much detail as possible:
Permission overwrites on old and new channel in channelUpdate are the same, making the permission bits from before the update inaccessible.
Include a reproducible code sample here, if possible:
client.on('channelUpdate', (o, n) => {
if (o instanceof DMChannel || n instanceof DMChannel) return;
console.log(inspect(o.permissionOverwrites.cache, { depth: 10 }));
console.log(inspect(n.permiss...
Please describe the changes this PR makes and why it should be merged:
This PR fixes #6082 by cloning GuildChannel#permissionOverwrites when cloning the channel itself.
This PR also addresses the issue that a passed iterable would cause the then created PermissionOverwrites to be without a channel as the channel property would be initialized after the parent's constructor added them.
(This might be better solved with another private method to be called from the deriving class...
d6c43a5 types(Partial): add partial reactions (#6066) - DTrombett
295c248 Docs build for branch master: d6c43a50bd608c233... - iCrawl
Please describe the changes this PR makes and why it should be merged:
Updates the typings for InteractionCollectorOptions so that a message sent by a webhook can be passed to it.
Status and versioning classification:
- I know how to update typings and have done so, or typings don't need updating
The typins are incorrect as it might be an ephemeral message too.
Please describe the changes this PR makes and why it should be merged:
Without this change the following code does not compile:
const client = new Client();
(async function() {
const options: WebhookMessageOptions = {
content: 'Testing content',
username: 'Testing',
};
const webhook = new Webhook(client, {id: '123', token: '456abc'});
const msg = await webhook.send({ content: 'Test' });
await webhook.deleteMessage(msg); // Argument of type 'Mess...
Do you mean that the typings are still incorrect, or that my change is incorrect?
My specific use-case is that I use webhooks, looking at the implementation of InteractionCollector it only uses the ID of the message, which APIMessage has.
Yeah, not sure what ephemerals have to do with this - there's no unique typings for those. This seems fine.
Well ephemeral messages only have the id and flags (ephemeral) properties, so it cannot be a valid Message - It should have its own type/be considered as a partial message.
The more I think about this - this isn't strictly correct. The implementation of InteractionCollector isn't fully designed to support raw messages.
I dont think you should just slap another typing on it without making changes to handle the fact that channel and guild properties won't exist, and therefore can't bind delete listeners.
Please describe the changes this PR makes and why it should be merged:
This PR fixes a bad check suggested in https://github.com/discordjs/discord.js/pull/6035#pullrequestreview-698709229 that would always return false since you can't check for values in an array.
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't need updating
PS C:\Users\NuL\Documents\BOT> npm install discord.js
npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git

npm ERR! errno -4058
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://git@github.com/discordjs/discord.js.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent...
PS C:\Users\NuL\Documents\BOT> npm install discord.js
npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git

npm ERR! errno -4058
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://git@github.com/discordjs/discord.js.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent...
You are missing git from your machine! You'll need to install it accoeding to your OS instructions
I dont think you should just slap another typing on it without making changes to handle the fact that
channelandguildproperties won't exist, and therefore can't bind delete listeners.
@monbrey
Correction: The library should actually handle this perfectly fine. this.message.channel will be undefined
f72ce7c fix(GuildChannel): clone its PermissionOverwrit... - SpaceEEC
3dd44f7 Docs build for branch master: f72ce7c136cf2dfe3... - iCrawl
Please describe the changes this PR makes and why it should be merged:
If you are in any guilds with stage channels, discord.js@11.6.4 will throw an error. This addition prevents that from happening and makes it work as intended.
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't need updating
Discord.js v11 is no longer maintained and will not be fixed.
Converting draft https://github.com/discordjs/discord.js/pull/4598 to an issue, since it serves the purpose of a note more than that of an actual draft at this point.
Setting the category of a guild channel is currently implemented with some major workaround. Should the suggested API feature come to pass this entire feature could very easily be implemented with a flag during the rest call.
Useful upstream topics:
serves more as a note than as a draft, hence converting to issue https://github.com/discordjs/discord.js/issues/6090
could this be related to https://github.com/discordjs/discord.js/issues/6082 and accordingly be fixed now?
Please describe the problem you are having in as much detail as possible:
When listening to the channelUpdate event and comparing the permissionOverwrites.cache from the old and new channel
they're exactly the same when editing permission overwrites in a guild channel
adding or removing a role/member is the most obvious way to see this with the code included below
Include a reproducible code sample here, if possible:
const Discord = require("discord.js");
const clien...
No problem, sorry for the delay I should check my mail more often, kinda my bad as well, since I couldn't explain it properly
I dont think you should just slap another typing on it without making changes to handle the fact that
channelandguildproperties won't exist, and therefore can't bind delete listeners.
@monbreyCorrection: The library should actually handle this perfectly fine.
this.message.channelwill be undefined
Nope, this still happens as of f72ce7c136cf2dfe31a67b190c00e30ba7d70bfa.
this is a much easier expression, thanks so much!
Please describe the changes this PR makes and why it should be merged:
In some situations PermissionsOverwrites#_patch was being called with an existing PermissionsOverwrites object rather than raw packet data from Discord (I observed this locally when an overwrite was removed from a channel). This meant that type was already a string, and so the enum conversion was resulting in it incorrectly being stored as a number.
This PR tweaks the patch logic in PermissionsOverwrites ...
@monbrey I think I get what you mean now. Does 15837bf39ce69be6ef4f6f71dcf3897695d0015a solve what you are talking about?
but an APIMessage isn't a MessageResolvable
might it be worth having some sort of resolveId function for resolving the message ID?
same here, perhaps using this.client.channels.resolveId but would require some modifications to accept raw api data so unsure
Please describe the problem you are having in as much detail as possible:
Updated Discord.js from 13.0.0-dev.5b6be0c.1625789033 to 13.0.0-dev.d6c43a5.1625918569 after noticing that #6082 was fixed in f72ce7c. Yet, while listening to the channelUpdate event, The Permissions overwrites for both old and new channel are still th...
Duplicate of #6082 and #6091
There's a PR to fix this already opened.
Duplicate of #6082 and #6091
There's a PR to fix this already opened. #6093Edit: It should be already fixed with this commit: https://github.com/discordjs/discord.js/commit/f72ce7c136cf2dfe31a67b190c00e30ba7d70bfa
Nope. Still logs the same bits.
Unable to reproduce as of f72ce7c136cf2dfe31a67b190c00e30ba7d70bfa, I can detect overwrites being added, removed and updated just fine.
@ZEUSGMJ You are reporting here that you updated to d6c43a5, which is before f72ce7c which was when the fix was merged...
Nope. Still logs the same bits.
The commit you provided is related to a pr merged 1 day ago. Try to update djs to get a newer commit.
Oh, my bad. ๐
I'll update it right now and check it.
Ah, do you recommend I change the following line instead?
So that it's: deleteMessage(message: MessageResolvable | APIMessage | '@original'): Promise<void>;
yeah that might be the better option
Shouldn't npm update discord.js@dev update it to the latest one? Running the command would just say that it's up to date (13.0.0-dev.d6c43a5.1625918569). Not sure what I'm missing/doing wrong.
Dev releases are only cut every 12h.
d433fe8 fix: channel type check in actions (#6086) - ImRodry
66931d3 Docs build for branch master: d433fe8a0827e6275... - iCrawl
Shouldn't
npm update discord.js@devupdate it to the latest one? Running the command would just say that it's up to date(13.0.0-dev.d6c43a5.1625918569). Not sure what I'm missing/doing wrong.
The command is actually npm i discord.js@dev
Using the npm update doesn't always work.
Shouldn't
npm update discord.js@devupdate it to the latest one? Running the command would just say that it's up to date(13.0.0-dev.d6c43a5.1625918569). Not sure what I'm missing/doing wrong.The command is actually
npm i discord.js@dev
Using the npm update doesn't always work.
Yeah, I also re-installed the package when trying to update it. But now it finally updated and it's working properly as expected.
In case of Windows, which seems to be your OS: https://gitforwindows.org
You are missing git from your machine! You'll need to install it according to your OS instructions
Please describe the changes this PR makes and why it should be merged:
This PR removes the inGuild method in Interaction, because, as discussed in the [Discord server](#archive-library-discussion message), it's used only in this structure (not in any other Structure like Message or Channel) and doesn't provide any type guard for TS users so it's really useless as shown below:
client.on("interactionCreate", (intera...
Please describe the changes this PR makes and why it should be merged:
This PR adds typings for the limits parameter in the cacheWIthLimits method and improve the description of the makeCache property in ClientOptions, replacing the old one that was still there.
Tests also updated.
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don...
Are you guys sure there will even be another type of Row? What advantages would this even give compared to the current rows? This PR literally just makes our life 10x harder than it was before :/
Please describe the problem you are having in as much detail as possible:
When deleting a permission ovewrrite from a channel the oldChannel keeps the permissionOverwrite type as a number (0 for role 1 for member)
Include a reproducible code sample here, if possible:
- Delete a permission overwrite to show the bug
client.on("channelUpdate", (oldChannel, newChannel) => {
console.log(oldChannel.permissionOverwrites.cache.first()?.type, newChannel.permissionOverwrit...
I don't think this should be deleted at all, but rather refactored to actually assert that the Interaction instance is received from a guild (consider this: example
client.on('interactionCreate', async (interaction) => {
if (interaction.inGuild()) {
// We know that member is not null now!
const roles = interaction.member.roles;
const roleCount = Array.isArray(roles) ? roles.length : roles.cache.size;
await interaction.reply({ content: `Hello ${interaction.user.tag}, ...
Hello, when i'm trying to make Role protection when someone enable ADMINISTRATOR Permissions in a role the bot automotaclly remove it but the bot don't show any error and didn't change anything! and i tried the code below and i got the same results (No error and didn't change the permissions)
TestCode:
client.on("message", message =>{
if(message.content.startsWith("$test")){
let adminRole = message.mentions.roles.first(); //Mention ADMINISTRATOR role!
adminRole.p...
Please describe the problem you are having in as much detail as possible:
the code explains itself
Include a reproducible code sample here, if possible:
const Discord = require('discord.js');
const client = new Discord.Client({ intents: ['GUILDS', 'GUILD_MEMBERS', 'GUILD_INVITES', 'GUILD_MESSAGES', 'DIRECT_MESSAGES'] });
const config = require("../database/config.json");
client.login(config.token);
var invites = {};
client.on("ready", () => {
c...
Please describe the changes this PR makes and why it should be merged:
Guild#fetchVoiceRegions was removed in https://github.com/discordjs/discord.js/pull/5766, but wasn't removed from the typings. This PR fixes that.
Status and versioning classification:
Please move lines that apply to you out of the comment:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't need updatin...
Have discussed with Vlad, this type should achieve the original intention of the method:
public inGuild(): this is this & { guildId: Snowflake, member: GuildMember | APIInteractionGuildMember };
a8984bc types(Guild): remove fetchVoiceRegions (#6099) - ThaTiemsz
a23f67a Docs build for branch master: a8984bc68c8ac6be6... - iCrawl
It could be because the classes are mutable so since you're not cloning any of the invite classes from the cache that you fetch from the ready event they will change when the patch method is called. Fetching invites from the guild also looks in the cache before fetching from the API by default so since you aren't forcing the fetch you are just getting the same cached classes both times you fetch the invites.
Basically both invitation_before and invitation_after will contain the same data s...
Please describe the problem you are having in as much detail as possible:
Include a reproducible code sample here, if possible:
// Place your code here
Further details:
- discord.js version:
- Node.js version:
- Operating system:
- Priority this issue should have โ please be realistic and elaborate if possible:
Relevant client options:
- partials: none
- gateway intents: none
- other: none
**I have just moved into discord.js@dev, and in this version it is required to use intents unlike the other version. While using the intents, I got this error: **
TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.
This error is not only crashing the bot, but not allowing the bot to login.
NEW CODE:
const Discord = require('discord.js')
const { Client, Intents } = Discord
const client = new Client({
partials: ["REACTION", "MESSAGE"],
...
The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue โ you will get redirected there anyway.
dee5c83 fix(PermissionsOverwrites): only convert type i... - MattIPv4
1dcad05 revert: support for nested arrays of components... - monbrey
876e4cc Docs build for branch master: dee5c83fc0d1147d5... - iCrawl
1ab110f Docs build for branch master: 1dcad051a835407bc... - iCrawl
If you want to modify the role's permissions (which this looks like) you need to call Role#setPermissions,
Permissions#remove modifies the underlying bitfield but does not push any changes to the Discord API. It's a method on the Bitfield wrapper, rather than the role.
The issue tracker is only for bug reports and enhancement suggestions. ...
It's quite horribly chained I agree, using resolveId will help a bit I suppose.
this.channelId = this.client.channels.resolveId(options.message?.channel) ?? options.message.channel_id ?? this.client.channels.resolveId(options.channel) ?? null;
No, this still introduces the same flaws in the design. I was originally considering the same things - why not just accept Snowflakes/Resolvables for these parameters?
The answer is because there's really no way to guarantee three different Snowflakes are remotely related, if provided for all of message/channel/guild in options. This is why the original code preferred the Message object over any additionally provided options.
If this is the redesign you want to go with then yes, `resolv...
It could be because the classes are mutable so since you're not cloning any of the invite classes from the cache that you fetch from the ready event they will change when the patch method is called. Fetching invites from the guild also looks in the cache before fetching from the API by default so since you aren't forcing the fetch you are just getting the same cached classes both times you fetch the invites.
Basically both invitation_before and invitation_after will contain the same ...
Ok, that seems like the best solution. I will work on it as soon as possible.
I've looked at the ActionsManager.js file, and saw that it was pretty impractical. So, here's my easier and way less complex version using fs.
Status and versioning classification:
let allFiles = fs.readdirSync("./").filter(file => !["Action.js","ActionsManager.js"].some(a => a === file))
file => !["Action.js","ActionsManager.js"].includes(file)
for (const file of allFiles) {
You're aren't ever updating the value of file, so const should be preferred
Never thought of it that way, so sure.
const allFiles = fs.readdirSync("./").filter(
I love this, why hasn't discord.js staff accepted this yet?
const allFiles = fs.readdirSync(__dirname).filter(
Is your feature request related to a problem? Please describe.
Discord is adding the Guild Avatars feature to have different profile images in different guilds. There is already a PR to add it to retrieve the guild avatar from a GuildMember (#5696) but I think it should be possible for the client itself to change avatars in different guilds. I'm not aware if this is implemented in the API yet, I can't find it in the official docs page where it would be (https://discord.com/developers...
We like to keep our Issue Tracker empty of useless issues.
Currently there is no plans as I see it to implement this for bots, so reopen when it is actaully planned/docuemnted in their docs.
The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue โ you will get redirected there anyway.
Not to be confused with your custom status, the "bio" or "about me" section of a user's profile.
You'll have to ask Discord, but currently it looks like they suspect bio data to be identifying, private information which they don't want to be scraped by bots as per https://github.com/discord/discord-api-docs/pull/2951, https://github.com/discord/discord-api-docs/issues/3095
The banner might become accessible soon as per https://github.com/discord/discord-api-docs/issues/3095#issuecomment-868817186 . If this gets documented on the API docs we will include the feature into discord.js at ...
You'll have to ask Discord, but currently it looks like they suspect bio data to be identifying, private information which they don't want to be scraped by bots as per https://github.com/discord/discord-api-docs/pull/2951, https://github.com/discord/discord-api-docs/issues/3095
The banner might become accessible soon as per https://github.com/discord/discord-api-docs/issues/3095#issuecomment-868817186 . If this gets documented on the API docs we will include the feature into discord.js at ...
The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue โ you will get redirected there anyway.
I already asked but no one knew
๐งน
file => !['Action.js', 'ActionsManager.js'].includes(file)
@xHyroM let's change everything to ' instead of " bcuz you already changed the one ESlint thingy
Djs has a code style, which uses ' instead of ". You should run npm test and npm run prettier in your terminal to fix all your ESLint and prettier errors
You can save a second iteration here:
const files = fs.readdirSync(__dirname);
for (const file of files) {
if (['Action.js', 'ActionsManager.js'].includes(file)) continue;
this.register(require(`./${file}`));
}
what about iterating through WSEvents?
Please describe the problem you are having in as much detail as possible:
When I try to spawn multiple shards with ShardingManager in the worker mode I get an error for every ws message
Include a reproducible code sample here, if possible:
const Iscord require('discord.js');
new Discord.ShardingManager('index
js', {
token: 'token',
mode: 'worker',
totalShards: 2
}).spawn();
Further details:
- discord.js version: ^13.0.0-dev.1dcad05.162609138...
@Sly-Little-Fox
Then discord.js v13 will not work on replit
You still can install newer version of node in replit
Simply typenpm i node@14in shell.. and enjoy! ๐
I just tested it- it doesn't look like that works- I still get an error thrown when I attempt to run a v13 bot. Looking at some comments online, it seems like Repl.it doesn't like other versions of Node... unless there's a glaring issue I've overlooked and the answer was a switch I forgot to flip somewher...
You should be able to use it if you have a start script in your package.json, like:
"scripts": {
"start": "node bot.js"
}
That would use the npm package node instead of the machine's node installation.
Please describe the changes this PR makes and why it should be merged:
This PR creates a new structure, CommandInteractionOptionResolver, which acts as a resolver for CommandInteraction options. This replaces the existing Collection on CommandInteraction#options with the new class.
The new class will allow for easier usage and validation of command options. It also will serve as an additional check against users having mismatches between their option types and their execution ...
Please describe the problem you are having in as much detail as possible:
- I really don't know why but I receive these errors even though I'm on the latest version.

- My discord.js version:

Include a reproducible code sample here, if possible:
imp...
Please describe the changes this PR makes and why it should be merged:
Fixes an issue with Interaction#defer, due to the overload types the return type would default to Promise when no parameter was passed.
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't need updating
If you could add some type tests in typings/index.ts to ensure the returned type is the correct one, this would be perfect. Otherwise LGTM
Use npm instead of yarn or clear yarn cache, then reinstall djs dev.
The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue โ you will get redirected there anyway.
Wait, this means that we can't use interaction.defer() without passing any parameter?
Changed inGuild return type and added tests. LMK if it's ok.
Please describe the changes this PR makes and why it should be merged:
โ ๏ธ Updates Collection dep, including breaking changers
Adds SweptCollection (mainly for use with threads but has other uses). This can replace Client#sweepMessages, however with the loss of debug events, which is why it was not removed.
Other breaking change is the change in ThreadManager, to automatically sweep archived threads older than 4 hours every hour (default sweep settings)
I'm open to changes for...
typeof setting !== 'object' should already exclude undefined.
setting === null || typeof setting !== 'object' || setting.sweepInterval
This should be converted to a plain function since arrow functions don't have this and cannot be binded.
Wouldn't be good here to use !(client instanceof Client) instead?
Should I wait for #6110 to be merged to add types for new methods too?
I actually bound this out of habit, it's unnecessary. Arrow functions use the parent scope, so I'll just remove the bind
98c6078 types(Interactions): fix function overloads (#6... - thehackerboi69github
552444f Docs build for branch master: 98c60789a2bc38a99... - iCrawl
Please describe the problem you are having in as much detail as possible:
In version v13 of discord.js, I can't fetch members of any guild. .guild.members.cache.map(x => x) always returns me and bot, instead of all members from guild. In v12 bug doesn't exists.
Include a reproducible code sample here, if possible:
`client.on("messageCreate", async msg => {
console.log(msg.guild.members.cache.map(x => x).length) //returns 2 ALWAYS
console.log(msg.guild.memberCount) ...
You're missing the GUILD_MEMBERS intent, which explains why the cache is so empty.
This issue tracker is only for bug reports and suggesting enhancements.
If you have a question, please ask it in the Discord Server instead of opening an issue โ you'll be redirected there anyways.
Shouldn't this be called something like.. SweepableCollection? English is beating me, so I'll summon the @discordjs/the-big-3
Please describe the changes this PR makes and why it should be merged:
This PR allows you to append information about the bot (like a website, version) to the end of the (already required) user agent. As specified in the API documentations, users should be able to do so and are encouraged to do it.
Discord.js users could alternatively modify the constants file, where the user agent string is defined, but it can lead to them...
Now that you don't instantiate a collection anymore, this method could technically also be replaced by a map call:
this.options = new CommandInteractionOptionResolver(
data.data.options?.map(option => this.transformOption(option, data.data.resolved)),
);
Same as above
if ('options' in option) result.options = option.options.map(option => this.transformOption(option, resolved));
You should add all error messages to /src/errors/Messages.js and require the custom error class from ../errors
Why not making it a string instead of an array?
Why not making it a string instead of an array?
It takes the approach of RFC7231. Each segment is divided, and it would be useful if those are reflected in the client option as well.
I think the validateOptions method should be updated as well
https://github.com/discordjs/discord.js/blob/72473e0bf73187a0b3f5bac3ebe4ab273be68d90/src/client/Client.js#L468
I think the validateOptions method should be updated as well
Ahh, my bad! I'll fix it in a moment
They would behave the same as far as I can tell. Not sure what the need would be for a separate method.
Users will always have at least one subcommand at the same level, but usually more. It doesn't make much sense to me for it to be required.
Technically speaking the jsdoc and typings say that you pass a djs client, but that's not necessarily a requirement, its just an easy way to describe what it wants. For typings I can make it better, I have no idea what to do for the docs though.
The idea is you could pass your own client with a setInterval method since this doesn't have to be used within djs, allowing it to be destroyed with your client (that's the whole reason for it anyways, when done internally, we want to destroy th...
I followed the convention of LimitedCollection, open to change though
this.fullUserAgent = `${UserAgent}${userAgentSuffix.length ? `, ${userAgentSuffix.join(', ')}` : ''}`;
Collections have a sweep method, which makes them... sweepable.
SweptCollection is fine.
I considered doing this. However, further down the line, I saw the same thing with this.path. Thought it would make the most sense if it were to be consistent.
@Sly-Little-Fox
Then discord.js v13 will not work on replit
You still can install newer version of node in replit
Simply typenpm i node@14in shell.. and enjoy! slightly_smiling_faceI just tested it- it doesn't look like that works- I still get an error thrown when I attempt to run a v13 bot. Looking at some comments online, it seems like Repl.it doesn't like other versions of Node... unless there's a glaring issue I've overlooked and the answer wa...
* @returns {?(GuildChannel|APIInteractionDataResolvedChannel)}
* @returns {?(Role|APIRole)} The value of the option, or null if not set and not required.
* @returns {?(GuildMember|APIInteractionDataResolvedGuildMember)}
I considered doing this. However, further down the line, I saw the same thing with
this.path. Thought it would make the most sense if it were to be consistent.
It's a different implementation. For queryString to be falsy, it has to be an empty string. As for userAgentSuffix.length, it has to be 0, resulting in ${UserAgent}0
guess i forgot to add an actual comment, but yes pretty much what @almeidx said, in this case it would add a 0 after the user agent
Ah, my bad! I didn't notice. Fix will be pushed soonโข
I guess I should have explained why, the reasoning for this is explained here: #6021
return option && new CommandInteractionOptionResolver(this.client, option.options);
Also, just one tiny question... we need to access to the Client instance, in an object that is used to build the instance itself, do you have an example on how to use this?
So... per hour?
Also, why is this in seconds?
suppose you could do [required=false] but I only thought this after I made all the review comments and im lazy
const option = this.get(name, required);
if (!option) return null;
else if (!types.includes(option.type)) {
throw new TypeError('COMMAND_INTERACTION_OPTION_TYPE', name, option.type, types);
} else if (required && properties.every(prop => option[prop] === null || typeof option[prop] === 'undefined')) {
throw new TypeError('COMMAND_INTERACTION_OPTION_EMPTY', name, option.type);
}
return option;
return option && (option.member ?? option.user ?? option.role ?? null);
const option = this._options.find(opt => opt.name === name);
if (!option) {
if (required) {
throw new TypeError('COMMAND_INTERACTION_OPTION_NOT_FOUND', name);
}
return null;
}
return option;
typeof null is object, next line will fail because properties can't be deconstructed out of null
perhaps no default initilization for the parameter
Please describe the changes this PR makes and why it should be merged:
:warning: This PR removes the following methods:
Client#setTimeoutClient#setIntervalClient#setImmediateClient#clearTimeoutClient#clearIntervalClient#clearImmediateClient#destroy
Why?
The aforementioned methods existed to make timers not hang the process when it's destroyed and nothing else kept the process on (from the user's side). Since all timers have an unref method ([`Im...
From the discord, my suggestions on the interface:
-
Remove client related stuff after #6113.
-
More general interface like so:
export class SweptCollection<K, V> extends Collection<K, V> {
public constructor(options: SweptCollectionOptions<K, V>, iterable?: Iterable<readonly [K, V]>);
public maxSize: number;
public maxSizePredicate: ((value: V) => boolean) | null;
public interval: number | null;
}
export interface SweptCollectionOptions<K, V> {
maxSize?: numb...
eh, i feel like it makes more sense here since if option is null, you're just doing undefined ?? undefined ?? undefined ?? null
i feel like if statements make more sense than assigning the property to itself
So is it a property or many properties?
return new Collection(data.map(sticker => [sticker.id, this.add(sticker, cache)]));
can't multiline comment on mobile, line below needs to be removed also
if (file?.file) body.append(file.key ?? file.name, file.file, file.name);
Can you make the name parameter in getSubCommand optional? A command has multiple subcommands but only one can be ran at once so it doesnโt make much sense to specify the name of the command since youโre not supposed to know what name thatโs gonna be.
return this.avatarURL(options) ?? this.user.displayAvatarURL(options);
That's why getSubCommand can't be required. It is as intended. Here is an example:
async function run(interaction: CommandInteraction) {
const subcommand1 = interaction.options.getSubCommand("sub1");
const subcommand2 = interaction.options.getSubCommand("sub2");
if (subcommand1) {
const subarg1 = subcommand1.getInteger("subarg1");
// etc.
} else if (subcommand2) {
const subarg2 = subcommand2.getUser("subarg2");
// etc.
}
}
Yeah, sweeps hourly by default, I have no idea if thats a good interval, it definitely could be pretty long.
Do you mean in seconds vs minutes or seconds vs ms
I swear I handled that ๐คฆ. I want to not be able to pass no options though, so default is just wrong, will be {} , while still needing the check for null just in caes.
const subcommand1 = interaction.options.getSubCommand("sub1");
const subcommand2 = interaction.options.getSubCommand("sub2");
I don't think this captures what Rodry meant, nor does it really address #5880 if I still don't immediately know which subcommand was run. Why would I want to try to get both (or more) subcommands - you know it has to be one of them. I just want to get whichever one it is.
const subcommand = interaction.options.getSubCommand();
if (...
I think we'd use interfaces there, if we go that route.
So I should move them to the main index.d.ts file and convert them to interfaces?
This could be keyof CacheFactoryArgs, but it does not seem to be used anywhere (anymore?)?
client is now removed from this :)
This what? The generic type T?
Did most of what comp suggested, couple of name changes to make it clearer what these things do.
The only thing I didn't touch:
- Too many
cacheWiths now, I think it's best to do this perhaps:public static cacheByManager(fs: Record<string, () => Collection<any, any>>): CacheFactory { ... }
What's the point in this, this seems harder than just implementing your own makeCache function. In fact, the only difference is that you're not building the default case.
The interval should be unref'd, so it doesn't hang the process.
sweepInterval > 0 && sweepFilter ? setInterval(() => this.sweep(this.sweepFilter()), sweepInterval * 1000).unref() : null;
sweepInterval: require('./SweptCollection').filterByLifetime({
Maybe make a special callback that always returns false when excludeFromSweep is null?
if (excludeFromSweep === null) return () => false;
That way we can optimize this kind of operation, and we skip a check in this callback.
Is it really okay to not clear at least the intervals anymore?
A destroyed client will now continue sending typing start requests.
(As well as sweep messages and handlers, but those don't hit up Discord's api)
This is the exact opposite of what its supposed to do, when null it should sweep everything. I've just changed the default to be () => false since it'll make it more clear
[discordjs/discord.js] New comment on pull request #6078: refactor: change const enums to interfaces
Converted all const enums to interfaces. LMK if it's ok.
That is to match the current message sweep options and because sweeping on ms intervals seems impractical, also looks cleaner in end code.
Please describe the changes this PR makes and why it should be merged:
- Added
Typingstructure. - Renamed
TextBasedChannel#startTypingtosendTyping.
Additionally, this will not longer run a 9s interval sending additional requests, but instead, it will do so only once without any internal tracking. - Removed
TextBasedChannel#stopTypingas it relied on internal tracking. - Removed
TextBasedChannel#typingas it relied on internal tracking. - Removed `TextBasedChannel#typingCou...
should probably mention how long it lasts
How long it lasts is not documented in the docs.
The member getter can returns null when the channel is in a guild if it's not cached.
public inGuild(): this is this & {
channel: TextChannel | NewsChannel | ThreadChannel;
readonly guild: Guild;
};
This is missing the return. Also why is there async / await if the promise is returned?
sendTyping() {
return this.client.api.channels(this.id).typing.post();
}
The count parameter doesn't exist anymore.
sendTyping(): Promise<void>;
A destroyed client will now continue sending typing start requests.
Fixed with #6114 ๐
(As well as sweep messages and handlers, but those don't hit up Discord's api)
Assigned the relevant intervals and calling clear on them since the last commit, good catch ๐๐ผ
It returns a Buffer instance, which may not be elegant.

Ohh, so the async / await without returning is to returns the Promise without the result of the post call? Nice!
A very large downside of this is that we can't use them like enums anymore in types, which forces us to do typeof ConstantsEvents['MESSAGE_CREATE'] over ConstantsEvents.MESSAGE_CREATE, but sure.
Optional destructuring, but otherwise LGTM
const { userAgentSuffix } = this.client.options;
Should be converted into an else if instead (so it doesn't run if the first check passes)
Shouldn't this be the same as the functions below?
D:\Bot discord\XG-up-timer\node_modules\discord.js\src\rest\RequestHandler.js:15
4
throw new DiscordAPIError(request.path, data, request.method, res.status);
^
DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (D:\Bot discord\XG-up-timer\node_modules\discord.j
s\src\rest\RequestHandler.js:154:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (D:\Bot discord\XG-up-timer\node_modul...
The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue โ you will get redirected there anyway.
a9e7ebd types(PartialWebhookFields): add APIMessage to ... - Bluenix2
60148c6 types(Interaction): change inGuild return type ... - DTrombett
774ca13 Docs build for branch master: a9e7ebd94fa430bfc... - iCrawl
9b7a06f Docs build for branch master: 60148c6a78d905719... - iCrawl
4206e35 feat(Client): add conditional ready typings (#6... - shinotheshino
3701da8 Docs build for branch master: 4206e35b2316431c1... - iCrawl
Hey @MattIPv4, from what I understood in this issue, in the child category the new and old channel gives the same out when called for permissionsLocked.
Also, what is permissionOverwrites.some?
in the child category the new and old channel gives the same out when called for permissionsLocked.
That is one consequence of the issue, yes, but it is not the root cause. The root cause is that the parent receives an update first, so when the child update comes through the child is perceived to be out of sync with the parent, when in reality the child is being updated because it is in sync with the parent.
Also, what is permissionOverwrites.some?
Do you think it is possible that the child is updated first and then the parent channel, which could be a possible reason why this is happening? I'm testing trying to debug and this issue and had this thought.
Thoughts @MattIPv4 ?
No, the parent is updated first. If you run my repro code locally you will be able to observe the parent update event arrives first, which updates the d.js cache for both the parent and therefore the child. The child update event then arrives after, at which point the parent has already been updated and so the child is perceived as out of sync.
I'm trying to run your code and getting this error
TypeError: newChannel.permissionOverwrites.some is not a function
Node: 14.6.0
Yup, as I noticed two replies above, with recent changes to master I believe it is now permissionOverwrites.cache.some...
From what I understood and debugged only we can see channel category being updated for new and old channel. So we need to handle the events in such a way that the differences in the permission would be seen in the child channel too(Text, Voice, etc).
And yes you were right first the category is being updated and then the child channels.
Hey @MattIPv4 so I tried this:
client.on('channelUpdate', (oldChannel, newChannel) => {
console.log(newChannel.type);
if (newChannel.type === 'GUILD_CATEGORY') {
console.log('Category permissions updated');
return;
}
if (newChannel.type === 'GUILD_TEXT') {
console.log('Text channel permissions updated');
console.log('Synced before update:', oldChannel.permissionsLocked);
console.log('Synced after update:', newChannel.p...
Yeah, that looks like it also demonstrates the issue here -- permissionsLocked is incorrectly reported as false for the children updates, because the category has already been updated in the cache.
Yeah, that looks like it also demonstrates the issue here --
permissionsLockedis incorrectly reported asfalsefor the children updates, because the category has already been updated in the cache.
Hey, Matt isn't it how it is supposed to be?
Let's assume:
Category Channel Updated -> TextChannel Updated so the oldChannel.permissionsLocked (text channel) would be false because the parent channel has different perms. And the updated `NewChannel.permissionsLocked (te...
- Also adding to this please send the message to the user after the role is assigned, this would make more sense to the user and he/she/they won't be confused why they got a message and still don't have the
verified roles. - Also try to make the encapsulate
AssignUserRole()andchangeRoles()inone function, - [Optionally] if possible try to
return a promisefrom your function to the main call, which we would ensure that the role was assigned or not. - One more thing would b...
Yes, based on the current logic, it is the expected behaviour. However, given that permissionsLocked is a helper provided by D.js rather than by Discord, it would be nice for it to be improved, so that it can handle this situation and correctly reflect that the permissions were set to be in sync the whole time.
What should be the desired output here instead, how can we change the handling here?
Can you give me an example?
I would expect permissionsLocked to report true always here, as the permissions were still set to be synced, and were updating because they are synced with the parent category.
console.log('Synced before update:', oldChannel.permissionsLocked);
console.log('Synced after update:', newChannel.permissionsLocked);
So basically both should return true?
Yes ๐, because they were still set to be synced, and were updated in exactly the same way the parent was, as they are synced.
No, because subcommand groups will have an options property which needs to be assigned
This would then defeat the purpose, would it be better if we just had NewChannel.permissionsLocked so that it's always in sync?
No, it does not defeat the purpose... the whole idea here is that I want to be able to accurately report when a channel has its permissions updated in such a way that means the permissions are no longer set to sync. This current behaviour results in continual false positives, as the value of permissionsLocked switches indicating that the sync of the channel permissions was updated, when in reality the option to sync wasn't updated, the permissions were in fact updating to remain in syc.
Oh, got it! I was not able to understand the sync thingy for a while now I get it. Ok, so we can actually do that by check the permissionsLocked of oldChannel(text channel) with the old Permission of the Category channel. This would result in
`oldChannel.permissionLocked to be true and the channel to be synced always if it was synced.
I hope this would solve the issues here?
Yup, that sounds like the right theory.
banner and banner_color are documented in https://github.com/discord/discord-api-docs/pull/3448 and are currently accessible via the canary API (in ClientOptions: http: {headers: {'x-debug-options': 'canary'}} or http: {api: 'https://canary.discord.com/api'})
Open to suggestions for a better default, don't know what it would be atm
I want it to be an intentional decision to not sweep, not an oh I forgot to add a return before the functoin, that's why my memory is going out of control
* @property {?SweepFilter} [sweepFilter=null] A function run every `sweepInterval` to determine how to sweep
* @param {Object<string, SweptCollectionOptions|number>} [settings={}] Settings passed to the relevant constructor.
Record type doesn't exist in jsdoc
it is the object, I just still associate the return value with the id ๐
I'll need someone else to take care of that PR because I won't be available for the next 2 weeks and Discord seems to be slowly releasing the banner on the API.
Why did you remove structures? I have used it very often in my projects.
Kindly read the original PR https://github.com/discordjs/discord.js/pull/6027 which is linked in both the opening post, it explains the reasoning of why this was a bad idea to implement to begin with and why it was subsequently removed in at-dev (which will release as v13)
No backticks would apply the users font ๐
@advaith1 will be taking over this in a new PR.
Please describe the changes this PR makes and why it should be merged:
Currently, User#fetch ignores the force parameter, always treating it as false. This PR fixes it.
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't need updating
While you're at it, could you fix the same problem with the other structures, like Channel#fetch ()?
Please describe the changes this PR makes and why it should be merged:
This PR is a continuation of #5930
Adds User#banner, User#bannerURL(), User#bannerColor, and User#hexBannerColor (all require the user to be force fetched)
Since this is currently only implemented in the canary API, you must add http: {headers: {'x-debug-options': 'canary'}} or http: {api: 'https://canary.discord.com/api'} to your ClientOptions to test this
Status and versioning classification:
- C...
* @param {boolean} [force=true] Whether to skip the cache check and request the API
* @param {boolean} [force=true] Whether to skip the cache check and request the API
* @param {boolean} [force=true] Whether to skip the cache check and request the API
this is just the larger discussion of:
"should we prioritise other people's code quality, and add major breaking changes that will make a lot of people mad for breaking code that has been valid for years"
or
"should we be a normal library, and not break every standard in the rulebook, and prevent users from going 356 different ways about it"
and if you've used Discord.js, you already know it's an opinionated library /shrug
No, because https://github.com/discordjs/discord.js/pull/6107/commits/6d4f5ad11bc8c59321c946e87af8f74ec5beca90#diff-b7a378d6e6f1796a78cb4f3d3465eb376681eb389a2980c4b7c955642b213beaR91 -- according to the API docs, you can't have any other option types at the same level as a sub-command/sub-command group, so it makes sense to assert this.
This is code:
message.channel.send({files: [./downloader/music/${musictitle}_Edo-Music.mp3]});
// or
Const musicfile = new Discord.Attechment(./downloader/music/${musictitle}_Edo-Music.mp3);
Message.channel.send("mp3 file", musicfile);
And i recive this error:
how to fix this?
(node:7036) UnhandledPromiseRejectionWarning: AbortError: The user aborted a request.
at RequestHandler.execute (C:\Users\Lion\Desktop\Music Discord - V4\node_modules\discor...
The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue โ you will get redirected there anyway.
banner and banner_color is now in the stable API
Discord will make banner_color an integer instead of a string to be consistent with other colors; this PR will be updated when that change is live
So I'm trying to send an embed as a result of an interaction. The issue is that I can't send a post callback to the interaction unless theres a message. Is there a way I can attach the embed as part of the message body or return an interaction resolve so that on discord I don't get the error "Interaction failed"? Any help is appreciated thanks!
Sounds like you might be sending the embed incorrectly, as it should be an acceptable response.
interaction.reply({ embeds: [yourEmbed] })
okay thanks! Do you know where I could find this in the documentation? The issue is that I do Client.ws.on("INTERACTION_CREATE", func) and I'm not sure how to defer the interaction or send a resolve promise. When I tried doing the above, it says that interaction.reply() is not a function
you should use discord.js v13 and the d.js interaction event (client.on('interaction', func))
guide: https://v13-prep.discordjs.guide/interactions/replying-to-slash-commands.html
you can also ask in #djs-slash-commands in https://discord.gg/djs
Problem: Whenever I set the activity for the client user in the ready event, it doesn't appear on Discord and I get no errors thrown.
const statuses = {
"online": "Online",
"idle": "Idle",
"dnd": "Do Not Disturb",
"invisible": "Offline"
};
await client.user.setPresence({
status: "online",
activity: {
name: `${client.guilds.cache.size} servers | ${client.commandHandler.prefix}help`,
type: "WATCHING"
}
})
.then(async prese...
I think we already resolved that on the discord.
The dev branch uses activities and takes an array.
Yeah sorry, I just tried using the array method on v12 and it worked.
Never mind, I had the code for v13 running on the same bot as v12, so I'll need to reopen the issue, apologies
Well everyone's telling me to close it and ask in the support channels even I already have done so plenty of times so due to the pressure I will close this issue.
Can not reproduce on 13.0.0-dev.4206e35.1626393827 after using an activities array, as documented.
Running two bots on the same token will additionally mess with presence data and is not a supported use case. If tested on the above version with a single process running on the token the adapted code (again, v13/@dev requires an activities array to be passed) works as expected.
The issue tracker is only...
Above should be the marked answer, but GitHub only allows toplevel responses to be marked so here we go.
You should be using the library native approach to handling interactions
Sounds like you might be sending the embed incorrectly, as it should be an acceptable response.
interaction.reply({ embeds: [yourEmbed] })
I'm not a fan of this code, since it's the checks and user agent are done in every request rather than doing it only once (maybe in the RESTManager?).
I won't block, we can seek an alternative with a smaller performance impact later in another PR.
8db6df3 types(Options): add types for cacheWithLimits (... - DTrombett
2e0fbd3 Docs build for branch master: 576eee8de26bf9e62... - iCrawl
578a435 Docs build for branch master: 8db6df3d1eb58c542... - iCrawl
f200f14 feat(REST): append additional information to th... - QSmally
9d09d22 Docs build for branch master: f200f14a409a56df5... - iCrawl
Collection.get() returns undefined when it doesn't find the specified key so I think this behavior should stay the same
remove NonNullable instead of | undefined - because NonNullable was originally used here to exclude undefined
no need to ?? undefined because role can't be null, either Role | APIRole | undefined
@kyranet - I did not notice that the RESTManager was created on every request. Of course, we can look into quite possibly creating the final user agent at startup of the bot, rather than on every request.
5ca97c9 refactor: remove timer utilities from Client (#... - kyranet
f399b02 Docs build for branch master: 5ca97c93515d4dfaa... - iCrawl
I don't agree with changing the interface to return undefined rather than the current null
I know that a similar request has already been created, but my suggested implementation is a bit different.
The current method of making slash commands is a bit complicated (especially for beginners)
Maybe make slash commands a bit simpler.
For example, in the WOKCommands command handler, slash commands are extremely simple: You just specify slash: true in the command properties, along with name, description, etc.
Here is the documentation for that command handler (for referen...
Please describe the changes this PR makes and why it should be merged:
So I had noticed that the "deleted" flag wasn't updating when a message was actually deleted, so here I've added a small change. Hope I've fixed it correctly, after all this is my first ever change proposal.
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
Perhaps this will be easier for you once https://github.com/discordjs/builders/pull/3 is landed ๐
Problem:
collector.on('collect') and client.on('interactionCreate') always triggers two times, when i use a command on my server discord, the message sent in the console is sent two times and the second time the bot crashes for 'Unknown Interaction' when replying.
Code sample:
bot.js
import { CommandInteraction, InteractionCollector } from "discord.js";
const commandHandler = new InteractionCollector(bot, { interactionType: "APPLICATION_COMMAND" });
commandHandler.on('c...
- A Collector is a temporary event listener, which emits "collected" elements, if they pass the provided filter and ends when it's end criteria is hit, if any. Naturally it listens to a subset of the global event instances
- The client listener listens to all events of the specified type. The two listeners don't know of the existence of one another and perform their specific task independently. Any instance that emits from the collector will always also hit the global event and emit on clien...
Actually, following the convo on the [discord server](#archive-library-discussion message) let's make group and subcommand properties instead of methods
Hi Everyone! Thank you all for the help! I'll try the above and see if that works! Much appreciated!
Describe the ideal solution
It would be great if we could add Go Live / Screen Sharing to the list of Activity Types and show meta data related to the stream. The STREAMING type doesn't seem to cover this.
Describe alternatives you've considered
The STREAMING type doesn't seem to cover this and though I can get whether the user is streaming, I can't get any information about the stream / screen share itself
i don't use the colector and the listener at the same time, i tried both (one at the time) and it fire the event two times
you should use discord.js v13 and the d.js interaction event (
client.on('interactionCreate', func))
docs: https://discord.js.org/#/docs/main/master/class/Client?scrollTo=e-interactionCreate
guide: https://v13-prep.discordjs.guide/interactions/replying-to-slash-commands.html
you can also ask in #djs-slash-commands in https://discord.gg/djs
Im trying to follow the guide https://v13-prep.discordjs.guide/interactions/registering-slash-commands.html but I'm confused why there are q...
I opened a separate feature request here, but I'd argue that this hasn't been fixed at least from the Discord Go Live setting. The STREAMING activity still doesn't fire. My code example mirrors the use case mentioned above
- This is the wrong place where the assignment should be added. It should be added in
MessageManager#delete(). - This is automatically done when the bot receives the gateway event
MESSAGE_DELETEso when this event (messageDelete) is re...
Please describe the changes this PR makes and why it should be merged:
Remove the usage of var in APIRequest class
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't need updating
Might as well make this a constant, since d.js runs only on node now
The question marks are valid in javascript as of node 14 and called optional chaining. We will be using language features up to the current minimum required node version, which for v13 of discord.js is currently 14.0.0 or newer.
Is this always defined?
const agent = new https.Agent?.({ keepAlive: true });
It should always be defined ๐ค
We don't accept PRs to v12.
Ohh lol, didn't notice Vlad's comment. So sorry :+1:
Wouldn't it be better to do it like this?
this.banner = {
url: "url",
color: "Hex"
}
```
Wouldn't it be better to do it like this?
this.banner = { url: "url", color: "Hex" }
pretty sure it's not like that for consistency with other properties/methods
Please describe the problem you are having in as much detail as possible:
As of #6094, #inGuild() marks interactions that are not in guild as never for typescript users, ignoring DM interactions for example.
Include a reproducible code sample here, if possible:
client.on('interactionCreate', interaction => {
if (interaction.isCommand()) {
if (interaction.inGuild()) {
//normal behaviour
}
else{
//interaction type...
Wouldn't it be better to do it like this?
this.banner = { url: "url", color: "Hex" }pretty sure it's not like that for consistency with other properties/methods
So, you know, I say that because it would be good if it was the same everywhere. With embed footer you have footer.value/etc and stuff. That's why I suggested this change.
This only happens when you have "strict" disabled in your tsconfig.json/jsconfig.json file. In this case, the guildId and member properties will never show up as null, so tsc thinks that the inGuild() method always returns true and the code in the else block will never run.
Please describe the changes this PR makes and why it should be merged:
I added User#asMention that returns a mention that can be displayed on a message, because its more intuitive
example:
msg.channel.send(`Hi ${msg.author.asMention}!`)
will send:
Hi @tiagodinis33!
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't n...
Isn't this the exact same as User#toString()?
User.toString() does this.
wait, toString already do that?
i thougth it would return the object as string
I had the same exact problem and then I enabled strict mode and it worked just fine.
Please describe the changes this PR makes and why it should be merged:
Since this is currently only implemented in the canary API, you must add http: {headers: {'x-debug-options': 'canary'}} or http: {api: 'https://canary.discord.com/api'} to your ClientOptions to create type 10 options. They can also currently only be viewed on the canary client.
Status and versioning classification:
- Code changes have been tested a...
Please describe the changes this PR makes and why it should be merged:
Message#thread is marked as nullable in JSDocs, but not in the typings.
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't need updating
- This PR only includes non-code changes, like changes to documentation, README, etc.
Please describe the changes this PR makes and why it should be merged:
GuildPreview is missing the createdAt & createdTimestamp fields since it doesn't extend the BaseGuild class, so this PR adds it.
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't need updating
- This PR changes the library's interface (methods or parameters added)
Since Go Live / Screen Sharing is not actually an activity, we can't really document it as such.
Further I don't think Discord is exposing anything more than self_stream (VoiceState#streaming) to bots.
At least on a quick glance I didn't see anything more in the received dispatches.
de38404 chore(ApiRequest): remove mention of var (#6125) - alanlichen
525a6fb Docs build for branch master: de384047b302f70b4... - iCrawl
ef5ba05 types(Message): mark #thread as nullable (#6129) - kyranet
366f3c9 feat: make Instance#fetch force true by default... - advaith1
7d30364 Docs build for branch master: ef5ba05996ba45b56... - iCrawl
e008445 Docs build for branch master: 366f3c910a370ff1e... - iCrawl
4d53d0f refactor(ActionsManager): less complex code (#6... - xHyroM
70abe02 Docs build for branch master: 4d53d0fd115e3a31e... - iCrawl
I know that a similar request has already been created, but my suggested implementation is a bit different.
The current method of making slash commands is a bit complicated (especially for beginners)
Maybe make slash commands a bit simpler.For example, in the WOKCommands command handler, slash commands are extremely simple: You just specify
slash: truein the command properties, along withname,description, etc.Here is the documentation for that command hand...
A release for builders is coming soon! Alongside that, discord.js won't come with a command handler included (that's on you to code, or use a framework ๐), so this is outside the scope of this library.
Please describe the changes this PR makes and why it should be merged:
Status and versioning classification:
iirc the stream metadata Discord displays will just be from PLAYING/other activities that the user has (except for the stream preview image, which bots cannot access)
CommandInteractionOption#user is always a User object, never an APIUser. However I updated getMentionable() and added the raw data types.
Please describe the changes this PR makes and why it should be merged:
Following the renaming of ID properties to Id, this particular instance was missed, which cases GuildChannel#fetchInvites to fetch all invites from the guild rather than just the specific channel.
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't need updating
...
So i have a weird issue as to where my discord bot is working perfectly and out of no where it "hangs" meaning commands stopped working, its unresponsive but its still online. I am currently using it with socket.io and mongoose, at first i thought perhaps this is whats causing it to hang but that is not the case. After the bot gets stuck i restart my ubuntu server, i restart the process, and this is when it just stops working completely. When the discord bot is stuck in the ubuntu server, i...
The issue template exists for a reason, please use it.
As a side note, that line comes from #5889, which landed at 4th July 23:53, #6036 landed at 4th July 20:54, roughly 3 hours earlier, so it wasn't an oversight, just concurrency 101 ๐
I just scanned for IDs again, and found those two references of xID that need renaming:
Oh, that makes a lot more sense! I assume some kind of regex find/replace was used for that PR, so it was a little surprising to see something missed. I'll go ahead and fix those instances as well.
Since the structures are removed can we get a more structurized way rather than using "functions"
Yes - [a-z]ID with case sensitive and regex search in VSCode:
<details>
<summary>Screenshot of results</summary>

</details>
Without the issues mentioned in my previous comment? I don't think it's really possible.
Also, given how much inheritance discord.js has, the functional way of doing things is very good, for example, if you added a getter or a method in your channels to send localized input, you'd need to extend TextChannel, NewsChannel, ThreadChannel, and a few more to come in the future.
Since functions don't rely on that, you can seamlessly make it so it works for any channel, current and fut...
Perhaps this will be easier for you once discordjs/builders#3 is landed ๐
Thanks a lot! :)
Can you log the debug event and show what is being logged there?
e.g. client.on('debug', console.log);
Alternatively, if someone still wants structures they can just use Object.defineProperties so I don't think there's anything to worry about.
Can you log the debug event and show what is being logged there?
e.g.
client.on('debug', console.log);
Yeah just added it to my code, everything is working fine now, but just need to wait for it to happen again and ill post it
[discordjs/discord.js] New comment on pull request #6071: refactor\(Message\): combine patch methods
Ended up doing it for everything, makes the code overall much easier to read.
I think I wrote this before I allowed a non function return (which is now null instead of false)...yes I should use it.
You can easily also import the class you wanna modify and then extend
const { Message } = require("discord.js");
Message.prototype.myFunc = (arg1) => {
//code here
};
Please describe the problem you are having in as much detail as possible:
I have an embed that is navigable through reactions, and after updating to the Master branch of Discord.js, the navigation through reactions has stopped working.
As described in the latest version of the documentation, I have moved the filter into the collector options, but execution does not continue and the code after `awa...
You need to specify the GUILD_MESSAGE_REACTIONS intent to receive reactions. See the available intents in the docs.
Thanks a lot @kyranet! After several conversations on the official Discord, I could not reach a conclusion, but the need for that attempt was really obvious and I did not realize it. It worked like a charm!
Please describe the changes this PR makes and why it should be merged:
Status and versioning classification:
f293132 feat(CommandInteraction): add CommandInteractio... - shinotheshino
c40c0f9 fix(GuildChannel): only fetch invites for the s... - eeehh
eecd629 Docs build for branch master: f293132345294e33e... - iCrawl
54d0c82 Docs build for branch master: c40c0f934a571c100... - iCrawl
9f039a8 feat(GuildPreview): add createdAt & createdTime... - GoldenAngel2
0e6d2c9 Docs build for branch master: 9f039a86798352e36... - iCrawl
63ce065 refactor: change const enums to interfaces (#6078) - DTrombett
06be06e Docs build for branch master: 63ce065fc3cee478a... - iCrawl
Is your feature request related to a problem? Please describe.
With discord-api-types there isn't really a reason to modify values received from the api anymore. Obviously object keys should still be modified (guild_id -> guildId, ...) but channel types (for example) should not be transformed from numbers -> strings.
Describe the ideal solution
For example:
import { ChannelType } from 'discord-api-types';
declare co...
It looks like the docs have a cache with limits method. Are there any plans to allow developers to choose what gets cached? For example, caching guild emojis could be irrelevant for your bot, and keeping that data would be wasting memory.
yes, just set a manager to 0 (#6013)
you already can, just set a manager to 0:
- #6013
It looks like the docs have a cache with limits method. Are there any plans to allow developers to choose what gets cached? For example, caching guild emojis could be irrelevant for your bot, and keeping that data would be wasting memory.
you already can, just set a manager to 0:
- #6013
Should make this into a type, SweepFilter or something like that.
Would prefer no default at all, but whatever works.
It doesn't? In my testing it did
lol nope, I'm dumb, got falses and trues mixed up, i'll just disable the eslint rule and == check null
Please describe the changes this PR makes and why it should be merged:
This fixes a typings issue on CommandInteractionOption#options which still referenced the Collection logic that was removed in f293132345294e33e80866272feaedf2e4a70d45. This PR updates the type to an array, as it is in the code. This PR also adds test cases for related typings and removes a removed method from CommandInteraction.
Status and versioning classification:
- Code changes have been tested ag...
Baby am going to ur parents and am going to tell them everything ur going through n plz don't deny it ok am going full force ur not alone I love u n Alison be strong te amo
Please describe the changes this PR makes and why it should be merged:
The correct scope name is identify as referenced by Discord and the comment in Constants.js.
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't need updating
- This PR changes the library's interface (methods or parameters added)
เธเธกเธเธฑเธเนเธเธฅเธเธชเนเธงเธเธเธฑเนเธเนเธเธทเนเธญเธฅเนเธญเนเธซเน (เธเธฅเธธเนเธกเนเธเนเธฒเธซเธกเธฒเธข) เธเธตเนเนเธฎเธเนเธเนเธฒเธกเธฒเนเธเนเธเธฃเธทเนเธญเธเธเธกเนเธเนเธเธฑเนเธเธเธฃเธฑเธ เธญเธตเธเธญเธขเนเธฒเธเธเธกเธเนเนเธกเนเนเธเนเนเธเธชเธฅเธ เธเธทเนเธเธเธตเนเธชเธฒเธเธฒเธฃเธเธฐ
เธชเนเธเธเธฒเธ iPhone เธเธญเธเธเธฑเธ
เนเธกเธทเนเธญ 19 เธ.เธ. 2564 เนเธงเธฅเธฒ 12:07 เนเธเธตเธขเธเนเธเธข Nolovehere @.***>:
Enhancement
โ
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHubhttps://github.com/discordjs/discord.js/issues/6136#issuecomment-882240950, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AU4L...
Is your feature request related to a problem? Please describe.
When you call message.reference it does not return a message promise like most things do, but rather an MessageReference object. This makes doing anything useful significantly harder, as shown here await message.channel.messages.fetch(message.reference.messageID)
Describe the ideal solution
Instead of using an MessageReference object, it should instead return a message promise
Is your feature request related to a problem? Please describe.
CommandInteractionOptionResolver.getSubCommand() currently throws an error if a sub command isn't used. I think it would be easier if it returned undefined and had a required parameter similar to [CommandInteractionOptionResolver.get()](https://discord.js.org/#/docs/main/master/class/CommandInteractionOptionResol...
This has been addressed in master/v13 with the Message#fetchReference method.
https://discord.js.org/#/docs/main/master/class/Message?scrollTo=fetchReference
If this change is to be made it should return null, not undefined.
This has been addressed in master/v13 with the
Message#fetchReferencemethod.
https://discord.js.org/#/docs/main/master/class/Message?scrollTo=fetchReference
Should reference be deprecated?
This has been addressed in master/v13 with the
Message#fetchReferencemethod.
https://discord.js.org/#/docs/main/master/class/Message?scrollTo=fetchReferenceShould reference be deprecated?
no, as the Message#fetchReference function relies on Message#reference
8ea04b2 Updates identity to correct scope name of `id... - icdevin
77784ac fix(CommandInteraction): change options type fr... - shinotheshino
8c5e630 Docs build for branch master: 8ea04b295da2f499e... - iCrawl
3abe643 Docs build for branch master: 77784aca431709ff3... - iCrawl
You can import the ChannelTypes "enum" from discord.js and pass it the string that djs have for types to get the respective number for it.
According to the docs, you can't have a sub-command/group defined and also use the top-level command. What is the use case for this? One of the benefits of CommandInteractionOptionResolver is validating options at runtime against the command data when defined and I don't see how this would really play into that.
According to the docs, you can't have a sub-command/group defined and also use the top-level command.
You could have a global and a guild command with the same name, one with subcommands and one without.
I think that's an absolutely terrible design but it is theoretically possible.
Is your feature request related to a problem? Please describe.
Hi hi! Thank you for the CommandInteractionOptionResolver!
I have a use case for some of my Slash Commands where no options are required but sending across no options results in behaviour still (and not an error). Previously, I would be able to do if (.options.size === 0) {...}, but it seems now that I must check each and every parameter to ensure that they are all not present to ensure this behaviour works.
A...
That could still be handled safely by if (interaction.command.guildId), though, couldn't it?
How about something like:
const evidence = [];
for (let i = 1; i <= 10; i++) {
const value = i.options.getString(`evidence-${i}`);
if (value !== null)
evidence.push(value);
}
if (evidence.length === 0) {
// No evidence provided.
} else {
// Do stuff with evidence.
}
You could put it in a helper function in your program if you have a lot of similar commands, perhaps.
I think I have found a way thats way more efficient than before
and it supports the . operator
import Message
function messageExtender (){
Message.prototype.customized = 'this will work'
}
messageExtender()
client.on('messageCreate', msg => {
if (msg.content === 'ping') {
msg.reply(msg.customized)
}
});
How about something like:
const evidence = []; for (let i = 1; i <= 10; i++) { const value = interaction.options.getString(`evidence-${i}`); if (value !== null) evidence.push(value); } if (evidence.length === 0) { // No evidence provided. } else { // Do stuff with evidence. }You could put it in a helper function in your program if you have a lot of similar commands, perhaps.
Thank you for the reply! But this...
so i saw that slash command options in the form of a collection were replaced by the CommandInteractionOptionResolver, this only has .get methods, will this ever get .has methods or are they redundant?
The many .get() methods on the CommandInteractionOptionResolver all return null if your specified option does not exist. Does this help you?
Before you could have done:
const options = <CommandInteraction>.options;
if (options.has("option name")) {
// There exists a specified option name!
}
Presently, you can do this:
const options = <CommandInteraction>.options;
if (options.get("option name") !== null) {
// There exists a specified ...
Yeah, thats what im using for now, i just thought .has might make more sense especially since the .get methods have the required parameter
The many .get() methods on the CommandInteractionOptionResolver all return null if your specified option does not exist. Does this help you?
Before you could have done:
const options = <CommandInteraction>.options;
if (options.has("option name")) {
// There exists a specified option name!
}
Presently, you can do this:
const options = <CommandInteraction>.options;
if (options.get("option name") !== null) {
// There exists a specified ...
That parameter is false by default, but if chosen to be true, It will run throw new TypeError('COMMAND_INTERACTION_OPTION_NOT_FOUND', "option name"); so it'll actually throw a TypeError instead of returning just null!
Please describe the changes this PR makes and why it should be merged:
CommandInteractionOptionResolver is exported in the typings, but not in the index.js file
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't need updating
that was 1 example just showing why transforming the data isn't necessarily needed anymore, I believe interaction data types are also transformed (and probably other properties) that would also fall under this change
you aware changes weren't merged?
The reason djs converts types from numbers to strings is because it makes debugging easier. When logging an object, it is better to have a descriptive string for a type than a number that will make you open the docs everytime you see it. Also, all the transformations from numbers -> string are done using the enum for that specific type. You can import it and use it to get the number back by passing it the string.
What I'm not able to understand is "why". channel.type === 'GUILD_TEXT'...
Now uses the accent_color property (currently only in the canary API) which returns the color as an integer; bannerColor and hexBannerColor were renamed to accentColor (prop) and hexAccentColor (getter)
Upstream PR has landed, and this needs a rebase ๐
cc19e09 chore(Deps): update discord-api-types to 0.19.0 - vladfrangu
[discordjs/discord.js] New branch created: chore/deps/update\-discord\-api\-types\-to\-0\.19\.0
Please describe the changes this PR makes and why it should be merged:
Status and versioning classification:
[discordjs/discord.js] branch deleted: chore/deps/update\-discord\-api\-types\-to\-0\.19\.0
76888e6 chore(Deps): update discord-api-types to 0.19... - vladfrangu
7e4595a Docs build for branch master: 76888e6c1bfcd15e0... - iCrawl
54d6a3a feat(Sticker): updates, sticker packs, and guil... - advaith1
196e084 Docs build for branch master: 54d6a3a0708105acd... - iCrawl
8ccfd6e fix(CommandInteractionOptionResolver): Export C... - Floffah
ca9f5be Docs build for branch master: 8ccfd6e07b3208568... - iCrawl
MEMBER isn't an option type, it should be USER.
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't need updating
02f55f0 fix(CommandInteractionOptionResolver): type sho... - monbrey
3c4ded5 Docs build for branch master: 02f55f09712af5d6a... - iCrawl
let templink = args[0]
let errho = new Discord.GuildTemplate(client, templink)
errho.createGuild('name', 'https://upload.wikimedia.org/wikipedia/commons/d/dc/YES-Snowboards-logo.jpg')
Running this code gives me an error of cannot read property 'id' of undefined
- discord.js version: latest
- Node.js version: latest
- Operating system: Windows
Relevant client options:
- partials: none
- gateway intents: none
- other: none
The second parameter of the GuildTemplate class takes an object, not a string. You shouldn't need to initialize a new GuildTemplate class instead you can use Guild#fetchTemplates or Client#fetchGuildTemplate to fetch an existing template.
The second parameter of the GuildTemplate class takes an object, not a string. You shouldn't need to initialize a new GuildTemplate class instead you can use Guild#fetchTemplates or Client#fetchGuildTemplate to fetch an existing template.
how do i send an object
as BannerBomb said, you should not be constructing a GuildTemplate object, you should use a d.js method to fetch the template. for more help, ask in the server.
The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue โ you will get redirected there anyway.
I was coding something on my discord bot main file (server.js) then I decided to update my discord.js npm to v13 so I did, Then I got an issue "const token = this.client.token ?? this.client.accessToken;
^
SyntaxError: Unexpected token '?'"
And my bot can't go online now, What do I do? please help me

Update Node to v14.
[discordjs/discord.js] New comment on pull request #6071: refactor\(Message\): combine patch methods
As a wise, young man once said, this needs a rebase
Please describe the problem you are having in as much detail as possible:
When a thread's rateLimitPerUser is updated to "Off" (0) it doesn't update the property, providing the event with the wrong data.
Include a reproducible code sample here, if possible:
const { Client, Intents: { FLAGS } } = require("discord.js");
const client = new Client({
intents: [
FLAGS.GUILD_MESSAGES,
FLAGS.GUILD_MEMBERS,
FLAGS.GUILD_INVITES,
FLAGS.G...
Please describe the changes this PR makes and why it should be merged:
When you provide a parameter of type K to DataManager.resolveId(...), the typing consider that the result can be 'null' or 'K' type however, it will never be the case given the code of the function. So, this PR adds the type K for the parameter of the resolveId function which has as return type 'K' only.
More information here : #archive-library-discussion message...
Please describe the changes this PR makes and why it should be merged:
Add the readonly keyword on the tuple of ColorResolvable.
Since the tuple don't have to be mutated, make it readonly make ColorResolvable type wider.
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code changes
- I know how to update typings and have done so, or typings don't need updating
- This PR only includes non-code changes...
Please describe the changes this PR makes and why it should be merged:
The reason why it accepted an array was because sub-commands and sub-command groups used to share the same method, however now that those are split up it is no longer needed.
Status and versioning classification:
- I know how to update typings and have done so
All <CommandInteractionOptionResolver>.getSubCommand() does is retrieve the private property ._subCommand and fails with a thrown error if does not exist. The same also applies to sub-command groups.
Why not just make both those private properties public? You could then remove the methods and instead make those properties nullable (which they already are). I don't see a need for these two methods to exist when they exist fine as properties.
I also ask this because I utilise a comman...
I'm not sure what's major about this, but well ๐
Since interactions.options is no longer a collection, some of my commands have broken, like the /poll command which has the function of creating polls.
So I ask that some method be created like options.cache which returns a Collection.
My code ended up crashing:

How my command worked:
 but for now if you want a temporary solution you can use the private property ._options, which is an array of CommandInteractionOption.
Please describe the changes this PR makes and why it should be merged:
This moves the _options property to the public data property as a read-only array, which allows custom usage of options.
This closes #6143.
Status and versioning classification:
- I know how to update typings and have done so, or typings don't need updating
- Code changes have been tested against the Discord API, or there are no code changes
Please describe the problem you are having in as much detail as possible:
Hi hi!
For one of my applications, I need to be able to fetch the message I replied with (from an interaction). .defer() returns Promise< | void> which I thought was strange since I never really got a Message from that?
Upon looking into the source code of InteractionResponses, the options th...
I mentioned this error some time ago on the Discord server ( #archive-library-discussion message ) but, yet, there is no pull request to add documentation on it. It's just an oversight...
If you know how to do it don't hesitate to make a pull request ๐
5addcd1 refactor(OptionResolver): accept single type in... - vaporox
1e90be8 types(ColorResolvable): readonly tuple (#6153) - tguichaoua
5f4cc0e Docs build for branch master: 5addcd15d8e6e151a... - iCrawl
be97052 Docs build for branch master: 1e90be8f7a7290886... - iCrawl
Can we create an npx package for discord.js to bootstrap the process of setting up the package?
npx create-discord-bot pokemon-bot
Thoughts?
https://peterthehan.github.io/create-discord-bot/
I got this article online he already has these things published, but something from discord.js would enforce best practices, and we can add this in the discord guide too.
So I went a bit into the folders and pointed where it permissions were getting allocated.

I hope this solves how the functioning of the sync
Original
const channelVal = this.permissionOverwrites.cache.get(key);
const parentVal = this.parent.permissionOverwrites.cache.get(key);
After Changes made
const channelVal = this.parent.permi...
To put it in simple terms, no, this doesn't sound like it solves the issue. It sounds like you're removing the concept of permissions overwrites on channels, which makes no sense at all.
I recommend creating a PR though so that proposed changes to solve this issue can be discussed there, directly on your proposed changes, rather than in the issue :)
One of the purposes of the resolver is to abstract away as many possibilities for bugs as possible for the user. With this intent in mind, throwing an error when attempting to access the sub-command of an interaction without one makes sense. For your logging use-case, a try/catch expression, checking the error code, is perfectly reasonable and explicit.
IMO, it makes no sense to add less strict code to the library just to accommodate such a case when there's a perfectly reasonable way ...
Yes I know this makes no sense, this just pinpoints where the things are allocated. I want to add a helper function of the sort which checks if the permission should be synced or not. If yes then we can implement this logic and produce the above output.
Question: Do you want me to check how the permissionsOverwrites and handle it there?
Question: Does the above output is your desired output?
I recommend creating a PR though so that proposed changes to solve this issue can be discussed there, directly on your proposed changes, rather than in the issue :)
Sure, would make a PR and would continue the discussion there. Just wanted to know if this is what the library wants from the permissionOverwrites because this would change how the library handles permissionOverwrites.
@MattIPv4 @almostSouji
Please describe the problem you are having in as much detail as possible:
When using MessageCommandInteraction#deferUpdate(), the component interaction should be deferred for 15min to allow for a later update, however if deferUpdate() is called, It seems to think that the message is replied to already, which it shouldn't do.
For example using a button component collector:
const collector = message.createMessageComponentCollector({ componentType: 'BUTTON' });
colle...
This isn't a bug - if this check wasn't done internally, you would receive an API error instead.
You can either deferUpdate or update the button initially - both these methods send an acknowledgement of the interaction to Discord. You can only acknowledge once. If you deferUpdate, future edits must be made using editReply.
Ok thank you for the clarification.
I don't really see the point of this; if you want rti quickly get started, just copy-paste the example from the discord.js homepage
To put it in simple terms, no, this doesn't sound like it solves the issue. It sounds like you're removing the concept of permissions overwrites on channels, which makes no sense at all.
Ohh ok, I think I'll wait for someone to add more comments on how to solve this.
Please describe the changes this PR makes and why it should be merged:
This PR fix a bug due the change of all xID into xId. In this function, the change has not been made resulting in an error all the time since !this.guildID is always true.
Bug report in Discord - #archive-library-discussion message
Status and versioning classification:
- Code changes have been tested against the Discord API, or there are no code chan...
permissionsLocked here isn't a clear value though - the API doesn't provide a boolean telling us that a channel is synced or not. It's a getter that compares the channel's overwrites to the parent's overwrites at runtime. Because it's a runtime check, there's several reasons this simply can't be accurate.
oldChildChannel.permissionsLocked would be comparing to the current, updated parent channels overwrites. I don't think its even possible to freeze the parent's old state for this, or ...
Side note - since this isn't a proper API-provided boolean doesnt this mean it can return a false positive if a parent and child have the same overwrites without being in sync?
From my quick testing, no -- Discord seems to potentially apply the same logic as D.js does. If you have a channel & parent sync'ed, and then update the channel to be out of sync, and then match that update in the parent the channel will show as sync'ed again.
One of the purposes of the resolver is to abstract away as many possibilities for bugs as possible for the user. With this intent in mind, throwing an error when attempting to access the sub-command of an interaction without one makes sense.
Then, I don't think this should be the purpose of the resolver. Ideally, the resolver would have looked at the data received and parsed them into a more accessible format for the user rather than chaining through the Collection as before. Throwing ...
Though as I say this, if this issue isn't addressed, at least we have #6156 so we can ignore all the methods and choose to go into the options ourselves to handle what we want how we want.
This one will be merged to provide raw access, which sounds like it meets the use case you described of logging the raw format. We acknowledged and agreed that there were reasons people want the actual data rather than resolving things, and will be providing both.
What I'm still not seeing here is...
Should this be modified to have data be the top-level options array? For cases where people want to access the original interaction option array with the sub-command included.
๐ค Excellent question. I personally lean to yes, I'd like to see discord.js providing the completely original, unparsed data.
This might mean you keep a private _data / _options property too if you want to do keep the hoisted sub-command options somewhere.
This one will be merged to provide raw access
It doesn't seem raw to me - it looks to be processed! Though I'm fine with that.
What I'm still not seeing here is a use case where people would want to be using the resolver, and trying to call
getSubCommandwhen a sub-command doesn't exist. If a command has sub-commands, then one of the must have been used.
One other thing is that I have my commands set up something like this as a Collection for my Slash Command handler:
...
Per [discussion](#archive-library-discussion message), this will stay as-is in this PR.
Can you log the debug event and show what is being logged there?
e.g.client.on('debug', console.log);
So it started happening again and i keep getting "429 hit on route /gateway/bot", I am not spamming log in, or anything. My Discord Bot is in One server only.
are you using a shared host such as replit? the IP is probably blocked
are you using a shared host such as replit? the IP is probably blocked
I am currently using AWS EC2 instance, dont think it shares an ip
Please describe the changes this PR makes and why it should be merged:
The applicationCommandCreate/Update/Delete events are sent when guild commands owned by any bot in the server are created, updated, or deleted - and not just the commands owned by the client user. This meant that Discord.js was caching commands owned by other bots.
This PR:
- makes sure the command events only cache commands from the own bot (thanks @vladfrangu for the code suggestions)
- adds `ApplicationComma...
Looks like Discord is saving 23 bytes by not sending rate_limit_per_user when it's 0. (But not the 30 bytes that could be saved by omitting locked and archived when they are false)
This could be solved by checking for another property in the payload (maybe thread_metadata?) to not erroneously overwrite rateLimitPerUser when the channel is patched with partial data.
I've opened an issue on the discord-api-docs repo about the field not being included for THREAD_UPDATE
https://github.com/discord/discord-api-docs/issues/3486
8586505 types(DataManager): add 'K' to type parameter o... - Apokalypt
07017a9 fix(Sticker): replace 'this.guildID' (undefined... - Apokalypt
687eec3 Docs build for branch master: 85865058ed3ab13e3... - iCrawl
bd85b37 Docs build for branch master: 07017a9699eecc4af... - iCrawl
Please describe the changes this PR makes and why it should be merged:
Currently, if you want to remove attachments from a message you have to use message.removeAttachments(), and if you need to edit the content as well that is 2 API calls. Assigning attachments: [] does work, but sparks errors in TypeScript that require // @ts-ignore - which is generally considered a bad practice. This PR fixes the typings allowing you to assign attachments: [] without having to use ts-ignore....
const attachments: MessageAttachment[] = [];
msg.edit({ attachments, content: 'abc' });
This works without using TS ignore...
If that works then logically speaking I would expect attachments: [] as MessageAttachment[] to work but I still get the same error if I just gave it a blank array
attachments?: (MessageAttachment | never)[];
Djs doesn't use the Array<Type> form.
Also, this error also pops up when using <MessageComponentInteraction>.update({attachments: []}) - I can't seem to find an interface that corrosponds to the attachments field. It's all just chains of Omit's
I can't replicate any issue with message.edit({ attachments: [] }), TypeScript isnt complaining.
Odd. I also get this error when trying to update a MesaageComponentInteraction with no attachments.
attachments is not a valid property for InteractionUpdateOptions. We briefly discussed this in dev chats but never applied a fix. Ignoring the Omit typings, it's basically a chain.
InteractionUpdateOptions > InteractionReplyOptions > WebhookMessageOptions > MessageOptions
This isn't quite what it should be; InteractionUpdateOptions should probably be something more like:
export interface InteractionUpdateOptions extends Omit<WebhookEditMessageOptions, 'username' | 'av...
Picking from MessageOptions makes more sense. I'll try to implement a fix.
export interface WebhookEditMessageOptions extends Pick<
WebhookMessageOptions,
'content' | 'embeds' | 'files' | 'allowedMentions' | 'components'
> {
attachments: MessageAttachment[];
}
From what you said, this implies that when you are assigning attachments it'll cause the same error this is PR trying to fix. I'll go with attachments: (MessageAttachment | never)[] as that's what this PR is fixing.
You're referring to an error I was unable to replicate on message.edit. I don't believe typing it as never is the correct fix for the issue you described, which does exist on interaction.update as no typings for attachments exist as all.
So all this has to do is type attachments for InteractionUpdateOptions?
So all this has to do is type
attachmentsforInteractionUpdateOptions?
I think so, yes. But as its a long chain of Omits as you pointed out, finding the right place/editing that chain is the tricky part.
Otherwise if you are running into the issue on message.edit({ attachments: [] }), where those typings do already exist, please provide a reproducible code sample because I wasn't able to get any errors.
Yea, I think it was something to do with Yarn's PnP and my workspace typescript version, that one seems to of been fixed, this PR should now focus on fixing InteractionUpdateOptions
This is now missing fetchReply
Anything else need to be changed?
Now uses the
accent_colorproperty (currently only in the canary API) which returns the color as an integer;
It looks like it's on the stable API too.
bannerColor and hexBannerColor were renamed to accentColor (prop) and hexAccentColor (getter)
The API returns both theaccent_colorandbanner_colorproperties though?
It looks like it's on the stable API too, but the banner_color property has not been removed on stable.
yeah it's
there are accent_color Too though in the Stable API (at the moment)
