make command global
This commit is contained in:
parent
ac3d3c204b
commit
2a3ec00b58
2 changed files with 29 additions and 7 deletions
|
@ -12,8 +12,8 @@
|
|||
- and a group called `Apple` and `Apple Core`
|
||||
- the bot group needs to be above `Apple`
|
||||
- [funbot](./cmd/funbot/main.go) sends funny and cute pictures
|
||||
- needs env `disgo_token`, `disgo_guild_id` and `disgo_imgur`
|
||||
- TODO: make global and remove `disgo_guild_id`
|
||||
- needs env `disgo_token` and `disgo_imgur`
|
||||
- if `disgo_global` is not TRUE, `disgo_guild_id` is needed
|
||||
- TODO: add other apis
|
||||
- [dealsbot](./cmd/dealsbot/main.go) send deals from steam, epic and more
|
||||
- needs env `disgo_token`, `disgo_guild_id`
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
var (
|
||||
token = os.Getenv("disgo_token")
|
||||
apiImgurKey = os.Getenv("disgo_imgur")
|
||||
globalComandsEnv = os.Getenv("disgo_global")
|
||||
registerGuildID = snowflake.GetEnv("disgo_guild_id")
|
||||
|
||||
// TODO: add jokes
|
||||
|
@ -83,6 +84,8 @@ var (
|
|||
},
|
||||
},
|
||||
}
|
||||
|
||||
noCommands []discord.ApplicationCommandCreate
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -110,9 +113,28 @@ func main() {
|
|||
|
||||
defer client.Close(context.TODO())
|
||||
|
||||
var globalComands bool
|
||||
if strings.ToUpper(globalComandsEnv) == "TRUE" {
|
||||
globalComands = true
|
||||
}
|
||||
|
||||
if globalComands {
|
||||
if _, err = client.Rest().SetGlobalCommands(client.ApplicationID(), commands); err != nil {
|
||||
log.Fatal("error while registering commands: ", err)
|
||||
}
|
||||
if registerGuildID != 0 {
|
||||
if _, err = client.Rest().SetGuildCommands(client.ApplicationID(), registerGuildID, noCommands); err != nil {
|
||||
log.Info("error deleting guild commands", err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if _, err = client.Rest().SetGuildCommands(client.ApplicationID(), registerGuildID, commands); err != nil {
|
||||
log.Fatal("error while registering commands: ", 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)
|
||||
|
|
Loading…
Reference in a new issue