fix nil map dereference in discord commands, and add option type to slash command option
Signed-off-by: Ava Affine <ava@sunnypup.io>
This commit is contained in:
parent
359ff427e3
commit
55f9725af1
1 changed files with 9 additions and 8 deletions
|
|
@ -12,7 +12,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// map of guildID to registeredCommands
|
// map of guildID to registeredCommands
|
||||||
registeredCommands map[string][]*discordgo.ApplicationCommand
|
registeredCommands = make(map[string][]*discordgo.ApplicationCommand)
|
||||||
|
|
||||||
// all commands
|
// all commands
|
||||||
commandList = []*discordgo.ApplicationCommand{
|
commandList = []*discordgo.ApplicationCommand{
|
||||||
|
|
@ -28,6 +28,7 @@ var (
|
||||||
Description: "anonymously post a confession in configured channel",
|
Description: "anonymously post a confession in configured channel",
|
||||||
Options: []*discordgo.ApplicationCommandOption{
|
Options: []*discordgo.ApplicationCommandOption{
|
||||||
&discordgo.ApplicationCommandOption{
|
&discordgo.ApplicationCommandOption{
|
||||||
|
Type: discordgo.ApplicationCommandOptionString,
|
||||||
Name: "confession",
|
Name: "confession",
|
||||||
Description: "A confession to be posted anonymously",
|
Description: "A confession to be posted anonymously",
|
||||||
Required: true,
|
Required: true,
|
||||||
|
|
@ -79,11 +80,11 @@ func registerCommands(s *discordgo.Session) {
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logging.Error(
|
logging.Error(
|
||||||
"Failed to register commands for guild %s: %s",
|
"Failed to register commands for guild",
|
||||||
guild.ID, err.Error(),
|
guild.ID, ": ", err.Error(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
logging.Info("Registered commands for guild %s", guild.ID)
|
logging.Info("Registered commands for guild ", guild.ID)
|
||||||
registeredCommands[guild.ID] = cmds
|
registeredCommands[guild.ID] = cmds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -98,13 +99,13 @@ func deregisterCommands(s *discordgo.Session) {
|
||||||
cmd.ID,
|
cmd.ID,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
logging.Error(
|
logging.Error(
|
||||||
"Failed to delete %s command (id: %s) from guild %s",
|
"Failed to delete", cmd.Name, "command (id:", cmd.ID,
|
||||||
cmd.Name, cmd.ID, guild,
|
") from guild ", guild,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
logging.Info(
|
logging.Info(
|
||||||
"Deregistered command %s (id: %s) from guild %s",
|
"Deregistered command ", cmd.Name,"(id:", cmd.ID,
|
||||||
cmd.Name, cmd.ID, guild,
|
") from guild ", guild,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue