diff --git a/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/base.ts b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/base.ts new file mode 100644 index 00000000..489e61c3 --- /dev/null +++ b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/base.ts @@ -0,0 +1,26 @@ +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts'; + +export interface APIApplicationCommandOptionBase { + type: Type; + name: string; + description: string; + required?: boolean; +} + +export interface APIInteractionDataOptionBase { + name: string; + type: T; + value: D; +} + +export type APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + Base extends APIApplicationCommandOptionBase, + ChoiceType extends APIApplicationCommandOptionChoice, +> = + | (Base & { + autocomplete: true; + }) + | (Base & { + autocomplete?: false; + choices?: ChoiceType[]; + }); diff --git a/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/boolean.ts b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/boolean.ts new file mode 100644 index 00000000..5d069f5a --- /dev/null +++ b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/boolean.ts @@ -0,0 +1,9 @@ +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export type APIApplicationCommandBooleanOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataBooleanOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Boolean, + boolean +>; diff --git a/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/channel.ts b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/channel.ts new file mode 100644 index 00000000..c2132700 --- /dev/null +++ b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/channel.ts @@ -0,0 +1,14 @@ +import type { Snowflake } from '../../../../../globals.ts'; +import type { ChannelType } from '../../../channel.ts'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export interface APIApplicationCommandChannelOption + extends APIApplicationCommandOptionBase { + channel_types?: Exclude[]; +} + +export type APIApplicationCommandInteractionDataChannelOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Channel, + Snowflake +>; diff --git a/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/integer.ts b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/integer.ts new file mode 100644 index 00000000..1985ba1f --- /dev/null +++ b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/integer.ts @@ -0,0 +1,28 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base.ts'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts'; + +export interface APIApplicationCommandIntegerOptionBase + extends APIApplicationCommandOptionBase { + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + min_value?: number; + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + max_value?: number; +} + +export type APIApplicationCommandIntegerOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandIntegerOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataIntegerOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/mentionable.ts b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/mentionable.ts new file mode 100644 index 00000000..20679c3c --- /dev/null +++ b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/mentionable.ts @@ -0,0 +1,11 @@ +import type { Snowflake } from '../../../../../globals.ts'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export type APIApplicationCommandMentionableOption = + APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataMentionableOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Mentionable, + Snowflake +>; diff --git a/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/number.ts b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/number.ts new file mode 100644 index 00000000..859450bb --- /dev/null +++ b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/number.ts @@ -0,0 +1,28 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base.ts'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts'; + +export interface APIApplicationCommandNumberOptionBase + extends APIApplicationCommandOptionBase { + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + min_value?: number; + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + max_value?: number; +} + +export type APIApplicationCommandNumberOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandNumberOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataNumberOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/role.ts b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/role.ts new file mode 100644 index 00000000..b59f55a4 --- /dev/null +++ b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/role.ts @@ -0,0 +1,10 @@ +import type { Snowflake } from '../../../../../globals.ts'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export type APIApplicationCommandRoleOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataRoleOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Role, + Snowflake +>; diff --git a/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/shared.ts b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/shared.ts new file mode 100644 index 00000000..8e2f8213 --- /dev/null +++ b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/shared.ts @@ -0,0 +1,23 @@ +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type + */ +export enum ApplicationCommandOptionType { + Subcommand = 1, + SubcommandGroup, + String, + Integer, + Boolean, + User, + Channel, + Role, + Mentionable, + Number, +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure + */ +export interface APIApplicationCommandOptionChoice { + name: string; + value: ValueType; +} diff --git a/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/string.ts b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/string.ts new file mode 100644 index 00000000..5c6853ac --- /dev/null +++ b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/string.ts @@ -0,0 +1,16 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base.ts'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts'; + +export type APIApplicationCommandStringOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataStringOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/subcommand.ts b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/subcommand.ts new file mode 100644 index 00000000..5c7e132a --- /dev/null +++ b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/subcommand.ts @@ -0,0 +1,14 @@ +import type { APIApplicationCommandBasicOption, APIApplicationCommandInteractionDataBasicOption } from '../chatInput.ts'; +import type { APIApplicationCommandOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export interface APIApplicationCommandSubcommandOption + extends APIApplicationCommandOptionBase { + options?: APIApplicationCommandBasicOption[]; +} + +export interface APIApplicationCommandInteractionDataSubcommandOption { + name: string; + type: ApplicationCommandOptionType.Subcommand; + options?: APIApplicationCommandInteractionDataBasicOption[]; +} diff --git a/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts new file mode 100644 index 00000000..78698d1d --- /dev/null +++ b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts @@ -0,0 +1,17 @@ +import type { APIApplicationCommandOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; +import type { + APIApplicationCommandInteractionDataSubcommandOption, + APIApplicationCommandSubcommandOption, +} from './subcommand.ts'; + +export interface APIApplicationCommandSubcommandGroupOption + extends APIApplicationCommandOptionBase { + options?: APIApplicationCommandSubcommandOption[]; +} + +export interface APIApplicationCommandInteractionDataSubcommandGroupOption { + name: string; + type: ApplicationCommandOptionType.SubcommandGroup; + options: APIApplicationCommandInteractionDataSubcommandOption[]; +} diff --git a/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/user.ts b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/user.ts new file mode 100644 index 00000000..71f5b357 --- /dev/null +++ b/deno/payloads/v8/_interactions/_applicationCommands/_chatInput/user.ts @@ -0,0 +1,10 @@ +import type { Snowflake } from '../../../../../globals.ts'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export type APIApplicationCommandUserOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataUserOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.User, + Snowflake +>; diff --git a/deno/payloads/v8/_interactions/_applicationCommands/chatInput.ts b/deno/payloads/v8/_interactions/_applicationCommands/chatInput.ts index 95070d18..951b2423 100644 --- a/deno/payloads/v8/_interactions/_applicationCommands/chatInput.ts +++ b/deno/payloads/v8/_interactions/_applicationCommands/chatInput.ts @@ -1,231 +1,105 @@ -import type { APIRole, APIUser, ChannelType } from '../../mod.ts'; import type { Snowflake } from '../../../../globals.ts'; -import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base.ts'; +import type { APIRole, APIUser } from '../../mod.ts'; import type { APIApplicationCommandInteractionWrapper, APIInteractionDataResolvedChannel, APIInteractionDataResolvedGuildMember, ApplicationCommandType, } from '../applicationCommands.ts'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base.ts'; import type { APIBaseApplicationCommandInteractionData } from './internals.ts'; -interface APIApplicationCommandOptionBase { - type: - | ApplicationCommandOptionType.Boolean - | ApplicationCommandOptionType.User - | ApplicationCommandOptionType.Role - | ApplicationCommandOptionType.Mentionable; - name: string; - description: string; - required?: boolean; -} +import type { + APIApplicationCommandStringOption, + APIApplicationCommandInteractionDataStringOption, +} from './_chatInput/string.ts'; +import type { + APIApplicationCommandIntegerOptionBase, + APIApplicationCommandInteractionDataIntegerOption, +} from './_chatInput/integer.ts'; +import type { + APIApplicationCommandBooleanOption, + APIApplicationCommandInteractionDataBooleanOption, +} from './_chatInput/boolean.ts'; +import type { + APIApplicationCommandUserOption, + APIApplicationCommandInteractionDataUserOption, +} from './_chatInput/user.ts'; +import type { + APIApplicationCommandChannelOption, + APIApplicationCommandInteractionDataChannelOption, +} from './_chatInput/channel.ts'; +import type { + APIApplicationCommandRoleOption, + APIApplicationCommandInteractionDataRoleOption, +} from './_chatInput/role.ts'; +import type { + APIApplicationCommandMentionableOption, + APIApplicationCommandInteractionDataMentionableOption, +} from './_chatInput/mentionable.ts'; +import type { + APIApplicationCommandNumberOptionBase, + APIApplicationCommandInteractionDataNumberOption, +} from './_chatInput/number.ts'; +import type { + APIApplicationCommandSubcommandOption, + APIApplicationCommandInteractionDataSubcommandOption, +} from './_chatInput/subcommand.ts'; +import type { + APIApplicationCommandSubcommandGroupOption, + APIApplicationCommandInteractionDataSubcommandGroupOption, +} from './_chatInput/subcommandGroup.ts'; + +export * from './_chatInput/string.ts'; +export * from './_chatInput/integer.ts'; +export * from './_chatInput/boolean.ts'; +export * from './_chatInput/user.ts'; +export * from './_chatInput/channel.ts'; +export * from './_chatInput/role.ts'; +export * from './_chatInput/mentionable.ts'; +export * from './_chatInput/number.ts'; +export * from './_chatInput/subcommand.ts'; +export * from './_chatInput/subcommandGroup.ts'; +export * from './_chatInput/shared.ts'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure + */ +export type APIApplicationCommandBasicOption = + | APIApplicationCommandStringOption + | APIApplicationCommandIntegerOptionBase + | APIApplicationCommandBooleanOption + | APIApplicationCommandUserOption + | APIApplicationCommandChannelOption + | APIApplicationCommandRoleOption + | APIApplicationCommandMentionableOption + | APIApplicationCommandNumberOptionBase; /** * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure */ export type APIApplicationCommandOption = - | APIApplicationCommandStringArgumentOptions - | APIApplicationCommandSubCommandOptions - | APIApplicationCommandOptionBase - | APIApplicationCommandChannelOptions - | APIApplicationCommandOptionBase - | APIApplicationCommandNumberArgumentOptions - | APIApplicationCommandStringAutocompleteOptions - | APIApplicationCommandNumericAutocompleteOptions; - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters - */ -export interface APIApplicationCommandSubCommandOptions extends Omit { - type: ApplicationCommandOptionType.Subcommand | ApplicationCommandOptionType.SubcommandGroup; - options?: APIApplicationCommandOption[]; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array, - * but they can have a `choices` one - */ -export interface APIApplicationCommandStringArgumentOptions extends Omit { - type: ApplicationCommandOptionType.String; - choices?: APIApplicationCommandOptionChoice[]; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array, - * but they can have a `choices`, a `min_value` and `max_value` field - */ -export interface APIApplicationCommandNumberArgumentOptions - extends Omit { - type: ApplicationCommandOptionType.Integer | ApplicationCommandOptionType.Number; - choices?: APIApplicationCommandOptionChoice[]; - /** - * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. - */ - min_value?: number; - /** - * if the option is an `INTEGER` or `NUMBER` type, the maximum value permitted - */ - max_value?: number; - autocomplete?: false; -} -export interface APIApplicationCommandArgumentOptions - extends Omit { - type: - | ApplicationCommandOptionType.String - | ApplicationCommandOptionType.Integer - | ApplicationCommandOptionType.Number; - choices?: APIApplicationCommandOptionChoice[]; - autocomplete?: false; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandArgumentOptions`, these types cannot have an `choices` array, - * but they can a `autocomplete` field where it's set to `true` - */ -export interface APIApplicationCommandStringAutocompleteOptions - extends Omit { - type: ApplicationCommandOptionType.String; - autocomplete: true; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandArgumentOptions`, these types cannot have an `choices` array, - * but they can a `autocomplete` field where it's set to `true` - */ -export interface APIApplicationCommandNumericAutocompleteOptions - extends Omit { - type: ApplicationCommandOptionType.Integer | ApplicationCommandOptionType.Number; - autocomplete: true; - /** - * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. - */ - min_value?: number; - /** - * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. - */ - max_value?: number; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandSubCommandOptions` and `APIApplicationCommandArgumentOptions`, - * these types cannot have an `options` array, or a `choices` array, but they can have a `channel_types` one. - */ -export interface APIApplicationCommandChannelOptions extends Omit { - type: ApplicationCommandOptionType.Channel; - channel_types?: Exclude[]; -} - -/** - * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type - */ -export enum ApplicationCommandOptionType { - Subcommand = 1, - SubcommandGroup, - String, - Integer, - Boolean, - User, - Channel, - Role, - Mentionable, - Number, -} - -/** - * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure - */ -export interface APIApplicationCommandOptionChoice { - name: string; - value: string | number; -} + | APIApplicationCommandSubcommandOption + | APIApplicationCommandSubcommandGroupOption + | APIApplicationCommandBasicOption; /** * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-interaction-data-option-structure */ export type APIApplicationCommandInteractionDataOption = - | ApplicationCommandInteractionDataOptionSubCommand - | ApplicationCommandInteractionDataOptionSubCommandGroup - | APIApplicationCommandInteractionDataOptionWithValues; + | APIApplicationCommandInteractionDataSubcommandOption + | APIApplicationCommandInteractionDataSubcommandGroupOption + | APIApplicationCommandInteractionDataBasicOption; -export interface ApplicationCommandInteractionDataOptionSubCommand { - name: string; - type: ApplicationCommandOptionType.Subcommand; - options?: APIApplicationCommandInteractionDataOptionWithValues[]; -} - -export interface ApplicationCommandInteractionDataOptionSubCommandGroup { - name: string; - type: ApplicationCommandOptionType.SubcommandGroup; - options: ApplicationCommandInteractionDataOptionSubCommand[]; -} - -export type APIApplicationCommandInteractionDataOptionWithValues = - | ApplicationCommandInteractionDataOptionString - | ApplicationCommandInteractionDataOptionRole - | ApplicationCommandInteractionDataOptionChannel - | ApplicationCommandInteractionDataOptionUser - | ApplicationCommandInteractionDataOptionMentionable - | ApplicationCommandInteractionDataOptionInteger - | ApplicationCommandInteractionDataOptionNumber - | ApplicationCommandInteractionDataOptionBoolean; - -export interface ApplicationCommandInteractionDataOptionString - extends InteractionDataOptionBase { - focused?: boolean; -} - -export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase< - ApplicationCommandOptionType.Role, - Snowflake ->; - -export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase< - ApplicationCommandOptionType.Channel, - Snowflake ->; - -export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase< - ApplicationCommandOptionType.User, - Snowflake ->; - -export type ApplicationCommandInteractionDataOptionMentionable = InteractionDataOptionBase< - ApplicationCommandOptionType.Mentionable, - Snowflake ->; - -export interface ApplicationCommandInteractionDataOptionInteger - extends InteractionDataOptionBase { - focused?: boolean; -} - -export interface ApplicationCommandInteractionDataOptionNumber - extends InteractionDataOptionBase { - focused?: boolean; -} - -export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase< - ApplicationCommandOptionType.Boolean, - boolean ->; - -interface InteractionDataOptionBase { - name: string; - type: T; - value: D; -} +export type APIApplicationCommandInteractionDataBasicOption = + | APIApplicationCommandInteractionDataStringOption + | APIApplicationCommandInteractionDataIntegerOption + | APIApplicationCommandInteractionDataBooleanOption + | APIApplicationCommandInteractionDataUserOption + | APIApplicationCommandInteractionDataChannelOption + | APIApplicationCommandInteractionDataRoleOption + | APIApplicationCommandInteractionDataMentionableOption + | APIApplicationCommandInteractionDataNumberOption; /** * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure diff --git a/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/base.ts b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/base.ts new file mode 100644 index 00000000..489e61c3 --- /dev/null +++ b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/base.ts @@ -0,0 +1,26 @@ +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts'; + +export interface APIApplicationCommandOptionBase { + type: Type; + name: string; + description: string; + required?: boolean; +} + +export interface APIInteractionDataOptionBase { + name: string; + type: T; + value: D; +} + +export type APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + Base extends APIApplicationCommandOptionBase, + ChoiceType extends APIApplicationCommandOptionChoice, +> = + | (Base & { + autocomplete: true; + }) + | (Base & { + autocomplete?: false; + choices?: ChoiceType[]; + }); diff --git a/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/boolean.ts b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/boolean.ts new file mode 100644 index 00000000..5d069f5a --- /dev/null +++ b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/boolean.ts @@ -0,0 +1,9 @@ +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export type APIApplicationCommandBooleanOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataBooleanOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Boolean, + boolean +>; diff --git a/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/channel.ts b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/channel.ts new file mode 100644 index 00000000..c2132700 --- /dev/null +++ b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/channel.ts @@ -0,0 +1,14 @@ +import type { Snowflake } from '../../../../../globals.ts'; +import type { ChannelType } from '../../../channel.ts'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export interface APIApplicationCommandChannelOption + extends APIApplicationCommandOptionBase { + channel_types?: Exclude[]; +} + +export type APIApplicationCommandInteractionDataChannelOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Channel, + Snowflake +>; diff --git a/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/integer.ts b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/integer.ts new file mode 100644 index 00000000..1985ba1f --- /dev/null +++ b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/integer.ts @@ -0,0 +1,28 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base.ts'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts'; + +export interface APIApplicationCommandIntegerOptionBase + extends APIApplicationCommandOptionBase { + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + min_value?: number; + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + max_value?: number; +} + +export type APIApplicationCommandIntegerOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandIntegerOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataIntegerOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/mentionable.ts b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/mentionable.ts new file mode 100644 index 00000000..20679c3c --- /dev/null +++ b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/mentionable.ts @@ -0,0 +1,11 @@ +import type { Snowflake } from '../../../../../globals.ts'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export type APIApplicationCommandMentionableOption = + APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataMentionableOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Mentionable, + Snowflake +>; diff --git a/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/number.ts b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/number.ts new file mode 100644 index 00000000..859450bb --- /dev/null +++ b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/number.ts @@ -0,0 +1,28 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base.ts'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts'; + +export interface APIApplicationCommandNumberOptionBase + extends APIApplicationCommandOptionBase { + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + min_value?: number; + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + max_value?: number; +} + +export type APIApplicationCommandNumberOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandNumberOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataNumberOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/role.ts b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/role.ts new file mode 100644 index 00000000..b59f55a4 --- /dev/null +++ b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/role.ts @@ -0,0 +1,10 @@ +import type { Snowflake } from '../../../../../globals.ts'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export type APIApplicationCommandRoleOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataRoleOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Role, + Snowflake +>; diff --git a/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/shared.ts b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/shared.ts new file mode 100644 index 00000000..8e2f8213 --- /dev/null +++ b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/shared.ts @@ -0,0 +1,23 @@ +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type + */ +export enum ApplicationCommandOptionType { + Subcommand = 1, + SubcommandGroup, + String, + Integer, + Boolean, + User, + Channel, + Role, + Mentionable, + Number, +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure + */ +export interface APIApplicationCommandOptionChoice { + name: string; + value: ValueType; +} diff --git a/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/string.ts b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/string.ts new file mode 100644 index 00000000..5c6853ac --- /dev/null +++ b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/string.ts @@ -0,0 +1,16 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base.ts'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared.ts'; + +export type APIApplicationCommandStringOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataStringOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommand.ts b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommand.ts new file mode 100644 index 00000000..5c7e132a --- /dev/null +++ b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommand.ts @@ -0,0 +1,14 @@ +import type { APIApplicationCommandBasicOption, APIApplicationCommandInteractionDataBasicOption } from '../chatInput.ts'; +import type { APIApplicationCommandOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export interface APIApplicationCommandSubcommandOption + extends APIApplicationCommandOptionBase { + options?: APIApplicationCommandBasicOption[]; +} + +export interface APIApplicationCommandInteractionDataSubcommandOption { + name: string; + type: ApplicationCommandOptionType.Subcommand; + options?: APIApplicationCommandInteractionDataBasicOption[]; +} diff --git a/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts new file mode 100644 index 00000000..78698d1d --- /dev/null +++ b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts @@ -0,0 +1,17 @@ +import type { APIApplicationCommandOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; +import type { + APIApplicationCommandInteractionDataSubcommandOption, + APIApplicationCommandSubcommandOption, +} from './subcommand.ts'; + +export interface APIApplicationCommandSubcommandGroupOption + extends APIApplicationCommandOptionBase { + options?: APIApplicationCommandSubcommandOption[]; +} + +export interface APIApplicationCommandInteractionDataSubcommandGroupOption { + name: string; + type: ApplicationCommandOptionType.SubcommandGroup; + options: APIApplicationCommandInteractionDataSubcommandOption[]; +} diff --git a/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/user.ts b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/user.ts new file mode 100644 index 00000000..71f5b357 --- /dev/null +++ b/deno/payloads/v9/_interactions/_applicationCommands/_chatInput/user.ts @@ -0,0 +1,10 @@ +import type { Snowflake } from '../../../../../globals.ts'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base.ts'; +import type { ApplicationCommandOptionType } from './shared.ts'; + +export type APIApplicationCommandUserOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataUserOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.User, + Snowflake +>; diff --git a/deno/payloads/v9/_interactions/_applicationCommands/chatInput.ts b/deno/payloads/v9/_interactions/_applicationCommands/chatInput.ts index f0053503..951b2423 100644 --- a/deno/payloads/v9/_interactions/_applicationCommands/chatInput.ts +++ b/deno/payloads/v9/_interactions/_applicationCommands/chatInput.ts @@ -1,226 +1,105 @@ -import type { APIRole, APIUser, ChannelType } from '../../mod.ts'; import type { Snowflake } from '../../../../globals.ts'; -import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base.ts'; +import type { APIRole, APIUser } from '../../mod.ts'; import type { APIApplicationCommandInteractionWrapper, APIInteractionDataResolvedChannel, APIInteractionDataResolvedGuildMember, ApplicationCommandType, } from '../applicationCommands.ts'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base.ts'; import type { APIBaseApplicationCommandInteractionData } from './internals.ts'; -interface APIApplicationCommandOptionBase { - type: - | ApplicationCommandOptionType.Boolean - | ApplicationCommandOptionType.User - | ApplicationCommandOptionType.Role - | ApplicationCommandOptionType.Mentionable; - name: string; - description: string; - required?: boolean; -} +import type { + APIApplicationCommandStringOption, + APIApplicationCommandInteractionDataStringOption, +} from './_chatInput/string.ts'; +import type { + APIApplicationCommandIntegerOptionBase, + APIApplicationCommandInteractionDataIntegerOption, +} from './_chatInput/integer.ts'; +import type { + APIApplicationCommandBooleanOption, + APIApplicationCommandInteractionDataBooleanOption, +} from './_chatInput/boolean.ts'; +import type { + APIApplicationCommandUserOption, + APIApplicationCommandInteractionDataUserOption, +} from './_chatInput/user.ts'; +import type { + APIApplicationCommandChannelOption, + APIApplicationCommandInteractionDataChannelOption, +} from './_chatInput/channel.ts'; +import type { + APIApplicationCommandRoleOption, + APIApplicationCommandInteractionDataRoleOption, +} from './_chatInput/role.ts'; +import type { + APIApplicationCommandMentionableOption, + APIApplicationCommandInteractionDataMentionableOption, +} from './_chatInput/mentionable.ts'; +import type { + APIApplicationCommandNumberOptionBase, + APIApplicationCommandInteractionDataNumberOption, +} from './_chatInput/number.ts'; +import type { + APIApplicationCommandSubcommandOption, + APIApplicationCommandInteractionDataSubcommandOption, +} from './_chatInput/subcommand.ts'; +import type { + APIApplicationCommandSubcommandGroupOption, + APIApplicationCommandInteractionDataSubcommandGroupOption, +} from './_chatInput/subcommandGroup.ts'; + +export * from './_chatInput/string.ts'; +export * from './_chatInput/integer.ts'; +export * from './_chatInput/boolean.ts'; +export * from './_chatInput/user.ts'; +export * from './_chatInput/channel.ts'; +export * from './_chatInput/role.ts'; +export * from './_chatInput/mentionable.ts'; +export * from './_chatInput/number.ts'; +export * from './_chatInput/subcommand.ts'; +export * from './_chatInput/subcommandGroup.ts'; +export * from './_chatInput/shared.ts'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure + */ +export type APIApplicationCommandBasicOption = + | APIApplicationCommandStringOption + | APIApplicationCommandIntegerOptionBase + | APIApplicationCommandBooleanOption + | APIApplicationCommandUserOption + | APIApplicationCommandChannelOption + | APIApplicationCommandRoleOption + | APIApplicationCommandMentionableOption + | APIApplicationCommandNumberOptionBase; /** * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure */ export type APIApplicationCommandOption = - | APIApplicationCommandStringArgumentOptions - | APIApplicationCommandSubCommandOptions - | APIApplicationCommandOptionBase - | APIApplicationCommandChannelOptions - | APIApplicationCommandNumberArgumentOptions - | APIApplicationCommandStringAutocompleteOptions - | APIApplicationCommandNumericAutocompleteOptions; - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters - */ -export interface APIApplicationCommandSubCommandOptions extends Omit { - type: ApplicationCommandOptionType.Subcommand | ApplicationCommandOptionType.SubcommandGroup; - options?: APIApplicationCommandOption[]; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array, - * but they can have a either a `choices` or a `autocomplete` field where it's set to false. - */ -export interface APIApplicationCommandStringArgumentOptions - extends Omit { - type: - | ApplicationCommandOptionType.String - | ApplicationCommandOptionType.Integer - | ApplicationCommandOptionType.Number; - choices?: APIApplicationCommandOptionChoice[]; - autocomplete?: false; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandArgumentOptions`, these types cannot have an `choices` array, - * but they can a `autocomplete` field where it's set to `true` - */ -export interface APIApplicationCommandStringAutocompleteOptions - extends Omit { - type: ApplicationCommandOptionType.String; - autocomplete: true; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandArgumentOptions`, these types cannot have an `choices` array, - * but they can a `autocomplete` field where it's set to `true` - */ -export interface APIApplicationCommandNumericAutocompleteOptions - extends Omit { - type: ApplicationCommandOptionType.Integer | ApplicationCommandOptionType.Number; - autocomplete: true; - /** - * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. - */ - min_value?: number; - /** - * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. - */ - max_value?: number; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array, - * but they can have a `choices`, a `min_value` and `max_value` field - */ -export interface APIApplicationCommandNumberArgumentOptions - extends Omit { - type: ApplicationCommandOptionType.Integer | ApplicationCommandOptionType.Number; - choices?: APIApplicationCommandOptionChoice[]; - /** - * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. - */ - min_value?: number; - /** - * if the option is an `INTEGER` or `NUMBER` type, the maximum value permitted - */ - max_value?: number; - autocomplete?: false; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandSubCommandOptions` and `APIApplicationCommandArgumentOptions`, - * these types cannot have an `options` array, or a `choices` array, but they can have a `channel_types` one. - */ -export interface APIApplicationCommandChannelOptions extends Omit { - type: ApplicationCommandOptionType.Channel; - channel_types?: Exclude[]; -} - -/** - * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type - */ -export enum ApplicationCommandOptionType { - Subcommand = 1, - SubcommandGroup, - String, - Integer, - Boolean, - User, - Channel, - Role, - Mentionable, - Number, -} - -/** - * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure - */ -export interface APIApplicationCommandOptionChoice { - name: string; - value: string | number; -} + | APIApplicationCommandSubcommandOption + | APIApplicationCommandSubcommandGroupOption + | APIApplicationCommandBasicOption; /** * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-interaction-data-option-structure */ export type APIApplicationCommandInteractionDataOption = - | ApplicationCommandInteractionDataOptionSubCommand - | ApplicationCommandInteractionDataOptionSubCommandGroup - | APIApplicationCommandInteractionDataOptionWithValues; + | APIApplicationCommandInteractionDataSubcommandOption + | APIApplicationCommandInteractionDataSubcommandGroupOption + | APIApplicationCommandInteractionDataBasicOption; -export interface ApplicationCommandInteractionDataOptionSubCommand { - name: string; - type: ApplicationCommandOptionType.Subcommand; - options?: APIApplicationCommandInteractionDataOptionWithValues[]; -} - -export interface ApplicationCommandInteractionDataOptionSubCommandGroup { - name: string; - type: ApplicationCommandOptionType.SubcommandGroup; - options: ApplicationCommandInteractionDataOptionSubCommand[]; -} - -export type APIApplicationCommandInteractionDataOptionWithValues = - | ApplicationCommandInteractionDataOptionString - | ApplicationCommandInteractionDataOptionRole - | ApplicationCommandInteractionDataOptionChannel - | ApplicationCommandInteractionDataOptionUser - | ApplicationCommandInteractionDataOptionMentionable - | ApplicationCommandInteractionDataOptionInteger - | ApplicationCommandInteractionDataOptionNumber - | ApplicationCommandInteractionDataOptionBoolean; - -export interface ApplicationCommandInteractionDataOptionString - extends InteractionDataOptionBase { - focused?: boolean; -} - -export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase< - ApplicationCommandOptionType.Role, - Snowflake ->; - -export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase< - ApplicationCommandOptionType.Channel, - Snowflake ->; - -export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase< - ApplicationCommandOptionType.User, - Snowflake ->; - -export type ApplicationCommandInteractionDataOptionMentionable = InteractionDataOptionBase< - ApplicationCommandOptionType.Mentionable, - Snowflake ->; - -export interface ApplicationCommandInteractionDataOptionInteger - extends InteractionDataOptionBase { - focused?: boolean; -} - -export interface ApplicationCommandInteractionDataOptionNumber - extends InteractionDataOptionBase { - focused?: boolean; -} - -export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase< - ApplicationCommandOptionType.Boolean, - boolean ->; - -interface InteractionDataOptionBase { - name: string; - type: T; - value: D; -} +export type APIApplicationCommandInteractionDataBasicOption = + | APIApplicationCommandInteractionDataStringOption + | APIApplicationCommandInteractionDataIntegerOption + | APIApplicationCommandInteractionDataBooleanOption + | APIApplicationCommandInteractionDataUserOption + | APIApplicationCommandInteractionDataChannelOption + | APIApplicationCommandInteractionDataRoleOption + | APIApplicationCommandInteractionDataMentionableOption + | APIApplicationCommandInteractionDataNumberOption; /** * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure diff --git a/payloads/v8/_interactions/_applicationCommands/_chatInput/base.ts b/payloads/v8/_interactions/_applicationCommands/_chatInput/base.ts new file mode 100644 index 00000000..3412a5fc --- /dev/null +++ b/payloads/v8/_interactions/_applicationCommands/_chatInput/base.ts @@ -0,0 +1,26 @@ +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared'; + +export interface APIApplicationCommandOptionBase { + type: Type; + name: string; + description: string; + required?: boolean; +} + +export interface APIInteractionDataOptionBase { + name: string; + type: T; + value: D; +} + +export type APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + Base extends APIApplicationCommandOptionBase, + ChoiceType extends APIApplicationCommandOptionChoice, +> = + | (Base & { + autocomplete: true; + }) + | (Base & { + autocomplete?: false; + choices?: ChoiceType[]; + }); diff --git a/payloads/v8/_interactions/_applicationCommands/_chatInput/boolean.ts b/payloads/v8/_interactions/_applicationCommands/_chatInput/boolean.ts new file mode 100644 index 00000000..5743325f --- /dev/null +++ b/payloads/v8/_interactions/_applicationCommands/_chatInput/boolean.ts @@ -0,0 +1,9 @@ +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export type APIApplicationCommandBooleanOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataBooleanOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Boolean, + boolean +>; diff --git a/payloads/v8/_interactions/_applicationCommands/_chatInput/channel.ts b/payloads/v8/_interactions/_applicationCommands/_chatInput/channel.ts new file mode 100644 index 00000000..f474491f --- /dev/null +++ b/payloads/v8/_interactions/_applicationCommands/_chatInput/channel.ts @@ -0,0 +1,14 @@ +import type { Snowflake } from '../../../../../globals'; +import type { ChannelType } from '../../../channel'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export interface APIApplicationCommandChannelOption + extends APIApplicationCommandOptionBase { + channel_types?: Exclude[]; +} + +export type APIApplicationCommandInteractionDataChannelOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Channel, + Snowflake +>; diff --git a/payloads/v8/_interactions/_applicationCommands/_chatInput/integer.ts b/payloads/v8/_interactions/_applicationCommands/_chatInput/integer.ts new file mode 100644 index 00000000..6b735127 --- /dev/null +++ b/payloads/v8/_interactions/_applicationCommands/_chatInput/integer.ts @@ -0,0 +1,28 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared'; + +export interface APIApplicationCommandIntegerOptionBase + extends APIApplicationCommandOptionBase { + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + min_value?: number; + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + max_value?: number; +} + +export type APIApplicationCommandIntegerOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandIntegerOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataIntegerOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/payloads/v8/_interactions/_applicationCommands/_chatInput/mentionable.ts b/payloads/v8/_interactions/_applicationCommands/_chatInput/mentionable.ts new file mode 100644 index 00000000..475bd28a --- /dev/null +++ b/payloads/v8/_interactions/_applicationCommands/_chatInput/mentionable.ts @@ -0,0 +1,11 @@ +import type { Snowflake } from '../../../../../globals'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export type APIApplicationCommandMentionableOption = + APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataMentionableOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Mentionable, + Snowflake +>; diff --git a/payloads/v8/_interactions/_applicationCommands/_chatInput/number.ts b/payloads/v8/_interactions/_applicationCommands/_chatInput/number.ts new file mode 100644 index 00000000..cfc888dc --- /dev/null +++ b/payloads/v8/_interactions/_applicationCommands/_chatInput/number.ts @@ -0,0 +1,28 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared'; + +export interface APIApplicationCommandNumberOptionBase + extends APIApplicationCommandOptionBase { + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + min_value?: number; + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + max_value?: number; +} + +export type APIApplicationCommandNumberOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandNumberOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataNumberOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/payloads/v8/_interactions/_applicationCommands/_chatInput/role.ts b/payloads/v8/_interactions/_applicationCommands/_chatInput/role.ts new file mode 100644 index 00000000..1a776472 --- /dev/null +++ b/payloads/v8/_interactions/_applicationCommands/_chatInput/role.ts @@ -0,0 +1,10 @@ +import type { Snowflake } from '../../../../../globals'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export type APIApplicationCommandRoleOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataRoleOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Role, + Snowflake +>; diff --git a/payloads/v8/_interactions/_applicationCommands/_chatInput/shared.ts b/payloads/v8/_interactions/_applicationCommands/_chatInput/shared.ts new file mode 100644 index 00000000..12373332 --- /dev/null +++ b/payloads/v8/_interactions/_applicationCommands/_chatInput/shared.ts @@ -0,0 +1,23 @@ +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type + */ +export const enum ApplicationCommandOptionType { + Subcommand = 1, + SubcommandGroup, + String, + Integer, + Boolean, + User, + Channel, + Role, + Mentionable, + Number, +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure + */ +export interface APIApplicationCommandOptionChoice { + name: string; + value: ValueType; +} diff --git a/payloads/v8/_interactions/_applicationCommands/_chatInput/string.ts b/payloads/v8/_interactions/_applicationCommands/_chatInput/string.ts new file mode 100644 index 00000000..33b5d824 --- /dev/null +++ b/payloads/v8/_interactions/_applicationCommands/_chatInput/string.ts @@ -0,0 +1,16 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared'; + +export type APIApplicationCommandStringOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataStringOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/payloads/v8/_interactions/_applicationCommands/_chatInput/subcommand.ts b/payloads/v8/_interactions/_applicationCommands/_chatInput/subcommand.ts new file mode 100644 index 00000000..d443fb8d --- /dev/null +++ b/payloads/v8/_interactions/_applicationCommands/_chatInput/subcommand.ts @@ -0,0 +1,14 @@ +import type { APIApplicationCommandBasicOption, APIApplicationCommandInteractionDataBasicOption } from '../chatInput'; +import type { APIApplicationCommandOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export interface APIApplicationCommandSubcommandOption + extends APIApplicationCommandOptionBase { + options?: APIApplicationCommandBasicOption[]; +} + +export interface APIApplicationCommandInteractionDataSubcommandOption { + name: string; + type: ApplicationCommandOptionType.Subcommand; + options?: APIApplicationCommandInteractionDataBasicOption[]; +} diff --git a/payloads/v8/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts b/payloads/v8/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts new file mode 100644 index 00000000..37d5f725 --- /dev/null +++ b/payloads/v8/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts @@ -0,0 +1,17 @@ +import type { APIApplicationCommandOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; +import type { + APIApplicationCommandInteractionDataSubcommandOption, + APIApplicationCommandSubcommandOption, +} from './subcommand'; + +export interface APIApplicationCommandSubcommandGroupOption + extends APIApplicationCommandOptionBase { + options?: APIApplicationCommandSubcommandOption[]; +} + +export interface APIApplicationCommandInteractionDataSubcommandGroupOption { + name: string; + type: ApplicationCommandOptionType.SubcommandGroup; + options: APIApplicationCommandInteractionDataSubcommandOption[]; +} diff --git a/payloads/v8/_interactions/_applicationCommands/_chatInput/user.ts b/payloads/v8/_interactions/_applicationCommands/_chatInput/user.ts new file mode 100644 index 00000000..90719acb --- /dev/null +++ b/payloads/v8/_interactions/_applicationCommands/_chatInput/user.ts @@ -0,0 +1,10 @@ +import type { Snowflake } from '../../../../../globals'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export type APIApplicationCommandUserOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataUserOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.User, + Snowflake +>; diff --git a/payloads/v8/_interactions/_applicationCommands/chatInput.ts b/payloads/v8/_interactions/_applicationCommands/chatInput.ts index 83500ac1..003752c2 100644 --- a/payloads/v8/_interactions/_applicationCommands/chatInput.ts +++ b/payloads/v8/_interactions/_applicationCommands/chatInput.ts @@ -1,231 +1,105 @@ -import type { APIRole, APIUser, ChannelType } from '../../index'; import type { Snowflake } from '../../../../globals'; -import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base'; +import type { APIRole, APIUser } from '../../index'; import type { APIApplicationCommandInteractionWrapper, APIInteractionDataResolvedChannel, APIInteractionDataResolvedGuildMember, ApplicationCommandType, } from '../applicationCommands'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base'; import type { APIBaseApplicationCommandInteractionData } from './internals'; -interface APIApplicationCommandOptionBase { - type: - | ApplicationCommandOptionType.Boolean - | ApplicationCommandOptionType.User - | ApplicationCommandOptionType.Role - | ApplicationCommandOptionType.Mentionable; - name: string; - description: string; - required?: boolean; -} +import type { + APIApplicationCommandStringOption, + APIApplicationCommandInteractionDataStringOption, +} from './_chatInput/string'; +import type { + APIApplicationCommandIntegerOptionBase, + APIApplicationCommandInteractionDataIntegerOption, +} from './_chatInput/integer'; +import type { + APIApplicationCommandBooleanOption, + APIApplicationCommandInteractionDataBooleanOption, +} from './_chatInput/boolean'; +import type { + APIApplicationCommandUserOption, + APIApplicationCommandInteractionDataUserOption, +} from './_chatInput/user'; +import type { + APIApplicationCommandChannelOption, + APIApplicationCommandInteractionDataChannelOption, +} from './_chatInput/channel'; +import type { + APIApplicationCommandRoleOption, + APIApplicationCommandInteractionDataRoleOption, +} from './_chatInput/role'; +import type { + APIApplicationCommandMentionableOption, + APIApplicationCommandInteractionDataMentionableOption, +} from './_chatInput/mentionable'; +import type { + APIApplicationCommandNumberOptionBase, + APIApplicationCommandInteractionDataNumberOption, +} from './_chatInput/number'; +import type { + APIApplicationCommandSubcommandOption, + APIApplicationCommandInteractionDataSubcommandOption, +} from './_chatInput/subcommand'; +import type { + APIApplicationCommandSubcommandGroupOption, + APIApplicationCommandInteractionDataSubcommandGroupOption, +} from './_chatInput/subcommandGroup'; + +export * from './_chatInput/string'; +export * from './_chatInput/integer'; +export * from './_chatInput/boolean'; +export * from './_chatInput/user'; +export * from './_chatInput/channel'; +export * from './_chatInput/role'; +export * from './_chatInput/mentionable'; +export * from './_chatInput/number'; +export * from './_chatInput/subcommand'; +export * from './_chatInput/subcommandGroup'; +export * from './_chatInput/shared'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure + */ +export type APIApplicationCommandBasicOption = + | APIApplicationCommandStringOption + | APIApplicationCommandIntegerOptionBase + | APIApplicationCommandBooleanOption + | APIApplicationCommandUserOption + | APIApplicationCommandChannelOption + | APIApplicationCommandRoleOption + | APIApplicationCommandMentionableOption + | APIApplicationCommandNumberOptionBase; /** * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure */ export type APIApplicationCommandOption = - | APIApplicationCommandStringArgumentOptions - | APIApplicationCommandSubCommandOptions - | APIApplicationCommandOptionBase - | APIApplicationCommandChannelOptions - | APIApplicationCommandOptionBase - | APIApplicationCommandNumberArgumentOptions - | APIApplicationCommandStringAutocompleteOptions - | APIApplicationCommandNumericAutocompleteOptions; - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters - */ -export interface APIApplicationCommandSubCommandOptions extends Omit { - type: ApplicationCommandOptionType.Subcommand | ApplicationCommandOptionType.SubcommandGroup; - options?: APIApplicationCommandOption[]; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array, - * but they can have a `choices` one - */ -export interface APIApplicationCommandStringArgumentOptions extends Omit { - type: ApplicationCommandOptionType.String; - choices?: APIApplicationCommandOptionChoice[]; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array, - * but they can have a `choices`, a `min_value` and `max_value` field - */ -export interface APIApplicationCommandNumberArgumentOptions - extends Omit { - type: ApplicationCommandOptionType.Integer | ApplicationCommandOptionType.Number; - choices?: APIApplicationCommandOptionChoice[]; - /** - * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. - */ - min_value?: number; - /** - * if the option is an `INTEGER` or `NUMBER` type, the maximum value permitted - */ - max_value?: number; - autocomplete?: false; -} -export interface APIApplicationCommandArgumentOptions - extends Omit { - type: - | ApplicationCommandOptionType.String - | ApplicationCommandOptionType.Integer - | ApplicationCommandOptionType.Number; - choices?: APIApplicationCommandOptionChoice[]; - autocomplete?: false; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandArgumentOptions`, these types cannot have an `choices` array, - * but they can a `autocomplete` field where it's set to `true` - */ -export interface APIApplicationCommandStringAutocompleteOptions - extends Omit { - type: ApplicationCommandOptionType.String; - autocomplete: true; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandArgumentOptions`, these types cannot have an `choices` array, - * but they can a `autocomplete` field where it's set to `true` - */ -export interface APIApplicationCommandNumericAutocompleteOptions - extends Omit { - type: ApplicationCommandOptionType.Integer | ApplicationCommandOptionType.Number; - autocomplete: true; - /** - * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. - */ - min_value?: number; - /** - * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. - */ - max_value?: number; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandSubCommandOptions` and `APIApplicationCommandArgumentOptions`, - * these types cannot have an `options` array, or a `choices` array, but they can have a `channel_types` one. - */ -export interface APIApplicationCommandChannelOptions extends Omit { - type: ApplicationCommandOptionType.Channel; - channel_types?: Exclude[]; -} - -/** - * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type - */ -export const enum ApplicationCommandOptionType { - Subcommand = 1, - SubcommandGroup, - String, - Integer, - Boolean, - User, - Channel, - Role, - Mentionable, - Number, -} - -/** - * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure - */ -export interface APIApplicationCommandOptionChoice { - name: string; - value: string | number; -} + | APIApplicationCommandSubcommandOption + | APIApplicationCommandSubcommandGroupOption + | APIApplicationCommandBasicOption; /** * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-interaction-data-option-structure */ export type APIApplicationCommandInteractionDataOption = - | ApplicationCommandInteractionDataOptionSubCommand - | ApplicationCommandInteractionDataOptionSubCommandGroup - | APIApplicationCommandInteractionDataOptionWithValues; + | APIApplicationCommandInteractionDataSubcommandOption + | APIApplicationCommandInteractionDataSubcommandGroupOption + | APIApplicationCommandInteractionDataBasicOption; -export interface ApplicationCommandInteractionDataOptionSubCommand { - name: string; - type: ApplicationCommandOptionType.Subcommand; - options?: APIApplicationCommandInteractionDataOptionWithValues[]; -} - -export interface ApplicationCommandInteractionDataOptionSubCommandGroup { - name: string; - type: ApplicationCommandOptionType.SubcommandGroup; - options: ApplicationCommandInteractionDataOptionSubCommand[]; -} - -export type APIApplicationCommandInteractionDataOptionWithValues = - | ApplicationCommandInteractionDataOptionString - | ApplicationCommandInteractionDataOptionRole - | ApplicationCommandInteractionDataOptionChannel - | ApplicationCommandInteractionDataOptionUser - | ApplicationCommandInteractionDataOptionMentionable - | ApplicationCommandInteractionDataOptionInteger - | ApplicationCommandInteractionDataOptionNumber - | ApplicationCommandInteractionDataOptionBoolean; - -export interface ApplicationCommandInteractionDataOptionString - extends InteractionDataOptionBase { - focused?: boolean; -} - -export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase< - ApplicationCommandOptionType.Role, - Snowflake ->; - -export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase< - ApplicationCommandOptionType.Channel, - Snowflake ->; - -export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase< - ApplicationCommandOptionType.User, - Snowflake ->; - -export type ApplicationCommandInteractionDataOptionMentionable = InteractionDataOptionBase< - ApplicationCommandOptionType.Mentionable, - Snowflake ->; - -export interface ApplicationCommandInteractionDataOptionInteger - extends InteractionDataOptionBase { - focused?: boolean; -} - -export interface ApplicationCommandInteractionDataOptionNumber - extends InteractionDataOptionBase { - focused?: boolean; -} - -export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase< - ApplicationCommandOptionType.Boolean, - boolean ->; - -interface InteractionDataOptionBase { - name: string; - type: T; - value: D; -} +export type APIApplicationCommandInteractionDataBasicOption = + | APIApplicationCommandInteractionDataStringOption + | APIApplicationCommandInteractionDataIntegerOption + | APIApplicationCommandInteractionDataBooleanOption + | APIApplicationCommandInteractionDataUserOption + | APIApplicationCommandInteractionDataChannelOption + | APIApplicationCommandInteractionDataRoleOption + | APIApplicationCommandInteractionDataMentionableOption + | APIApplicationCommandInteractionDataNumberOption; /** * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/base.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/base.ts new file mode 100644 index 00000000..3412a5fc --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/base.ts @@ -0,0 +1,26 @@ +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared'; + +export interface APIApplicationCommandOptionBase { + type: Type; + name: string; + description: string; + required?: boolean; +} + +export interface APIInteractionDataOptionBase { + name: string; + type: T; + value: D; +} + +export type APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + Base extends APIApplicationCommandOptionBase, + ChoiceType extends APIApplicationCommandOptionChoice, +> = + | (Base & { + autocomplete: true; + }) + | (Base & { + autocomplete?: false; + choices?: ChoiceType[]; + }); diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/boolean.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/boolean.ts new file mode 100644 index 00000000..5743325f --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/boolean.ts @@ -0,0 +1,9 @@ +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export type APIApplicationCommandBooleanOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataBooleanOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Boolean, + boolean +>; diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/channel.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/channel.ts new file mode 100644 index 00000000..f474491f --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/channel.ts @@ -0,0 +1,14 @@ +import type { Snowflake } from '../../../../../globals'; +import type { ChannelType } from '../../../channel'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export interface APIApplicationCommandChannelOption + extends APIApplicationCommandOptionBase { + channel_types?: Exclude[]; +} + +export type APIApplicationCommandInteractionDataChannelOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Channel, + Snowflake +>; diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/integer.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/integer.ts new file mode 100644 index 00000000..6b735127 --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/integer.ts @@ -0,0 +1,28 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared'; + +export interface APIApplicationCommandIntegerOptionBase + extends APIApplicationCommandOptionBase { + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + min_value?: number; + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + max_value?: number; +} + +export type APIApplicationCommandIntegerOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandIntegerOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataIntegerOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/mentionable.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/mentionable.ts new file mode 100644 index 00000000..475bd28a --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/mentionable.ts @@ -0,0 +1,11 @@ +import type { Snowflake } from '../../../../../globals'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export type APIApplicationCommandMentionableOption = + APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataMentionableOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Mentionable, + Snowflake +>; diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/number.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/number.ts new file mode 100644 index 00000000..cfc888dc --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/number.ts @@ -0,0 +1,28 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared'; + +export interface APIApplicationCommandNumberOptionBase + extends APIApplicationCommandOptionBase { + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + min_value?: number; + /** + * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. + */ + max_value?: number; +} + +export type APIApplicationCommandNumberOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandNumberOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataNumberOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/role.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/role.ts new file mode 100644 index 00000000..1a776472 --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/role.ts @@ -0,0 +1,10 @@ +import type { Snowflake } from '../../../../../globals'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export type APIApplicationCommandRoleOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataRoleOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.Role, + Snowflake +>; diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/shared.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/shared.ts new file mode 100644 index 00000000..12373332 --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/shared.ts @@ -0,0 +1,23 @@ +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type + */ +export const enum ApplicationCommandOptionType { + Subcommand = 1, + SubcommandGroup, + String, + Integer, + Boolean, + User, + Channel, + Role, + Mentionable, + Number, +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure + */ +export interface APIApplicationCommandOptionChoice { + name: string; + value: ValueType; +} diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/string.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/string.ts new file mode 100644 index 00000000..33b5d824 --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/string.ts @@ -0,0 +1,16 @@ +import type { + APIApplicationCommandOptionBase, + APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper, + APIInteractionDataOptionBase, +} from './base'; +import type { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from './shared'; + +export type APIApplicationCommandStringOption = APIApplicationCommandOptionWithAutocompleteOrChoicesWrapper< + APIApplicationCommandOptionBase, + APIApplicationCommandOptionChoice +>; + +export interface APIApplicationCommandInteractionDataStringOption + extends APIInteractionDataOptionBase { + focused?: boolean; +} diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommand.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommand.ts new file mode 100644 index 00000000..d443fb8d --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommand.ts @@ -0,0 +1,14 @@ +import type { APIApplicationCommandBasicOption, APIApplicationCommandInteractionDataBasicOption } from '../chatInput'; +import type { APIApplicationCommandOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export interface APIApplicationCommandSubcommandOption + extends APIApplicationCommandOptionBase { + options?: APIApplicationCommandBasicOption[]; +} + +export interface APIApplicationCommandInteractionDataSubcommandOption { + name: string; + type: ApplicationCommandOptionType.Subcommand; + options?: APIApplicationCommandInteractionDataBasicOption[]; +} diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts new file mode 100644 index 00000000..37d5f725 --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommandGroup.ts @@ -0,0 +1,17 @@ +import type { APIApplicationCommandOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; +import type { + APIApplicationCommandInteractionDataSubcommandOption, + APIApplicationCommandSubcommandOption, +} from './subcommand'; + +export interface APIApplicationCommandSubcommandGroupOption + extends APIApplicationCommandOptionBase { + options?: APIApplicationCommandSubcommandOption[]; +} + +export interface APIApplicationCommandInteractionDataSubcommandGroupOption { + name: string; + type: ApplicationCommandOptionType.SubcommandGroup; + options: APIApplicationCommandInteractionDataSubcommandOption[]; +} diff --git a/payloads/v9/_interactions/_applicationCommands/_chatInput/user.ts b/payloads/v9/_interactions/_applicationCommands/_chatInput/user.ts new file mode 100644 index 00000000..90719acb --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/_chatInput/user.ts @@ -0,0 +1,10 @@ +import type { Snowflake } from '../../../../../globals'; +import type { APIApplicationCommandOptionBase, APIInteractionDataOptionBase } from './base'; +import type { ApplicationCommandOptionType } from './shared'; + +export type APIApplicationCommandUserOption = APIApplicationCommandOptionBase; + +export type APIApplicationCommandInteractionDataUserOption = APIInteractionDataOptionBase< + ApplicationCommandOptionType.User, + Snowflake +>; diff --git a/payloads/v9/_interactions/_applicationCommands/chatInput.ts b/payloads/v9/_interactions/_applicationCommands/chatInput.ts index 2764114c..003752c2 100644 --- a/payloads/v9/_interactions/_applicationCommands/chatInput.ts +++ b/payloads/v9/_interactions/_applicationCommands/chatInput.ts @@ -1,226 +1,105 @@ -import type { APIRole, APIUser, ChannelType } from '../../index'; import type { Snowflake } from '../../../../globals'; -import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base'; +import type { APIRole, APIUser } from '../../index'; import type { APIApplicationCommandInteractionWrapper, APIInteractionDataResolvedChannel, APIInteractionDataResolvedGuildMember, ApplicationCommandType, } from '../applicationCommands'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base'; import type { APIBaseApplicationCommandInteractionData } from './internals'; -interface APIApplicationCommandOptionBase { - type: - | ApplicationCommandOptionType.Boolean - | ApplicationCommandOptionType.User - | ApplicationCommandOptionType.Role - | ApplicationCommandOptionType.Mentionable; - name: string; - description: string; - required?: boolean; -} +import type { + APIApplicationCommandStringOption, + APIApplicationCommandInteractionDataStringOption, +} from './_chatInput/string'; +import type { + APIApplicationCommandIntegerOptionBase, + APIApplicationCommandInteractionDataIntegerOption, +} from './_chatInput/integer'; +import type { + APIApplicationCommandBooleanOption, + APIApplicationCommandInteractionDataBooleanOption, +} from './_chatInput/boolean'; +import type { + APIApplicationCommandUserOption, + APIApplicationCommandInteractionDataUserOption, +} from './_chatInput/user'; +import type { + APIApplicationCommandChannelOption, + APIApplicationCommandInteractionDataChannelOption, +} from './_chatInput/channel'; +import type { + APIApplicationCommandRoleOption, + APIApplicationCommandInteractionDataRoleOption, +} from './_chatInput/role'; +import type { + APIApplicationCommandMentionableOption, + APIApplicationCommandInteractionDataMentionableOption, +} from './_chatInput/mentionable'; +import type { + APIApplicationCommandNumberOptionBase, + APIApplicationCommandInteractionDataNumberOption, +} from './_chatInput/number'; +import type { + APIApplicationCommandSubcommandOption, + APIApplicationCommandInteractionDataSubcommandOption, +} from './_chatInput/subcommand'; +import type { + APIApplicationCommandSubcommandGroupOption, + APIApplicationCommandInteractionDataSubcommandGroupOption, +} from './_chatInput/subcommandGroup'; + +export * from './_chatInput/string'; +export * from './_chatInput/integer'; +export * from './_chatInput/boolean'; +export * from './_chatInput/user'; +export * from './_chatInput/channel'; +export * from './_chatInput/role'; +export * from './_chatInput/mentionable'; +export * from './_chatInput/number'; +export * from './_chatInput/subcommand'; +export * from './_chatInput/subcommandGroup'; +export * from './_chatInput/shared'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure + */ +export type APIApplicationCommandBasicOption = + | APIApplicationCommandStringOption + | APIApplicationCommandIntegerOptionBase + | APIApplicationCommandBooleanOption + | APIApplicationCommandUserOption + | APIApplicationCommandChannelOption + | APIApplicationCommandRoleOption + | APIApplicationCommandMentionableOption + | APIApplicationCommandNumberOptionBase; /** * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure */ export type APIApplicationCommandOption = - | APIApplicationCommandStringArgumentOptions - | APIApplicationCommandSubCommandOptions - | APIApplicationCommandOptionBase - | APIApplicationCommandChannelOptions - | APIApplicationCommandNumberArgumentOptions - | APIApplicationCommandStringAutocompleteOptions - | APIApplicationCommandNumericAutocompleteOptions; - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * If the option is a `SUB_COMMAND` or `SUB_COMMAND_GROUP` type, this nested options will be the parameters - */ -export interface APIApplicationCommandSubCommandOptions extends Omit { - type: ApplicationCommandOptionType.Subcommand | ApplicationCommandOptionType.SubcommandGroup; - options?: APIApplicationCommandOption[]; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array, - * but they can have a either a `choices` or a `autocomplete` field where it's set to false. - */ -export interface APIApplicationCommandStringArgumentOptions - extends Omit { - type: - | ApplicationCommandOptionType.String - | ApplicationCommandOptionType.Integer - | ApplicationCommandOptionType.Number; - choices?: APIApplicationCommandOptionChoice[]; - autocomplete?: false; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandArgumentOptions`, these types cannot have an `choices` array, - * but they can a `autocomplete` field where it's set to `true` - */ -export interface APIApplicationCommandStringAutocompleteOptions - extends Omit { - type: ApplicationCommandOptionType.String; - autocomplete: true; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandArgumentOptions`, these types cannot have an `choices` array, - * but they can a `autocomplete` field where it's set to `true` - */ -export interface APIApplicationCommandNumericAutocompleteOptions - extends Omit { - type: ApplicationCommandOptionType.Integer | ApplicationCommandOptionType.Number; - autocomplete: true; - /** - * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. - */ - min_value?: number; - /** - * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. - */ - max_value?: number; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandSubCommandOptions`, these types cannot have an `options` array, - * but they can have a `choices`, a `min_value` and `max_value` field - */ -export interface APIApplicationCommandNumberArgumentOptions - extends Omit { - type: ApplicationCommandOptionType.Integer | ApplicationCommandOptionType.Number; - choices?: APIApplicationCommandOptionChoice[]; - /** - * If the option is an `INTEGER` or `NUMBER` type, the minimum value permitted. - */ - min_value?: number; - /** - * if the option is an `INTEGER` or `NUMBER` type, the maximum value permitted - */ - max_value?: number; - autocomplete?: false; -} - -/** - * This type is exported as a way to make it stricter for you when you're writing your commands - * - * In contrast to `APIApplicationCommandSubCommandOptions` and `APIApplicationCommandArgumentOptions`, - * these types cannot have an `options` array, or a `choices` array, but they can have a `channel_types` one. - */ -export interface APIApplicationCommandChannelOptions extends Omit { - type: ApplicationCommandOptionType.Channel; - channel_types?: Exclude[]; -} - -/** - * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type - */ -export const enum ApplicationCommandOptionType { - Subcommand = 1, - SubcommandGroup, - String, - Integer, - Boolean, - User, - Channel, - Role, - Mentionable, - Number, -} - -/** - * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure - */ -export interface APIApplicationCommandOptionChoice { - name: string; - value: string | number; -} + | APIApplicationCommandSubcommandOption + | APIApplicationCommandSubcommandGroupOption + | APIApplicationCommandBasicOption; /** * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-interaction-data-option-structure */ export type APIApplicationCommandInteractionDataOption = - | ApplicationCommandInteractionDataOptionSubCommand - | ApplicationCommandInteractionDataOptionSubCommandGroup - | APIApplicationCommandInteractionDataOptionWithValues; + | APIApplicationCommandInteractionDataSubcommandOption + | APIApplicationCommandInteractionDataSubcommandGroupOption + | APIApplicationCommandInteractionDataBasicOption; -export interface ApplicationCommandInteractionDataOptionSubCommand { - name: string; - type: ApplicationCommandOptionType.Subcommand; - options?: APIApplicationCommandInteractionDataOptionWithValues[]; -} - -export interface ApplicationCommandInteractionDataOptionSubCommandGroup { - name: string; - type: ApplicationCommandOptionType.SubcommandGroup; - options: ApplicationCommandInteractionDataOptionSubCommand[]; -} - -export type APIApplicationCommandInteractionDataOptionWithValues = - | ApplicationCommandInteractionDataOptionString - | ApplicationCommandInteractionDataOptionRole - | ApplicationCommandInteractionDataOptionChannel - | ApplicationCommandInteractionDataOptionUser - | ApplicationCommandInteractionDataOptionMentionable - | ApplicationCommandInteractionDataOptionInteger - | ApplicationCommandInteractionDataOptionNumber - | ApplicationCommandInteractionDataOptionBoolean; - -export interface ApplicationCommandInteractionDataOptionString - extends InteractionDataOptionBase { - focused?: boolean; -} - -export type ApplicationCommandInteractionDataOptionRole = InteractionDataOptionBase< - ApplicationCommandOptionType.Role, - Snowflake ->; - -export type ApplicationCommandInteractionDataOptionChannel = InteractionDataOptionBase< - ApplicationCommandOptionType.Channel, - Snowflake ->; - -export type ApplicationCommandInteractionDataOptionUser = InteractionDataOptionBase< - ApplicationCommandOptionType.User, - Snowflake ->; - -export type ApplicationCommandInteractionDataOptionMentionable = InteractionDataOptionBase< - ApplicationCommandOptionType.Mentionable, - Snowflake ->; - -export interface ApplicationCommandInteractionDataOptionInteger - extends InteractionDataOptionBase { - focused?: boolean; -} - -export interface ApplicationCommandInteractionDataOptionNumber - extends InteractionDataOptionBase { - focused?: boolean; -} - -export type ApplicationCommandInteractionDataOptionBoolean = InteractionDataOptionBase< - ApplicationCommandOptionType.Boolean, - boolean ->; - -interface InteractionDataOptionBase { - name: string; - type: T; - value: D; -} +export type APIApplicationCommandInteractionDataBasicOption = + | APIApplicationCommandInteractionDataStringOption + | APIApplicationCommandInteractionDataIntegerOption + | APIApplicationCommandInteractionDataBooleanOption + | APIApplicationCommandInteractionDataUserOption + | APIApplicationCommandInteractionDataChannelOption + | APIApplicationCommandInteractionDataRoleOption + | APIApplicationCommandInteractionDataMentionableOption + | APIApplicationCommandInteractionDataNumberOption; /** * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure diff --git a/tests/v9/chatInputOptions.test-d.ts b/tests/v9/chatInputOptions.test-d.ts index 01636732..3357f87c 100644 --- a/tests/v9/chatInputOptions.test-d.ts +++ b/tests/v9/chatInputOptions.test-d.ts @@ -1,8 +1,9 @@ import { expectAssignable, expectNotAssignable, expectNotType } from 'tsd'; import { - APIApplicationCommandNumericAutocompleteOptions, + APIApplicationCommandIntegerOption, + APIApplicationCommandNumberOption, APIApplicationCommandOption, - APIApplicationCommandStringAutocompleteOptions, + APIApplicationCommandStringOption, ApplicationCommandOptionType, } from '../../v9'; @@ -11,45 +12,45 @@ const baseValues = { description: 'test', }; -expectAssignable({ +expectAssignable({ ...baseValues, type: ApplicationCommandOptionType.String, autocomplete: true, }); -expectAssignable({ +expectAssignable({ ...baseValues, type: ApplicationCommandOptionType.Integer, autocomplete: true, }); -expectAssignable({ +expectAssignable({ ...baseValues, type: ApplicationCommandOptionType.Number, autocomplete: true, }); -expectNotType({ +expectNotType({ ...baseValues, type: ApplicationCommandOptionType.String, choices: [], }); -expectNotAssignable({ +expectNotAssignable({ ...baseValues, type: ApplicationCommandOptionType.String, choices: [], autocomplete: true, }); -expectNotAssignable({ +expectAssignable({ ...baseValues, type: ApplicationCommandOptionType.String, choices: [], autocomplete: false, }); -expectNotAssignable({ +expectAssignable({ ...baseValues, type: ApplicationCommandOptionType.Number, choices: [],