aboutsummaryrefslogtreecommitdiff
path: root/handlers
diff options
context:
space:
mode:
authorBobby <[email protected]>2024-11-16 16:21:51 -0500
committerBobby <[email protected]>2024-11-16 16:21:51 -0500
commit2e79b5aa8cfe8433bcd9d1d415826056fea8fcb2 (patch)
treee9a8e4fe1f8dfc598f68f3a2c1909fa381f46961 /handlers
parentc7e9ca772b03c2edc3a1893e9c9ac2eeba90acfa (diff)
downloadyuzaki-2e79b5aa8cfe8433bcd9d1d415826056fea8fcb2.tar.xz
yuzaki-2e79b5aa8cfe8433bcd9d1d415826056fea8fcb2.zip
bot setup with basic message handler
Diffstat (limited to 'handlers')
-rw-r--r--handlers/messageGatewayHandler.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/handlers/messageGatewayHandler.go b/handlers/messageGatewayHandler.go
new file mode 100644
index 0000000..a6ec4d7
--- /dev/null
+++ b/handlers/messageGatewayHandler.go
@@ -0,0 +1,18 @@
+package handlers
+
+import (
+ "strings"
+
+ "github.com/bwmarrin/discordgo"
+)
+
+func MessageGatewayHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
+ if m.Author.ID == s.State.User.ID || m.Author.Bot {
+ return
+ }
+
+ // if says "hello @bot" <- case insensitive <- bot responds with "Hello @user!"
+ if strings.EqualFold(strings.TrimSpace(m.Content), "hello "+s.State.User.Mention()) {
+ s.ChannelMessageSendReply(m.ChannelID, "Hello "+m.Author.Mention()+"!", m.Reference())
+ }
+}