removing old (possibly broken) commands;
This commit is contained in:
parent
b2850d668a
commit
cb57f2e0ce
|
|
@ -196,6 +196,22 @@ func updateForum(conf *domain.Config, s *discordgo.Session) ([]discordgo.ForumTa
|
|||
}
|
||||
|
||||
func commandRegistration(s *discordgo.Session, commands []discordgo.ApplicationCommand) []*discordgo.ApplicationCommand {
|
||||
oldCommands, err := s.ApplicationCommands(s.State.User.ID, s.State.Application.GuildID)
|
||||
if err != nil {
|
||||
log.Panicf("Cannot get old commands: %v", err)
|
||||
}
|
||||
|
||||
var removedCommands []string
|
||||
for _, cmd := range oldCommands {
|
||||
err := s.ApplicationCommandDelete(s.State.User.ID, s.State.Application.GuildID, cmd.ID)
|
||||
if err != nil {
|
||||
log.Printf("commands removed: %v", removedCommands)
|
||||
log.Panicf("removing old comands failed with %s command, err: %v", cmd.Name, err)
|
||||
}
|
||||
removedCommands = append(removedCommands, cmd.Name)
|
||||
}
|
||||
log.Printf("commands removed: %v", removedCommands)
|
||||
|
||||
log.Println("Adding commands...")
|
||||
var cmds []*discordgo.ApplicationCommand
|
||||
for _, cmd := range commands {
|
||||
|
|
|
|||
Loading…
Reference in New Issue