From a4e7ecb92e99023c76404cd78006915a34dd4315 Mon Sep 17 00:00:00 2001 From: kageru Date: Sat, 2 Mar 2019 13:25:39 +0100 Subject: [PATCH] Fixed AllowedChannels not being initialized by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I didn’t even know go could panic like that selphyDerp --- command.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/command.go b/command.go index f513ed4..eba1d42 100644 --- a/command.go +++ b/command.go @@ -56,6 +56,9 @@ func registerCommand(command Command) { command.Trigger = strings.ToLower(command.Trigger) } command.UsersOnCooldown = mapset.NewSet() + if command.AllowedChannels == nil { + command.AllowedChannels = mapset.NewSet() + } commands = append(commands, &command) } @@ -164,7 +167,9 @@ func commandAllowed(session *discordgo.Session, message *discordgo.MessageCreate } // no allowed channels = all channels are allowed. // DMs are whitelisted by default - if command.AllowedChannels.Cardinality() != 0 && !command.AllowedChannels.Contains(message.ChannelID) && !isDM(session, message) { + if command.AllowedChannels.Cardinality() != 0 && + !command.AllowedChannels.Contains(message.ChannelID) && + isDM(session, message) { return false } return true