removing old (possibly broken) commands;

This commit is contained in:
naudachu 2024-02-01 21:30:41 +05:00
parent b2850d668a
commit cb57f2e0ce
1 changed files with 16 additions and 0 deletions

View File

@ -196,6 +196,22 @@ func updateForum(conf *domain.Config, s *discordgo.Session) ([]discordgo.ForumTa
} }
func commandRegistration(s *discordgo.Session, commands []discordgo.ApplicationCommand) []*discordgo.ApplicationCommand { 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...") log.Println("Adding commands...")
var cmds []*discordgo.ApplicationCommand var cmds []*discordgo.ApplicationCommand
for _, cmd := range commands { for _, cmd := range commands {