Bot: Added AllowBot
This commit is contained in:
parent
86d32bdbe9
commit
70ace8e5e4
|
@ -77,6 +77,10 @@ type Context struct {
|
||||||
// NewPrefix().
|
// NewPrefix().
|
||||||
HasPrefix Prefixer
|
HasPrefix Prefixer
|
||||||
|
|
||||||
|
// AllowBot makes the router also process MessageCreate events from bots.
|
||||||
|
// This is false by default and only applies to MessageCreate.
|
||||||
|
AllowBot bool
|
||||||
|
|
||||||
// FormatError formats any errors returned by anything, including the method
|
// FormatError formats any errors returned by anything, including the method
|
||||||
// commands or the reflect functions. This also includes invalid usage
|
// commands or the reflect functions. This also includes invalid usage
|
||||||
// errors or unknown command errors. Returning an empty string means
|
// errors or unknown command errors. Returning an empty string means
|
||||||
|
|
|
@ -134,6 +134,11 @@ func (ctx *Context) callCmd(ev interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *Context) callMessageCreate(mc *gateway.MessageCreateEvent) error {
|
func (ctx *Context) callMessageCreate(mc *gateway.MessageCreateEvent) error {
|
||||||
|
// check if bot
|
||||||
|
if !ctx.AllowBot && mc.Author.Bot {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// check if prefix
|
// check if prefix
|
||||||
pf, ok := ctx.HasPrefix(mc)
|
pf, ok := ctx.HasPrefix(mc)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
Loading…
Reference in New Issue