tyzbit / go-discord-modtools

Moderator tools
GNU General Public License v3.0
5 stars 0 forks source link

Bug: If bot recieves an DM with the slash commands, it panics #23

Closed samip5 closed 1 month ago

samip5 commented 8 months ago
panic: runtime error: invalid memory address or nil pointer dereference
2024-03-14T22:22:34.373091135Z [signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0x82d380]
2024-03-14T22:22:34.373099969Z 
2024-03-14T22:22:34.373104552Z goroutine 27 [running]:
2024-03-14T22:22:34.373108719Z github.com/tyzbit/go-discord-modtools/bot.(*ModeratorBot).isAllowed(0xb65060?, {{0x4000038780, 0x12}, {0x4000038798, 0x13}, 0x40003cf048, {0x40000387b0, 0x12}, {0x0, 0x0}, ...}, ...)
2024-03-14T22:22:34.373113344Z  /bot/util_bot.go:19 +0x70
2024-03-14T22:22:34.373117760Z github.com/tyzbit/go-discord-modtools/bot.(*ModeratorBot).InteractionHandler(0x400078e2d0, 0x4000548388, 0x4000068e60)
2024-03-14T22:22:34.373122177Z  /bot/discord_handlers.go:151 +0x1140
2024-03-14T22:22:34.373126385Z github.com/bwmarrin/discordgo.interactionCreateEventHandler.Handle(0x0?, 0x0?, {0xba51c0?, 0x4000068e60?})
2024-03-14T22:22:34.373130677Z  /vendor/github.com/bwmarrin/discordgo/eventhandlers.go:714 +0x44
2024-03-14T22:22:34.373134802Z created by github.com/bwmarrin/discordgo.(*Session).handle in goroutine 24
2024-03-14T22:22:34.373138885Z  /vendor/github.com/bwmarrin/discordgo/event.go:171 +0x134
tyzbit commented 8 months ago

The bot's functionality is really only useful when used in a server, but /help at the very least should work in a DM. Otherwise I will have it explain it must be added to a server.

samip5 commented 8 months ago

Yeah, the command I tried was help in a DM. :)