1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2025-03-23 02:19:22 +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 {
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 {
@ -53,7 +58,12 @@ func (ctx *Context) filterEventType(evT reflect.Type) []*CommandContext {
}
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)
}
}
}
}