aboutsummaryrefslogtreecommitdiff
path: root/handlers
diff options
context:
space:
mode:
authorBobby <[email protected]>2024-11-16 21:51:29 -0500
committerBobby <[email protected]>2024-11-16 21:51:29 -0500
commitf393ac1cf42a827196318c3a119a61adf1b3d14c (patch)
treed4de5f98d9c39f00b35ca4a9daa63386a0065291 /handlers
parent2cb6be7cf2c5ae6c583678c0675188fc327bc10b (diff)
downloadyuzaki-f393ac1cf42a827196318c3a119a61adf1b3d14c.tar.xz
yuzaki-f393ac1cf42a827196318c3a119a61adf1b3d14c.zip
added purge command
Diffstat (limited to 'handlers')
-rw-r--r--handlers/interactionCreateHandler.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/handlers/interactionCreateHandler.go b/handlers/interactionCreateHandler.go
new file mode 100644
index 0000000..2d9e0e7
--- /dev/null
+++ b/handlers/interactionCreateHandler.go
@@ -0,0 +1,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.")
+ }
+ }
+}