Milen/commands/commands.go

41 lines
1009 B
Go

package commands
import (
"strings"
"github.com/bwmarrin/discordgo"
"gitea.teamortix.com/chanbakjsd/Milen/db"
"gitea.teamortix.com/chanbakjsd/Milen/humanify"
"gitea.teamortix.com/chanbakjsd/Milen/util"
)
func Event(dg *discordgo.Session, m *discordgo.MessageCreate) {
if !strings.HasPrefix(m.Content, "milen ") {
return
}
split := strings.Split(m.Content, " ")
switch split[1] {
case "autorole":
util.RequireAdmin(dg, m.Author.ID, m.ChannelID, func() {
if len(split) < 6 {
util.SendCheckError(dg, m.ChannelID, humanify.Eng.Usage.Autorole)
return
}
role := util.ParseRole(split[2])
if role == "" {
util.SendCheckError(dg, m.ChannelID, humanify.Eng.Usage.Autorole)
return
}
emoji := util.ParseEmoji(split[5])
db.CreateReactRole(split[4], emoji, role)
err := dg.MessageReactionAdd(split[3], split[4], emoji)
if err != nil {
util.ReportError(dg, err)
return
}
util.SendCheckError(dg, m.ChannelID, humanify.Eng.Autorole.Success)
})
}
}