diff options
-rw-r--r-- | bot/exts/holidays/easter/egghead_quiz.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/bot/exts/holidays/easter/egghead_quiz.py b/bot/exts/holidays/easter/egghead_quiz.py index d77ebe01..2e4d1931 100644 --- a/bot/exts/holidays/easter/egghead_quiz.py +++ b/bot/exts/holidays/easter/egghead_quiz.py @@ -119,14 +119,16 @@ class EggheadQuiz(commands.Cog): await ctx.send(content, embed=a_embed) @staticmethod - async def already_reacted(message: discord.Message, user: Union[discord.Member, discord.User]) -> bool: + async def already_reacted(new_reaction: discord.Reaction, user: Union[discord.Member, discord.User]) -> bool: """Returns whether a given user has reacted more than once to a given message.""" - users = [] + message = new_reaction.message for reaction in message.reactions: + if reaction.emoji == new_reaction.emoji: + continue # can't react with same emoji twice so skip 2nd reaction check async for usr in reaction.users(): - users.append(usr.id) - - return users.count(user.id) > 1 # Old reaction plus new reaction + if usr.id == user.id: # user also reacted with the emoji, i.e. has already reacted + return True + return False @commands.Cog.listener() async def on_reaction_add(self, reaction: discord.Reaction, user: Union[discord.Member, discord.User]) -> None: @@ -137,7 +139,7 @@ class EggheadQuiz(commands.Cog): return if str(reaction.emoji) not in self.quiz_messages[reaction.message.id]: return await reaction.message.remove_reaction(reaction, user) - if await self.already_reacted(reaction.message, user): + if await self.already_reacted(reaction, user): return await reaction.message.remove_reaction(reaction, user) |