From 18b3a19810a6436fa8bb4b490ec5137eaecbd465 Mon Sep 17 00:00:00 2001 From: Almeida Date: Fri, 16 Dec 2022 16:56:29 +0000 Subject: [PATCH 01/11] fix: add `@discordjs/formatters` to dependency list (#8939) --- packages/discord.js/package.json | 1 + yarn.lock | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/discord.js/package.json b/packages/discord.js/package.json index 267733a1226c..8006308c4dc8 100644 --- a/packages/discord.js/package.json +++ b/packages/discord.js/package.json @@ -51,6 +51,7 @@ "dependencies": { "@discordjs/builders": "workspace:^", "@discordjs/collection": "workspace:^", + "@discordjs/formatters": "workspace:^", "@discordjs/rest": "workspace:^", "@discordjs/util": "workspace:^", "@sapphire/snowflake": "^3.2.2", diff --git a/yarn.lock b/yarn.lock index 8c53f2a9ddcf..84c41490dd25 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8471,6 +8471,7 @@ __metadata: "@discordjs/builders": "workspace:^" "@discordjs/collection": "workspace:^" "@discordjs/docgen": "workspace:^" + "@discordjs/formatters": "workspace:^" "@discordjs/rest": "workspace:^" "@discordjs/util": "workspace:^" "@favware/cliff-jumper": ^1.9.0 From 83eafb6146e4ea7faeeb05885c2b40a8da63bc23 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Fri, 16 Dec 2022 17:19:44 +0000 Subject: [PATCH 02/11] chore: Add backport label (#8942) --- .github/labels.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/labels.yml b/.github/labels.yml index 02bfd8513752..a8a1f128e2b7 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -8,6 +8,8 @@ color: fbca04 - name: backlog color: 7ef7ef +- name: backport + color: 88aabb - name: blocked color: fc1423 - name: bug From dd62be077d3e4fbd73a0c10ca344d93d3d19fa38 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Fri, 16 Dec 2022 17:20:11 +0000 Subject: [PATCH 03/11] docs(GuildForumThreadManager): Fix `sticker` type (#8940) --- packages/discord.js/src/managers/GuildForumThreadManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/discord.js/src/managers/GuildForumThreadManager.js b/packages/discord.js/src/managers/GuildForumThreadManager.js index 3a0fe761670d..2d521d4956d4 100644 --- a/packages/discord.js/src/managers/GuildForumThreadManager.js +++ b/packages/discord.js/src/managers/GuildForumThreadManager.js @@ -18,7 +18,7 @@ class GuildForumThreadManager extends ThreadManager { /** * @typedef {BaseMessageOptions} GuildForumThreadMessageCreateOptions - * @property {stickers} [stickers] The stickers to send with the message + * @property {StickerResolvable} [stickers] The stickers to send with the message * @property {BitFieldResolvable} [flags] The flags to send with the message */ From 0cf29abcf0835355b6c0d0dc09c32a3a28b9d81a Mon Sep 17 00:00:00 2001 From: iCrawl Date: Sat, 17 Dec 2022 16:54:06 +0100 Subject: [PATCH 04/11] chore(formatters): release @discordjs/formatters@0.1.0 --- packages/formatters/CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 packages/formatters/CHANGELOG.md diff --git a/packages/formatters/CHANGELOG.md b/packages/formatters/CHANGELOG.md new file mode 100644 index 000000000000..4207aa30c01a --- /dev/null +++ b/packages/formatters/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +# [@discordjs/formatters@0.1.0](https://github.com/discordjs/discord.js/tree/@discordjs/formatters@0.1.0) - (2022-12-16) + +## Features + +- Add `@discordjs/formatters` (#8889) ([3fca638](https://github.com/discordjs/discord.js/commit/3fca638a8470dcea2f79ddb9f18526dbc0017c88)) + From 5eab5fc06ca6be36ecf1557f2ad29a670d4d5ae7 Mon Sep 17 00:00:00 2001 From: Qjuh <76154676+Qjuh@users.noreply.github.com> Date: Sun, 18 Dec 2022 16:18:07 +0100 Subject: [PATCH 05/11] fix(WebSocketShard): only cleanup the connection if a connection still exists (#8946) fix(WebSocketShard): only cleanup if connection --- packages/discord.js/src/client/websocket/WebSocketShard.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/discord.js/src/client/websocket/WebSocketShard.js b/packages/discord.js/src/client/websocket/WebSocketShard.js index 167cd7badb72..c18c82aea353 100644 --- a/packages/discord.js/src/client/websocket/WebSocketShard.js +++ b/packages/discord.js/src/client/websocket/WebSocketShard.js @@ -603,7 +603,9 @@ class WebSocketShard extends EventEmitter { ); // Cleanup connection listeners - this._cleanupConnection(); + if (this.connection) { + this._cleanupConnection(); + } this.emitClose(); // Setting the variable false to check for zombie connections. From 25c27eac1417e75c9b601b17cf177b1f47b699a9 Mon Sep 17 00:00:00 2001 From: Almeida Date: Tue, 20 Dec 2022 16:20:43 +0000 Subject: [PATCH 06/11] fix: export missing `escapeX()` functions (#8944) fix: export missing escapeX functions Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- packages/discord.js/src/util/Util.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/discord.js/src/util/Util.js b/packages/discord.js/src/util/Util.js index d1be2882e5ad..d1ca63e02876 100644 --- a/packages/discord.js/src/util/Util.js +++ b/packages/discord.js/src/util/Util.js @@ -608,6 +608,10 @@ module.exports = { escapeUnderline, escapeStrikethrough, escapeSpoiler, + escapeHeading, + escapeBulletedList, + escapeNumberedList, + escapeMaskedLink, fetchRecommendedShardCount, parseEmoji, resolvePartialEmoji, From 429dbccc85cabd9986b2e8bf443bf384e4ddc61a Mon Sep 17 00:00:00 2001 From: Almeida Date: Tue, 20 Dec 2022 20:32:45 +0000 Subject: [PATCH 07/11] feat(CommandInteractionOptionResolver): add `channelTypes` option to `getChannel` (#8934) * feat(CommandInteractionOptionResolver): add `channelTypes` option to `getChannel` * fix: thread types Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- packages/discord.js/src/errors/ErrorCodes.js | 2 ++ packages/discord.js/src/errors/Messages.js | 2 ++ .../CommandInteractionOptionResolver.js | 16 ++++++++-- packages/discord.js/typings/index.d.ts | 32 +++++++++++++++++-- packages/discord.js/typings/index.test-d.ts | 18 +++++++++++ 5 files changed, 66 insertions(+), 4 deletions(-) diff --git a/packages/discord.js/src/errors/ErrorCodes.js b/packages/discord.js/src/errors/ErrorCodes.js index b5faf0c1cefa..3f074a1dad06 100644 --- a/packages/discord.js/src/errors/ErrorCodes.js +++ b/packages/discord.js/src/errors/ErrorCodes.js @@ -135,6 +135,7 @@ * @property {'CommandInteractionOptionEmpty'} CommandInteractionOptionEmpty * @property {'CommandInteractionOptionNoSubcommand'} CommandInteractionOptionNoSubcommand * @property {'CommandInteractionOptionNoSubcommandGroup'} CommandInteractionOptionNoSubcommandGroup + * @property {'CommandInteractionOptionInvalidChannelType'} CommandInteractionOptionInvalidChannelType * @property {'AutocompleteInteractionOptionNoFocusedOption'} AutocompleteInteractionOptionNoFocusedOption * @property {'ModalSubmitInteractionFieldNotFound'} ModalSubmitInteractionFieldNotFound @@ -281,6 +282,7 @@ const keys = [ 'CommandInteractionOptionEmpty', 'CommandInteractionOptionNoSubcommand', 'CommandInteractionOptionNoSubcommandGroup', + 'CommandInteractionOptionInvalidChannelType', 'AutocompleteInteractionOptionNoFocusedOption', 'ModalSubmitInteractionFieldNotFound', diff --git a/packages/discord.js/src/errors/Messages.js b/packages/discord.js/src/errors/Messages.js index 24437b5023c9..1b79ec030023 100644 --- a/packages/discord.js/src/errors/Messages.js +++ b/packages/discord.js/src/errors/Messages.js @@ -145,6 +145,8 @@ const Messages = { `Required option "${name}" is of type: ${type}; expected a non-empty value.`, [DjsErrorCodes.CommandInteractionOptionNoSubcommand]: 'No subcommand specified for interaction.', [DjsErrorCodes.CommandInteractionOptionNoSubcommandGroup]: 'No subcommand group specified for interaction.', + [DjsErrorCodes.CommandInteractionOptionInvalidChannelType]: (name, type, expected) => + `The type of channel of the option "${name}" is: ${type}; expected ${expected}.`, [DjsErrorCodes.AutocompleteInteractionOptionNoFocusedOption]: 'No focused option for autocomplete interaction.', [DjsErrorCodes.ModalSubmitInteractionFieldNotFound]: customId => diff --git a/packages/discord.js/src/structures/CommandInteractionOptionResolver.js b/packages/discord.js/src/structures/CommandInteractionOptionResolver.js index 23ff96264e03..1e85412e281e 100644 --- a/packages/discord.js/src/structures/CommandInteractionOptionResolver.js +++ b/packages/discord.js/src/structures/CommandInteractionOptionResolver.js @@ -142,12 +142,24 @@ class CommandInteractionOptionResolver { * Gets a channel option. * @param {string} name The name of the option. * @param {boolean} [required=false] Whether to throw an error if the option is not found. + * @param {ChannelType[]} [channelTypes=[]] The allowed types of channels. If empty, all channel types are allowed. * @returns {?(GuildChannel|ThreadChannel|APIChannel)} * The value of the option, or null if not set and not required. */ - getChannel(name, required = false) { + getChannel(name, required = false, channelTypes = []) { const option = this._getTypedOption(name, [ApplicationCommandOptionType.Channel], ['channel'], required); - return option?.channel ?? null; + const channel = option?.channel ?? null; + + if (channel && channelTypes.length > 0 && !channelTypes.includes(channel.type)) { + throw new DiscordjsTypeError( + ErrorCodes.CommandInteractionOptionInvalidChannelType, + name, + channel.type, + channelTypes.join(', '), + ); + } + + return channel; } /** diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 6f758eecbaa4..6860e422837a 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -1113,8 +1113,36 @@ export class CommandInteractionOptionResolver['channel']>; - public getChannel(name: string, required?: boolean): NonNullable['channel']> | null; + public getChannel( + name: string, + required: true, + channelTypes?: T[], + ): Extract< + NonNullable['channel']>, + { + // The `type` property of the PublicThreadChannel class is typed as `ChannelType.PublicThread | ChannelType.AnnouncementThread` + // If the user only passed one of those channel types, the Extract<> would have resolved to `never` + // Hence the need for this ternary + type: T extends ChannelType.PublicThread | ChannelType.AnnouncementThread + ? ChannelType.PublicThread | ChannelType.AnnouncementThread + : T; + } + >; + public getChannel( + name: string, + required?: boolean, + channelTypes?: T[], + ): Extract< + NonNullable['channel']>, + { + // The `type` property of the PublicThreadChannel class is typed as `ChannelType.PublicThread | ChannelType.AnnouncementThread` + // If the user only passed one of those channel types, the Extract<> would have resolved to `never` + // Hence the need for this ternary + type: T extends ChannelType.PublicThread | ChannelType.AnnouncementThread + ? ChannelType.PublicThread | ChannelType.AnnouncementThread + : T; + } + > | null; public getString(name: string, required: true): string; public getString(name: string, required?: boolean): string | null; public getInteger(name: string, required: true): number; diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index bbde22286237..905f4bbffdd2 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -152,6 +152,8 @@ import { AutoModerationActionExecution, AutoModerationRule, AutoModerationRuleManager, + PrivateThreadChannel, + PublicThreadChannel, } from '.'; import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd'; import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders'; @@ -1744,6 +1746,22 @@ client.on('interactionCreate', async interaction => { expectType(interaction.options.getChannel('test', true)); expectType(interaction.options.getRole('test', true)); + + expectType(interaction.options.getChannel('test', true, [ChannelType.PublicThread])); + expectType(interaction.options.getChannel('test', true, [ChannelType.AnnouncementThread])); + expectType( + interaction.options.getChannel('test', true, [ChannelType.PublicThread, ChannelType.AnnouncementThread]), + ); + expectType(interaction.options.getChannel('test', true, [ChannelType.PrivateThread])); + + expectType(interaction.options.getChannel('test', true, [ChannelType.GuildText])); + expectType(interaction.options.getChannel('test', false, [ChannelType.GuildText])); + expectType( + interaction.options.getChannel('test', true, [ChannelType.GuildForum, ChannelType.GuildVoice]), + ); + expectType( + interaction.options.getChannel('test', false, [ChannelType.GuildForum, ChannelType.GuildVoice]), + ); } else { // @ts-expect-error consumeCachedCommand(interaction); From 153352ad7a1ccb4a9461523cf2597d81df93b69c Mon Sep 17 00:00:00 2001 From: Synbulat Biishev Date: Fri, 23 Dec 2022 22:57:20 +0300 Subject: [PATCH 08/11] types: add generic to `ActionRowBuilder.from()` (#8414) * types: add generic to `ActionRowBuilder#from()` * test: add tests for `ActionRowBuilder.from()` * tests: add more tests --- packages/discord.js/typings/index.d.ts | 8 ++++---- packages/discord.js/typings/index.test-d.ts | 22 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 6860e422837a..f1f32d1a7f32 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -288,11 +288,11 @@ export class ActionRowBuilder >, ); - public static from( + public static from( other: - | JSONEncodable> - | APIActionRowComponent, - ): ActionRowBuilder; + | JSONEncodable>> + | APIActionRowComponent>, + ): ActionRowBuilder; } export type MessageActionRowComponent = diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index 905f4bbffdd2..1dab0ca0fdce 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -24,6 +24,8 @@ import { APIEmbed, ApplicationCommandType, APIMessage, + APIActionRowComponent, + APIActionRowComponentTypes, APIStringSelectComponent, } from 'discord-api-types/v10'; import { @@ -134,6 +136,8 @@ import { Webhook, WebhookClient, InteractionWebhook, + ActionRowComponent, + ActionRow, GuildAuditLogsActionType, GuildAuditLogsTargetType, ModalSubmitInteraction, @@ -2046,6 +2050,24 @@ EmbedBuilder.from(embedData); declare const embedComp: Embed; EmbedBuilder.from(embedComp); +declare const actionRowData: APIActionRowComponent; +ActionRowBuilder.from(actionRowData); + +declare const actionRowComp: ActionRow; +ActionRowBuilder.from(actionRowComp); + +declare const buttonsActionRowData: APIActionRowComponent; +declare const buttonsActionRowComp: ActionRow; + +expectType>(ActionRowBuilder.from(buttonsActionRowData)); +expectType>(ActionRowBuilder.from(buttonsActionRowComp)); + +declare const anyComponentsActionRowData: APIActionRowComponent; +declare const anyComponentsActionRowComp: ActionRow; + +expectType(ActionRowBuilder.from(anyComponentsActionRowData)); +expectType(ActionRowBuilder.from(anyComponentsActionRowComp)); + declare const stageChannel: StageChannel; declare const partialGroupDMChannel: PartialGroupDMChannel; From 66146033268a4db1279b2eaee4bd418f326c0d4b Mon Sep 17 00:00:00 2001 From: MrMythicalYT <91077061+MrMythicalYT@users.noreply.github.com> Date: Sat, 24 Dec 2022 02:29:32 -0500 Subject: [PATCH 09/11] fix: return only boolean for `disabled` (#8965) * fix: return only boolean for `disabled` * fix: return only boolean for `disabled` Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- packages/discord.js/src/structures/BaseSelectMenuComponent.js | 4 ++-- packages/discord.js/src/structures/ButtonComponent.js | 4 ++-- packages/discord.js/typings/index.d.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/discord.js/src/structures/BaseSelectMenuComponent.js b/packages/discord.js/src/structures/BaseSelectMenuComponent.js index bb08087630a6..7177f4329bbf 100644 --- a/packages/discord.js/src/structures/BaseSelectMenuComponent.js +++ b/packages/discord.js/src/structures/BaseSelectMenuComponent.js @@ -45,11 +45,11 @@ class BaseSelectMenuComponent extends Component { /** * Whether this select menu is disabled - * @type {?boolean} + * @type {boolean} * @readonly */ get disabled() { - return this.data.disabled ?? null; + return this.data.disabled ?? false; } } diff --git a/packages/discord.js/src/structures/ButtonComponent.js b/packages/discord.js/src/structures/ButtonComponent.js index b6dd52a4d35b..7319c3a5f19f 100644 --- a/packages/discord.js/src/structures/ButtonComponent.js +++ b/packages/discord.js/src/structures/ButtonComponent.js @@ -36,11 +36,11 @@ class ButtonComponent extends Component { /** * Whether this button is disabled - * @type {?boolean} + * @type {boolean} * @readonly */ get disabled() { - return this.data.disabled ?? null; + return this.data.disabled ?? false; } /** diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index f1f32d1a7f32..16be44dbdd43 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -678,7 +678,7 @@ export class ButtonComponent extends Component { public get style(): ButtonStyle; public get label(): string | null; public get emoji(): APIMessageComponentEmoji | null; - public get disabled(): boolean | null; + public get disabled(): boolean; public get customId(): string | null; public get url(): string | null; } @@ -759,7 +759,7 @@ export class BaseSelectMenuComponent extend public get maxValues(): number | null; public get minValues(): number | null; public get customId(): string; - public get disabled(): boolean | null; + public get disabled(): boolean; } export class StringSelectMenuComponent extends BaseSelectMenuComponent { From 0b8b114761f961a2bf8e5aae342ed711b154a89e Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Sat, 24 Dec 2022 07:35:32 +0000 Subject: [PATCH 10/11] docs: Fix malformed overridden documentation (#8954) * docs: override `resolve()` & `resolveId()` * docs(CategoryChannel): move `setParent()` up Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../src/managers/AutoModerationRuleManager.js | 36 +++++++++---------- .../src/structures/CategoryChannel.js | 18 +++++----- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/packages/discord.js/src/managers/AutoModerationRuleManager.js b/packages/discord.js/src/managers/AutoModerationRuleManager.js index 308610988d0b..b212babb064f 100644 --- a/packages/discord.js/src/managers/AutoModerationRuleManager.js +++ b/packages/discord.js/src/managers/AutoModerationRuleManager.js @@ -26,6 +26,24 @@ class AutoModerationRuleManager extends CachedManager { * @name AutoModerationRuleManager#cache */ + /** + * Resolves an {@link AutoModerationRuleResolvable} to an {@link AutoModerationRule} object. + * @method resolve + * @memberof AutoModerationRuleManager + * @instance + * @param {AutoModerationRuleResolvable} autoModerationRule The AutoModerationRule resolvable to resolve + * @returns {?AutoModerationRule} + */ + + /** + * Resolves an {@link AutoModerationRuleResolvable} to a {@link AutoModerationRule} id. + * @method resolveId + * @memberof AutoModerationRuleManager + * @instance + * @param {AutoModerationRuleResolvable} autoModerationRule The AutoModerationRule resolvable to resolve + * @returns {?Snowflake} + */ + _add(data, cache) { return super._add(data, cache, { extras: [this.guild] }); } @@ -259,24 +277,6 @@ class AutoModerationRuleManager extends CachedManager { const autoModerationRuleId = this.resolveId(autoModerationRule); await this.client.rest.delete(Routes.guildAutoModerationRule(this.guild.id, autoModerationRuleId), { reason }); } - - /** - * Resolves an {@link AutoModerationRuleResolvable} to an {@link AutoModerationRule} object. - * @method resolve - * @memberof AutoModerationRuleManager - * @instance - * @param {AutoModerationRuleResolvable} autoModerationRule The AutoModerationRule resolvable to resolve - * @returns {?AutoModerationRule} - */ - - /** - * Resolves an {@link AutoModerationRuleResolvable} to a {@link AutoModerationRule} id. - * @method resolveId - * @memberof AutoModerationRuleManager - * @instance - * @param {AutoModerationRuleResolvable} autoModerationRule The AutoModerationRule resolvable to resolve - * @returns {?Snowflake} - */ } module.exports = AutoModerationRuleManager; diff --git a/packages/discord.js/src/structures/CategoryChannel.js b/packages/discord.js/src/structures/CategoryChannel.js index 6f53858cea95..df3621f4e138 100644 --- a/packages/discord.js/src/structures/CategoryChannel.js +++ b/packages/discord.js/src/structures/CategoryChannel.js @@ -8,15 +8,6 @@ const CategoryChannelChildManager = require('../managers/CategoryChannelChildMan * @extends {GuildChannel} */ class CategoryChannel extends GuildChannel { - /** - * A manager of the channels belonging to this category - * @type {CategoryChannelChildManager} - * @readonly - */ - get children() { - return new CategoryChannelChildManager(this); - } - /** * Sets the category parent of this channel. * It is not currently possible to set the parent of a CategoryChannel. @@ -27,6 +18,15 @@ class CategoryChannel extends GuildChannel { * @param {SetParentOptions} [options={}] The options for setting the parent * @returns {Promise} */ + + /** + * A manager of the channels belonging to this category + * @type {CategoryChannelChildManager} + * @readonly + */ + get children() { + return new CategoryChannelChildManager(this); + } } module.exports = CategoryChannel; From 7ce990954e2f73d7a996df0afa42ab287cb12514 Mon Sep 17 00:00:00 2001 From: Almeida Date: Sat, 24 Dec 2022 07:42:53 +0000 Subject: [PATCH 11/11] fix(DMChannel): `recipientId` edge case (#8950) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- packages/discord.js/src/structures/DMChannel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/discord.js/src/structures/DMChannel.js b/packages/discord.js/src/structures/DMChannel.js index b5452ca09db1..cc5c38144419 100644 --- a/packages/discord.js/src/structures/DMChannel.js +++ b/packages/discord.js/src/structures/DMChannel.js @@ -30,7 +30,7 @@ class DMChannel extends BaseChannel { super._patch(data); if (data.recipients) { - const recipient = data.recipients[0]; + const recipient = data.recipients.find(user => user.id !== this.client.user.id); /** * The recipient's id