feat: allow reactions to also update the rsvp#7
Conversation
| func reactionUserID(r *discordgo.MessageReaction) string { | ||
| if r == nil { | ||
| return "" | ||
| } | ||
| if r.UserID != "" { | ||
| return r.UserID | ||
| } | ||
| return "" | ||
| } |
There was a problem hiding this comment.
currently this function doesn't do anything, onReactionAdd and onReactionRemove are the only functions that call this and they already do a nil check for r.MessageReaction
| return buf.String(), nil | ||
| } | ||
|
|
||
| func refreshEventMessage(s *discordgo.Session, channelID string) { |
There was a problem hiding this comment.
can we change the implementation of this so that we don't have duplicate db reads from callers
| return "" | ||
| } | ||
| switch emoji.Name { | ||
| case "✅", "white_check_mark", "☑️", "✔️": |
There was a problem hiding this comment.
don't need all these checks, just need the bot to respond to whatever reaction the bot initially adds
| if r == nil || r.MessageReaction == nil { | ||
| return | ||
| } | ||
| userID := reactionUserID(r.MessageReaction) | ||
| if userID == "" && r.Member != nil && r.Member.User != nil { | ||
| userID = r.Member.User.ID | ||
| } | ||
| if userID == "" || userID == s.State.User.ID { | ||
| return | ||
| } |
There was a problem hiding this comment.
i think we can simplify this down to
if r == nil || r.MessageReaction == nil || r.UserID == s.State.User.ID {
return
}
and then just use r.messageReaction.UserID in UpsertResponse
| refreshEventMessage(s, r.ChannelID) | ||
| } | ||
|
|
||
| func onReactionRemove(s *discordgo.Session, r *discordgo.MessageReactionRemove) { |
| return buf.String(), nil | ||
| } | ||
|
|
||
| func refreshEventMessage(s *discordgo.Session, channelID string) { |
There was a problem hiding this comment.
can we also move the location of this somewhere else so render.go stays pure template rendering
Users can RSVP by reacting on the event announcement post, in addition to /rsvp.
I did not test this :^)