Fixed AllowedChannels not being initialized by default
I didn’t even know go could panic like that selphyDerp
This commit is contained in:
parent
67fb364f4f
commit
a4e7ecb92e
|
@ -56,6 +56,9 @@ func registerCommand(command Command) {
|
||||||
command.Trigger = strings.ToLower(command.Trigger)
|
command.Trigger = strings.ToLower(command.Trigger)
|
||||||
}
|
}
|
||||||
command.UsersOnCooldown = mapset.NewSet()
|
command.UsersOnCooldown = mapset.NewSet()
|
||||||
|
if command.AllowedChannels == nil {
|
||||||
|
command.AllowedChannels = mapset.NewSet()
|
||||||
|
}
|
||||||
commands = append(commands, &command)
|
commands = append(commands, &command)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +167,9 @@ func commandAllowed(session *discordgo.Session, message *discordgo.MessageCreate
|
||||||
}
|
}
|
||||||
// no allowed channels = all channels are allowed.
|
// no allowed channels = all channels are allowed.
|
||||||
// DMs are whitelisted by default
|
// 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 false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in New Issue
Block a user