mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-03-22 09:59:37 +00:00
Bot: Added better middleware documentation
This commit is contained in:
parent
3db68bcb0e
commit
d888a5a7ac
|
@ -328,7 +328,21 @@ func (sub *Subcommand) parseCommands() error {
|
||||||
|
|
||||||
// AddMiddleware adds a middleware into multiple or all methods, including
|
// AddMiddleware adds a middleware into multiple or all methods, including
|
||||||
// commands and events. Multiple method names can be comma-delimited. For all
|
// commands and events. Multiple method names can be comma-delimited. For all
|
||||||
// methods, use a star (*).
|
// methods, use a star (*). The given middleware argument can either be a
|
||||||
|
// function with one of the allowed methods or a *MiddlewareContext.
|
||||||
|
//
|
||||||
|
// Allowed function signatures
|
||||||
|
//
|
||||||
|
// Below are the acceptable function signatures that would be parsed as a proper
|
||||||
|
// middleware. A return value of type T will be ignored. If the given function
|
||||||
|
// is invalid, then this method will panic.
|
||||||
|
//
|
||||||
|
// func(<AnyEvent>) (T, error)
|
||||||
|
// func(<AnyEvent>) error
|
||||||
|
// func(<AnyEvent>)
|
||||||
|
//
|
||||||
|
// Note that although technically all of the above function signatures are
|
||||||
|
// acceptable, one should almost always return only an error.
|
||||||
func (sub *Subcommand) AddMiddleware(methodName string, middleware interface{}) {
|
func (sub *Subcommand) AddMiddleware(methodName string, middleware interface{}) {
|
||||||
var mw *MiddlewareContext
|
var mw *MiddlewareContext
|
||||||
// Allow *MiddlewareContext to be passed into.
|
// Allow *MiddlewareContext to be passed into.
|
||||||
|
|
Loading…
Reference in a new issue