Skip to content

Commit

Permalink
refactor: Use deprecate() directly (#9026)
Browse files Browse the repository at this point in the history
* refactor: just call `deprecate()`

* docs: prevent crash

* refactor: back to prototype deprecation
  • Loading branch information
Jiralite committed Jan 12, 2023
1 parent bb58395 commit 1c871b5
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 14 deletions.
14 changes: 6 additions & 8 deletions packages/discord.js/src/structures/ActionRow.js
Expand Up @@ -23,16 +23,16 @@ class ActionRow extends Component {

/**
* Creates a new action row builder from JSON data
* @method from
* @memberof ActionRow
* @param {JSONEncodable<APIActionRowComponent>|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
Expand All @@ -43,6 +43,4 @@ class ActionRow extends Component {
}
}

ActionRow.from = deprecate(ActionRow.from, 'ActionRow.from() is deprecated. Use ActionRowBuilder.from() instead.');

module.exports = ActionRow;
2 changes: 0 additions & 2 deletions packages/discord.js/src/structures/BaseInteraction.js
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/structures/SelectMenuBuilder.js
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/structures/SelectMenuComponent.js
Expand Up @@ -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;
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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;
Expand Down

2 comments on commit 1c871b5

@vercel
Copy link

@vercel vercel bot commented on 1c871b5 Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 1c871b5 Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.