package commands import ( "github.com/bwmarrin/discordgo" "gitea.teamortix.com/chanbakjsd/Milen/db" "gitea.teamortix.com/chanbakjsd/Milen/util" ) func handleAutorole(dg *discordgo.Session, m *discordgo.MessageCreate, arguments []string) { if !util.HasAdmin(dg, m.Author.ID, m.ChannelID) { util.SendErrorEmbed(dg, m.ChannelID, util.ErrRequireAdmin) return } parsedMessageLink, err := util.ParseMessageLink(arguments[0]) if err != nil { util.SendErrorEmbed(dg, m.ChannelID, err) return } emoji, err := util.ParseEmoji(arguments[1]) if err != nil { util.SendErrorEmbed(dg, m.ChannelID, err) return } role, err := util.ParseRole(arguments[2]) if err != nil { util.SendErrorEmbed(dg, m.ChannelID, err) return } db.CreateReactRole(parsedMessageLink.MessageID, emoji, role) err = dg.MessageReactionAdd(parsedMessageLink.ChannelID, parsedMessageLink.MessageID, emoji) if err != nil { util.ReportError(dg, err) return } util.SendSuccessEmbed(dg, m.ChannelID, "Autorole has been registered successfully.") }