diff options
| author | 2020-06-12 14:06:12 +0200 | |
|---|---|---|
| committer | 2020-06-12 14:07:28 +0200 | |
| commit | 1f6cd4313c91ed114a1de04de14355648fe88bf9 (patch) | |
| tree | dc7836d13fc1c2d0756b5399a860c6750ce10381 | |
| parent | Incidents: make `on_message` ignore pinned messages (diff) | |
Incidents: only `add_signals` if missing
| -rw-r--r-- | bot/cogs/moderation/incidents.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/bot/cogs/moderation/incidents.py b/bot/cogs/moderation/incidents.py index 1b9d26522..43b1106ad 100644 --- a/bot/cogs/moderation/incidents.py +++ b/bot/cogs/moderation/incidents.py @@ -64,9 +64,17 @@ class Incidents(Cog): @staticmethod async def add_signals(incident: discord.Message) -> None: """Add `Signal` member emoji to `incident` as reactions.""" + existing_reacts = {str(reaction.emoji) for reaction in incident.reactions if reaction.me} + for signal_emoji in Signal: - log.debug(f"Adding reaction: {signal_emoji.value}") - await incident.add_reaction(signal_emoji.value) + + # This will not raise, but it is a superfluous API call that can be avoided + if signal_emoji.value in existing_reacts: + log.debug(f"Skipping emoji as it's already been placed: {signal_emoji}") + + else: + log.debug(f"Adding reaction: {signal_emoji}") + await incident.add_reaction(signal_emoji.value) @Cog.listener() async def on_message(self, message: discord.Message) -> None: |