5HT2 / taro-bot

A fast, scalable and easily expandable Discord bot
https://frogg.ie/invite-taro-bot
ISC License
11 stars 1 forks source link

(cmd) Permission system panics in DMs #48

Closed 5HT2 closed 2 years ago

5HT2 commented 2 years ago

Easy fix oops

https://github.com/5HT2/taro-bot/blob/b65d57d5006588a488a371f4eeeb28ff997dfacd/cmd/permissions.go#L91

2022/10/17 04:05:59 HasAdminCached: found 995142503391047770
2022/10/17 04:06:12 panic: goroutine 76807 [running]:
runtime/debug.Stack()
    /usr/local/go/src/runtime/debug/stack.go:24 +0x68
github.com/5HT2/taro-bot/util.LogPanic()
    /taro-bot/util/builtin.go:20 +0x30
panic({0x991220, 0xe40bf0})
    /usr/local/go/src/runtime/panic.go:838 +0x20c
github.com/5HT2/taro-bot/cmd.UserHasPermission({0x4000eb9800, {0xffff6d8b6d5e, 0xb}, {0x4000a78254, 0x4}, {0x4000055370, 0x0, 0x1}}, 0x4, 0xdcf74d59784305a)
    /taro-bot/cmd/permissions.go:91 +0x58
github.com/5HT2/taro-bot/cmd.HasPermission({0x4000eb9800, {0xffff6d8b6d5e, 0xb}, {0x4000a78254, 0x4}, {0x4000055370, 0x0, 0x1}}, 0x4)
    /taro-bot/cmd/permissions.go:82 +0x154
github.com/5HT2/taro-bot/plugins/hrtgen.DoseCommand({0x4000eb9800, {0xffff6d8b6d5e, 0xb}, {0x4000a78254, 0x4}, {0x4000055370, 0x0, 0x1}})
    /taro-bot/plugins/hrtgen/hrtgen.go:57 +0x8c
github.com/5HT2/taro-bot/cmd.CommandHandlerWithCommand(0x4000eb9800, {0x4000a78254, 0x4}, {0x4000055370?, 0x0?, 0x1?})
    /taro-bot/cmd/util.go:47 +0x228
github.com/5HT2/taro-bot/cmd.CommandHandler(0x4000eb9800)
    /taro-bot/cmd/util.go:20 +0x94
created by main.main.func1
    /taro-bot/main.go:52 +0x64

2022/10/17 04:06:15 HasAdminCached: found 995142503391047770
5HT2 commented 2 years ago

This was inadvertently solved by ed46d0be37eff32bbfa44b67b28be887a5e9386d (which made it impossible for the panicking line to be reached in all existing cases where cmd.HasPermission is used), but I added another commit to prevent it entirely.