Context
Context
new Context(commandkit, config)
Parameter | Type | Optional | Description |
---|---|---|---|
commandkit | CommandKit | ❌ | The command kit instance. |
config | ContextParameters<ExecutionMode, Args> | ❌ | The context parameters. |
Properties
public channel: any
The channel where the command was triggered.
public channelId: any
The channel id where the command was triggered.
public client: any
The client instance.
public command: any
The command that this context belongs to.
public commandkit: any
The command kit instance.
public config: any
The context parameters.
public guild: any
The guild where the command was triggered.
public guildId: any
The guild ID where the command was triggered.
public interaction: any
The interaction that triggered the command.
public message: any
The message that triggered the command.
public commandName: any
public executionMode: any
The execution mode of the command.
public forwarded: any
Whether this context was forwarded from another context. This happens when a command forwards its context to another command.
public options: any
public store: any
The shared key-value store for this context. This can be used to store data that needs to be shared between middlewares or commands. This store is shared across all contexts in the same command execution, including the cloned contexts and middleware contexts.
Methods
public args(): Array<string>
public clone(config?): Context<ExecutionMode>
Creates a clone of this context
Parameter | Type | Optional |
---|---|---|
config | Partial<ContextParameters<ExecutionMode>> | ✅ |
public exit(): void
Stops upcoming middleware or current command execution. If this is called inside pre-stage middleware, the next run will be the actual command, skipping all other pre-stage middlewares. If this is called inside a command itself, it will skip all post-stage middlewares. If this is called inside post-stage middleware, it will skip all other post-stage middlewares.
public forwardCommand(command): Promise<never>
Forwards the context to another command. The target handler will be the same as current handler.
Parameter | Type | Optional | Description |
---|---|---|---|
command | C | ❌ | The command to forward to. |
public getCommandIdentifier(): string
Returns the command identifier.
public getGuildLocale(): null | Locale
Returns the locale of the guild where this command was triggered.
public getLocale(preferUser): Locale
Returns the locale for this command.
Parameter | Type | Optional | Description |
---|---|---|---|
preferUser | boolean | ❌ | Whether to prefer the user's locale over the guild's locale. |
public getUserLocale(): null | Locale
Returns the locale of the user who triggered this command.
public isAutocomplete(): is | AutocompleteCommandContext
Whether the command was triggered by an autocomplete interaction.
public isChatInputCommand(): is | ChatInputCommandContext
Whether the command was triggered by a slash command interaction.
public isInteraction(): is | InteractionCommandContext
Whether the command was triggered by an interaction.
public isMessage(): is | Context<'message'>
Whether the command was triggered by a message.
public isMessageContextMenu(): is | MessageContextMenuCommandContext
Whether the command was triggered by a message context menu interaction.
public isMiddleware(): is | MiddlewareContext<ExecutionMode>
public isUserContextMenu(): is | UserContextMenuCommandContext
Whether the command was triggered by a user context menu interaction.
public setLocale(locale): void
Sets the locale for this command.
Parameter | Type | Optional | Description |
---|---|---|---|
locale | null | Locale | ❌ |