Represents a the next
function that is given to Command Rules and Middleware
that will call the next Rule/Middleware in sequence to continue execution. Will
cancel execution if given Result.cancel()
or Result.error()
. Result.ok()
will allow Rules/Middleware/dispatch
to continue. Defaults to Result.ok()
if no Result
is passed
Represents a function that enforces a command dispatch rule or modifies dispatch behavior
Generated using TypeDoc
Represents a middleware function for a specific command that can modify command dispatch behavior, enforce an execution rule, transform or add arguments, etc. Will be run after arguments have been parsed.
A middleware function must call
next()
in order for command execution to progress. Ifnext()
is not called, execution of the command will halt silently. Middleware functions can also passResult.cancel()
tonext()
to silently cancel execution.If the middleware is designed to inhibit execution (Like a middleware that dictates what permissions the command caller should have in order to call the command),
Result.error()
should be returned with some type of error that can then be handled by the Command'sonError()
method or the global error handler.NOTE: The above is only really important if you are designing a middleware to be used by others and you want others to choose how to handle the result of the middleware. If it's just a middleware for a personal bot, you can just handle the result in the middleware itself (like sending a response to discord, etc.)