MiddlewareContext
MiddlewareContext
Extended context class for middleware execution with additional control methods.
Signature
class MiddlewareContext<T extends CommandExecutionMode = CommandExecutionMode> extends Context<T, MiddlewareContextArgs> {
cancelled: boolean
cancel() => void;
setCommandRunner(fn: RunCommand) => void;
}
- Extends:
Context<T, MiddlewareContextArgs>
cancelled
property
boolean
Whether the command execution was cancelled.
cancel
method
() => void
Cancels the command execution.
setCommandRunner
method
(fn: RunCommand) => void
Sets command runner function to wrap the command execution.
Example
ctx.setCommandRunner(async (execute) => {
// do something before command execution
await execute();
// do something after command execution
})