From 1c871b5b576dddef12c5afacecf416dbd6243dea Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Thu, 12 Jan 2023 20:38:31 +0000 Subject: [PATCH] refactor: Use `deprecate()` directly (#9026) * refactor: just call `deprecate()` * docs: prevent crash * refactor: back to prototype deprecation --- packages/discord.js/src/structures/ActionRow.js | 14 ++++++-------- .../discord.js/src/structures/BaseInteraction.js | 2 -- .../discord.js/src/structures/SelectMenuBuilder.js | 2 +- .../src/structures/SelectMenuComponent.js | 2 +- .../src/structures/SelectMenuInteraction.js | 2 +- .../src/structures/SelectMenuOptionBuilder.js | 2 +- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/packages/discord.js/src/structures/ActionRow.js b/packages/discord.js/src/structures/ActionRow.js index ac5413821e1e..ffa2fe7ed314 100644 --- a/packages/discord.js/src/structures/ActionRow.js +++ b/packages/discord.js/src/structures/ActionRow.js @@ -23,16 +23,16 @@ class ActionRow extends Component { /** * Creates a new action row builder from JSON data + * @method from + * @memberof ActionRow * @param {JSONEncodable|APIActionRowComponent} other The other data * @returns {ActionRowBuilder} * @deprecated Use {@link ActionRowBuilder.from} instead. */ - static from(other) { - if (isJSONEncodable(other)) { - return new this(other.toJSON()); - } - return new this(other); - } + static from = deprecate( + other => new this(isJSONEncodable(other) ? other.toJSON() : other), + 'ActionRow.from() is deprecated. Use ActionRowBuilder.from() instead.', + ); /** * Returns the API-compatible JSON for this component @@ -43,6 +43,4 @@ class ActionRow extends Component { } } -ActionRow.from = deprecate(ActionRow.from, 'ActionRow.from() is deprecated. Use ActionRowBuilder.from() instead.'); - module.exports = ActionRow; diff --git a/packages/discord.js/src/structures/BaseInteraction.js b/packages/discord.js/src/structures/BaseInteraction.js index df4d1bbf049a..3b6db688ef02 100644 --- a/packages/discord.js/src/structures/BaseInteraction.js +++ b/packages/discord.js/src/structures/BaseInteraction.js @@ -270,11 +270,9 @@ class BaseInteraction extends Base { return this.type === InteractionType.MessageComponent && this.componentType === ComponentType.Button; } - // TODO: Get rid of this in the next major /** * Indicates whether this interaction is a {@link StringSelectMenuInteraction}. * @returns {boolean} - * * @deprecated Use {@link BaseInteraction#isStringSelectMenu} instead. */ isSelectMenu() { diff --git a/packages/discord.js/src/structures/SelectMenuBuilder.js b/packages/discord.js/src/structures/SelectMenuBuilder.js index bae3e66fc5e8..a77937054777 100644 --- a/packages/discord.js/src/structures/SelectMenuBuilder.js +++ b/packages/discord.js/src/structures/SelectMenuBuilder.js @@ -15,7 +15,7 @@ class SelectMenuBuilder extends StringSelectMenuBuilder { if (!deprecationEmitted) { process.emitWarning( - 'The SelectMenuBuilder class is deprecated, use StringSelectMenuBuilder instead.', + 'The SelectMenuBuilder class is deprecated. Use StringSelectMenuBuilder instead.', 'DeprecationWarning', ); deprecationEmitted = true; diff --git a/packages/discord.js/src/structures/SelectMenuComponent.js b/packages/discord.js/src/structures/SelectMenuComponent.js index 540acb7e2b8b..2cd8097c95f3 100644 --- a/packages/discord.js/src/structures/SelectMenuComponent.js +++ b/packages/discord.js/src/structures/SelectMenuComponent.js @@ -15,7 +15,7 @@ class SelectMenuComponent extends StringSelectMenuComponent { if (!deprecationEmitted) { process.emitWarning( - 'The SelectMenuComponent class is deprecated, use StringSelectMenuComponent instead.', + 'The SelectMenuComponent class is deprecated. Use StringSelectMenuComponent instead.', 'DeprecationWarning', ); deprecationEmitted = true; diff --git a/packages/discord.js/src/structures/SelectMenuInteraction.js b/packages/discord.js/src/structures/SelectMenuInteraction.js index 923725ece6ed..a09655958846 100644 --- a/packages/discord.js/src/structures/SelectMenuInteraction.js +++ b/packages/discord.js/src/structures/SelectMenuInteraction.js @@ -15,7 +15,7 @@ class SelectMenuInteraction extends StringSelectMenuInteraction { if (!deprecationEmitted) { process.emitWarning( - 'The SelectMenuInteraction class is deprecated, use StringSelectMenuInteraction instead.', + 'The SelectMenuInteraction class is deprecated. Use StringSelectMenuInteraction instead.', 'DeprecationWarning', ); deprecationEmitted = true; diff --git a/packages/discord.js/src/structures/SelectMenuOptionBuilder.js b/packages/discord.js/src/structures/SelectMenuOptionBuilder.js index 4646848ce30b..85309d1542bb 100644 --- a/packages/discord.js/src/structures/SelectMenuOptionBuilder.js +++ b/packages/discord.js/src/structures/SelectMenuOptionBuilder.js @@ -15,7 +15,7 @@ class SelectMenuOptionBuilder extends StringSelectMenuOptionBuilder { if (!deprecationEmitted) { process.emitWarning( - 'The SelectMenuOptionBuilder class is deprecated, use StringSelectMenuOptionBuilder instead.', + 'The SelectMenuOptionBuilder class is deprecated. Use StringSelectMenuOptionBuilder instead.', 'DeprecationWarning', ); deprecationEmitted = true;