1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2025-12-01 00:29:49 +00:00

Fixed bug where MessageCreate middlewares are called for other events

This commit is contained in:
diamondburned (Forefront) 2020-01-24 18:56:08 -08:00
parent 7f2b663dba
commit b45c0489bb

View file

@ -30,7 +30,12 @@ func (ctx *Context) filterEventType(evT reflect.Type) []*CommandContext {
} }
if found { if found {
middles = append(middles, ctx.mwMethods...) // Search for middlewares with the same type:
for _, mw := range ctx.mwMethods {
if mw.event == evT {
middles = append(middles, mw)
}
}
} }
for _, sub := range ctx.subcommands { for _, sub := range ctx.subcommands {
@ -53,7 +58,12 @@ func (ctx *Context) filterEventType(evT reflect.Type) []*CommandContext {
} }
if found { if found {
middles = append(middles, sub.mwMethods...) // Search for middlewares with the same type:
for _, mw := range sub.mwMethods {
if mw.event == evT {
middles = append(middles, mw)
}
}
} }
} }