diff --git a/apps/website/docs/api-reference/commandkit/classes/context.mdx b/apps/website/docs/api-reference/commandkit/classes/context.mdx index d553b701..a7281a68 100644 --- a/apps/website/docs/api-reference/commandkit/classes/context.mdx +++ b/apps/website/docs/api-reference/commandkit/classes/context.mdx @@ -31,6 +31,7 @@ class Context) store: void commandName: string + invokedCommandName: string options: CommandContextOptions forwarded: boolean forwardCommand(command: C) => Promise; @@ -110,6 +111,11 @@ This store is shared across all contexts in the same command execution, includin Gets the name of the current command. +### invokedCommandName + + + +Gets the invoked command name (could be an alias for message commands) ### options CommandContextOptions<ExecutionMode>`} /> diff --git a/apps/website/docs/api-reference/commandkit/classes/middleware-context.mdx b/apps/website/docs/api-reference/commandkit/classes/middleware-context.mdx index 049b8051..397124db 100644 --- a/apps/website/docs/api-reference/commandkit/classes/middleware-context.mdx +++ b/apps/website/docs/api-reference/commandkit/classes/middleware-context.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## MiddlewareContext - + Extended context class for middleware execution with additional control methods. diff --git a/packages/commandkit/src/app/commands/Context.ts b/packages/commandkit/src/app/commands/Context.ts index 1e3614b8..8b2bca8b 100644 --- a/packages/commandkit/src/app/commands/Context.ts +++ b/packages/commandkit/src/app/commands/Context.ts @@ -308,6 +308,17 @@ export class Context< return this.commandkit.commandHandler.resolveMessageCommandName(maybeAlias); } + /** + * Gets the invoked command name (could be an alias for message commands) + */ + public get invokedCommandName(): string { + if (this.isInteraction()) { + return this.interaction.commandName; + } + + return this.config.messageCommandParser!.getCommand(); + } + /** * Gets the command options based on the execution mode. */