diff options
| author | 2021-11-04 15:50:14 +0000 | |
|---|---|---|
| committer | 2021-12-01 01:10:41 +0000 | |
| commit | 0a4ba0b5d6341bc8cef13a30e35af5b4dc24248b (patch) | |
| tree | 7f00ee973b15ddf0a2e994b408d20d5a7258b0ff | |
| parent | Update nomination message regex (diff) | |
Supress NotFound when archiving a nomination
This supresses both the mesage deleteions and the thread archive, so that if they are removed before the code can get to them, it does not raise an error.
Diffstat (limited to '')
| -rw-r--r-- | bot/exts/recruitment/talentpool/_review.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/bot/exts/recruitment/talentpool/_review.py b/bot/exts/recruitment/talentpool/_review.py index 8b61a0eb5..fab126408 100644 --- a/bot/exts/recruitment/talentpool/_review.py +++ b/bot/exts/recruitment/talentpool/_review.py @@ -10,7 +10,7 @@ from typing import List, Optional, Union import arrow from dateutil.parser import isoparse -from discord import Embed, Emoji, Member, Message, NoMoreItems, PartialMessage, TextChannel +from discord import Embed, Emoji, Member, Message, NoMoreItems, NotFound, PartialMessage, TextChannel from discord.ext.commands import Context from bot.api import ResponseCodeError @@ -220,10 +220,13 @@ class Reviewer: if not nomination_thread: log.warning(f"Could not find a thread linked to {message.channel.id}-{message.id}") return - await nomination_thread.edit(archived=True) for message_ in messages: - await message_.delete() + with contextlib.suppress(NotFound): + await message_.delete() + + with contextlib.suppress(NotFound): + await nomination_thread.edit(archived=True) async def _construct_review_body(self, member: Member) -> str: """Formats the body of the nomination, with details of activity, infractions, and previous nominations.""" |