diff --git a/src/commands/applications/chatcontext.ts b/src/commands/applications/chatcontext.ts index 45e888c..24b80fe 100644 --- a/src/commands/applications/chatcontext.ts +++ b/src/commands/applications/chatcontext.ts @@ -177,4 +177,8 @@ export class CommandContext< > { return this.interaction?.member || ((this.message! as Message)?.member as any); } + + isChat(): this is CommandContext { + return true; + } } diff --git a/src/commands/applications/menucontext.ts b/src/commands/applications/menucontext.ts index 8494b39..7265f55 100644 --- a/src/commands/applications/menucontext.ts +++ b/src/commands/applications/menucontext.ts @@ -4,9 +4,9 @@ import { toSnakeCase, type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, + type ModalCreateBodyRequest, type UnionToTuple, type When, - type ModalCreateBodyRequest, } from '../../common'; import { Message, @@ -152,4 +152,16 @@ export class MenuCommandContext< get member() { return this.interaction.member; } + + isMenu(): this is MenuCommandContext { + return true; + } + + isMenuUser(): this is MenuCommandContext { + return this.target instanceof User; + } + + isMenuMessage(): this is MenuCommandContext { + return this.target instanceof Message; + } } diff --git a/src/commands/basecontex.ts b/src/commands/basecontex.ts index 401fb75..3558f87 100644 --- a/src/commands/basecontex.ts +++ b/src/commands/basecontex.ts @@ -1,13 +1,5 @@ -import { ApplicationCommandType, InteractionType } from 'discord-api-types/v10'; import type { ComponentCommandInteractionMap, ComponentContext } from '../components/componentcontext'; -import { - Message, - User, - type ChatInputCommandInteraction, - type ComponentInteraction, - type MessageCommandInteraction, - type UserCommandInteraction, -} from '../structures'; +import type { MessageCommandInteraction, UserCommandInteraction } from '../structures'; import type { CommandContext } from './applications/chatcontext'; import type { MenuCommandContext } from './applications/menucontext'; import type { UsingClient } from './applications/shared'; @@ -20,26 +12,22 @@ export class BaseContext { } isChat(): this is CommandContext { - //@ts-expect-error - return this.message || (this.interaction as ChatInputCommandInteraction).type === ApplicationCommandType.ChatInput; + return false; } isMenu(): this is MenuCommandContext { - return this.isMenuUser() || this.isMenuMessage(); + return false; } isMenuUser(): this is MenuCommandContext { - //@ts-expect-error - return this.target instanceof User; + return false; } isMenuMessage(): this is MenuCommandContext { - //@ts-expect-error - return this.target instanceof Message; + return false; } isComponent(): this is ComponentContext { - //@ts-expect-error - return (this.interaction as ComponentInteraction).type === InteractionType.MessageComponent; + return false; } } diff --git a/src/components/componentcontext.ts b/src/components/componentcontext.ts index 5068b3c..39a6f1c 100644 --- a/src/components/componentcontext.ts +++ b/src/components/componentcontext.ts @@ -196,6 +196,10 @@ export class ComponentContext get member() { return this.interaction.member; } + + isComponent(): this is ComponentContext { + return true; + } } export interface ComponentCommandInteractionMap {