Skip to content

Commit d3e3f8f

Browse files
authored
Merge pull request #578 from underctrl-io/raw-name
feat: add raw command name fetcher to context
2 parents f00ec13 + 230bf1e commit d3e3f8f

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

apps/website/docs/api-reference/commandkit/classes/context.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Context<ExecutionMode extends CommandExecutionMode = CommandExecutionMode,
3131
constructor(commandkit: CommandKit, config: ContextParameters<ExecutionMode, Args>)
3232
store: void
3333
commandName: string
34+
invokedCommandName: string
3435
options: CommandContextOptions<ExecutionMode>
3536
forwarded: boolean
3637
forwardCommand(command: C) => Promise<never>;
@@ -110,6 +111,11 @@ This store is shared across all contexts in the same command execution, includin
110111
<MemberInfo kind="property" type={`string`} />
111112

112113
Gets the name of the current command.
114+
### invokedCommandName
115+
116+
<MemberInfo kind="property" type={`string`} />
117+
118+
Gets the invoked command name (could be an alias for message commands)
113119
### options
114120

115121
<MemberInfo kind="property" type={`<a href='/docs/api-reference/commandkit/types/command-context-options#commandcontextoptions'>CommandContextOptions</a>&#60;ExecutionMode&#62;`} />

apps/website/docs/api-reference/commandkit/classes/middleware-context.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription';
1313

1414
## MiddlewareContext
1515

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

1818
Extended context class for middleware execution with additional control methods.
1919

packages/commandkit/src/app/commands/Context.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,17 @@ export class Context<
308308
return this.commandkit.commandHandler.resolveMessageCommandName(maybeAlias);
309309
}
310310

311+
/**
312+
* Gets the invoked command name (could be an alias for message commands)
313+
*/
314+
public get invokedCommandName(): string {
315+
if (this.isInteraction()) {
316+
return this.interaction.commandName;
317+
}
318+
319+
return this.config.messageCommandParser!.getCommand();
320+
}
321+
311322
/**
312323
* Gets the command options based on the execution mode.
313324
*/

0 commit comments

Comments
 (0)