mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 13:03:31 +01:00
feat(applicationCommand): add max min length in string option (#8215)
This commit is contained in:
@@ -441,6 +441,8 @@ class ApplicationCommand extends Base {
|
|||||||
(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.minValue ?? option.min_value) !== existing.minValue ||
|
||||||
(option.maxValue ?? option.max_value) !== existing.maxValue ||
|
(option.maxValue ?? option.max_value) !== existing.maxValue ||
|
||||||
|
(option.minLength ?? option.min_length) !== existing.minLength ||
|
||||||
|
(option.maxLength ?? option.max_length) !== existing.maxLength ||
|
||||||
!isEqual(option.nameLocalizations ?? option.name_localizations ?? {}, existing.nameLocalizations ?? {}) ||
|
!isEqual(option.nameLocalizations ?? option.name_localizations ?? {}, existing.nameLocalizations ?? {}) ||
|
||||||
!isEqual(
|
!isEqual(
|
||||||
option.descriptionLocalizations ?? option.description_localizations ?? {},
|
option.descriptionLocalizations ?? option.description_localizations ?? {},
|
||||||
@@ -509,6 +511,10 @@ class ApplicationCommand extends Base {
|
|||||||
* {@link ApplicationCommandOptionType.Number} option
|
* {@link ApplicationCommandOptionType.Number} option
|
||||||
* @property {number} [maxValue] The maximum value for an {@link ApplicationCommandOptionType.Integer} or
|
* @property {number} [maxValue] The maximum value for an {@link ApplicationCommandOptionType.Integer} or
|
||||||
* {@link ApplicationCommandOptionType.Number} option
|
* {@link ApplicationCommandOptionType.Number} option
|
||||||
|
* @property {number} [minLength] The minimum length for an {@link ApplicationCommandOptionType.String} option
|
||||||
|
* (minimum of 0, maximum of `6000`)
|
||||||
|
* @property {number} [maxLength] The maximum length for an {@link ApplicationCommandOptionType.String} option
|
||||||
|
* (minimum of 1, maximum of `6000`)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -531,6 +537,8 @@ class ApplicationCommand extends Base {
|
|||||||
const channelTypesKey = received ? 'channelTypes' : 'channel_types';
|
const channelTypesKey = received ? 'channelTypes' : 'channel_types';
|
||||||
const minValueKey = received ? 'minValue' : 'min_value';
|
const minValueKey = received ? 'minValue' : 'min_value';
|
||||||
const maxValueKey = received ? 'maxValue' : 'max_value';
|
const maxValueKey = received ? 'maxValue' : 'max_value';
|
||||||
|
const minLengthKey = received ? 'minLength' : 'min_length';
|
||||||
|
const maxLengthKey = received ? 'maxLength' : 'max_length';
|
||||||
const nameLocalizationsKey = received ? 'nameLocalizations' : 'name_localizations';
|
const nameLocalizationsKey = received ? 'nameLocalizations' : 'name_localizations';
|
||||||
const nameLocalizedKey = received ? 'nameLocalized' : 'name_localized';
|
const nameLocalizedKey = received ? 'nameLocalized' : 'name_localized';
|
||||||
const descriptionLocalizationsKey = received ? 'descriptionLocalizations' : 'description_localizations';
|
const descriptionLocalizationsKey = received ? 'descriptionLocalizations' : 'description_localizations';
|
||||||
@@ -560,6 +568,8 @@ class ApplicationCommand extends Base {
|
|||||||
[channelTypesKey]: option.channelTypes ?? option.channel_types,
|
[channelTypesKey]: option.channelTypes ?? option.channel_types,
|
||||||
[minValueKey]: option.minValue ?? option.min_value,
|
[minValueKey]: option.minValue ?? option.min_value,
|
||||||
[maxValueKey]: option.maxValue ?? option.max_value,
|
[maxValueKey]: option.maxValue ?? option.max_value,
|
||||||
|
[minLengthKey]: option.minLength ?? option.min_length,
|
||||||
|
[maxLengthKey]: option.maxLength ?? option.max_length,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
21
packages/discord.js/typings/index.d.ts
vendored
21
packages/discord.js/typings/index.d.ts
vendored
@@ -3783,7 +3783,7 @@ export interface ApplicationCommandChoicesData extends Omit<BaseApplicationComma
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ApplicationCommandChoicesOption extends Omit<BaseApplicationCommandOptionsData, 'autocomplete'> {
|
export interface ApplicationCommandChoicesOption extends Omit<BaseApplicationCommandOptionsData, 'autocomplete'> {
|
||||||
type: Exclude<CommandOptionChoiceResolvableType, ApplicationCommandOptionType>;
|
type: CommandOptionChoiceResolvableType;
|
||||||
choices?: ApplicationCommandOptionChoiceData[];
|
choices?: ApplicationCommandOptionChoiceData[];
|
||||||
autocomplete?: false;
|
autocomplete?: false;
|
||||||
}
|
}
|
||||||
@@ -3796,12 +3796,26 @@ export interface ApplicationCommandNumericOptionData extends ApplicationCommandC
|
|||||||
max_value?: number;
|
max_value?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ApplicationCommandStringOptionData extends ApplicationCommandChoicesData {
|
||||||
|
type: ApplicationCommandOptionType.String;
|
||||||
|
minLength?: number;
|
||||||
|
min_length?: number;
|
||||||
|
maxLength?: number;
|
||||||
|
max_length?: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ApplicationCommandNumericOption extends ApplicationCommandChoicesOption {
|
export interface ApplicationCommandNumericOption extends ApplicationCommandChoicesOption {
|
||||||
type: Exclude<CommandOptionNumericResolvableType, ApplicationCommandOptionType>;
|
type: CommandOptionNumericResolvableType;
|
||||||
minValue?: number;
|
minValue?: number;
|
||||||
maxValue?: number;
|
maxValue?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ApplicationCommandStringOption extends ApplicationCommandChoicesOption {
|
||||||
|
type: ApplicationCommandOptionType.String;
|
||||||
|
minLength?: number;
|
||||||
|
maxLength?: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ApplicationCommandSubGroupData extends Omit<BaseApplicationCommandOptionsData, 'required'> {
|
export interface ApplicationCommandSubGroupData extends Omit<BaseApplicationCommandOptionsData, 'required'> {
|
||||||
type: ApplicationCommandOptionType.SubcommandGroup;
|
type: ApplicationCommandOptionType.SubcommandGroup;
|
||||||
options?: ApplicationCommandSubCommandData[];
|
options?: ApplicationCommandSubCommandData[];
|
||||||
@@ -3820,6 +3834,7 @@ export interface ApplicationCommandSubCommandData extends Omit<BaseApplicationCo
|
|||||||
| ApplicationCommandChannelOptionData
|
| ApplicationCommandChannelOptionData
|
||||||
| ApplicationCommandAutocompleteOption
|
| ApplicationCommandAutocompleteOption
|
||||||
| ApplicationCommandNumericOptionData
|
| ApplicationCommandNumericOptionData
|
||||||
|
| ApplicationCommandStringOptionData
|
||||||
)[];
|
)[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3843,6 +3858,7 @@ export type ApplicationCommandOptionData =
|
|||||||
| ApplicationCommandChoicesData
|
| ApplicationCommandChoicesData
|
||||||
| ApplicationCommandAutocompleteOption
|
| ApplicationCommandAutocompleteOption
|
||||||
| ApplicationCommandNumericOptionData
|
| ApplicationCommandNumericOptionData
|
||||||
|
| ApplicationCommandStringOptionData
|
||||||
| ApplicationCommandSubCommandData;
|
| ApplicationCommandSubCommandData;
|
||||||
|
|
||||||
export type ApplicationCommandOption =
|
export type ApplicationCommandOption =
|
||||||
@@ -3851,6 +3867,7 @@ export type ApplicationCommandOption =
|
|||||||
| ApplicationCommandChannelOption
|
| ApplicationCommandChannelOption
|
||||||
| ApplicationCommandChoicesOption
|
| ApplicationCommandChoicesOption
|
||||||
| ApplicationCommandNumericOption
|
| ApplicationCommandNumericOption
|
||||||
|
| ApplicationCommandStringOption
|
||||||
| ApplicationCommandAttachmentOption
|
| ApplicationCommandAttachmentOption
|
||||||
| ApplicationCommandSubCommand;
|
| ApplicationCommandSubCommand;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user