From fd1958bd67b35faa0222b3c125c9265596f054de Mon Sep 17 00:00:00 2001 From: Danial Raza Date: Thu, 12 Dec 2024 11:21:00 +0100 Subject: [PATCH] refactor!: replace `isAnySelectMenu` with `isSelectMenu` (#10656) BREAKING CHANGE: `BaseInteraction#isAnySelectMenu()` has been removed. Use `BaseInteraction#isSelectMenu()` instead. --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --- packages/discord.js/src/structures/BaseInteraction.js | 2 +- packages/discord.js/typings/index.d.ts | 4 +--- packages/discord.js/typings/index.test-d.ts | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/discord.js/src/structures/BaseInteraction.js b/packages/discord.js/src/structures/BaseInteraction.js index 1386a75f9..5c79b7e47 100644 --- a/packages/discord.js/src/structures/BaseInteraction.js +++ b/packages/discord.js/src/structures/BaseInteraction.js @@ -262,7 +262,7 @@ class BaseInteraction extends Base { * Indicates whether this interaction is a select menu of any known type. * @returns {boolean} */ - isAnySelectMenu() { + isSelectMenu() { return this.type === InteractionType.MessageComponent && SelectMenuTypes.includes(this.componentType); } diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 36aba253d..9baa4c2e4 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -1987,7 +1987,7 @@ export class BaseInteraction extends Base public isMessageContextMenuCommand(): this is MessageContextMenuCommandInteraction; public isModalSubmit(): this is ModalSubmitInteraction; public isUserContextMenuCommand(): this is UserContextMenuCommandInteraction; - public isAnySelectMenu(): this is SelectMenuInteraction; + public isSelectMenu(): this is SelectMenuInteraction; public isStringSelectMenu(): this is StringSelectMenuInteraction; public isUserSelectMenu(): this is UserSelectMenuInteraction; public isRoleSelectMenu(): this is RoleSelectMenuInteraction; @@ -2964,8 +2964,6 @@ export class ChannelSelectMenuInteraction< public inRawGuild(): this is ChannelSelectMenuInteraction<'raw'>; } -// Ideally this should be named SelectMenuInteraction, but that's the name of the "old" StringSelectMenuInteraction, meaning -// the type name is reserved as a re-export to prevent a breaking change from being made, as such: export type SelectMenuInteraction = | StringSelectMenuInteraction | UserSelectMenuInteraction diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index 266205746..b587e3bf2 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -2399,7 +2399,7 @@ expectType>(threadChannel.flags); expectType(partialGroupDMChannel.flags); // Select menu type narrowing -if (interaction.isAnySelectMenu()) { +if (interaction.isSelectMenu()) { expectType(interaction); }