#archive-github-djs

1 messages ยท Page 3 of 1

heavy crowBOT
heavy crowBOT
#

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...

#

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 to boolean which 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...

heavy crowBOT
#

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...

heavy crowBOT
#

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.

#

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...

heavy crowBOT
#

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...

heavy crowBOT
#

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.

heavy crowBOT
#

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 Base generic and set classes that could be retrieved without a logged-in client to extend Base<boolean> instead of Base<true>. This doesn't really offer a benefit, overall, though, since for example `Gu...
heavy crowBOT
heavy crowBOT
#

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 ...
heavy crowBOT
#

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...

heavy crowBOT
heavy crowBOT
#

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 *...
heavy crowBOT
heavy crowBOT
#

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 Client to Client<true> and it works, no need to import another type.

heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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' &...
heavy crowBOT
#

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 ...
heavy crowBOT
heavy crowBOT
#

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...
heavy crowBOT
#

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...

heavy crowBOT
#

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...
heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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
heavy crowBOT
#

PS C:\Users\NuL\Documents\BOT> npm install discord.js
npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
Annotation 2021-07-10 040139

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
Annotation 2021-07-10 040139

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...

heavy crowBOT
#

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
#

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:

heavy crowBOT
#

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...
#

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.
@monbrey

Correction: The library should actually handle this perfectly fine. this.message.channel will be undefined

https://github.com/discordjs/discord.js/blob/d6c43a50bd608c233919e6386683c126cf821346/src/structures/InteractionCollector.js#L44

https://github.com/discordjs/...

heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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 ...

heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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.

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.

heavy crowBOT
#

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...
heavy crowBOT
#

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...
#

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...
heavy crowBOT
#

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...
heavy crowBOT
#

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...
heavy crowBOT
#

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...
heavy crowBOT
heavy crowBOT
#

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...

heavy crowBOT
#

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"],
...
heavy crowBOT
heavy crowBOT
#

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 ...

heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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...

#

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 ...

heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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...
heavy crowBOT
#

@Sly-Little-Fox

Then discord.js v13 will not work on replit

You still can install newer version of node in replit
Simply type npm i node@14 in 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...

heavy crowBOT
heavy crowBOT
#

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 ...

heavy crowBOT
heavy crowBOT
#

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
heavy crowBOT
heavy crowBOT
#

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...

heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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) ...

#

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...

heavy crowBOT
heavy crowBOT
#

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...

heavy crowBOT
#

@Sly-Little-Fox

Then discord.js v13 will not work on replit

You still can install newer version of node in replit
Simply type npm i node@14 in shell.. and enjoy! slightly_smiling_face

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 wa...

#
    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;
heavy crowBOT
#

Please describe the changes this PR makes and why it should be merged:

:warning: This PR removes the following methods:

  • Client#setTimeout
  • Client#setInterval
  • Client#setImmediate
  • Client#clearTimeout
  • Client#clearInterval
  • Client#clearImmediate
  • Client#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...

heavy crowBOT
#

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...
heavy crowBOT
#

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.
  }
}
heavy crowBOT
heavy crowBOT
#
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 (...
heavy crowBOT
#

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.

heavy crowBOT
#

Please describe the changes this PR makes and why it should be merged:

  • Added Typing structure.
  • Renamed TextBasedChannel#startTyping to sendTyping.
    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#stopTyping as it relied on internal tracking.
  • Removed TextBasedChannel#typing as it relied on internal tracking.
  • Removed `TextBasedChannel#typingCou...
heavy crowBOT
heavy crowBOT
#

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...

heavy crowBOT
#

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?

https://discord.js.org/#/docs...

#

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.

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...

heavy crowBOT
#
  1. 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.
  2. Also try to make the encapsulate AssignUserRole() and changeRoles() in one function,
  3. [Optionally] if possible try to return a promise from your function to the main call, which we would ensure that the role was assigned or not.
  4. One more thing would b...
heavy crowBOT
#

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?

heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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
heavy crowBOT
#

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...
heavy crowBOT
#

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

heavy crowBOT
#

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...
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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...
heavy crowBOT
#

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...

heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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
heavy crowBOT
#

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...
heavy crowBOT
#

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

heavy crowBOT
#
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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...
heavy crowBOT
heavy crowBOT
#

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...
heavy crowBOT
#

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...
heavy crowBOT
#

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.
heavy crowBOT
#

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)
heavy crowBOT
heavy crowBOT
#

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 hand...

heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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
    ...
heavy crowBOT
#

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...

heavy crowBOT
heavy crowBOT
#

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:

https://github.com/discordjs/discord.js/blob/4d53d0fd115e3a31e7a431c5dece8fc251c2115d/src/managers/GuildInviteManager.js#L149-L150

#

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...

heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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...

heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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...
heavy crowBOT
heavy crowBOT
#

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...
heavy crowBOT
#

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

heavy crowBOT
#

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...

heavy crowBOT
heavy crowBOT
#

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...

heavy crowBOT
#

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.

heavy crowBOT
heavy crowBOT
#

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...

#

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 ...
#

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 ...
#

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
heavy crowBOT
heavy crowBOT
#

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'...

heavy crowBOT
heavy crowBOT
#
[discordjs/discord.js] New branch created: chore/deps/update\-discord\-api\-types\-to\-0\.19\.0
heavy crowBOT
#
[discordjs/discord.js] branch deleted: chore/deps/update\-discord\-api\-types\-to\-0\.19\.0
heavy crowBOT
#
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
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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
Screenshot_18

heavy crowBOT
heavy crowBOT
#

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...
heavy crowBOT
#

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...

heavy crowBOT
#

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...
heavy crowBOT
heavy crowBOT
#

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...

heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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
heavy crowBOT
heavy crowBOT
heavy crowBOT
heavy crowBOT
#

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

heavy crowBOT
#

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...
#

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...

#

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 getSubCommand when 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:

...
heavy crowBOT
heavy crowBOT
#

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...
heavy crowBOT
#

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....

heavy crowBOT
heavy crowBOT
#

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...
#
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.

#

So all this has to do is type attachments for InteractionUpdateOptions?

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.

heavy crowBOT
heavy crowBOT