Milen/reactrole/listener.go

31 lines
693 B
Go

package reactrole
import (
"github.com/bwmarrin/discordgo"
"gitea.teamortix.com/chanbakjsd/Milen/db"
"gitea.teamortix.com/chanbakjsd/Milen/util"
)
func EventAdd(dg *discordgo.Session, r *discordgo.MessageReactionAdd) {
role := db.GetReactRole(r.MessageID, r.Emoji.APIName())
if role == "" {
return
}
err := dg.GuildMemberRoleAdd(r.GuildID, r.UserID, role)
if err != nil {
util.ReportError(dg, err)
}
}
func EventRemove(dg *discordgo.Session, r *discordgo.MessageReactionRemove) {
role := db.GetReactRole(r.MessageID, r.Emoji.APIName())
if role == "" {
return
}
err := dg.GuildMemberRoleRemove(r.GuildID, r.UserID, role)
if err != nil {
util.ReportError(dg, err)
}
}