From fdc1c1a5b411d8ef3d635ad90bd97c2b1bf77cf1 Mon Sep 17 00:00:00 2001 From: Advaith Date: Sat, 14 Aug 2021 10:58:34 -0700 Subject: [PATCH] feat(Interactions): context menu items (#166) --- .../chatInput.ts} | 167 ++++-------------- .../_applicationCommands/contextMenu.ts | 104 +++++++++++ .../_applicationCommands/internals.ts | 8 + .../_applicationCommands/permissions.ts | 49 +++++ .../v8/_interactions/applicationCommands.ts | 118 +++++++++++++ deno/payloads/v8/_interactions/base.ts | 6 +- deno/payloads/v8/_interactions/responses.ts | 8 +- deno/payloads/v8/interactions.ts | 13 +- deno/payloads/v8/oauth2.ts | 8 +- deno/payloads/v8/permissions.ts | 2 +- .../chatInput.ts} | 167 ++++-------------- .../_applicationCommands/contextMenu.ts | 104 +++++++++++ .../_applicationCommands/internals.ts | 8 + .../_applicationCommands/permissions.ts | 49 +++++ .../v9/_interactions/applicationCommands.ts | 118 +++++++++++++ deno/payloads/v9/_interactions/base.ts | 4 +- deno/payloads/v9/_interactions/responses.ts | 8 +- deno/payloads/v9/interactions.ts | 13 +- deno/payloads/v9/oauth2.ts | 8 +- deno/payloads/v9/permissions.ts | 2 +- deno/rest/v8/interactions.ts | 103 ++++++----- deno/rest/v9/interactions.ts | 103 ++++++----- .../chatInput.ts} | 167 ++++-------------- .../_applicationCommands/contextMenu.ts | 104 +++++++++++ .../_applicationCommands/internals.ts | 8 + .../_applicationCommands/permissions.ts | 49 +++++ .../v8/_interactions/applicationCommands.ts | 118 +++++++++++++ payloads/v8/_interactions/base.ts | 6 +- payloads/v8/_interactions/responses.ts | 8 +- payloads/v8/interactions.ts | 13 +- payloads/v8/oauth2.ts | 8 +- payloads/v8/permissions.ts | 2 +- .../chatInput.ts} | 167 ++++-------------- .../_applicationCommands/contextMenu.ts | 104 +++++++++++ .../_applicationCommands/internals.ts | 8 + .../_applicationCommands/permissions.ts | 49 +++++ .../v9/_interactions/applicationCommands.ts | 118 +++++++++++++ payloads/v9/_interactions/base.ts | 4 +- payloads/v9/_interactions/responses.ts | 8 +- payloads/v9/interactions.ts | 13 +- payloads/v9/oauth2.ts | 8 +- payloads/v9/permissions.ts | 2 +- rest/v8/interactions.ts | 103 ++++++----- rest/v9/interactions.ts | 103 ++++++----- 44 files changed, 1610 insertions(+), 730 deletions(-) rename deno/payloads/v8/_interactions/{slashCommands.ts => _applicationCommands/chatInput.ts} (50%) create mode 100644 deno/payloads/v8/_interactions/_applicationCommands/contextMenu.ts create mode 100644 deno/payloads/v8/_interactions/_applicationCommands/internals.ts create mode 100644 deno/payloads/v8/_interactions/_applicationCommands/permissions.ts create mode 100644 deno/payloads/v8/_interactions/applicationCommands.ts rename deno/payloads/v9/_interactions/{slashCommands.ts => _applicationCommands/chatInput.ts} (50%) create mode 100644 deno/payloads/v9/_interactions/_applicationCommands/contextMenu.ts create mode 100644 deno/payloads/v9/_interactions/_applicationCommands/internals.ts create mode 100644 deno/payloads/v9/_interactions/_applicationCommands/permissions.ts create mode 100644 deno/payloads/v9/_interactions/applicationCommands.ts rename payloads/v8/_interactions/{slashCommands.ts => _applicationCommands/chatInput.ts} (50%) create mode 100644 payloads/v8/_interactions/_applicationCommands/contextMenu.ts create mode 100644 payloads/v8/_interactions/_applicationCommands/internals.ts create mode 100644 payloads/v8/_interactions/_applicationCommands/permissions.ts create mode 100644 payloads/v8/_interactions/applicationCommands.ts rename payloads/v9/_interactions/{slashCommands.ts => _applicationCommands/chatInput.ts} (50%) create mode 100644 payloads/v9/_interactions/_applicationCommands/contextMenu.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/internals.ts create mode 100644 payloads/v9/_interactions/_applicationCommands/permissions.ts create mode 100644 payloads/v9/_interactions/applicationCommands.ts diff --git a/deno/payloads/v8/_interactions/slashCommands.ts b/deno/payloads/v8/_interactions/_applicationCommands/chatInput.ts similarity index 50% rename from deno/payloads/v8/_interactions/slashCommands.ts rename to deno/payloads/v8/_interactions/_applicationCommands/chatInput.ts index 57de779f..6446b5d2 100644 --- a/deno/payloads/v8/_interactions/slashCommands.ts +++ b/deno/payloads/v8/_interactions/_applicationCommands/chatInput.ts @@ -1,45 +1,13 @@ -import type { APIRole, APIUser } from '../mod.ts'; -import type { Permissions, Snowflake } from '../../../globals.ts'; -import type { APIPartialChannel } from '../channel.ts'; -import type { APIGuildMember } from '../guild.ts'; -import type { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts'; -import type { InteractionType } from './responses.ts'; - -/** - * https://discord.com/developers/docs/interactions/slash-commands#application-command-object - */ -export interface APIApplicationCommand { - /** - * Unique id of the command - */ - id: Snowflake; - /** - * Unique id of the parent application - */ - application_id: Snowflake; - /** - * Guild id of the command, if not global - */ - guild_id?: Snowflake; - /** - * 1-32 character name matching `^[\w-]{1,32}$` - */ - name: string; - /** - * 1-100 character description - */ - description: string; - /** - * The parameters for the command - */ - options?: APIApplicationCommandOption[]; - /** - * Whether the command is enabled by default when the app is added to a guild - * - * If missing, this property should be assumed as `true` - */ - default_permission?: boolean; -} +import type { APIRole, APIUser } from '../../mod.ts'; +import type { Snowflake } from '../../../../globals.ts'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base.ts'; +import type { + APIApplicationCommandInteractionWrapper, + APIInteractionDataResolvedChannel, + APIInteractionDataResolvedGuildMember, + ApplicationCommandType, +} from '../applicationCommands.ts'; +import type { APIBaseApplicationCommandInteractionData } from './internals.ts'; interface APIApplicationCommandOptionBase { type: @@ -55,7 +23,7 @@ interface APIApplicationCommandOptionBase { } /** - * https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-structure + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure */ export type APIApplicationCommandOption = | APIApplicationCommandArgumentOptions @@ -87,7 +55,7 @@ export interface APIApplicationCommandArgumentOptions extends Omit; - roles?: Record; - members?: Record; - channels?: Record; - }; -} - -/** - * https://discord.com/developers/docs/resources/channel#channel-object - */ -export interface APIInteractionDataResolvedChannel extends Required { - permissions: Permissions; -} - -/** - * https://discord.com/developers/docs/resources/guild#guild-member-object - */ -export interface APIInteractionDataResolvedGuildMember extends Omit { - permissions: Permissions; -} - -/** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-object-application-command-interaction-data-option-structure + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-interaction-data-option-structure */ export type APIApplicationCommandInteractionDataOption = | ApplicationCommandInteractionDataOptionSubCommand @@ -215,69 +154,39 @@ interface InteractionDataOptionBase { + options?: APIApplicationCommandInteractionDataOption[]; + resolved?: APIChatInputApplicationCommandInteractionDataResolved; } /** - * https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-application-command-permissions-structure + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure */ -export interface APIApplicationCommandPermission { - /** - * The id of the role or user - */ - id: Snowflake; - /** - * Role or user - */ - type: ApplicationCommandPermissionType; - /** - * `true` to allow, `false`, to disallow - */ - permission: boolean; +export interface APIChatInputApplicationCommandInteractionDataResolved { + users?: Record; + roles?: Record; + members?: Record; + channels?: Record; } /** - * https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissiontype + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ -export enum ApplicationCommandPermissionType { - Role = 1, - User, -} +export type APIChatInputApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; -// INTERACTIONS +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIChatInputApplicationCommandDMInteraction = + APIDMInteractionWrapper; -export type APIApplicationCommandInteraction = APIBaseInteraction< - InteractionType.ApplicationCommand, - APIApplicationCommandInteractionData -> & - Required< - Pick< - APIBaseInteraction, - 'channel_id' | 'data' - > - >; - -export type APIApplicationCommandDMInteraction = APIDMInteractionWrapper; - -export type APIApplicationCommandGuildInteraction = APIGuildInteractionWrapper; +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIChatInputApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; diff --git a/deno/payloads/v8/_interactions/_applicationCommands/contextMenu.ts b/deno/payloads/v8/_interactions/_applicationCommands/contextMenu.ts new file mode 100644 index 00000000..ac59b971 --- /dev/null +++ b/deno/payloads/v8/_interactions/_applicationCommands/contextMenu.ts @@ -0,0 +1,104 @@ +import type { APIUser } from '../../user.ts'; +import type { Snowflake } from '../../../../globals.ts'; +import type { APIMessage } from '../../channel.ts'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base.ts'; +import type { + APIApplicationCommandInteractionWrapper, + APIInteractionDataResolvedGuildMember, + ApplicationCommandType, +} from '../applicationCommands.ts'; +import type { APIBaseApplicationCommandInteractionData } from './internals.ts'; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export interface APIUserApplicationCommandInteractionData + extends APIBaseApplicationCommandInteractionData { + target_id: Snowflake; + resolved: APIUserApplicationCommandInteractionDataResolved; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure + */ +export interface APIUserApplicationCommandInteractionDataResolved { + users: Record; + members?: Record; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export interface APIMessageApplicationCommandInteractionData + extends APIBaseApplicationCommandInteractionData { + target_id: Snowflake; + resolved: APIMessageApplicationCommandInteractionDataResolved; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure + */ +export interface APIMessageApplicationCommandInteractionDataResolved { + messages: Record; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export type APIContextMenuInteractionData = + | APIUserApplicationCommandInteractionData + | APIMessageApplicationCommandInteractionData; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandDMInteraction = APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandDMInteraction = + APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuInteraction = APIUserApplicationCommandInteraction | APIMessageApplicationCommandInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuDMInteraction = + | APIUserApplicationCommandDMInteraction + | APIMessageApplicationCommandDMInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuGuildInteraction = + | APIUserApplicationCommandGuildInteraction + | APIMessageApplicationCommandGuildInteraction; diff --git a/deno/payloads/v8/_interactions/_applicationCommands/internals.ts b/deno/payloads/v8/_interactions/_applicationCommands/internals.ts new file mode 100644 index 00000000..6e2d4b8b --- /dev/null +++ b/deno/payloads/v8/_interactions/_applicationCommands/internals.ts @@ -0,0 +1,8 @@ +import type { Snowflake } from '../../../../globals.ts'; +import type { ApplicationCommandType } from '../applicationCommands.ts'; + +export interface APIBaseApplicationCommandInteractionData { + id: Snowflake; + type: Type; + name: string; +} diff --git a/deno/payloads/v8/_interactions/_applicationCommands/permissions.ts b/deno/payloads/v8/_interactions/_applicationCommands/permissions.ts new file mode 100644 index 00000000..38186f89 --- /dev/null +++ b/deno/payloads/v8/_interactions/_applicationCommands/permissions.ts @@ -0,0 +1,49 @@ +import type { Snowflake } from '../../../../globals.ts'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure + */ +export interface APIGuildApplicationCommandPermissions { + /** + * The id of the command + */ + id: Snowflake; + /** + * The id of the application the command belongs to + */ + application_id: Snowflake; + /** + * The id of the guild + */ + guild_id: Snowflake; + /** + * The permissions for the command in the guild + */ + permissions: APIApplicationCommandPermission[]; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-structure + */ +export interface APIApplicationCommandPermission { + /** + * The id of the role or user + */ + id: Snowflake; + /** + * Role or user + */ + type: ApplicationCommandPermissionType; + /** + * `true` to allow, `false`, to disallow + */ + permission: boolean; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type + */ +export enum ApplicationCommandPermissionType { + Role = 1, + User, +} diff --git a/deno/payloads/v8/_interactions/applicationCommands.ts b/deno/payloads/v8/_interactions/applicationCommands.ts new file mode 100644 index 00000000..46370ba4 --- /dev/null +++ b/deno/payloads/v8/_interactions/applicationCommands.ts @@ -0,0 +1,118 @@ +import type { Permissions, Snowflake } from '../../../globals.ts'; +import type { APIPartialChannel } from '../channel.ts'; +import type { APIGuildMember } from '../guild.ts'; +import type { APIBaseInteraction } from './base.ts'; +import type { InteractionType } from './responses.ts'; +import type { + APIApplicationCommandOption, + APIChatInputApplicationCommandDMInteraction, + APIChatInputApplicationCommandGuildInteraction, + APIChatInputApplicationCommandInteraction, + APIChatInputApplicationCommandInteractionData, +} from './_applicationCommands/chatInput.ts'; +import type { + APIContextMenuDMInteraction, + APIContextMenuGuildInteraction, + APIContextMenuInteraction, + APIContextMenuInteractionData, +} from './_applicationCommands/contextMenu.ts'; + +export * from './_applicationCommands/chatInput.ts'; +export * from './_applicationCommands/contextMenu.ts'; +export * from './_applicationCommands/permissions.ts'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object + */ +export interface APIApplicationCommand { + /** + * Unique id of the command + */ + id: Snowflake; + /** + * Type of the command + */ + type: ApplicationCommandType; + /** + * Unique id of the parent application + */ + application_id: Snowflake; + /** + * Guild id of the command, if not global + */ + guild_id?: Snowflake; + /** + * 1-32 character name; `CHAT_INPUT` command names must be all lowercase matching `^[\w-]{1,32}$` + */ + name: string; + /** + * 1-100 character description for `CHAT_INPUT` commands, empty string for `USER` and `MESSAGE` commands + */ + description: string; + /** + * The parameters for the `CHAT_INPUT` command, max 25 + */ + options?: APIApplicationCommandOption[]; + /** + * Whether the command is enabled by default when the app is added to a guild + * + * If missing, this property should be assumed as `true` + */ + default_permission?: boolean; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types + */ +export enum ApplicationCommandType { + ChatInput = 1, + User, + Message, +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export type APIApplicationCommandInteractionData = + | APIChatInputApplicationCommandInteractionData + | APIContextMenuInteractionData; + +/** + * https://discord.com/developers/docs/resources/channel#channel-object + */ +export interface APIInteractionDataResolvedChannel extends Required { + permissions: Permissions; +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-member-object + */ +export interface APIInteractionDataResolvedGuildMember extends Omit { + permissions: Permissions; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandInteractionWrapper = + APIBaseInteraction & + Required, 'channel_id' | 'data'>>; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandInteraction = APIChatInputApplicationCommandInteraction | APIContextMenuInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandDMInteraction = + | APIChatInputApplicationCommandDMInteraction + | APIContextMenuDMInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandGuildInteraction = + | APIChatInputApplicationCommandGuildInteraction + | APIContextMenuGuildInteraction; diff --git a/deno/payloads/v8/_interactions/base.ts b/deno/payloads/v8/_interactions/base.ts index 0608200c..0addcefb 100644 --- a/deno/payloads/v8/_interactions/base.ts +++ b/deno/payloads/v8/_interactions/base.ts @@ -1,11 +1,11 @@ import type { Permissions, Snowflake } from '../../../globals.ts'; -import type { InteractionType } from '../../v8.ts'; +import type { InteractionType } from './responses.ts'; import type { APIMessage } from '../channel.ts'; import type { APIGuildMember } from '../guild.ts'; import type { APIUser } from '../user.ts'; /** - * https://discord.com/developers/docs/interactions/slash-commands#message-interaction-object-message-interaction-structure + * https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object */ export interface APIMessageInteraction { /** @@ -37,7 +37,7 @@ export interface APIInteractionGuildMember extends APIGuildMember { // INTERACTIONS RECEIVED /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-object + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ export interface APIBaseInteraction { /** diff --git a/deno/payloads/v8/_interactions/responses.ts b/deno/payloads/v8/_interactions/responses.ts index fe47b6f9..d3e3db3d 100644 --- a/deno/payloads/v8/_interactions/responses.ts +++ b/deno/payloads/v8/_interactions/responses.ts @@ -2,7 +2,7 @@ import type { MessageFlags } from '../mod.ts'; import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v8.ts'; /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-request-type + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type */ export enum InteractionType { Ping = 1, @@ -11,7 +11,7 @@ export enum InteractionType { } /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object */ export type APIInteractionResponse = | APIInteractionResponsePong @@ -44,7 +44,7 @@ export interface APIInteractionResponseUpdateMessage { } /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-callback-type + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type */ export enum InteractionResponseType { /** @@ -70,7 +70,7 @@ export enum InteractionResponseType { } /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-application-command-callback-data-structure + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-data-structure */ export type APIInteractionResponseCallbackData = Omit< RESTPostAPIWebhookWithTokenJSONBody, diff --git a/deno/payloads/v8/interactions.ts b/deno/payloads/v8/interactions.ts index c87c3042..f88a00cb 100644 --- a/deno/payloads/v8/interactions.ts +++ b/deno/payloads/v8/interactions.ts @@ -8,16 +8,25 @@ import type { APIApplicationCommandDMInteraction, APIApplicationCommandGuildInteraction, APIApplicationCommandInteraction, -} from './_interactions/slashCommands.ts'; +} from './_interactions/applicationCommands.ts'; export * from './_interactions/base.ts'; export * from './_interactions/messageComponents.ts'; export * from './_interactions/ping.ts'; export * from './_interactions/responses.ts'; -export * from './_interactions/slashCommands.ts'; +export * from './_interactions/applicationCommands.ts'; +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ export type APIInteraction = APIPingInteraction | APIApplicationCommandInteraction | APIMessageComponentInteraction; +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ export type APIDMInteraction = APIApplicationCommandDMInteraction | APIMessageComponentDMInteraction; +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ export type APIGuildInteraction = APIApplicationCommandGuildInteraction | APIMessageComponentGuildInteraction; diff --git a/deno/payloads/v8/oauth2.ts b/deno/payloads/v8/oauth2.ts index 970e68e4..022f82d1 100644 --- a/deno/payloads/v8/oauth2.ts +++ b/deno/payloads/v8/oauth2.ts @@ -94,15 +94,15 @@ export enum OAuth2Scopes { */ ActivitiesWrite = 'activities.write', /** - * Allows your app to use Slash Commands in a guild + * Allows your app to use Application Commands in a guild * - * See https://discord.com/developers/docs/interactions/slash-commands + * See https://discord.com/developers/docs/interactions/application-commands */ ApplicationsCommands = 'applications.commands', /** - * Allows your app to update its Slash Commands via this bearer token - client credentials grant only + * Allows your app to update its Application Commands via this bearer token - client credentials grant only * - * See https://discord.com/developers/docs/interactions/slash-commands + * See https://discord.com/developers/docs/interactions/application-commands */ ApplicationsCommandsUpdate = 'applications.commands.update', } diff --git a/deno/payloads/v8/permissions.ts b/deno/payloads/v8/permissions.ts index 965cf953..790e4b4c 100644 --- a/deno/payloads/v8/permissions.ts +++ b/deno/payloads/v8/permissions.ts @@ -43,7 +43,7 @@ export const PermissionFlagsBits = { ManageRoles: 1n << 28n, ManageWebhooks: 1n << 29n, ManageEmojisAndStickers: 1n << 30n, - UseSlashCommands: 1n << 31n, + UseApplicationCommands: 1n << 31n, RequestToSpeak: 1n << 32n, UseExternalStickers: 1n << 37n, } as const; diff --git a/deno/payloads/v9/_interactions/slashCommands.ts b/deno/payloads/v9/_interactions/_applicationCommands/chatInput.ts similarity index 50% rename from deno/payloads/v9/_interactions/slashCommands.ts rename to deno/payloads/v9/_interactions/_applicationCommands/chatInput.ts index 57de779f..6446b5d2 100644 --- a/deno/payloads/v9/_interactions/slashCommands.ts +++ b/deno/payloads/v9/_interactions/_applicationCommands/chatInput.ts @@ -1,45 +1,13 @@ -import type { APIRole, APIUser } from '../mod.ts'; -import type { Permissions, Snowflake } from '../../../globals.ts'; -import type { APIPartialChannel } from '../channel.ts'; -import type { APIGuildMember } from '../guild.ts'; -import type { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base.ts'; -import type { InteractionType } from './responses.ts'; - -/** - * https://discord.com/developers/docs/interactions/slash-commands#application-command-object - */ -export interface APIApplicationCommand { - /** - * Unique id of the command - */ - id: Snowflake; - /** - * Unique id of the parent application - */ - application_id: Snowflake; - /** - * Guild id of the command, if not global - */ - guild_id?: Snowflake; - /** - * 1-32 character name matching `^[\w-]{1,32}$` - */ - name: string; - /** - * 1-100 character description - */ - description: string; - /** - * The parameters for the command - */ - options?: APIApplicationCommandOption[]; - /** - * Whether the command is enabled by default when the app is added to a guild - * - * If missing, this property should be assumed as `true` - */ - default_permission?: boolean; -} +import type { APIRole, APIUser } from '../../mod.ts'; +import type { Snowflake } from '../../../../globals.ts'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base.ts'; +import type { + APIApplicationCommandInteractionWrapper, + APIInteractionDataResolvedChannel, + APIInteractionDataResolvedGuildMember, + ApplicationCommandType, +} from '../applicationCommands.ts'; +import type { APIBaseApplicationCommandInteractionData } from './internals.ts'; interface APIApplicationCommandOptionBase { type: @@ -55,7 +23,7 @@ interface APIApplicationCommandOptionBase { } /** - * https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-structure + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure */ export type APIApplicationCommandOption = | APIApplicationCommandArgumentOptions @@ -87,7 +55,7 @@ export interface APIApplicationCommandArgumentOptions extends Omit; - roles?: Record; - members?: Record; - channels?: Record; - }; -} - -/** - * https://discord.com/developers/docs/resources/channel#channel-object - */ -export interface APIInteractionDataResolvedChannel extends Required { - permissions: Permissions; -} - -/** - * https://discord.com/developers/docs/resources/guild#guild-member-object - */ -export interface APIInteractionDataResolvedGuildMember extends Omit { - permissions: Permissions; -} - -/** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-object-application-command-interaction-data-option-structure + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-interaction-data-option-structure */ export type APIApplicationCommandInteractionDataOption = | ApplicationCommandInteractionDataOptionSubCommand @@ -215,69 +154,39 @@ interface InteractionDataOptionBase { + options?: APIApplicationCommandInteractionDataOption[]; + resolved?: APIChatInputApplicationCommandInteractionDataResolved; } /** - * https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-application-command-permissions-structure + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure */ -export interface APIApplicationCommandPermission { - /** - * The id of the role or user - */ - id: Snowflake; - /** - * Role or user - */ - type: ApplicationCommandPermissionType; - /** - * `true` to allow, `false`, to disallow - */ - permission: boolean; +export interface APIChatInputApplicationCommandInteractionDataResolved { + users?: Record; + roles?: Record; + members?: Record; + channels?: Record; } /** - * https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissiontype + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ -export enum ApplicationCommandPermissionType { - Role = 1, - User, -} +export type APIChatInputApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; -// INTERACTIONS +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIChatInputApplicationCommandDMInteraction = + APIDMInteractionWrapper; -export type APIApplicationCommandInteraction = APIBaseInteraction< - InteractionType.ApplicationCommand, - APIApplicationCommandInteractionData -> & - Required< - Pick< - APIBaseInteraction, - 'channel_id' | 'data' - > - >; - -export type APIApplicationCommandDMInteraction = APIDMInteractionWrapper; - -export type APIApplicationCommandGuildInteraction = APIGuildInteractionWrapper; +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIChatInputApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; diff --git a/deno/payloads/v9/_interactions/_applicationCommands/contextMenu.ts b/deno/payloads/v9/_interactions/_applicationCommands/contextMenu.ts new file mode 100644 index 00000000..ac59b971 --- /dev/null +++ b/deno/payloads/v9/_interactions/_applicationCommands/contextMenu.ts @@ -0,0 +1,104 @@ +import type { APIUser } from '../../user.ts'; +import type { Snowflake } from '../../../../globals.ts'; +import type { APIMessage } from '../../channel.ts'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base.ts'; +import type { + APIApplicationCommandInteractionWrapper, + APIInteractionDataResolvedGuildMember, + ApplicationCommandType, +} from '../applicationCommands.ts'; +import type { APIBaseApplicationCommandInteractionData } from './internals.ts'; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export interface APIUserApplicationCommandInteractionData + extends APIBaseApplicationCommandInteractionData { + target_id: Snowflake; + resolved: APIUserApplicationCommandInteractionDataResolved; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure + */ +export interface APIUserApplicationCommandInteractionDataResolved { + users: Record; + members?: Record; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export interface APIMessageApplicationCommandInteractionData + extends APIBaseApplicationCommandInteractionData { + target_id: Snowflake; + resolved: APIMessageApplicationCommandInteractionDataResolved; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure + */ +export interface APIMessageApplicationCommandInteractionDataResolved { + messages: Record; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export type APIContextMenuInteractionData = + | APIUserApplicationCommandInteractionData + | APIMessageApplicationCommandInteractionData; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandDMInteraction = APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandDMInteraction = + APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuInteraction = APIUserApplicationCommandInteraction | APIMessageApplicationCommandInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuDMInteraction = + | APIUserApplicationCommandDMInteraction + | APIMessageApplicationCommandDMInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuGuildInteraction = + | APIUserApplicationCommandGuildInteraction + | APIMessageApplicationCommandGuildInteraction; diff --git a/deno/payloads/v9/_interactions/_applicationCommands/internals.ts b/deno/payloads/v9/_interactions/_applicationCommands/internals.ts new file mode 100644 index 00000000..6e2d4b8b --- /dev/null +++ b/deno/payloads/v9/_interactions/_applicationCommands/internals.ts @@ -0,0 +1,8 @@ +import type { Snowflake } from '../../../../globals.ts'; +import type { ApplicationCommandType } from '../applicationCommands.ts'; + +export interface APIBaseApplicationCommandInteractionData { + id: Snowflake; + type: Type; + name: string; +} diff --git a/deno/payloads/v9/_interactions/_applicationCommands/permissions.ts b/deno/payloads/v9/_interactions/_applicationCommands/permissions.ts new file mode 100644 index 00000000..38186f89 --- /dev/null +++ b/deno/payloads/v9/_interactions/_applicationCommands/permissions.ts @@ -0,0 +1,49 @@ +import type { Snowflake } from '../../../../globals.ts'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure + */ +export interface APIGuildApplicationCommandPermissions { + /** + * The id of the command + */ + id: Snowflake; + /** + * The id of the application the command belongs to + */ + application_id: Snowflake; + /** + * The id of the guild + */ + guild_id: Snowflake; + /** + * The permissions for the command in the guild + */ + permissions: APIApplicationCommandPermission[]; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-structure + */ +export interface APIApplicationCommandPermission { + /** + * The id of the role or user + */ + id: Snowflake; + /** + * Role or user + */ + type: ApplicationCommandPermissionType; + /** + * `true` to allow, `false`, to disallow + */ + permission: boolean; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type + */ +export enum ApplicationCommandPermissionType { + Role = 1, + User, +} diff --git a/deno/payloads/v9/_interactions/applicationCommands.ts b/deno/payloads/v9/_interactions/applicationCommands.ts new file mode 100644 index 00000000..46370ba4 --- /dev/null +++ b/deno/payloads/v9/_interactions/applicationCommands.ts @@ -0,0 +1,118 @@ +import type { Permissions, Snowflake } from '../../../globals.ts'; +import type { APIPartialChannel } from '../channel.ts'; +import type { APIGuildMember } from '../guild.ts'; +import type { APIBaseInteraction } from './base.ts'; +import type { InteractionType } from './responses.ts'; +import type { + APIApplicationCommandOption, + APIChatInputApplicationCommandDMInteraction, + APIChatInputApplicationCommandGuildInteraction, + APIChatInputApplicationCommandInteraction, + APIChatInputApplicationCommandInteractionData, +} from './_applicationCommands/chatInput.ts'; +import type { + APIContextMenuDMInteraction, + APIContextMenuGuildInteraction, + APIContextMenuInteraction, + APIContextMenuInteractionData, +} from './_applicationCommands/contextMenu.ts'; + +export * from './_applicationCommands/chatInput.ts'; +export * from './_applicationCommands/contextMenu.ts'; +export * from './_applicationCommands/permissions.ts'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object + */ +export interface APIApplicationCommand { + /** + * Unique id of the command + */ + id: Snowflake; + /** + * Type of the command + */ + type: ApplicationCommandType; + /** + * Unique id of the parent application + */ + application_id: Snowflake; + /** + * Guild id of the command, if not global + */ + guild_id?: Snowflake; + /** + * 1-32 character name; `CHAT_INPUT` command names must be all lowercase matching `^[\w-]{1,32}$` + */ + name: string; + /** + * 1-100 character description for `CHAT_INPUT` commands, empty string for `USER` and `MESSAGE` commands + */ + description: string; + /** + * The parameters for the `CHAT_INPUT` command, max 25 + */ + options?: APIApplicationCommandOption[]; + /** + * Whether the command is enabled by default when the app is added to a guild + * + * If missing, this property should be assumed as `true` + */ + default_permission?: boolean; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types + */ +export enum ApplicationCommandType { + ChatInput = 1, + User, + Message, +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export type APIApplicationCommandInteractionData = + | APIChatInputApplicationCommandInteractionData + | APIContextMenuInteractionData; + +/** + * https://discord.com/developers/docs/resources/channel#channel-object + */ +export interface APIInteractionDataResolvedChannel extends Required { + permissions: Permissions; +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-member-object + */ +export interface APIInteractionDataResolvedGuildMember extends Omit { + permissions: Permissions; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandInteractionWrapper = + APIBaseInteraction & + Required, 'channel_id' | 'data'>>; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandInteraction = APIChatInputApplicationCommandInteraction | APIContextMenuInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandDMInteraction = + | APIChatInputApplicationCommandDMInteraction + | APIContextMenuDMInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandGuildInteraction = + | APIChatInputApplicationCommandGuildInteraction + | APIContextMenuGuildInteraction; diff --git a/deno/payloads/v9/_interactions/base.ts b/deno/payloads/v9/_interactions/base.ts index ba57b6d7..0addcefb 100644 --- a/deno/payloads/v9/_interactions/base.ts +++ b/deno/payloads/v9/_interactions/base.ts @@ -5,7 +5,7 @@ import type { APIGuildMember } from '../guild.ts'; import type { APIUser } from '../user.ts'; /** - * https://discord.com/developers/docs/interactions/slash-commands#message-interaction-object-message-interaction-structure + * https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object */ export interface APIMessageInteraction { /** @@ -37,7 +37,7 @@ export interface APIInteractionGuildMember extends APIGuildMember { // INTERACTIONS RECEIVED /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-object + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ export interface APIBaseInteraction { /** diff --git a/deno/payloads/v9/_interactions/responses.ts b/deno/payloads/v9/_interactions/responses.ts index ef4bab61..128677d4 100644 --- a/deno/payloads/v9/_interactions/responses.ts +++ b/deno/payloads/v9/_interactions/responses.ts @@ -2,7 +2,7 @@ import type { MessageFlags } from '../mod.ts'; import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v9.ts'; /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-request-type + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type */ export enum InteractionType { Ping = 1, @@ -11,7 +11,7 @@ export enum InteractionType { } /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object */ export type APIInteractionResponse = | APIInteractionResponsePong @@ -44,7 +44,7 @@ export interface APIInteractionResponseUpdateMessage { } /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-callback-type + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type */ export enum InteractionResponseType { /** @@ -70,7 +70,7 @@ export enum InteractionResponseType { } /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-application-command-callback-data-structure + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-data-structure */ export type APIInteractionResponseCallbackData = Omit< RESTPostAPIWebhookWithTokenJSONBody, diff --git a/deno/payloads/v9/interactions.ts b/deno/payloads/v9/interactions.ts index c87c3042..f88a00cb 100644 --- a/deno/payloads/v9/interactions.ts +++ b/deno/payloads/v9/interactions.ts @@ -8,16 +8,25 @@ import type { APIApplicationCommandDMInteraction, APIApplicationCommandGuildInteraction, APIApplicationCommandInteraction, -} from './_interactions/slashCommands.ts'; +} from './_interactions/applicationCommands.ts'; export * from './_interactions/base.ts'; export * from './_interactions/messageComponents.ts'; export * from './_interactions/ping.ts'; export * from './_interactions/responses.ts'; -export * from './_interactions/slashCommands.ts'; +export * from './_interactions/applicationCommands.ts'; +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ export type APIInteraction = APIPingInteraction | APIApplicationCommandInteraction | APIMessageComponentInteraction; +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ export type APIDMInteraction = APIApplicationCommandDMInteraction | APIMessageComponentDMInteraction; +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ export type APIGuildInteraction = APIApplicationCommandGuildInteraction | APIMessageComponentGuildInteraction; diff --git a/deno/payloads/v9/oauth2.ts b/deno/payloads/v9/oauth2.ts index 970e68e4..022f82d1 100644 --- a/deno/payloads/v9/oauth2.ts +++ b/deno/payloads/v9/oauth2.ts @@ -94,15 +94,15 @@ export enum OAuth2Scopes { */ ActivitiesWrite = 'activities.write', /** - * Allows your app to use Slash Commands in a guild + * Allows your app to use Application Commands in a guild * - * See https://discord.com/developers/docs/interactions/slash-commands + * See https://discord.com/developers/docs/interactions/application-commands */ ApplicationsCommands = 'applications.commands', /** - * Allows your app to update its Slash Commands via this bearer token - client credentials grant only + * Allows your app to update its Application Commands via this bearer token - client credentials grant only * - * See https://discord.com/developers/docs/interactions/slash-commands + * See https://discord.com/developers/docs/interactions/application-commands */ ApplicationsCommandsUpdate = 'applications.commands.update', } diff --git a/deno/payloads/v9/permissions.ts b/deno/payloads/v9/permissions.ts index 7fcf9b87..2049e4e1 100644 --- a/deno/payloads/v9/permissions.ts +++ b/deno/payloads/v9/permissions.ts @@ -43,7 +43,7 @@ export const PermissionFlagsBits = { ManageRoles: 1n << 28n, ManageWebhooks: 1n << 29n, ManageEmojisAndStickers: 1n << 30n, - UseSlashCommands: 1n << 31n, + UseApplicationCommands: 1n << 31n, RequestToSpeak: 1n << 32n, ManageThreads: 1n << 34n, UsePublicThreads: 1n << 35n, diff --git a/deno/rest/v8/interactions.ts b/deno/rest/v8/interactions.ts index 4a800979..95536fab 100644 --- a/deno/rest/v8/interactions.ts +++ b/deno/rest/v8/interactions.ts @@ -4,6 +4,7 @@ import type { APIGuildApplicationCommandPermissions, APIInteractionResponse, APIInteractionResponseCallbackData, + ApplicationCommandType, } from '../../payloads/v8/mod.ts'; import type { RESTDeleteAPIWebhookWithTokenMessageResult, @@ -15,92 +16,114 @@ import type { } from './webhook.ts'; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands */ export type RESTGetAPIApplicationCommandsResult = APIApplicationCommand[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-global-application-command + * https://discord.com/developers/docs/interactions/application-commands#get-global-application-command */ export type RESTGetAPIApplicationCommandResult = APIApplicationCommand; -/** - * https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command - */ -export type RESTPostAPIApplicationCommandsJSONBody = Omit; +type RESTPostAPIBaseApplicationCommandsJSONBody = Omit< + APIApplicationCommand, + 'id' | 'application_id' | 'description' | 'type' +>; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command + * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command + */ +export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody { + type?: ApplicationCommandType.ChatInput; + description: string; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command + */ +export interface RESTPostAPIContextMenuApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody { + type: ApplicationCommandType.User | ApplicationCommandType.Message; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command + */ +export type RESTPostAPIApplicationCommandsJSONBody = + | RESTPostAPIChatInputApplicationCommandsJSONBody + | RESTPostAPIContextMenuApplicationCommandsJSONBody; + +/** + * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command */ export type RESTPostAPIApplicationCommandsResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command + * https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command */ export type RESTPatchAPIApplicationCommandJSONBody = Partial; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command + * https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command */ export type RESTPatchAPIApplicationCommandResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands */ export type RESTPutAPIApplicationCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands */ export type RESTPutAPIApplicationCommandsResult = APIApplicationCommand[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-commands + * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */ export type RESTGetAPIApplicationGuildCommandsResult = APIApplicationCommand[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */ export type RESTGetAPIApplicationGuildCommandResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */ export type RESTPostAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */ export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */ export type RESTPatchAPIApplicationGuildCommandJSONBody = Partial; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */ export type RESTPatchAPIApplicationGuildCommandResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */ export type RESTPutAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */ export type RESTPutAPIApplicationGuildCommandsResult = APIApplicationCommand[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response */ export type RESTPostAPIInteractionCallbackJSONBody = APIInteractionResponse; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response */ export type RESTPostAPIInteractionCallbackFormDataBody = | { @@ -121,37 +144,37 @@ export type RESTPostAPIInteractionCallbackFormDataBody = }); /** - * https://discord.com/developers/docs/interactions/slash-commands#get-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response */ export type RESTGetAPIInteractionOriginalResponseResult = RESTGetAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response */ export type RESTPatchAPIInteractionOriginalResponseJSONBody = RESTPatchAPIWebhookWithTokenMessageJSONBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response */ export type RESTPatchAPIInteractionOriginalResponseFormDataBody = RESTPatchAPIWebhookWithTokenMessageFormDataBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response */ export type RESTPatchAPIInteractionOriginalResponseResult = RESTPatchAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#delete-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#delete-original-interaction-response */ export type RESTDeleteAPIInteractionOriginalResponseResult = RESTDeleteAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */ export type RESTPostAPIInteractionFollowupJSONBody = APIInteractionResponseCallbackData; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */ export type RESTPostAPIInteractionFollowupFormDataBody = | { @@ -172,59 +195,59 @@ export type RESTPostAPIInteractionFollowupFormDataBody = }); /** - * https://discord.com/developers/docs/interactions/slash-commands#create-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */ export type RESTPostAPIInteractionFollowupResult = RESTPostAPIWebhookWithTokenWaitResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#get-followup-message */ export type RESTGetAPIInteractionFollowupResult = RESTGetAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message */ export type RESTPatchAPIInteractionFollowupJSONBody = RESTPatchAPIWebhookWithTokenMessageJSONBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message */ export type RESTPatchAPIInteractionFollowupFormDataBody = RESTPatchAPIWebhookWithTokenMessageFormDataBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message */ export type RESTPatchAPIInteractionFollowupResult = RESTPatchAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#delete-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#delete-followup-message */ export type RESTDeleteAPIInteractionFollowupResult = RESTDeleteAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions */ export type RESTGetAPIGuildApplicationCommandsPermissionsResult = APIGuildApplicationCommandPermissions[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions */ export type RESTGetAPIApplicationCommandPermissionsResult = APIGuildApplicationCommandPermissions; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions */ export interface RESTPutAPIApplicationCommandPermissionsJSONBody { permissions: APIApplicationCommandPermission[]; } /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions */ export type RESTPutAPIApplicationCommandPermissionsResult = APIGuildApplicationCommandPermissions; /** - * https://discord.com/developers/docs/interactions/slash-commands#batch-edit-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#batch-edit-application-command-permissions */ export type RESTPutAPIGuildApplicationCommandsPermissionsJSONBody = Pick< APIGuildApplicationCommandPermissions, @@ -232,6 +255,6 @@ export type RESTPutAPIGuildApplicationCommandsPermissionsJSONBody = Pick< >[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#batch-edit-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#batch-edit-application-command-permissions */ export type RESTPutAPIGuildApplicationCommandsPermissionsResult = APIGuildApplicationCommandPermissions[]; diff --git a/deno/rest/v9/interactions.ts b/deno/rest/v9/interactions.ts index 3bbd325e..b85be180 100644 --- a/deno/rest/v9/interactions.ts +++ b/deno/rest/v9/interactions.ts @@ -4,6 +4,7 @@ import type { APIGuildApplicationCommandPermissions, APIInteractionResponse, APIInteractionResponseCallbackData, + ApplicationCommandType, } from '../../payloads/v9/mod.ts'; import type { RESTDeleteAPIWebhookWithTokenMessageResult, @@ -15,92 +16,114 @@ import type { } from './webhook.ts'; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands */ export type RESTGetAPIApplicationCommandsResult = APIApplicationCommand[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-global-application-command + * https://discord.com/developers/docs/interactions/application-commands#get-global-application-command */ export type RESTGetAPIApplicationCommandResult = APIApplicationCommand; -/** - * https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command - */ -export type RESTPostAPIApplicationCommandsJSONBody = Omit; +type RESTPostAPIBaseApplicationCommandsJSONBody = Omit< + APIApplicationCommand, + 'id' | 'application_id' | 'description' | 'type' +>; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command + * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command + */ +export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody { + type?: ApplicationCommandType.ChatInput; + description: string; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command + */ +export interface RESTPostAPIContextMenuApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody { + type: ApplicationCommandType.User | ApplicationCommandType.Message; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command + */ +export type RESTPostAPIApplicationCommandsJSONBody = + | RESTPostAPIChatInputApplicationCommandsJSONBody + | RESTPostAPIContextMenuApplicationCommandsJSONBody; + +/** + * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command */ export type RESTPostAPIApplicationCommandsResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command + * https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command */ export type RESTPatchAPIApplicationCommandJSONBody = Partial; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command + * https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command */ export type RESTPatchAPIApplicationCommandResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands */ export type RESTPutAPIApplicationCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands */ export type RESTPutAPIApplicationCommandsResult = APIApplicationCommand[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-commands + * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */ export type RESTGetAPIApplicationGuildCommandsResult = APIApplicationCommand[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */ export type RESTGetAPIApplicationGuildCommandResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */ export type RESTPostAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */ export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */ export type RESTPatchAPIApplicationGuildCommandJSONBody = Partial; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */ export type RESTPatchAPIApplicationGuildCommandResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */ export type RESTPutAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */ export type RESTPutAPIApplicationGuildCommandsResult = APIApplicationCommand[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response */ export type RESTPostAPIInteractionCallbackJSONBody = APIInteractionResponse; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response */ export type RESTPostAPIInteractionCallbackFormDataBody = | { @@ -121,37 +144,37 @@ export type RESTPostAPIInteractionCallbackFormDataBody = }); /** - * https://discord.com/developers/docs/interactions/slash-commands#get-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response */ export type RESTGetAPIInteractionOriginalResponseResult = RESTGetAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response */ export type RESTPatchAPIInteractionOriginalResponseJSONBody = RESTPatchAPIWebhookWithTokenMessageJSONBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response */ export type RESTPatchAPIInteractionOriginalResponseFormDataBody = RESTPatchAPIWebhookWithTokenMessageFormDataBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response */ export type RESTPatchAPIInteractionOriginalResponseResult = RESTPatchAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#delete-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#delete-original-interaction-response */ export type RESTDeleteAPIInteractionOriginalResponseResult = RESTDeleteAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */ export type RESTPostAPIInteractionFollowupJSONBody = APIInteractionResponseCallbackData; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */ export type RESTPostAPIInteractionFollowupFormDataBody = | { @@ -172,59 +195,59 @@ export type RESTPostAPIInteractionFollowupFormDataBody = }); /** - * https://discord.com/developers/docs/interactions/slash-commands#create-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */ export type RESTPostAPIInteractionFollowupResult = RESTPostAPIWebhookWithTokenWaitResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#get-followup-message */ export type RESTGetAPIInteractionFollowupResult = RESTGetAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message */ export type RESTPatchAPIInteractionFollowupJSONBody = RESTPatchAPIWebhookWithTokenMessageJSONBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message */ export type RESTPatchAPIInteractionFollowupFormDataBody = RESTPatchAPIWebhookWithTokenMessageFormDataBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message */ export type RESTPatchAPIInteractionFollowupResult = RESTPatchAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#delete-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#delete-followup-message */ export type RESTDeleteAPIInteractionFollowupResult = RESTDeleteAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions */ export type RESTGetAPIGuildApplicationCommandsPermissionsResult = APIGuildApplicationCommandPermissions[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions */ export type RESTGetAPIApplicationCommandPermissionsResult = APIGuildApplicationCommandPermissions; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions */ export interface RESTPutAPIApplicationCommandPermissionsJSONBody { permissions: APIApplicationCommandPermission[]; } /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions */ export type RESTPutAPIApplicationCommandPermissionsResult = APIGuildApplicationCommandPermissions; /** - * https://discord.com/developers/docs/interactions/slash-commands#batch-edit-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#batch-edit-application-command-permissions */ export type RESTPutAPIGuildApplicationCommandsPermissionsJSONBody = Pick< APIGuildApplicationCommandPermissions, @@ -232,6 +255,6 @@ export type RESTPutAPIGuildApplicationCommandsPermissionsJSONBody = Pick< >[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#batch-edit-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#batch-edit-application-command-permissions */ export type RESTPutAPIGuildApplicationCommandsPermissionsResult = APIGuildApplicationCommandPermissions[]; diff --git a/payloads/v8/_interactions/slashCommands.ts b/payloads/v8/_interactions/_applicationCommands/chatInput.ts similarity index 50% rename from payloads/v8/_interactions/slashCommands.ts rename to payloads/v8/_interactions/_applicationCommands/chatInput.ts index e2a04af9..9ecc7355 100644 --- a/payloads/v8/_interactions/slashCommands.ts +++ b/payloads/v8/_interactions/_applicationCommands/chatInput.ts @@ -1,45 +1,13 @@ -import type { APIRole, APIUser } from '../index'; -import type { Permissions, Snowflake } from '../../../globals'; -import type { APIPartialChannel } from '../channel'; -import type { APIGuildMember } from '../guild'; -import type { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base'; -import type { InteractionType } from './responses'; - -/** - * https://discord.com/developers/docs/interactions/slash-commands#application-command-object - */ -export interface APIApplicationCommand { - /** - * Unique id of the command - */ - id: Snowflake; - /** - * Unique id of the parent application - */ - application_id: Snowflake; - /** - * Guild id of the command, if not global - */ - guild_id?: Snowflake; - /** - * 1-32 character name matching `^[\w-]{1,32}$` - */ - name: string; - /** - * 1-100 character description - */ - description: string; - /** - * The parameters for the command - */ - options?: APIApplicationCommandOption[]; - /** - * Whether the command is enabled by default when the app is added to a guild - * - * If missing, this property should be assumed as `true` - */ - default_permission?: boolean; -} +import type { APIRole, APIUser } from '../../index'; +import type { Snowflake } from '../../../../globals'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base'; +import type { + APIApplicationCommandInteractionWrapper, + APIInteractionDataResolvedChannel, + APIInteractionDataResolvedGuildMember, + ApplicationCommandType, +} from '../applicationCommands'; +import type { APIBaseApplicationCommandInteractionData } from './internals'; interface APIApplicationCommandOptionBase { type: @@ -55,7 +23,7 @@ interface APIApplicationCommandOptionBase { } /** - * https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-structure + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure */ export type APIApplicationCommandOption = | APIApplicationCommandArgumentOptions @@ -87,7 +55,7 @@ export interface APIApplicationCommandArgumentOptions extends Omit; - roles?: Record; - members?: Record; - channels?: Record; - }; -} - -/** - * https://discord.com/developers/docs/resources/channel#channel-object - */ -export interface APIInteractionDataResolvedChannel extends Required { - permissions: Permissions; -} - -/** - * https://discord.com/developers/docs/resources/guild#guild-member-object - */ -export interface APIInteractionDataResolvedGuildMember extends Omit { - permissions: Permissions; -} - -/** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-object-application-command-interaction-data-option-structure + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-interaction-data-option-structure */ export type APIApplicationCommandInteractionDataOption = | ApplicationCommandInteractionDataOptionSubCommand @@ -215,69 +154,39 @@ interface InteractionDataOptionBase { + options?: APIApplicationCommandInteractionDataOption[]; + resolved?: APIChatInputApplicationCommandInteractionDataResolved; } /** - * https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-application-command-permissions-structure + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure */ -export interface APIApplicationCommandPermission { - /** - * The id of the role or user - */ - id: Snowflake; - /** - * Role or user - */ - type: ApplicationCommandPermissionType; - /** - * `true` to allow, `false`, to disallow - */ - permission: boolean; +export interface APIChatInputApplicationCommandInteractionDataResolved { + users?: Record; + roles?: Record; + members?: Record; + channels?: Record; } /** - * https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissiontype + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ -export const enum ApplicationCommandPermissionType { - Role = 1, - User, -} +export type APIChatInputApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; -// INTERACTIONS +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIChatInputApplicationCommandDMInteraction = + APIDMInteractionWrapper; -export type APIApplicationCommandInteraction = APIBaseInteraction< - InteractionType.ApplicationCommand, - APIApplicationCommandInteractionData -> & - Required< - Pick< - APIBaseInteraction, - 'channel_id' | 'data' - > - >; - -export type APIApplicationCommandDMInteraction = APIDMInteractionWrapper; - -export type APIApplicationCommandGuildInteraction = APIGuildInteractionWrapper; +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIChatInputApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; diff --git a/payloads/v8/_interactions/_applicationCommands/contextMenu.ts b/payloads/v8/_interactions/_applicationCommands/contextMenu.ts new file mode 100644 index 00000000..70681004 --- /dev/null +++ b/payloads/v8/_interactions/_applicationCommands/contextMenu.ts @@ -0,0 +1,104 @@ +import type { APIUser } from '../../user'; +import type { Snowflake } from '../../../../globals'; +import type { APIMessage } from '../../channel'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base'; +import type { + APIApplicationCommandInteractionWrapper, + APIInteractionDataResolvedGuildMember, + ApplicationCommandType, +} from '../applicationCommands'; +import type { APIBaseApplicationCommandInteractionData } from './internals'; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export interface APIUserApplicationCommandInteractionData + extends APIBaseApplicationCommandInteractionData { + target_id: Snowflake; + resolved: APIUserApplicationCommandInteractionDataResolved; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure + */ +export interface APIUserApplicationCommandInteractionDataResolved { + users: Record; + members?: Record; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export interface APIMessageApplicationCommandInteractionData + extends APIBaseApplicationCommandInteractionData { + target_id: Snowflake; + resolved: APIMessageApplicationCommandInteractionDataResolved; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure + */ +export interface APIMessageApplicationCommandInteractionDataResolved { + messages: Record; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export type APIContextMenuInteractionData = + | APIUserApplicationCommandInteractionData + | APIMessageApplicationCommandInteractionData; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandDMInteraction = APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandDMInteraction = + APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuInteraction = APIUserApplicationCommandInteraction | APIMessageApplicationCommandInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuDMInteraction = + | APIUserApplicationCommandDMInteraction + | APIMessageApplicationCommandDMInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuGuildInteraction = + | APIUserApplicationCommandGuildInteraction + | APIMessageApplicationCommandGuildInteraction; diff --git a/payloads/v8/_interactions/_applicationCommands/internals.ts b/payloads/v8/_interactions/_applicationCommands/internals.ts new file mode 100644 index 00000000..debe6d6b --- /dev/null +++ b/payloads/v8/_interactions/_applicationCommands/internals.ts @@ -0,0 +1,8 @@ +import type { Snowflake } from '../../../../globals'; +import type { ApplicationCommandType } from '../applicationCommands'; + +export interface APIBaseApplicationCommandInteractionData { + id: Snowflake; + type: Type; + name: string; +} diff --git a/payloads/v8/_interactions/_applicationCommands/permissions.ts b/payloads/v8/_interactions/_applicationCommands/permissions.ts new file mode 100644 index 00000000..ca4bbb6b --- /dev/null +++ b/payloads/v8/_interactions/_applicationCommands/permissions.ts @@ -0,0 +1,49 @@ +import type { Snowflake } from '../../../../globals'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure + */ +export interface APIGuildApplicationCommandPermissions { + /** + * The id of the command + */ + id: Snowflake; + /** + * The id of the application the command belongs to + */ + application_id: Snowflake; + /** + * The id of the guild + */ + guild_id: Snowflake; + /** + * The permissions for the command in the guild + */ + permissions: APIApplicationCommandPermission[]; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-structure + */ +export interface APIApplicationCommandPermission { + /** + * The id of the role or user + */ + id: Snowflake; + /** + * Role or user + */ + type: ApplicationCommandPermissionType; + /** + * `true` to allow, `false`, to disallow + */ + permission: boolean; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type + */ +export const enum ApplicationCommandPermissionType { + Role = 1, + User, +} diff --git a/payloads/v8/_interactions/applicationCommands.ts b/payloads/v8/_interactions/applicationCommands.ts new file mode 100644 index 00000000..16a4b5a7 --- /dev/null +++ b/payloads/v8/_interactions/applicationCommands.ts @@ -0,0 +1,118 @@ +import type { Permissions, Snowflake } from '../../../globals'; +import type { APIPartialChannel } from '../channel'; +import type { APIGuildMember } from '../guild'; +import type { APIBaseInteraction } from './base'; +import type { InteractionType } from './responses'; +import type { + APIApplicationCommandOption, + APIChatInputApplicationCommandDMInteraction, + APIChatInputApplicationCommandGuildInteraction, + APIChatInputApplicationCommandInteraction, + APIChatInputApplicationCommandInteractionData, +} from './_applicationCommands/chatInput'; +import type { + APIContextMenuDMInteraction, + APIContextMenuGuildInteraction, + APIContextMenuInteraction, + APIContextMenuInteractionData, +} from './_applicationCommands/contextMenu'; + +export * from './_applicationCommands/chatInput'; +export * from './_applicationCommands/contextMenu'; +export * from './_applicationCommands/permissions'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object + */ +export interface APIApplicationCommand { + /** + * Unique id of the command + */ + id: Snowflake; + /** + * Type of the command + */ + type: ApplicationCommandType; + /** + * Unique id of the parent application + */ + application_id: Snowflake; + /** + * Guild id of the command, if not global + */ + guild_id?: Snowflake; + /** + * 1-32 character name; `CHAT_INPUT` command names must be all lowercase matching `^[\w-]{1,32}$` + */ + name: string; + /** + * 1-100 character description for `CHAT_INPUT` commands, empty string for `USER` and `MESSAGE` commands + */ + description: string; + /** + * The parameters for the `CHAT_INPUT` command, max 25 + */ + options?: APIApplicationCommandOption[]; + /** + * Whether the command is enabled by default when the app is added to a guild + * + * If missing, this property should be assumed as `true` + */ + default_permission?: boolean; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types + */ +export const enum ApplicationCommandType { + ChatInput = 1, + User, + Message, +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export type APIApplicationCommandInteractionData = + | APIChatInputApplicationCommandInteractionData + | APIContextMenuInteractionData; + +/** + * https://discord.com/developers/docs/resources/channel#channel-object + */ +export interface APIInteractionDataResolvedChannel extends Required { + permissions: Permissions; +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-member-object + */ +export interface APIInteractionDataResolvedGuildMember extends Omit { + permissions: Permissions; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandInteractionWrapper = + APIBaseInteraction & + Required, 'channel_id' | 'data'>>; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandInteraction = APIChatInputApplicationCommandInteraction | APIContextMenuInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandDMInteraction = + | APIChatInputApplicationCommandDMInteraction + | APIContextMenuDMInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandGuildInteraction = + | APIChatInputApplicationCommandGuildInteraction + | APIContextMenuGuildInteraction; diff --git a/payloads/v8/_interactions/base.ts b/payloads/v8/_interactions/base.ts index 6b589a43..d6306852 100644 --- a/payloads/v8/_interactions/base.ts +++ b/payloads/v8/_interactions/base.ts @@ -1,11 +1,11 @@ import type { Permissions, Snowflake } from '../../../globals'; -import type { InteractionType } from '../../v8'; +import type { InteractionType } from './responses'; import type { APIMessage } from '../channel'; import type { APIGuildMember } from '../guild'; import type { APIUser } from '../user'; /** - * https://discord.com/developers/docs/interactions/slash-commands#message-interaction-object-message-interaction-structure + * https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object */ export interface APIMessageInteraction { /** @@ -37,7 +37,7 @@ export interface APIInteractionGuildMember extends APIGuildMember { // INTERACTIONS RECEIVED /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-object + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ export interface APIBaseInteraction { /** diff --git a/payloads/v8/_interactions/responses.ts b/payloads/v8/_interactions/responses.ts index 76b0bf72..44475d97 100644 --- a/payloads/v8/_interactions/responses.ts +++ b/payloads/v8/_interactions/responses.ts @@ -2,7 +2,7 @@ import type { MessageFlags } from '../index'; import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v8'; /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-request-type + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type */ export const enum InteractionType { Ping = 1, @@ -11,7 +11,7 @@ export const enum InteractionType { } /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object */ export type APIInteractionResponse = | APIInteractionResponsePong @@ -44,7 +44,7 @@ export interface APIInteractionResponseUpdateMessage { } /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-callback-type + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type */ export const enum InteractionResponseType { /** @@ -70,7 +70,7 @@ export const enum InteractionResponseType { } /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-application-command-callback-data-structure + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-data-structure */ export type APIInteractionResponseCallbackData = Omit< RESTPostAPIWebhookWithTokenJSONBody, diff --git a/payloads/v8/interactions.ts b/payloads/v8/interactions.ts index 6598241e..23d29d6a 100644 --- a/payloads/v8/interactions.ts +++ b/payloads/v8/interactions.ts @@ -8,16 +8,25 @@ import type { APIApplicationCommandDMInteraction, APIApplicationCommandGuildInteraction, APIApplicationCommandInteraction, -} from './_interactions/slashCommands'; +} from './_interactions/applicationCommands'; export * from './_interactions/base'; export * from './_interactions/messageComponents'; export * from './_interactions/ping'; export * from './_interactions/responses'; -export * from './_interactions/slashCommands'; +export * from './_interactions/applicationCommands'; +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ export type APIInteraction = APIPingInteraction | APIApplicationCommandInteraction | APIMessageComponentInteraction; +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ export type APIDMInteraction = APIApplicationCommandDMInteraction | APIMessageComponentDMInteraction; +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ export type APIGuildInteraction = APIApplicationCommandGuildInteraction | APIMessageComponentGuildInteraction; diff --git a/payloads/v8/oauth2.ts b/payloads/v8/oauth2.ts index 61f5af54..8355b374 100644 --- a/payloads/v8/oauth2.ts +++ b/payloads/v8/oauth2.ts @@ -94,15 +94,15 @@ export const enum OAuth2Scopes { */ ActivitiesWrite = 'activities.write', /** - * Allows your app to use Slash Commands in a guild + * Allows your app to use Application Commands in a guild * - * See https://discord.com/developers/docs/interactions/slash-commands + * See https://discord.com/developers/docs/interactions/application-commands */ ApplicationsCommands = 'applications.commands', /** - * Allows your app to update its Slash Commands via this bearer token - client credentials grant only + * Allows your app to update its Application Commands via this bearer token - client credentials grant only * - * See https://discord.com/developers/docs/interactions/slash-commands + * See https://discord.com/developers/docs/interactions/application-commands */ ApplicationsCommandsUpdate = 'applications.commands.update', } diff --git a/payloads/v8/permissions.ts b/payloads/v8/permissions.ts index bdb79324..1f2a4c3e 100644 --- a/payloads/v8/permissions.ts +++ b/payloads/v8/permissions.ts @@ -43,7 +43,7 @@ export const PermissionFlagsBits = { ManageRoles: 1n << 28n, ManageWebhooks: 1n << 29n, ManageEmojisAndStickers: 1n << 30n, - UseSlashCommands: 1n << 31n, + UseApplicationCommands: 1n << 31n, RequestToSpeak: 1n << 32n, UseExternalStickers: 1n << 37n, } as const; diff --git a/payloads/v9/_interactions/slashCommands.ts b/payloads/v9/_interactions/_applicationCommands/chatInput.ts similarity index 50% rename from payloads/v9/_interactions/slashCommands.ts rename to payloads/v9/_interactions/_applicationCommands/chatInput.ts index e2a04af9..9ecc7355 100644 --- a/payloads/v9/_interactions/slashCommands.ts +++ b/payloads/v9/_interactions/_applicationCommands/chatInput.ts @@ -1,45 +1,13 @@ -import type { APIRole, APIUser } from '../index'; -import type { Permissions, Snowflake } from '../../../globals'; -import type { APIPartialChannel } from '../channel'; -import type { APIGuildMember } from '../guild'; -import type { APIBaseInteraction, APIDMInteractionWrapper, APIGuildInteractionWrapper } from './base'; -import type { InteractionType } from './responses'; - -/** - * https://discord.com/developers/docs/interactions/slash-commands#application-command-object - */ -export interface APIApplicationCommand { - /** - * Unique id of the command - */ - id: Snowflake; - /** - * Unique id of the parent application - */ - application_id: Snowflake; - /** - * Guild id of the command, if not global - */ - guild_id?: Snowflake; - /** - * 1-32 character name matching `^[\w-]{1,32}$` - */ - name: string; - /** - * 1-100 character description - */ - description: string; - /** - * The parameters for the command - */ - options?: APIApplicationCommandOption[]; - /** - * Whether the command is enabled by default when the app is added to a guild - * - * If missing, this property should be assumed as `true` - */ - default_permission?: boolean; -} +import type { APIRole, APIUser } from '../../index'; +import type { Snowflake } from '../../../../globals'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base'; +import type { + APIApplicationCommandInteractionWrapper, + APIInteractionDataResolvedChannel, + APIInteractionDataResolvedGuildMember, + ApplicationCommandType, +} from '../applicationCommands'; +import type { APIBaseApplicationCommandInteractionData } from './internals'; interface APIApplicationCommandOptionBase { type: @@ -55,7 +23,7 @@ interface APIApplicationCommandOptionBase { } /** - * https://discord.com/developers/docs/interactions/slash-commands#application-command-object-application-command-option-structure + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure */ export type APIApplicationCommandOption = | APIApplicationCommandArgumentOptions @@ -87,7 +55,7 @@ export interface APIApplicationCommandArgumentOptions extends Omit; - roles?: Record; - members?: Record; - channels?: Record; - }; -} - -/** - * https://discord.com/developers/docs/resources/channel#channel-object - */ -export interface APIInteractionDataResolvedChannel extends Required { - permissions: Permissions; -} - -/** - * https://discord.com/developers/docs/resources/guild#guild-member-object - */ -export interface APIInteractionDataResolvedGuildMember extends Omit { - permissions: Permissions; -} - -/** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-object-application-command-interaction-data-option-structure + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-interaction-data-option-structure */ export type APIApplicationCommandInteractionDataOption = | ApplicationCommandInteractionDataOptionSubCommand @@ -215,69 +154,39 @@ interface InteractionDataOptionBase { + options?: APIApplicationCommandInteractionDataOption[]; + resolved?: APIChatInputApplicationCommandInteractionDataResolved; } /** - * https://discord.com/developers/docs/interactions/slash-commands#application-command-permissions-object-application-command-permissions-structure + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure */ -export interface APIApplicationCommandPermission { - /** - * The id of the role or user - */ - id: Snowflake; - /** - * Role or user - */ - type: ApplicationCommandPermissionType; - /** - * `true` to allow, `false`, to disallow - */ - permission: boolean; +export interface APIChatInputApplicationCommandInteractionDataResolved { + users?: Record; + roles?: Record; + members?: Record; + channels?: Record; } /** - * https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissiontype + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ -export const enum ApplicationCommandPermissionType { - Role = 1, - User, -} +export type APIChatInputApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; -// INTERACTIONS +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIChatInputApplicationCommandDMInteraction = + APIDMInteractionWrapper; -export type APIApplicationCommandInteraction = APIBaseInteraction< - InteractionType.ApplicationCommand, - APIApplicationCommandInteractionData -> & - Required< - Pick< - APIBaseInteraction, - 'channel_id' | 'data' - > - >; - -export type APIApplicationCommandDMInteraction = APIDMInteractionWrapper; - -export type APIApplicationCommandGuildInteraction = APIGuildInteractionWrapper; +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIChatInputApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; diff --git a/payloads/v9/_interactions/_applicationCommands/contextMenu.ts b/payloads/v9/_interactions/_applicationCommands/contextMenu.ts new file mode 100644 index 00000000..70681004 --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/contextMenu.ts @@ -0,0 +1,104 @@ +import type { APIUser } from '../../user'; +import type { Snowflake } from '../../../../globals'; +import type { APIMessage } from '../../channel'; +import type { APIDMInteractionWrapper, APIGuildInteractionWrapper } from '../base'; +import type { + APIApplicationCommandInteractionWrapper, + APIInteractionDataResolvedGuildMember, + ApplicationCommandType, +} from '../applicationCommands'; +import type { APIBaseApplicationCommandInteractionData } from './internals'; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export interface APIUserApplicationCommandInteractionData + extends APIBaseApplicationCommandInteractionData { + target_id: Snowflake; + resolved: APIUserApplicationCommandInteractionDataResolved; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure + */ +export interface APIUserApplicationCommandInteractionDataResolved { + users: Record; + members?: Record; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export interface APIMessageApplicationCommandInteractionData + extends APIBaseApplicationCommandInteractionData { + target_id: Snowflake; + resolved: APIMessageApplicationCommandInteractionDataResolved; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-resolved-data-structure + */ +export interface APIMessageApplicationCommandInteractionDataResolved { + messages: Record; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export type APIContextMenuInteractionData = + | APIUserApplicationCommandInteractionData + | APIMessageApplicationCommandInteractionData; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandDMInteraction = APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIUserApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandInteraction = + APIApplicationCommandInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandDMInteraction = + APIDMInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIMessageApplicationCommandGuildInteraction = + APIGuildInteractionWrapper; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuInteraction = APIUserApplicationCommandInteraction | APIMessageApplicationCommandInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuDMInteraction = + | APIUserApplicationCommandDMInteraction + | APIMessageApplicationCommandDMInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIContextMenuGuildInteraction = + | APIUserApplicationCommandGuildInteraction + | APIMessageApplicationCommandGuildInteraction; diff --git a/payloads/v9/_interactions/_applicationCommands/internals.ts b/payloads/v9/_interactions/_applicationCommands/internals.ts new file mode 100644 index 00000000..debe6d6b --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/internals.ts @@ -0,0 +1,8 @@ +import type { Snowflake } from '../../../../globals'; +import type { ApplicationCommandType } from '../applicationCommands'; + +export interface APIBaseApplicationCommandInteractionData { + id: Snowflake; + type: Type; + name: string; +} diff --git a/payloads/v9/_interactions/_applicationCommands/permissions.ts b/payloads/v9/_interactions/_applicationCommands/permissions.ts new file mode 100644 index 00000000..ca4bbb6b --- /dev/null +++ b/payloads/v9/_interactions/_applicationCommands/permissions.ts @@ -0,0 +1,49 @@ +import type { Snowflake } from '../../../../globals'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-guild-application-command-permissions-structure + */ +export interface APIGuildApplicationCommandPermissions { + /** + * The id of the command + */ + id: Snowflake; + /** + * The id of the application the command belongs to + */ + application_id: Snowflake; + /** + * The id of the guild + */ + guild_id: Snowflake; + /** + * The permissions for the command in the guild + */ + permissions: APIApplicationCommandPermission[]; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-structure + */ +export interface APIApplicationCommandPermission { + /** + * The id of the role or user + */ + id: Snowflake; + /** + * Role or user + */ + type: ApplicationCommandPermissionType; + /** + * `true` to allow, `false`, to disallow + */ + permission: boolean; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type + */ +export const enum ApplicationCommandPermissionType { + Role = 1, + User, +} diff --git a/payloads/v9/_interactions/applicationCommands.ts b/payloads/v9/_interactions/applicationCommands.ts new file mode 100644 index 00000000..16a4b5a7 --- /dev/null +++ b/payloads/v9/_interactions/applicationCommands.ts @@ -0,0 +1,118 @@ +import type { Permissions, Snowflake } from '../../../globals'; +import type { APIPartialChannel } from '../channel'; +import type { APIGuildMember } from '../guild'; +import type { APIBaseInteraction } from './base'; +import type { InteractionType } from './responses'; +import type { + APIApplicationCommandOption, + APIChatInputApplicationCommandDMInteraction, + APIChatInputApplicationCommandGuildInteraction, + APIChatInputApplicationCommandInteraction, + APIChatInputApplicationCommandInteractionData, +} from './_applicationCommands/chatInput'; +import type { + APIContextMenuDMInteraction, + APIContextMenuGuildInteraction, + APIContextMenuInteraction, + APIContextMenuInteractionData, +} from './_applicationCommands/contextMenu'; + +export * from './_applicationCommands/chatInput'; +export * from './_applicationCommands/contextMenu'; +export * from './_applicationCommands/permissions'; + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object + */ +export interface APIApplicationCommand { + /** + * Unique id of the command + */ + id: Snowflake; + /** + * Type of the command + */ + type: ApplicationCommandType; + /** + * Unique id of the parent application + */ + application_id: Snowflake; + /** + * Guild id of the command, if not global + */ + guild_id?: Snowflake; + /** + * 1-32 character name; `CHAT_INPUT` command names must be all lowercase matching `^[\w-]{1,32}$` + */ + name: string; + /** + * 1-100 character description for `CHAT_INPUT` commands, empty string for `USER` and `MESSAGE` commands + */ + description: string; + /** + * The parameters for the `CHAT_INPUT` command, max 25 + */ + options?: APIApplicationCommandOption[]; + /** + * Whether the command is enabled by default when the app is added to a guild + * + * If missing, this property should be assumed as `true` + */ + default_permission?: boolean; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types + */ +export const enum ApplicationCommandType { + ChatInput = 1, + User, + Message, +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure + */ +export type APIApplicationCommandInteractionData = + | APIChatInputApplicationCommandInteractionData + | APIContextMenuInteractionData; + +/** + * https://discord.com/developers/docs/resources/channel#channel-object + */ +export interface APIInteractionDataResolvedChannel extends Required { + permissions: Permissions; +} + +/** + * https://discord.com/developers/docs/resources/guild#guild-member-object + */ +export interface APIInteractionDataResolvedGuildMember extends Omit { + permissions: Permissions; +} + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandInteractionWrapper = + APIBaseInteraction & + Required, 'channel_id' | 'data'>>; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandInteraction = APIChatInputApplicationCommandInteraction | APIContextMenuInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandDMInteraction = + | APIChatInputApplicationCommandDMInteraction + | APIContextMenuDMInteraction; + +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ +export type APIApplicationCommandGuildInteraction = + | APIChatInputApplicationCommandGuildInteraction + | APIContextMenuGuildInteraction; diff --git a/payloads/v9/_interactions/base.ts b/payloads/v9/_interactions/base.ts index daa22339..d6306852 100644 --- a/payloads/v9/_interactions/base.ts +++ b/payloads/v9/_interactions/base.ts @@ -5,7 +5,7 @@ import type { APIGuildMember } from '../guild'; import type { APIUser } from '../user'; /** - * https://discord.com/developers/docs/interactions/slash-commands#message-interaction-object-message-interaction-structure + * https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object */ export interface APIMessageInteraction { /** @@ -37,7 +37,7 @@ export interface APIInteractionGuildMember extends APIGuildMember { // INTERACTIONS RECEIVED /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-object + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object */ export interface APIBaseInteraction { /** diff --git a/payloads/v9/_interactions/responses.ts b/payloads/v9/_interactions/responses.ts index cdfe37d1..5873352c 100644 --- a/payloads/v9/_interactions/responses.ts +++ b/payloads/v9/_interactions/responses.ts @@ -2,7 +2,7 @@ import type { MessageFlags } from '../index'; import type { RESTPostAPIWebhookWithTokenJSONBody } from '../../../v9'; /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-object-interaction-request-type + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type */ export const enum InteractionType { Ping = 1, @@ -11,7 +11,7 @@ export const enum InteractionType { } /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object */ export type APIInteractionResponse = | APIInteractionResponsePong @@ -44,7 +44,7 @@ export interface APIInteractionResponseUpdateMessage { } /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-callback-type + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type */ export const enum InteractionResponseType { /** @@ -70,7 +70,7 @@ export const enum InteractionResponseType { } /** - * https://discord.com/developers/docs/interactions/slash-commands#interaction-response-object-interaction-application-command-callback-data-structure + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-data-structure */ export type APIInteractionResponseCallbackData = Omit< RESTPostAPIWebhookWithTokenJSONBody, diff --git a/payloads/v9/interactions.ts b/payloads/v9/interactions.ts index 6598241e..23d29d6a 100644 --- a/payloads/v9/interactions.ts +++ b/payloads/v9/interactions.ts @@ -8,16 +8,25 @@ import type { APIApplicationCommandDMInteraction, APIApplicationCommandGuildInteraction, APIApplicationCommandInteraction, -} from './_interactions/slashCommands'; +} from './_interactions/applicationCommands'; export * from './_interactions/base'; export * from './_interactions/messageComponents'; export * from './_interactions/ping'; export * from './_interactions/responses'; -export * from './_interactions/slashCommands'; +export * from './_interactions/applicationCommands'; +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ export type APIInteraction = APIPingInteraction | APIApplicationCommandInteraction | APIMessageComponentInteraction; +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ export type APIDMInteraction = APIApplicationCommandDMInteraction | APIMessageComponentDMInteraction; +/** + * https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object + */ export type APIGuildInteraction = APIApplicationCommandGuildInteraction | APIMessageComponentGuildInteraction; diff --git a/payloads/v9/oauth2.ts b/payloads/v9/oauth2.ts index 61f5af54..8355b374 100644 --- a/payloads/v9/oauth2.ts +++ b/payloads/v9/oauth2.ts @@ -94,15 +94,15 @@ export const enum OAuth2Scopes { */ ActivitiesWrite = 'activities.write', /** - * Allows your app to use Slash Commands in a guild + * Allows your app to use Application Commands in a guild * - * See https://discord.com/developers/docs/interactions/slash-commands + * See https://discord.com/developers/docs/interactions/application-commands */ ApplicationsCommands = 'applications.commands', /** - * Allows your app to update its Slash Commands via this bearer token - client credentials grant only + * Allows your app to update its Application Commands via this bearer token - client credentials grant only * - * See https://discord.com/developers/docs/interactions/slash-commands + * See https://discord.com/developers/docs/interactions/application-commands */ ApplicationsCommandsUpdate = 'applications.commands.update', } diff --git a/payloads/v9/permissions.ts b/payloads/v9/permissions.ts index 1d281c4c..69cdb226 100644 --- a/payloads/v9/permissions.ts +++ b/payloads/v9/permissions.ts @@ -43,7 +43,7 @@ export const PermissionFlagsBits = { ManageRoles: 1n << 28n, ManageWebhooks: 1n << 29n, ManageEmojisAndStickers: 1n << 30n, - UseSlashCommands: 1n << 31n, + UseApplicationCommands: 1n << 31n, RequestToSpeak: 1n << 32n, ManageThreads: 1n << 34n, UsePublicThreads: 1n << 35n, diff --git a/rest/v8/interactions.ts b/rest/v8/interactions.ts index c28a87e8..2e971135 100644 --- a/rest/v8/interactions.ts +++ b/rest/v8/interactions.ts @@ -4,6 +4,7 @@ import type { APIGuildApplicationCommandPermissions, APIInteractionResponse, APIInteractionResponseCallbackData, + ApplicationCommandType, } from '../../payloads/v8/index'; import type { RESTDeleteAPIWebhookWithTokenMessageResult, @@ -15,92 +16,114 @@ import type { } from './webhook'; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands */ export type RESTGetAPIApplicationCommandsResult = APIApplicationCommand[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-global-application-command + * https://discord.com/developers/docs/interactions/application-commands#get-global-application-command */ export type RESTGetAPIApplicationCommandResult = APIApplicationCommand; -/** - * https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command - */ -export type RESTPostAPIApplicationCommandsJSONBody = Omit; +type RESTPostAPIBaseApplicationCommandsJSONBody = Omit< + APIApplicationCommand, + 'id' | 'application_id' | 'description' | 'type' +>; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command + * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command + */ +export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody { + type?: ApplicationCommandType.ChatInput; + description: string; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command + */ +export interface RESTPostAPIContextMenuApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody { + type: ApplicationCommandType.User | ApplicationCommandType.Message; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command + */ +export type RESTPostAPIApplicationCommandsJSONBody = + | RESTPostAPIChatInputApplicationCommandsJSONBody + | RESTPostAPIContextMenuApplicationCommandsJSONBody; + +/** + * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command */ export type RESTPostAPIApplicationCommandsResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command + * https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command */ export type RESTPatchAPIApplicationCommandJSONBody = Partial; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command + * https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command */ export type RESTPatchAPIApplicationCommandResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands */ export type RESTPutAPIApplicationCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands */ export type RESTPutAPIApplicationCommandsResult = APIApplicationCommand[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-commands + * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */ export type RESTGetAPIApplicationGuildCommandsResult = APIApplicationCommand[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */ export type RESTGetAPIApplicationGuildCommandResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */ export type RESTPostAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */ export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */ export type RESTPatchAPIApplicationGuildCommandJSONBody = Partial; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */ export type RESTPatchAPIApplicationGuildCommandResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */ export type RESTPutAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */ export type RESTPutAPIApplicationGuildCommandsResult = APIApplicationCommand[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response */ export type RESTPostAPIInteractionCallbackJSONBody = APIInteractionResponse; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response */ export type RESTPostAPIInteractionCallbackFormDataBody = | { @@ -121,37 +144,37 @@ export type RESTPostAPIInteractionCallbackFormDataBody = }); /** - * https://discord.com/developers/docs/interactions/slash-commands#get-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response */ export type RESTGetAPIInteractionOriginalResponseResult = RESTGetAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response */ export type RESTPatchAPIInteractionOriginalResponseJSONBody = RESTPatchAPIWebhookWithTokenMessageJSONBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response */ export type RESTPatchAPIInteractionOriginalResponseFormDataBody = RESTPatchAPIWebhookWithTokenMessageFormDataBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response */ export type RESTPatchAPIInteractionOriginalResponseResult = RESTPatchAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#delete-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#delete-original-interaction-response */ export type RESTDeleteAPIInteractionOriginalResponseResult = RESTDeleteAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */ export type RESTPostAPIInteractionFollowupJSONBody = APIInteractionResponseCallbackData; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */ export type RESTPostAPIInteractionFollowupFormDataBody = | { @@ -172,59 +195,59 @@ export type RESTPostAPIInteractionFollowupFormDataBody = }); /** - * https://discord.com/developers/docs/interactions/slash-commands#create-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */ export type RESTPostAPIInteractionFollowupResult = RESTPostAPIWebhookWithTokenWaitResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#get-followup-message */ export type RESTGetAPIInteractionFollowupResult = RESTGetAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message */ export type RESTPatchAPIInteractionFollowupJSONBody = RESTPatchAPIWebhookWithTokenMessageJSONBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message */ export type RESTPatchAPIInteractionFollowupFormDataBody = RESTPatchAPIWebhookWithTokenMessageFormDataBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message */ export type RESTPatchAPIInteractionFollowupResult = RESTPatchAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#delete-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#delete-followup-message */ export type RESTDeleteAPIInteractionFollowupResult = RESTDeleteAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions */ export type RESTGetAPIGuildApplicationCommandsPermissionsResult = APIGuildApplicationCommandPermissions[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions */ export type RESTGetAPIApplicationCommandPermissionsResult = APIGuildApplicationCommandPermissions; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions */ export interface RESTPutAPIApplicationCommandPermissionsJSONBody { permissions: APIApplicationCommandPermission[]; } /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions */ export type RESTPutAPIApplicationCommandPermissionsResult = APIGuildApplicationCommandPermissions; /** - * https://discord.com/developers/docs/interactions/slash-commands#batch-edit-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#batch-edit-application-command-permissions */ export type RESTPutAPIGuildApplicationCommandsPermissionsJSONBody = Pick< APIGuildApplicationCommandPermissions, @@ -232,6 +255,6 @@ export type RESTPutAPIGuildApplicationCommandsPermissionsJSONBody = Pick< >[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#batch-edit-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#batch-edit-application-command-permissions */ export type RESTPutAPIGuildApplicationCommandsPermissionsResult = APIGuildApplicationCommandPermissions[]; diff --git a/rest/v9/interactions.ts b/rest/v9/interactions.ts index 80260f11..3da19ff5 100644 --- a/rest/v9/interactions.ts +++ b/rest/v9/interactions.ts @@ -4,6 +4,7 @@ import type { APIGuildApplicationCommandPermissions, APIInteractionResponse, APIInteractionResponseCallbackData, + ApplicationCommandType, } from '../../payloads/v9/index'; import type { RESTDeleteAPIWebhookWithTokenMessageResult, @@ -15,92 +16,114 @@ import type { } from './webhook'; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands */ export type RESTGetAPIApplicationCommandsResult = APIApplicationCommand[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-global-application-command + * https://discord.com/developers/docs/interactions/application-commands#get-global-application-command */ export type RESTGetAPIApplicationCommandResult = APIApplicationCommand; -/** - * https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command - */ -export type RESTPostAPIApplicationCommandsJSONBody = Omit; +type RESTPostAPIBaseApplicationCommandsJSONBody = Omit< + APIApplicationCommand, + 'id' | 'application_id' | 'description' | 'type' +>; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command + * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command + */ +export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody { + type?: ApplicationCommandType.ChatInput; + description: string; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command + */ +export interface RESTPostAPIContextMenuApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody { + type: ApplicationCommandType.User | ApplicationCommandType.Message; +} + +/** + * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command + */ +export type RESTPostAPIApplicationCommandsJSONBody = + | RESTPostAPIChatInputApplicationCommandsJSONBody + | RESTPostAPIContextMenuApplicationCommandsJSONBody; + +/** + * https://discord.com/developers/docs/interactions/application-commands#create-global-application-command */ export type RESTPostAPIApplicationCommandsResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command + * https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command */ export type RESTPatchAPIApplicationCommandJSONBody = Partial; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command + * https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command */ export type RESTPatchAPIApplicationCommandResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands */ export type RESTPutAPIApplicationCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands */ export type RESTPutAPIApplicationCommandsResult = APIApplicationCommand[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-commands + * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */ export type RESTGetAPIApplicationGuildCommandsResult = APIApplicationCommand[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */ export type RESTGetAPIApplicationGuildCommandResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */ export type RESTPostAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */ export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */ export type RESTPatchAPIApplicationGuildCommandJSONBody = Partial; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command + * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */ export type RESTPatchAPIApplicationGuildCommandResult = APIApplicationCommand; /** - * https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */ export type RESTPutAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands + * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */ export type RESTPutAPIApplicationGuildCommandsResult = APIApplicationCommand[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response */ export type RESTPostAPIInteractionCallbackJSONBody = APIInteractionResponse; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response */ export type RESTPostAPIInteractionCallbackFormDataBody = | { @@ -121,37 +144,37 @@ export type RESTPostAPIInteractionCallbackFormDataBody = }); /** - * https://discord.com/developers/docs/interactions/slash-commands#get-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response */ export type RESTGetAPIInteractionOriginalResponseResult = RESTGetAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response */ export type RESTPatchAPIInteractionOriginalResponseJSONBody = RESTPatchAPIWebhookWithTokenMessageJSONBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response */ export type RESTPatchAPIInteractionOriginalResponseFormDataBody = RESTPatchAPIWebhookWithTokenMessageFormDataBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response */ export type RESTPatchAPIInteractionOriginalResponseResult = RESTPatchAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#delete-original-interaction-response + * https://discord.com/developers/docs/interactions/receiving-and-responding#delete-original-interaction-response */ export type RESTDeleteAPIInteractionOriginalResponseResult = RESTDeleteAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */ export type RESTPostAPIInteractionFollowupJSONBody = APIInteractionResponseCallbackData; /** - * https://discord.com/developers/docs/interactions/slash-commands#create-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */ export type RESTPostAPIInteractionFollowupFormDataBody = | { @@ -172,59 +195,59 @@ export type RESTPostAPIInteractionFollowupFormDataBody = }); /** - * https://discord.com/developers/docs/interactions/slash-commands#create-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */ export type RESTPostAPIInteractionFollowupResult = RESTPostAPIWebhookWithTokenWaitResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#get-followup-message */ export type RESTGetAPIInteractionFollowupResult = RESTGetAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message */ export type RESTPatchAPIInteractionFollowupJSONBody = RESTPatchAPIWebhookWithTokenMessageJSONBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message */ export type RESTPatchAPIInteractionFollowupFormDataBody = RESTPatchAPIWebhookWithTokenMessageFormDataBody; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message */ export type RESTPatchAPIInteractionFollowupResult = RESTPatchAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#delete-followup-message + * https://discord.com/developers/docs/interactions/receiving-and-responding#delete-followup-message */ export type RESTDeleteAPIInteractionFollowupResult = RESTDeleteAPIWebhookWithTokenMessageResult; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions */ export type RESTGetAPIGuildApplicationCommandsPermissionsResult = APIGuildApplicationCommandPermissions[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#get-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions */ export type RESTGetAPIApplicationCommandPermissionsResult = APIGuildApplicationCommandPermissions; /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions */ export interface RESTPutAPIApplicationCommandPermissionsJSONBody { permissions: APIApplicationCommandPermission[]; } /** - * https://discord.com/developers/docs/interactions/slash-commands#edit-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions */ export type RESTPutAPIApplicationCommandPermissionsResult = APIGuildApplicationCommandPermissions; /** - * https://discord.com/developers/docs/interactions/slash-commands#batch-edit-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#batch-edit-application-command-permissions */ export type RESTPutAPIGuildApplicationCommandsPermissionsJSONBody = Pick< APIGuildApplicationCommandPermissions, @@ -232,6 +255,6 @@ export type RESTPutAPIGuildApplicationCommandsPermissionsJSONBody = Pick< >[]; /** - * https://discord.com/developers/docs/interactions/slash-commands#batch-edit-application-command-permissions + * https://discord.com/developers/docs/interactions/application-commands#batch-edit-application-command-permissions */ export type RESTPutAPIGuildApplicationCommandsPermissionsResult = APIGuildApplicationCommandPermissions[];