From d1b31b702ccc9c35ca2f4307bb20456a3febeb89 Mon Sep 17 00:00:00 2001 From: Mateo Date: Sat, 2 Jul 2022 12:21:48 -0500 Subject: [PATCH 1/5] feat(ApplicationCommand): add min_length and max_length for string option (v13) --- src/structures/ApplicationCommand.js | 8 +++++++- typings/index.d.ts | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/structures/ApplicationCommand.js b/src/structures/ApplicationCommand.js index 778df2f9deeb..f7019a183650 100644 --- a/src/structures/ApplicationCommand.js +++ b/src/structures/ApplicationCommand.js @@ -454,7 +454,9 @@ class ApplicationCommand extends Base { option.options?.length !== existing.options?.length || (option.channelTypes ?? option.channel_types)?.length !== existing.channelTypes?.length || (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 ) { return false; } @@ -533,6 +535,8 @@ class ApplicationCommand extends Base { const channelTypesKey = received ? 'channelTypes' : 'channel_types'; const minValueKey = received ? 'minValue' : 'min_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 nameLocalizedKey = received ? 'nameLocalized' : 'name_localized'; const descriptionLocalizationsKey = received ? 'descriptionLocalizations' : 'description_localizations'; @@ -562,6 +566,8 @@ class ApplicationCommand extends Base { option.channel_types, [minValueKey]: option.minValue ?? option.min_value, [maxValueKey]: option.maxValue ?? option.max_value, + [minLengthKey]: option.minLength ?? option.min_length, + [maxLengthKey]: option.maxLength ?? option.max_length, }; } } diff --git a/typings/index.d.ts b/typings/index.d.ts index 1ba16f1e5a00..fab258c10baf 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3885,12 +3885,26 @@ export interface ApplicationCommandNumericOptionData extends ApplicationCommandC max_value?: number; } +export interface ApplicationCommandStringOptionData extends ApplicationCommandChoicesData { + type: ApplicationCommandOptionTypes.STRING; + minLength?: number; + min_length?: number; + maxLength?: number; + max_length?: number; +} + export interface ApplicationCommandNumericOption extends ApplicationCommandChoicesOption { type: Exclude; minValue?: number; maxValue?: number; } +export interface ApplicationCommandStringOption extends ApplicationCommandChoicesOption { + type: Exclude; + minLength?: number; + maxLength?: number; +} + export interface ApplicationCommandSubGroupData extends Omit { type: 'SUB_COMMAND_GROUP' | ApplicationCommandOptionTypes.SUB_COMMAND_GROUP; options?: ApplicationCommandSubCommandData[]; @@ -3909,6 +3923,7 @@ export interface ApplicationCommandSubCommandData extends Omit Date: Sat, 2 Jul 2022 12:30:23 -0500 Subject: [PATCH 2/5] fix: trailing spaces --- src/structures/ApplicationCommand.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/ApplicationCommand.js b/src/structures/ApplicationCommand.js index f7019a183650..6d33c12ac819 100644 --- a/src/structures/ApplicationCommand.js +++ b/src/structures/ApplicationCommand.js @@ -567,7 +567,7 @@ class ApplicationCommand extends Base { [minValueKey]: option.minValue ?? option.min_value, [maxValueKey]: option.maxValue ?? option.max_value, [minLengthKey]: option.minLength ?? option.min_length, - [maxLengthKey]: option.maxLength ?? option.max_length, + [maxLengthKey]: option.maxLength ?? option.max_length, }; } } From 969624bc188ce331934c7386cdb24b178ee5e05f Mon Sep 17 00:00:00 2001 From: Mateo Date: Sun, 3 Jul 2022 13:35:25 -0500 Subject: [PATCH 3/5] fix: upper limit and typings --- src/structures/ApplicationCommand.js | 4 ++++ typings/index.d.ts | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/structures/ApplicationCommand.js b/src/structures/ApplicationCommand.js index 6d33c12ac819..ae6435f3ea96 100644 --- a/src/structures/ApplicationCommand.js +++ b/src/structures/ApplicationCommand.js @@ -512,6 +512,10 @@ class ApplicationCommand extends Base { * 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 + * @property {number} [minLength] The minimum length for an `STRING` option + * (minimum of 0, maximum of `6000`) + * @property {number} [maxLength] The maximum length for an `STRING` option + * (minimum of 1, maximum of `6000`) */ /** diff --git a/typings/index.d.ts b/typings/index.d.ts index fab258c10baf..5ca21a564f35 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3872,7 +3872,7 @@ export interface ApplicationCommandChoicesData extends Omit { - type: Exclude; + type: CommandOptionChoiceResolvableType; choices?: ApplicationCommandOptionChoiceData[]; autocomplete?: false; } @@ -3894,13 +3894,13 @@ export interface ApplicationCommandStringOptionData extends ApplicationCommandCh } export interface ApplicationCommandNumericOption extends ApplicationCommandChoicesOption { - type: Exclude; + type: CommandOptionNumericResolvableType; minValue?: number; maxValue?: number; } export interface ApplicationCommandStringOption extends ApplicationCommandChoicesOption { - type: Exclude; + type: ApplicationCommandOptionTypes.STRING; minLength?: number; maxLength?: number; } From 2f84d26c961b6dcebb02f919a655bff22514ad79 Mon Sep 17 00:00:00 2001 From: Mateo Date: Tue, 5 Jul 2022 16:42:23 -0500 Subject: [PATCH 4/5] fix: documentation inconsistencies --- src/structures/ApplicationCommand.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/structures/ApplicationCommand.js b/src/structures/ApplicationCommand.js index ae6435f3ea96..40279ddc5f41 100644 --- a/src/structures/ApplicationCommand.js +++ b/src/structures/ApplicationCommand.js @@ -512,10 +512,10 @@ class ApplicationCommand extends Base { * 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 - * @property {number} [minLength] The minimum length for an `STRING` option - * (minimum of 0, maximum of `6000`) - * @property {number} [maxLength] The maximum length for an `STRING` option - * (minimum of 1, maximum of `6000`) + * @property {number} [minLength] The minimum length for a `STRING` option + * (minimum of `0`, maximum of `6000`) + * @property {number} [maxLength] The maximum length for a `STRING` option + * (minimum of `1`, maximum of `6000`) */ /** From 13823fb95ca200d8ef4057abfb6650291f3934a2 Mon Sep 17 00:00:00 2001 From: Mateo Date: Wed, 6 Jul 2022 12:02:24 -0500 Subject: [PATCH 5/5] fix: remove minimum limits and add properties to ApplicationCommandOptionData --- src/structures/ApplicationCommand.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/structures/ApplicationCommand.js b/src/structures/ApplicationCommand.js index 40279ddc5f41..c255cff39c3e 100644 --- a/src/structures/ApplicationCommand.js +++ b/src/structures/ApplicationCommand.js @@ -226,6 +226,10 @@ class ApplicationCommand extends Base { * 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 + * @property {number} [minLength] The minimum length for a `STRING` option + * (maximum of `6000`) + * @property {number} [maxLength] The maximum length for a `STRING` option + * (maximum of `6000`) */ /** @@ -513,9 +517,9 @@ class ApplicationCommand extends Base { * @property {number} [minValue] The minimum value for an `INTEGER` or `NUMBER` option * @property {number} [maxValue] The maximum value for an `INTEGER` or `NUMBER` option * @property {number} [minLength] The minimum length for a `STRING` option - * (minimum of `0`, maximum of `6000`) + * (maximum of `6000`) * @property {number} [maxLength] The maximum length for a `STRING` option - * (minimum of `1`, maximum of `6000`) + * (maximum of `6000`) */ /**