need a better way to determine if the reaction emoji is one of the poll emojis. This code does not consider that the question itself may contain an emoji and that emoji would be allowed to be used in the reactions
command.Handler(session, message, channel, b)
}
func (b *Bot) messageReactionAdd(session *discordgo.Session, message *discordgo.MessageReactionAdd) {
// Ignore all messages created by the bot itself
// This isn't required in this specific example but it's a good practice.
if message.UserID == session.State.User.ID {
return
}
msg, err := channelMessageF(session, message.ChannelID, message.MessageID)
if err != nil {
infra.Logger.Error().Err(err).Msg("get channel message")
return
}
if !strings.HasPrefix(msg.Content, pollPrefix) {
return
}
// remove emoji if not one of poll emojis
// TODO: need a better way to determine if the reaction emoji is one of the poll emojis. This code does not consider that the question itself may contain an emoji and that emoji would be allowed to be used in the reactions
if !strings.Contains(msg.Content, message.Emoji.Name) {
_ = messageReactionRemoveF(session, message.ChannelID, message.MessageID, message.Emoji.Name, message.UserID)
return
}
for _, reaction := range msg.Reactions {
if reaction.Emoji.Name == message.MessageReaction.Emoji.Name {
continue
}
_ = messageReactionRemoveF(session, message.ChannelID, message.MessageID, reaction.Emoji.Name, message.UserID)
}
}
need a better way to determine if the reaction emoji is one of the poll emojis. This code does not consider that the question itself may contain an emoji and that emoji would be allowed to be used in the reactions
https://github.com/osbytes/devy/blob/d862e31f8a476685d28a44227c3473fe4a30708d/internal/devy/handlers.go#L88
fa898684536c7ebecf70cb38d1b6b0beaeb074f5