diff options
author | 2022-11-26 14:40:04 +0400 | |
---|---|---|
committer | 2022-11-26 14:40:04 +0400 | |
commit | 555ed4e9195aae7b5af742c59125833ce8b01b4c (patch) | |
tree | 24baa06dbfdb3cb236469f8bf7777835dcb3d01c | |
parent | Catch Failure In Pining Help Starter Message (diff) |
Check If Thread Is Closed In wait_for_deletion
The wait_for_deletion utility would try to remove reactions from a
message after the timeout expires, which would normally be fine. In
threads however, they can be closed while waiting for the timeout to
expire. In such a case, the bot will try to remove the reactions after
the channel has been closed and fail. A special exception was added for
this case to do nothing, since this is only a QoL feature.
Signed-off-by: Hassan Abouelela <[email protected]>
-rw-r--r-- | bot/utils/messages.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/bot/utils/messages.py b/bot/utils/messages.py index a5ed84351..cc7e6dccb 100644 --- a/bot/utils/messages.py +++ b/bot/utils/messages.py @@ -98,7 +98,14 @@ async def wait_for_deletion( try: await bot.instance.wait_for('reaction_add', check=check, timeout=timeout) except asyncio.TimeoutError: - await message.clear_reactions() + try: + await message.clear_reactions() + except discord.HTTPException as e: + if isinstance(message.channel, discord.Thread): + # Threads might not be accessible by the time we try to remove the reaction. + pass + else: + raise e else: await message.delete() except discord.NotFound: |