Currently, for each reaction a message has we are checking all users who reacted to it.
This is extremely slow on messages with many reactions and/or people who reacted to them.
A possible solution could be to cache reactions, however, it could lead to problems if the DB isn't in sync anymore due to manual changes, outages, errors, etc.
|
for existing_reaction in msg.reactions: |
|
if str(existing_reaction.emoji) == reaction: |
|
continue |
|
reaction_users = await existing_reaction.users().flatten() |
|
reaction_users_ids = (reaction_user.id for reaction_user in reaction_users) |
|
if user_id in reaction_users_ids: |
|
await msg.remove_reaction(existing_reaction, user) |
|
# We can safely break since a user can only have one reaction at once |
|
break |
Currently, for each reaction a message has we are checking all users who reacted to it.
This is extremely slow on messages with many reactions and/or people who reacted to them.
A possible solution could be to cache reactions, however, it could lead to problems if the DB isn't in sync anymore due to manual changes, outages, errors, etc.
reaction-light/cogs/roles.py
Lines 79 to 87 in f6445e1