From dbde4eed954f4943649e6fc0ade5b5f6f35942ff Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Fri, 4 Sep 2026 10:35:31 +0100 Subject: [PATCH] fix: remove `options` and `handler` respectively (#1793) --- deno/rest/v10/interactions.ts | 6 +++ deno/rest/v9/interactions.ts | 6 +++ rest/v10/interactions.ts | 6 +++ rest/v9/interactions.ts | 6 +++ tests/v10/applicationCommands.ts | 63 ++++++++++++++++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 tests/v10/applicationCommands.ts diff --git a/deno/rest/v10/interactions.ts b/deno/rest/v10/interactions.ts index 2e3f5168..710c283b 100644 --- a/deno/rest/v10/interactions.ts +++ b/deno/rest/v10/interactions.ts @@ -1,11 +1,13 @@ import type { Snowflake } from '../../globals.ts'; import type { APIApplicationCommand, + APIApplicationCommandOption, APIApplicationCommandPermission, APIGuildApplicationCommandPermissions, APIInteractionResponse, APIInteractionResponseCallbackData, ApplicationCommandType, + EntryPointCommandHandlerType, InteractionResponseType, APIMessage, InteractionType, @@ -58,9 +60,11 @@ export interface RESTPostAPIBaseApplicationCommandsJSONBody | 'description_localized' | 'description' | 'guild_id' + | 'handler' | 'id' | 'integration_types' | 'name_localized' + | 'options' | 'type' | 'version' > @@ -78,6 +82,7 @@ export interface RESTPostAPIBaseApplicationCommandsJSONBody export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody { type?: ApplicationCommandType.ChatInput | undefined; description: string; + options?: APIApplicationCommandOption[] | undefined; } /** @@ -93,6 +98,7 @@ export interface RESTPostAPIContextMenuApplicationCommandsJSONBody extends RESTP export interface RESTPostAPIPrimaryEntryPointApplicationCommandJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody { type: ApplicationCommandType.PrimaryEntryPoint; description?: string | undefined; + handler?: EntryPointCommandHandlerType | undefined; } /** diff --git a/deno/rest/v9/interactions.ts b/deno/rest/v9/interactions.ts index 754a2009..2b5a445c 100644 --- a/deno/rest/v9/interactions.ts +++ b/deno/rest/v9/interactions.ts @@ -1,11 +1,13 @@ import type { Snowflake } from '../../globals.ts'; import type { APIApplicationCommand, + APIApplicationCommandOption, APIApplicationCommandPermission, APIGuildApplicationCommandPermissions, APIInteractionResponse, APIInteractionResponseCallbackData, ApplicationCommandType, + EntryPointCommandHandlerType, InteractionResponseType, APIMessage, InteractionType, @@ -58,9 +60,11 @@ export interface RESTPostAPIBaseApplicationCommandsJSONBody | 'description_localized' | 'description' | 'guild_id' + | 'handler' | 'id' | 'integration_types' | 'name_localized' + | 'options' | 'type' | 'version' > @@ -78,6 +82,7 @@ export interface RESTPostAPIBaseApplicationCommandsJSONBody export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody { type?: ApplicationCommandType.ChatInput | undefined; description: string; + options?: APIApplicationCommandOption[] | undefined; } /** @@ -93,6 +98,7 @@ export interface RESTPostAPIContextMenuApplicationCommandsJSONBody extends RESTP export interface RESTPostAPIPrimaryEntryPointApplicationCommandJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody { type: ApplicationCommandType.PrimaryEntryPoint; description?: string | undefined; + handler?: EntryPointCommandHandlerType | undefined; } /** diff --git a/rest/v10/interactions.ts b/rest/v10/interactions.ts index d98e1e2c..343154e7 100644 --- a/rest/v10/interactions.ts +++ b/rest/v10/interactions.ts @@ -1,11 +1,13 @@ import type { Snowflake } from '../../globals'; import type { APIApplicationCommand, + APIApplicationCommandOption, APIApplicationCommandPermission, APIGuildApplicationCommandPermissions, APIInteractionResponse, APIInteractionResponseCallbackData, ApplicationCommandType, + EntryPointCommandHandlerType, InteractionResponseType, APIMessage, InteractionType, @@ -58,9 +60,11 @@ export interface RESTPostAPIBaseApplicationCommandsJSONBody | 'description_localized' | 'description' | 'guild_id' + | 'handler' | 'id' | 'integration_types' | 'name_localized' + | 'options' | 'type' | 'version' > @@ -78,6 +82,7 @@ export interface RESTPostAPIBaseApplicationCommandsJSONBody export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody { type?: ApplicationCommandType.ChatInput | undefined; description: string; + options?: APIApplicationCommandOption[] | undefined; } /** @@ -93,6 +98,7 @@ export interface RESTPostAPIContextMenuApplicationCommandsJSONBody extends RESTP export interface RESTPostAPIPrimaryEntryPointApplicationCommandJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody { type: ApplicationCommandType.PrimaryEntryPoint; description?: string | undefined; + handler?: EntryPointCommandHandlerType | undefined; } /** diff --git a/rest/v9/interactions.ts b/rest/v9/interactions.ts index 22f081b6..40d6ced1 100644 --- a/rest/v9/interactions.ts +++ b/rest/v9/interactions.ts @@ -1,11 +1,13 @@ import type { Snowflake } from '../../globals'; import type { APIApplicationCommand, + APIApplicationCommandOption, APIApplicationCommandPermission, APIGuildApplicationCommandPermissions, APIInteractionResponse, APIInteractionResponseCallbackData, ApplicationCommandType, + EntryPointCommandHandlerType, InteractionResponseType, APIMessage, InteractionType, @@ -58,9 +60,11 @@ export interface RESTPostAPIBaseApplicationCommandsJSONBody | 'description_localized' | 'description' | 'guild_id' + | 'handler' | 'id' | 'integration_types' | 'name_localized' + | 'options' | 'type' | 'version' > @@ -78,6 +82,7 @@ export interface RESTPostAPIBaseApplicationCommandsJSONBody export interface RESTPostAPIChatInputApplicationCommandsJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody { type?: ApplicationCommandType.ChatInput | undefined; description: string; + options?: APIApplicationCommandOption[] | undefined; } /** @@ -93,6 +98,7 @@ export interface RESTPostAPIContextMenuApplicationCommandsJSONBody extends RESTP export interface RESTPostAPIPrimaryEntryPointApplicationCommandJSONBody extends RESTPostAPIBaseApplicationCommandsJSONBody { type: ApplicationCommandType.PrimaryEntryPoint; description?: string | undefined; + handler?: EntryPointCommandHandlerType | undefined; } /** diff --git a/tests/v10/applicationCommands.ts b/tests/v10/applicationCommands.ts new file mode 100644 index 00000000..f69a6aa1 --- /dev/null +++ b/tests/v10/applicationCommands.ts @@ -0,0 +1,63 @@ +import type { + RESTPatchAPIApplicationCommandJSONBody, + RESTPostAPIApplicationCommandsJSONBody, + RESTPostAPIBaseApplicationCommandsJSONBody, + RESTPostAPIApplicationGuildCommandsJSONBody, + RESTPostAPIChatInputApplicationCommandsJSONBody, + RESTPostAPIContextMenuApplicationCommandsJSONBody, + RESTPostAPIPrimaryEntryPointApplicationCommandJSONBody, + RESTPutAPIApplicationCommandsJSONBody, + RESTPutAPIApplicationGuildCommandsJSONBody, +} from '../../v10'; +import { ApplicationCommandType, EntryPointCommandHandlerType } from '../../v10'; +import { expectAssignable } from '../__utils__/type-assertions'; + +const chatInputCommand = { + name: 'Chat input', + description: 'description', + options: [], +}; + +const contextMenuCommand = { + type: ApplicationCommandType.User as const, + name: 'Context menu', +}; + +const primaryEntryPointCommand = { + type: ApplicationCommandType.PrimaryEntryPoint as const, + name: 'Entry point', + handler: EntryPointCommandHandlerType.DiscordLaunchActivity, +}; + +expectAssignable(chatInputCommand); +expectAssignable(contextMenuCommand); +expectAssignable(primaryEntryPointCommand); +expectAssignable([ + chatInputCommand, + contextMenuCommand, + primaryEntryPointCommand, +]); +expectAssignable(chatInputCommand); +expectAssignable([chatInputCommand, contextMenuCommand]); +expectAssignable({ options: [] }); +expectAssignable({ + handler: EntryPointCommandHandlerType.AppHandler, +}); + +// @ts-expect-error - Options are not on all types. +expectAssignable('options'); +expectAssignable('options'); + +// @ts-expect-error - Options are only valid for chat input commands. +expectAssignable('options'); +// @ts-expect-error - Options are only valid for chat input commands. +expectAssignable('options'); + +// @ts-expect-error - Handler is not on all types. +expectAssignable('handler'); + +// @ts-expect-error - Handler is only valid for primary entry point commands. +expectAssignable('handler'); +// @ts-expect-error - Handler is only valid for primary entry point commands. +expectAssignable('handler'); +expectAssignable('handler');