Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need a better way to determine if the reaction emoji is one of the poll emojis. ... #85

Open
github-actions bot opened this issue Dec 27, 2021 · 0 comments
Labels

Comments

@github-actions
Copy link

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

// 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

	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)
	}

}

fa898684536c7ebecf70cb38d1b6b0beaeb074f5

@github-actions github-actions bot added the todo label Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants