Skip to content

Commit a93f4b1

Browse files
authored
feat(ApplicationCommand): add min_length and max_length for string option (v13) (#8217)
1 parent f457cdd commit a93f4b1

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

src/structures/ApplicationCommand.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ class ApplicationCommand extends Base {
226226
* the allowed types of channels that can be selected
227227
* @property {number} [minValue] The minimum value for an `INTEGER` or `NUMBER` option
228228
* @property {number} [maxValue] The maximum value for an `INTEGER` or `NUMBER` option
229+
* @property {number} [minLength] The minimum length for a `STRING` option
230+
* (maximum of `6000`)
231+
* @property {number} [maxLength] The maximum length for a `STRING` option
232+
* (maximum of `6000`)
229233
*/
230234

231235
/**
@@ -454,7 +458,9 @@ class ApplicationCommand extends Base {
454458
option.options?.length !== existing.options?.length ||
455459
(option.channelTypes ?? option.channel_types)?.length !== existing.channelTypes?.length ||
456460
(option.minValue ?? option.min_value) !== existing.minValue ||
457-
(option.maxValue ?? option.max_value) !== existing.maxValue
461+
(option.maxValue ?? option.max_value) !== existing.maxValue ||
462+
(option.minLength ?? option.min_length) !== existing.minLength ||
463+
(option.maxLength ?? option.max_length) !== existing.maxLength
458464
) {
459465
return false;
460466
}
@@ -510,6 +516,10 @@ class ApplicationCommand extends Base {
510516
* the allowed types of channels that can be selected
511517
* @property {number} [minValue] The minimum value for an `INTEGER` or `NUMBER` option
512518
* @property {number} [maxValue] The maximum value for an `INTEGER` or `NUMBER` option
519+
* @property {number} [minLength] The minimum length for a `STRING` option
520+
* (maximum of `6000`)
521+
* @property {number} [maxLength] The maximum length for a `STRING` option
522+
* (maximum of `6000`)
513523
*/
514524

515525
/**
@@ -533,6 +543,8 @@ class ApplicationCommand extends Base {
533543
const channelTypesKey = received ? 'channelTypes' : 'channel_types';
534544
const minValueKey = received ? 'minValue' : 'min_value';
535545
const maxValueKey = received ? 'maxValue' : 'max_value';
546+
const minLengthKey = received ? 'minLength' : 'min_length';
547+
const maxLengthKey = received ? 'maxLength' : 'max_length';
536548
const nameLocalizationsKey = received ? 'nameLocalizations' : 'name_localizations';
537549
const nameLocalizedKey = received ? 'nameLocalized' : 'name_localized';
538550
const descriptionLocalizationsKey = received ? 'descriptionLocalizations' : 'description_localizations';
@@ -562,6 +574,8 @@ class ApplicationCommand extends Base {
562574
option.channel_types,
563575
[minValueKey]: option.minValue ?? option.min_value,
564576
[maxValueKey]: option.maxValue ?? option.max_value,
577+
[minLengthKey]: option.minLength ?? option.min_length,
578+
[maxLengthKey]: option.maxLength ?? option.max_length,
565579
};
566580
}
567581
}

typings/index.d.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3877,7 +3877,7 @@ export interface ApplicationCommandChoicesData extends Omit<BaseApplicationComma
38773877
}
38783878

38793879
export interface ApplicationCommandChoicesOption extends Omit<BaseApplicationCommandOptionsData, 'autocomplete'> {
3880-
type: Exclude<CommandOptionChoiceResolvableType, ApplicationCommandOptionTypes>;
3880+
type: CommandOptionChoiceResolvableType;
38813881
choices?: ApplicationCommandOptionChoiceData[];
38823882
autocomplete?: false;
38833883
}
@@ -3890,12 +3890,26 @@ export interface ApplicationCommandNumericOptionData extends ApplicationCommandC
38903890
max_value?: number;
38913891
}
38923892

3893+
export interface ApplicationCommandStringOptionData extends ApplicationCommandChoicesData {
3894+
type: ApplicationCommandOptionTypes.STRING;
3895+
minLength?: number;
3896+
min_length?: number;
3897+
maxLength?: number;
3898+
max_length?: number;
3899+
}
3900+
38933901
export interface ApplicationCommandNumericOption extends ApplicationCommandChoicesOption {
3894-
type: Exclude<CommandOptionNumericResolvableType, ApplicationCommandOptionTypes>;
3902+
type: CommandOptionNumericResolvableType;
38953903
minValue?: number;
38963904
maxValue?: number;
38973905
}
38983906

3907+
export interface ApplicationCommandStringOption extends ApplicationCommandChoicesOption {
3908+
type: ApplicationCommandOptionTypes.STRING;
3909+
minLength?: number;
3910+
maxLength?: number;
3911+
}
3912+
38993913
export interface ApplicationCommandSubGroupData extends Omit<BaseApplicationCommandOptionsData, 'required'> {
39003914
type: 'SUB_COMMAND_GROUP' | ApplicationCommandOptionTypes.SUB_COMMAND_GROUP;
39013915
options?: ApplicationCommandSubCommandData[];
@@ -3914,6 +3928,7 @@ export interface ApplicationCommandSubCommandData extends Omit<BaseApplicationCo
39143928
| ApplicationCommandChannelOptionData
39153929
| ApplicationCommandAutocompleteOption
39163930
| ApplicationCommandNumericOptionData
3931+
| ApplicationCommandStringOptionData
39173932
)[];
39183933
}
39193934

@@ -3937,6 +3952,7 @@ export type ApplicationCommandOptionData =
39373952
| ApplicationCommandChoicesData
39383953
| ApplicationCommandAutocompleteOption
39393954
| ApplicationCommandNumericOptionData
3955+
| ApplicationCommandStringOptionData
39403956
| ApplicationCommandSubCommandData;
39413957

39423958
export type ApplicationCommandOption =
@@ -3945,6 +3961,7 @@ export type ApplicationCommandOption =
39453961
| ApplicationCommandChannelOption
39463962
| ApplicationCommandChoicesOption
39473963
| ApplicationCommandNumericOption
3964+
| ApplicationCommandStringOption
39483965
| ApplicationCommandSubCommand;
39493966

39503967
export interface ApplicationCommandOptionChoiceData {

0 commit comments

Comments
 (0)