refactor: Use deprecate() directly (#9026)

* refactor: just call `deprecate()`

* docs: prevent crash

* refactor: back to prototype deprecation
This commit is contained in:
Jiralite
2023-01-12 20:38:31 +00:00
committed by GitHub
parent bb58395df0
commit 1c871b5b57
6 changed files with 10 additions and 14 deletions

View File

@@ -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
@@ -43,6 +43,4 @@ class ActionRow extends Component {
}
}
ActionRow.from = deprecate(ActionRow.from, 'ActionRow.from() is deprecated. Use ActionRowBuilder.from() instead.');
module.exports = ActionRow;

View File

@@ -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() {

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;