2024-08-01 20:37:18 +09:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
2024-08-17 16:54:14 +09:00
|
|
|
"strings"
|
|
|
|
|
2024-08-01 20:37:18 +09:00
|
|
|
"github.com/bwmarrin/discordgo"
|
2025-03-19 21:21:39 +09:00
|
|
|
"gitlab.wh64.net/muffin/goMuffin/commands"
|
2024-10-09 22:11:03 +09:00
|
|
|
"gitlab.wh64.net/muffin/goMuffin/configs"
|
2024-08-01 20:37:18 +09:00
|
|
|
)
|
|
|
|
|
2024-08-17 16:54:14 +09:00
|
|
|
// MessageCreate is handlers of messageCreate event
|
2024-08-01 20:37:18 +09:00
|
|
|
func MessageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
2024-10-09 21:08:17 +09:00
|
|
|
config := configs.Config
|
2024-08-01 20:37:18 +09:00
|
|
|
if m.Author.ID == s.State.User.ID && m.Author.Bot {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-10-09 21:08:17 +09:00
|
|
|
if strings.HasPrefix(m.Content, config.Prefix) {
|
|
|
|
content := strings.TrimPrefix(m.Content, config.Prefix)
|
2025-03-19 21:21:39 +09:00
|
|
|
command := commands.Discommand.Aliases[content]
|
|
|
|
|
|
|
|
if command == "" {
|
|
|
|
return
|
2024-08-17 16:54:14 +09:00
|
|
|
}
|
2025-03-19 21:21:39 +09:00
|
|
|
|
|
|
|
commands.Discommand.MessageRun(command, s, m)
|
2024-08-17 16:54:14 +09:00
|
|
|
} else {
|
|
|
|
return
|
2024-08-01 20:37:18 +09:00
|
|
|
}
|
|
|
|
}
|