mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix(ApplicationCommand): use new ApplicationCommandOptionType enums (#7257)
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const { ComponentType } = require('discord-api-types/v9');
|
||||
const { TypeError } = require('../errors');
|
||||
const { MessageComponentTypes, Events } = require('../util/Constants');
|
||||
const { Events } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents an interactive component of a Message. It should not be necessary to construct this directly.
|
||||
@@ -61,20 +62,20 @@ class BaseMessageComponent {
|
||||
let component;
|
||||
let type = data.type;
|
||||
|
||||
if (typeof type === 'string') type = MessageComponentTypes[type];
|
||||
if (typeof type === 'string') type = ComponentType[type];
|
||||
|
||||
switch (type) {
|
||||
case MessageComponentTypes.ACTION_ROW: {
|
||||
case ComponentType.ActionRow: {
|
||||
const MessageActionRow = require('./MessageActionRow');
|
||||
component = data instanceof MessageActionRow ? data : new MessageActionRow(data, client);
|
||||
break;
|
||||
}
|
||||
case MessageComponentTypes.BUTTON: {
|
||||
case ComponentType.Button: {
|
||||
const MessageButton = require('./MessageButton');
|
||||
component = data instanceof MessageButton ? data : new MessageButton(data);
|
||||
break;
|
||||
}
|
||||
case MessageComponentTypes.SELECT_MENU: {
|
||||
case ComponentType.SelectMenu: {
|
||||
const MessageSelectMenu = require('./MessageSelectMenu');
|
||||
component = data instanceof MessageSelectMenu ? data : new MessageSelectMenu(data);
|
||||
break;
|
||||
@@ -96,7 +97,7 @@ class BaseMessageComponent {
|
||||
* @private
|
||||
*/
|
||||
static resolveType(type) {
|
||||
return typeof type === 'string' ? type : MessageComponentTypes[type];
|
||||
return typeof type === 'string' ? type : ComponentType[type];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { ComponentType } = require('discord-api-types/v9');
|
||||
const BaseMessageComponent = require('./BaseMessageComponent');
|
||||
const { MessageComponentTypes } = require('../util/Constants');
|
||||
|
||||
/**
|
||||
* Represents an action row containing message components.
|
||||
@@ -88,7 +88,7 @@ class MessageActionRow extends BaseMessageComponent {
|
||||
toJSON() {
|
||||
return {
|
||||
components: this.components.map(c => c.toJSON()),
|
||||
type: MessageComponentTypes[this.type],
|
||||
type: ComponentType[this.type],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const { ButtonStyle, ComponentType } = require('discord-api-types/v9');
|
||||
const BaseMessageComponent = require('./BaseMessageComponent');
|
||||
const { RangeError } = require('../errors');
|
||||
const { MessageButtonStyles, MessageComponentTypes } = require('../util/Constants');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
@@ -138,8 +138,8 @@ class MessageButton extends BaseMessageComponent {
|
||||
disabled: this.disabled,
|
||||
emoji: this.emoji,
|
||||
label: this.label,
|
||||
style: MessageButtonStyles[this.style],
|
||||
type: MessageComponentTypes[this.type],
|
||||
style: ButtonStyle[this.style],
|
||||
type: ComponentType[this.type],
|
||||
url: this.url,
|
||||
};
|
||||
}
|
||||
@@ -158,7 +158,7 @@ class MessageButton extends BaseMessageComponent {
|
||||
* @private
|
||||
*/
|
||||
static resolveStyle(style) {
|
||||
return typeof style === 'string' ? style : MessageButtonStyles[style];
|
||||
return typeof style === 'string' ? style : ButtonStyle[style];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { ComponentType } = require('discord-api-types/v9');
|
||||
const BaseMessageComponent = require('./BaseMessageComponent');
|
||||
const { MessageComponentTypes } = require('../util/Constants');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
@@ -179,7 +179,7 @@ class MessageSelectMenu extends BaseMessageComponent {
|
||||
min_values: this.minValues,
|
||||
max_values: this.maxValues ?? (this.minValues ? this.options.length : undefined),
|
||||
options: this.options,
|
||||
type: typeof this.type === 'string' ? MessageComponentTypes[this.type] : this.type,
|
||||
type: typeof this.type === 'string' ? ComponentType[this.type] : this.type,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user