From e0086aa61d2d9d1c210a2a775dabaffa95c5b552 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sat, 26 Nov 2022 16:37:15 +0000 Subject: Catch case where starter message is deleted before pinning --- bot/exts/help_channels/_channel.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index ffdd1d2bf..25a1bf4d2 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -127,9 +127,11 @@ async def help_post_opened(opened_post: discord.Thread, *, reopen: bool = False) try: await opened_post.starter_message.pin() - except discord.HTTPException as e: + except (discord.HTTPException, AttributeError) as e: # Suppress if the message was not found, most likely deleted - if e.code != 10008: + # The message being deleted could be surfaced as an AttributeError on .starter_message, + # or as an exception from the Discord API, depending on timing and cache status. + if isinstance(e, discord.HTTPException) and e.code != 10008: raise e await send_opened_post_message(opened_post) -- cgit v1.2.3