mirror of
https://github.com/Xevion/banner.git
synced 2025-12-06 05:14:26 -06:00
Manual, temporary guild command unregistration
This commit is contained in:
15
main.go
15
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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user