From d888a5a7ac1f434b037e1d94fe84ea7f1a788ebc Mon Sep 17 00:00:00 2001 From: diamondburned Date: Tue, 11 Aug 2020 17:31:29 -0700 Subject: [PATCH] Bot: Added better middleware documentation --- bot/subcommand.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/bot/subcommand.go b/bot/subcommand.go index 33bbb6c..b545c1f 100644 --- a/bot/subcommand.go +++ b/bot/subcommand.go @@ -328,7 +328,21 @@ func (sub *Subcommand) parseCommands() error { // AddMiddleware adds a middleware into multiple or all methods, including // 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() (T, error) +// func() error +// func() +// +// 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{}) { var mw *MiddlewareContext // Allow *MiddlewareContext to be passed into.