Command
implementsMiddlewareChainer<M, C>
Description
An executable command which only executes if its Matcher is satisfied
Example
const command = new Command()
.match(matchPrefixes("sum"))
.use(context => {
const { content } = context
const numbers = content.split(" ").map(n => Number(n))
const result = numbers.reduce((a, b) => a + b)
console.log("The sum is:", result)
})
// Input: "sum 4 4"
// Output: "The sum is: 8"
Generics
M
C
D
S
Properties
metadata:
Dmiddleware:
Middleware<any, M, C>[]Methods
setMetadata(data)Command<M, C, T, S>
Parameters
data:
Tuse(middleware)Command<M, C, D, T & S>
Add Middleware. The order that you call this is the order the middleware will be in
Parameters
middleware:
Middleware<T & S, M, C>Middleware