fix: remove options and handler respectively (#1793)

This commit is contained in:
Jiralite
2026-09-04 12:35:31 +03:00
committed by GitHub
parent 1c6c9b6b51
commit dbde4eed95
5 changed files with 87 additions and 0 deletions
+6
View File
@@ -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;
}
/**
+6
View File
@@ -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;
}
/**
+6
View File
@@ -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;
}
/**
+6
View File
@@ -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;
}
/**
+63
View File
@@ -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<RESTPostAPIApplicationCommandsJSONBody>(chatInputCommand);
expectAssignable<RESTPostAPIApplicationCommandsJSONBody>(contextMenuCommand);
expectAssignable<RESTPostAPIApplicationCommandsJSONBody>(primaryEntryPointCommand);
expectAssignable<RESTPutAPIApplicationCommandsJSONBody>([
chatInputCommand,
contextMenuCommand,
primaryEntryPointCommand,
]);
expectAssignable<RESTPostAPIApplicationGuildCommandsJSONBody>(chatInputCommand);
expectAssignable<RESTPutAPIApplicationGuildCommandsJSONBody>([chatInputCommand, contextMenuCommand]);
expectAssignable<RESTPatchAPIApplicationCommandJSONBody>({ options: [] });
expectAssignable<RESTPatchAPIApplicationCommandJSONBody>({
handler: EntryPointCommandHandlerType.AppHandler,
});
// @ts-expect-error - Options are not on all types.
expectAssignable<keyof RESTPostAPIBaseApplicationCommandsJSONBody>('options');
expectAssignable<keyof RESTPostAPIChatInputApplicationCommandsJSONBody>('options');
// @ts-expect-error - Options are only valid for chat input commands.
expectAssignable<keyof RESTPostAPIContextMenuApplicationCommandsJSONBody>('options');
// @ts-expect-error - Options are only valid for chat input commands.
expectAssignable<keyof RESTPostAPIPrimaryEntryPointApplicationCommandJSONBody>('options');
// @ts-expect-error - Handler is not on all types.
expectAssignable<keyof RESTPostAPIBaseApplicationCommandsJSONBody>('handler');
// @ts-expect-error - Handler is only valid for primary entry point commands.
expectAssignable<keyof RESTPostAPIChatInputApplicationCommandsJSONBody>('handler');
// @ts-expect-error - Handler is only valid for primary entry point commands.
expectAssignable<keyof RESTPostAPIContextMenuApplicationCommandsJSONBody>('handler');
expectAssignable<keyof RESTPostAPIPrimaryEntryPointApplicationCommandJSONBody>('handler');