aboutsummaryrefslogtreecommitdiff
path: root/handlers/interactionCreateHandler.go
blob: 2d9e0e73ef2b51209c9811168ef7541f9c541665 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package handlers

import (
	"fmt"
	"yuzaki/commands/admin"

	"github.com/bwmarrin/discordgo"
)

var (
	SlashCommandHandlers = map[string]func(s *discordgo.Session, i *discordgo.InteractionCreate){
		"purge": admin.PurgeChat,
	}
)

func InteractionCreateHandler(s *discordgo.Session, interaction *discordgo.InteractionCreate) {
	switch interaction.Type {
	case discordgo.InteractionApplicationCommand:
		if handler, ok := SlashCommandHandlers[interaction.ApplicationCommandData().Name]; ok {
			handler(s, interaction)
		}
	case discordgo.InteractionMessageComponent:
		// Detect what type of message component interaction it is.
		switch interaction.MessageComponentData().ComponentType {
		case discordgo.ButtonComponent:
			fmt.Println("Button interaction detected.")
		case discordgo.SelectMenuComponent:
			fmt.Println("Select menu interaction detected.")
		default:
			fmt.Println("Unknown message component interaction detected.")
		}
	}
}