Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ApplicationCommand): add min_length and max_length for string option (v13) #8217

Merged
merged 5 commits into from Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/structures/ApplicationCommand.js
Expand Up @@ -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;
}
Expand Down Expand Up @@ -510,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 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`)
*/

/**
Expand All @@ -533,6 +539,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';
Expand Down Expand Up @@ -562,6 +570,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,
};
}
}
Expand Down
21 changes: 19 additions & 2 deletions typings/index.d.ts
Expand Up @@ -3872,7 +3872,7 @@ export interface ApplicationCommandChoicesData extends Omit<BaseApplicationComma
}

export interface ApplicationCommandChoicesOption extends Omit<BaseApplicationCommandOptionsData, 'autocomplete'> {
type: Exclude<CommandOptionChoiceResolvableType, ApplicationCommandOptionTypes>;
type: CommandOptionChoiceResolvableType;
choices?: ApplicationCommandOptionChoiceData[];
autocomplete?: false;
}
Expand All @@ -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<CommandOptionNumericResolvableType, ApplicationCommandOptionTypes>;
type: CommandOptionNumericResolvableType;
minValue?: number;
maxValue?: number;
}

export interface ApplicationCommandStringOption extends ApplicationCommandChoicesOption {
type: ApplicationCommandOptionTypes.STRING;
minLength?: number;
maxLength?: number;
}

export interface ApplicationCommandSubGroupData extends Omit<BaseApplicationCommandOptionsData, 'required'> {
type: 'SUB_COMMAND_GROUP' | ApplicationCommandOptionTypes.SUB_COMMAND_GROUP;
options?: ApplicationCommandSubCommandData[];
Expand All @@ -3909,6 +3923,7 @@ export interface ApplicationCommandSubCommandData extends Omit<BaseApplicationCo
| ApplicationCommandChannelOptionData
| ApplicationCommandAutocompleteOption
| ApplicationCommandNumericOptionData
| ApplicationCommandStringOptionData
)[];
}

Expand All @@ -3932,6 +3947,7 @@ export type ApplicationCommandOptionData =
| ApplicationCommandChoicesData
| ApplicationCommandAutocompleteOption
| ApplicationCommandNumericOptionData
| ApplicationCommandStringOptionData
| ApplicationCommandSubCommandData;

export type ApplicationCommandOption =
Expand All @@ -3940,6 +3956,7 @@ export type ApplicationCommandOption =
| ApplicationCommandChannelOption
| ApplicationCommandChoicesOption
| ApplicationCommandNumericOption
| ApplicationCommandStringOption
| ApplicationCommandSubCommand;

export interface ApplicationCommandOptionChoiceData {
Expand Down