40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package commands
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
|
|
"gitea.teamortix.com/chanbakjsd/Milen/db"
|
|
"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, "❌ Incorrect usage. Usage: `milen autorole <role> <channel> <message> <emoji>`")
|
|
return
|
|
}
|
|
role := util.ParseRole(split[2])
|
|
if role == "" {
|
|
util.SendCheckError(dg, m.ChannelID, "❌ Incorrect usage. Usage: `milen autorole <role> <channel> <message> <emoji>`")
|
|
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, "✅ Auto-role registered.")
|
|
})
|
|
}
|
|
}
|