package main import ( "context" "fmt" "github.com/disgoorg/disgo" "github.com/disgoorg/disgo/bot" "github.com/disgoorg/disgo/cache" "github.com/disgoorg/disgo/discord" "github.com/disgoorg/disgo/gateway" "github.com/disgoorg/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.SetLevel(log.LevelDebug) log.Info("starting delcombot...") log.Info("disgo version: ", 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.Info(fmt.Sprintf("error deleting guild commands from %v: ", guild.Name), err) } }) if _, err = client.Rest().SetGlobalCommands(client.ApplicationID(), noCommands); err != nil { log.Info("error deleting global commands", err) } if err = client.OpenGateway(context.TODO()); err != nil { log.Fatal("error while connecting to gateway: ", err) } log.Infof("delcombot removed all guild and global commands") }