From ee67cc1e2c43437976b393279f45a6c709207842 Mon Sep 17 00:00:00 2001 From: Xevion Date: Thu, 4 Jan 2024 09:21:16 -0600 Subject: [PATCH] Manual, temporary guild command unregistration --- main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/main.go b/main.go index 14acc9d..48b2731 100644 --- a/main.go +++ b/main.go @@ -2,10 +2,12 @@ package main import ( "context" + "fmt" "net/http" "net/http/cookiejar" "os" "os/signal" + "strconv" "syscall" "time" _ "time/tzdata" @@ -155,6 +157,19 @@ func main() { }) log.Info().Array("commands", arr).Msg("Registering commands") + // Unregister commands from server + guildId, _ := strconv.ParseInt(os.Getenv("BOT_TARGET_GUILD"), 10, 64) + commands, err := session.ApplicationCommands(session.State.User.ID, fmt.Sprint(guildId)) + if err != nil { + log.Fatal().Err(err).Msg("Cannot get commands") + } + for _, cmd := range commands { + err := session.ApplicationCommandDelete(session.State.User.ID, fmt.Sprint(guildId), cmd.ID) + if err != nil { + log.Fatal().Err(err).Msg("Cannot delete command") + } + } + // Register commands Register()