Skip to content

Commit

Permalink
Merge pull request #118 from python-discord/suppress-404-on-msg-delete
Browse files Browse the repository at this point in the history
Suppress not found errors on reaction clear
  • Loading branch information
jchristgit authored Apr 1, 2024
2 parents 13216f5 + 73809cc commit 4b1a847
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bot/exts/games.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import contextlib
import enum
import random
import textwrap
Expand All @@ -8,6 +9,7 @@

import arrow
import discord
import discord.errors
from async_rediscache import RedisCache
from discord.ext import commands, tasks
from discord.ext.commands import BadArgument
Expand Down Expand Up @@ -150,7 +152,10 @@ async def on_message(self, msg: discord.Message) -> None:

await asyncio.sleep(self.event_uptime)

await msg.clear_reaction(self.chosen_team.value.emoji)
# If the message was deleted in the meantime, the
# reaction is gone either way. Continue with cleanup.
with contextlib.suppress(discord.errors.NotFound):
await msg.clear_reaction(self.chosen_team.value.emoji)
self.team_game_message_id = self.chosen_team = None
self.team_game_users_already_reacted.clear()

Expand Down

0 comments on commit 4b1a847

Please sign in to comment.