|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
package reactrole
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
|
|
|
|
|
|
|
|
"gitea.teamortix.com/chanbakjsd/Milen/db"
|
|
|
|
@ -8,6 +10,17 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func EventAdd(dg *discordgo.Session, r *discordgo.MessageReactionAdd) {
|
|
|
|
|
defer func() {
|
|
|
|
|
if r := recover(); r != nil {
|
|
|
|
|
// Oh crap. We recovered from a panic.
|
|
|
|
|
if val, ok := r.(error); ok {
|
|
|
|
|
util.ReportError(dg, val)
|
|
|
|
|
} else {
|
|
|
|
|
util.ReportError(dg, fmt.Errorf("%T: %v", r, r))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
member, err := util.GetMember(dg, r.GuildID, r.UserID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
util.ReportError(dg, err)
|
|
|
|
@ -27,6 +40,17 @@ func EventAdd(dg *discordgo.Session, r *discordgo.MessageReactionAdd) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func EventRemove(dg *discordgo.Session, r *discordgo.MessageReactionRemove) {
|
|
|
|
|
defer func() {
|
|
|
|
|
if r := recover(); r != nil {
|
|
|
|
|
// Oh crap. We recovered from a panic.
|
|
|
|
|
if val, ok := r.(error); ok {
|
|
|
|
|
util.ReportError(dg, val)
|
|
|
|
|
} else {
|
|
|
|
|
util.ReportError(dg, fmt.Errorf("%T: %v", r, r))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
member, err := util.GetMember(dg, r.GuildID, r.UserID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
util.ReportError(dg, err)
|
|
|
|
|