Skip to content

Commit

Permalink
types: stricter types for choices in options
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiralite committed Aug 20, 2022
1 parent 8028813 commit c46c350
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/discord.js/typings/index.d.ts
Expand Up @@ -3868,27 +3868,29 @@ export interface ApplicationCommandAutocompleteStringOptionData
autocomplete: true;
}

export interface ApplicationCommandChoicesData extends Omit<BaseApplicationCommandOptionsData, 'autocomplete'> {
export interface ApplicationCommandChoicesData<Type extends string | number = string | number>
extends Omit<BaseApplicationCommandOptionsData, 'autocomplete'> {
type: CommandOptionChoiceResolvableType;
choices?: ApplicationCommandOptionChoiceData[];
choices?: ApplicationCommandOptionChoiceData<Type>[];
autocomplete?: false;
}

export interface ApplicationCommandChoicesOption extends Omit<BaseApplicationCommandOptionsData, 'autocomplete'> {
export interface ApplicationCommandChoicesOption<Type extends string | number = string | number>
extends Omit<BaseApplicationCommandOptionsData, 'autocomplete'> {
type: CommandOptionChoiceResolvableType;
choices?: ApplicationCommandOptionChoiceData[];
choices?: ApplicationCommandOptionChoiceData<Type>[];
autocomplete?: false;
}

export interface ApplicationCommandNumericOptionData extends ApplicationCommandChoicesData {
export interface ApplicationCommandNumericOptionData extends ApplicationCommandChoicesData<number> {
type: CommandOptionNumericResolvableType;
minValue?: number;
min_value?: number;
maxValue?: number;
max_value?: number;
}

export interface ApplicationCommandStringOptionData extends ApplicationCommandChoicesData {
export interface ApplicationCommandStringOptionData extends ApplicationCommandChoicesData<string> {
type: ApplicationCommandOptionType.String;
minLength?: number;
min_length?: number;
Expand All @@ -3900,13 +3902,13 @@ export interface ApplicationCommandBooleanOptionData extends BaseApplicationComm
type: ApplicationCommandOptionType.Boolean;
}

export interface ApplicationCommandNumericOption extends ApplicationCommandChoicesOption {
export interface ApplicationCommandNumericOption extends ApplicationCommandChoicesOption<number> {
type: CommandOptionNumericResolvableType;
minValue?: number;
maxValue?: number;
}

export interface ApplicationCommandStringOption extends ApplicationCommandChoicesOption {
export interface ApplicationCommandStringOption extends ApplicationCommandChoicesOption<string> {
type: ApplicationCommandOptionType.String;
minLength?: number;
maxLength?: number;
Expand Down Expand Up @@ -3948,7 +3950,6 @@ export type ApplicationCommandOptionData =
| ApplicationCommandSubGroupData
| ApplicationCommandNonOptionsData
| ApplicationCommandChannelOptionData
| ApplicationCommandChoicesData
| ApplicationCommandAutocompleteNumericOptionData
| ApplicationCommandAutocompleteStringOptionData
| ApplicationCommandNumericOptionData
Expand All @@ -3965,7 +3966,6 @@ export type ApplicationCommandOption =
| ApplicationCommandAutocompleteStringOption
| ApplicationCommandNonOptions
| ApplicationCommandChannelOption
| ApplicationCommandChoicesOption
| ApplicationCommandNumericOption
| ApplicationCommandStringOption
| ApplicationCommandRoleOption
Expand All @@ -3975,10 +3975,10 @@ export type ApplicationCommandOption =
| ApplicationCommandAttachmentOption
| ApplicationCommandSubCommand;

export interface ApplicationCommandOptionChoiceData {
export interface ApplicationCommandOptionChoiceData<Value extends string | number = string | number> {
name: string;
nameLocalizations?: LocalizationMap;
value: string | number;
value: Value;
}

export interface ApplicationCommandPermissions {
Expand Down

0 comments on commit c46c350

Please sign in to comment.