diff --git a/.gitignore b/.gitignore index 360b70b..3fb5444 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ .env -data.json \ No newline at end of file +data.json + +# Building +acecore +*.exe \ No newline at end of file diff --git a/handlers.go b/handlers.go index d8f3b5f..3953806 100644 --- a/handlers.go +++ b/handlers.go @@ -52,6 +52,15 @@ func ready(s *discordgo.Session, event *discordgo.Ready) { fmt.Print("\nSuccessfully started the Bot!") } +func guildCreate(s *discordgo.Session, event *discordgo.GuildCreate) { + for _, command := range commands { + _, err := s.ApplicationCommandCreate(s.State.User.ID, event.Guild.ID, &command.Definition) + if err != nil { + log.Printf("error creating command for guild %s: %v\n", event.Guild.Name, err) + } + } +} + func interactionCreate(s *discordgo.Session, i *discordgo.InteractionCreate) { for _, command := range commands { switch i.Type { diff --git a/main.go b/main.go index dd6dc73..52ac566 100644 --- a/main.go +++ b/main.go @@ -39,6 +39,7 @@ func main() { } bot.Identify.Intents = discordgo.IntentsGuildMessages | discordgo.IntentsGuilds | discordgo.IntentMessageContent | discordgo.IntentGuildMembers bot.AddHandler(ready) + bot.AddHandler(guildCreate) bot.AddHandler(interactionCreate) bot.AddHandler(messageCreate) bot.AddHandler(messageDelete)