diff --git a/main.go b/main.go index 4a02673..a083394 100644 --- a/main.go +++ b/main.go @@ -127,7 +127,23 @@ func interactionCreate(s *discordgo.Session, i *discordgo.InteractionCreate) { } func registerCommands(s *discordgo.Session) { - log.Println("Registering commands...") + // First, delete all existing commands + log.Println("Deleting existing commands...") + + existingCommands, err := s.ApplicationCommands(s.State.User.ID, "") + if err != nil { + log.Printf("Error fetching existing commands: %v", err) + } + + for _, cmd := range existingCommands { + err := s.ApplicationCommandDelete(s.State.User.ID, "", cmd.ID) + if err != nil { + log.Printf("Error deleting command %s: %v", cmd.Name, err) + } + } + + // Then register the new commands + log.Println("Registering new commands...") registeredCommands := make([]*discordgo.ApplicationCommand, len(commands)) for i, v := range commands { cmd, err := s.ApplicationCommandCreate(s.State.User.ID, "", v)