package main import ( "context" "github.com/disgoorg/disgo" "github.com/disgoorg/disgo/bot" "github.com/disgoorg/disgo/cache" "github.com/disgoorg/disgo/discord" "github.com/disgoorg/disgo/gateway" "log" "os" ) var ( token = os.Getenv("disgo_token") noCommands []discord.ApplicationCommandCreate ) // this bot should in theory delete all registered commands for a certain bot func main() { log.Printf("INFO: starting delcombot...") log.Printf("INFO: disgo version: %v", disgo.Version) // permissions: // intent: client, err := disgo.New(token, bot.WithGatewayConfigOpts( gateway.WithIntents(gateway.IntentsNone), ), bot.WithCacheConfigOpts( cache.WithCaches( cache.FlagsNone, ), ), ) if err != nil { log.Fatal("error while building disgo instance: ", err) return } defer client.Close(context.TODO()) client.Caches().GuildsForEach(func(guild discord.Guild) { if _, err = client.Rest().SetGuildCommands(client.ApplicationID(), guild.ID, noCommands); err != nil { log.Printf("INFO: error deleting guild commands from %v: %v", guild.Name, err) } }) if _, err = client.Rest().SetGlobalCommands(client.ApplicationID(), noCommands); err != nil { log.Printf("INFO: error deleting global commands %v", err) } if err = client.OpenGateway(context.TODO()); err != nil { log.Fatal("error while connecting to gateway: ", err) } log.Printf("INFO: delcombot removed all guild and global commands") }