Skip to content

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

Description

@github-actions

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions