diff --git a/src/structures/ApplicationCommand.js b/src/structures/ApplicationCommand.js
index b026d4ceae26..b1a253b32e5b 100644
--- a/src/structures/ApplicationCommand.js
+++ b/src/structures/ApplicationCommand.js
@@ -136,6 +136,10 @@ class ApplicationCommand extends Base {
/**
* An option for an application command or subcommand.
+ * In addition to the listed properties, when used as a parameter,
+ * API style `snake_case` properties can be used for compatibility with generators like `@discordjs/builders`.
+ * Note that providing a value for the `camelCase` counterpart for any `snake_case` property
+ * will discard the provided `snake_case` property.
* @typedef {Object} ApplicationCommandOptionData
* @property {ApplicationCommandOptionType|number} type The type of the option
* @property {string} name The name of the option
@@ -146,10 +150,8 @@ class ApplicationCommand extends Base {
* @property {ApplicationCommandOptionData[]} [options] Additional options if this option is a subcommand (group)
* @property {ChannelType[]|number[]} [channelTypes] When the option type is channel,
* the allowed types of channels that can be selected
- * @property {number[]} [channel_types] When the option type is channel,
- * the API data for allowed types of channels that can be selected
- * This is provided for compatibility with something like `@discordjs/builders`
- * and will be discarded when `channelTypes` is present
+ * @property {number} [minValue] The minimum value for an `INTEGER` or `NUMBER` option
+ * @property {number} [maxValue] The maximum value for an `INTEGER` or `NUMBER` option
*/
/**
@@ -261,7 +263,9 @@ class ApplicationCommand extends Base {
existing.required ||
option.choices?.length !== existing.choices?.length ||
option.options?.length !== existing.options?.length ||
- (option.channelTypes ?? option.channel_types)?.length !== existing.channelTypes?.length
+ (option.channelTypes ?? option.channel_types)?.length !== existing.channelTypes?.length ||
+ (option.minValue ?? option.min_value) !== existing.minValue ||
+ (option.maxValue ?? option.max_value) !== existing.maxValue
) {
return false;
}
@@ -311,6 +315,8 @@ class ApplicationCommand extends Base {
* @property {ApplicationCommandOption[]} [options] Additional options if this option is a subcommand (group)
* @property {ChannelType[]} [channelTypes] When the option type is channel,
* the allowed types of channels that can be selected
+ * @property {number} [minValue] The minimum value for an `INTEGER` or `NUMBER` option
+ * @property {number} [maxValue] The maximum value for an `INTEGER` or `NUMBER` option
*/
/**
@@ -330,6 +336,8 @@ class ApplicationCommand extends Base {
static transformOption(option, received) {
const stringType = typeof option.type === 'string' ? option.type : ApplicationCommandOptionTypes[option.type];
const channelTypesKey = received ? 'channelTypes' : 'channel_types';
+ const minValueKey = received ? 'minValue' : 'min_value';
+ const maxValueKey = received ? 'maxValue' : 'max_value';
return {
type: typeof option.type === 'number' && !received ? option.type : ApplicationCommandOptionTypes[option.type],
name: option.name,
@@ -344,6 +352,8 @@ class ApplicationCommand extends Base {
: option.channelTypes?.map(type => (typeof type === 'string' ? ChannelTypes[type] : type)) ??
// When transforming to API data, accept API data
option.channel_types,
+ [minValueKey]: option.minValue ?? option.min_value,
+ [maxValueKey]: option.maxValue ?? option.max_value,
};
}
}
diff --git a/typings/index.d.ts b/typings/index.d.ts
index d252ad7c8196..2c93e24758a4 100644
--- a/typings/index.d.ts
+++ b/typings/index.d.ts
@@ -3289,10 +3289,13 @@ export type CommandOptionDataTypeResolvable = ApplicationCommandOptionType | App
export type CommandOptionChannelResolvableType = ApplicationCommandOptionTypes.CHANNEL | 'CHANNEL';
export type CommandOptionChoiceResolvableType =
- | ApplicationCommandOptionTypes.NUMBER
- | 'NUMBER'
| ApplicationCommandOptionTypes.STRING
| 'STRING'
+ | CommandOptionNumericResolvableType;
+
+export type CommandOptionNumericResolvableType =
+ | ApplicationCommandOptionTypes.NUMBER
+ | 'NUMBER'
| ApplicationCommandOptionTypes.INTEGER
| 'INTEGER';
@@ -3354,6 +3357,20 @@ export interface ApplicationCommandChoicesOption extends BaseApplicationCommandO
choices?: ApplicationCommandOptionChoice[];
}
+export interface ApplicationCommandNumericOptionData extends ApplicationCommandChoicesData {
+ type: CommandOptionNumericResolvableType;
+ minValue?: number;
+ min_value?: number;
+ maxValue?: number;
+ max_value?: number;
+}
+
+export interface ApplicationCommandNumericOption extends ApplicationCommandChoicesOption {
+ type: Exclude;
+ minValue?: number;
+ maxValue?: number;
+}
+
export interface ApplicationCommandSubGroupData extends Omit {
type: 'SUB_COMMAND_GROUP' | ApplicationCommandOptionTypes.SUB_COMMAND_GROUP;
options?: ApplicationCommandSubCommandData[];
@@ -3387,6 +3404,7 @@ export type ApplicationCommandOptionData =
| ApplicationCommandNonOptionsData
| ApplicationCommandChannelOptionData
| ApplicationCommandChoicesData
+ | ApplicationCommandNumericOptionData
| ApplicationCommandSubCommandData;
export type ApplicationCommandOption =
@@ -3394,6 +3412,7 @@ export type ApplicationCommandOption =
| ApplicationCommandNonOptions
| ApplicationCommandChannelOption
| ApplicationCommandChoicesOption
+ | ApplicationCommandNumericOption
| ApplicationCommandSubCommand;
export interface ApplicationCommandOptionChoice {