Bot: Added AllowBot

This commit is contained in:
diamondburned (Forefront) 2020-04-09 21:46:21 -07:00
parent 86d32bdbe9
commit 70ace8e5e4
2 changed files with 9 additions and 0 deletions

View File

@ -77,6 +77,10 @@ type Context struct {
// NewPrefix().
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
// commands or the reflect functions. This also includes invalid usage
// errors or unknown command errors. Returning an empty string means

View File

@ -134,6 +134,11 @@ func (ctx *Context) callCmd(ev interface{}) error {
}
func (ctx *Context) callMessageCreate(mc *gateway.MessageCreateEvent) error {
// check if bot
if !ctx.AllowBot && mc.Author.Bot {
return nil
}
// check if prefix
pf, ok := ctx.HasPrefix(mc)
if !ok {