i thought i already added that event handler lol

This commit is contained in:
2024-03-12 10:01:06 +01:00
parent 0e921bbb9f
commit ce6df116fd
3 changed files with 15 additions and 1 deletions

4
.gitignore vendored
View File

@@ -1,2 +1,6 @@
.env .env
data.json data.json
# Building
acecore
*.exe

View File

@@ -52,6 +52,15 @@ func ready(s *discordgo.Session, event *discordgo.Ready) {
fmt.Print("\nSuccessfully started the Bot!") 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) { func interactionCreate(s *discordgo.Session, i *discordgo.InteractionCreate) {
for _, command := range commands { for _, command := range commands {
switch i.Type { switch i.Type {

View File

@@ -39,6 +39,7 @@ func main() {
} }
bot.Identify.Intents = discordgo.IntentsGuildMessages | discordgo.IntentsGuilds | discordgo.IntentMessageContent | discordgo.IntentGuildMembers bot.Identify.Intents = discordgo.IntentsGuildMessages | discordgo.IntentsGuilds | discordgo.IntentMessageContent | discordgo.IntentGuildMembers
bot.AddHandler(ready) bot.AddHandler(ready)
bot.AddHandler(guildCreate)
bot.AddHandler(interactionCreate) bot.AddHandler(interactionCreate)
bot.AddHandler(messageCreate) bot.AddHandler(messageCreate)
bot.AddHandler(messageDelete) bot.AddHandler(messageDelete)