Manual, temporary guild command unregistration

This commit is contained in:
2024-01-04 09:21:16 -06:00
parent 44d5e533f3
commit ee67cc1e2c

15
main.go
View File

@@ -2,10 +2,12 @@ package main
import ( import (
"context" "context"
"fmt"
"net/http" "net/http"
"net/http/cookiejar" "net/http/cookiejar"
"os" "os"
"os/signal" "os/signal"
"strconv"
"syscall" "syscall"
"time" "time"
_ "time/tzdata" _ "time/tzdata"
@@ -155,6 +157,19 @@ func main() {
}) })
log.Info().Array("commands", arr).Msg("Registering commands") 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 commands
Register() Register()