Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Context<ExecutionMode extends CommandExecutionMode = CommandExecutionMode,
constructor(commandkit: CommandKit, config: ContextParameters<ExecutionMode, Args>)
store: void
commandName: string
invokedCommandName: string
options: CommandContextOptions<ExecutionMode>
forwarded: boolean
forwardCommand(command: C) => Promise<never>;
Expand Down Expand Up @@ -110,6 +111,11 @@ This store is shared across all contexts in the same command execution, includin
<MemberInfo kind="property" type={`string`} />

Gets the name of the current command.
### invokedCommandName

<MemberInfo kind="property" type={`string`} />

Gets the invoked command name (could be an alias for message commands)
### options

<MemberInfo kind="property" type={`<a href='/docs/api-reference/commandkit/types/command-context-options#commandcontextoptions'>CommandContextOptions</a>&#60;ExecutionMode&#62;`} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription';

## MiddlewareContext

<GenerationInfo sourceFile="packages/commandkit/src/app/commands/Context.ts" sourceLine="570" packageName="commandkit" />
<GenerationInfo sourceFile="packages/commandkit/src/app/commands/Context.ts" sourceLine="581" packageName="commandkit" />

Extended context class for middleware execution with additional control methods.

Expand Down
11 changes: 11 additions & 0 deletions packages/commandkit/src/app/commands/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down