diff options
author | 2025-06-25 19:06:26 +0100 | |
---|---|---|
committer | 2025-06-25 19:06:26 +0100 | |
commit | bf9e84ff637087dd34707d8b75b6851f18e6e4f5 (patch) | |
tree | b56ce5f10fd8dd67074312ce45a83d686e92d991 | |
parent | Merge pull request #3340 from python-discord/jb3/mod-changes-refactor (diff) |
Gracefully handle attempting tidy-up in archived thread
-rw-r--r-- | bot/exts/moderation/infraction/_scheduler.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/bot/exts/moderation/infraction/_scheduler.py b/bot/exts/moderation/infraction/_scheduler.py index 63f47b7de..93d435556 100644 --- a/bot/exts/moderation/infraction/_scheduler.py +++ b/bot/exts/moderation/infraction/_scheduler.py @@ -28,6 +28,8 @@ log = get_logger(__name__) AUTOMATED_TIDY_UP_HOURS = 8 +# Error when trying to delete a message in an archived thread. +ARCHIVED_THREAD_ERROR = 50083 class InfractionScheduler: """Handles the application, pardoning, and expiration of infractions.""" @@ -122,9 +124,14 @@ class InfractionScheduler: log.warning(f"Channel or message {message_id} not found in channel {channel_id}.") except discord.Forbidden: log.info(f"Bot lacks permissions to delete message {message_id} in channel {channel_id}.") - except discord.HTTPException: - log.exception(f"Issue during scheduled deletion of message {message_id} in channel {channel_id}.") - return # Keep the task in Redis on HTTP errors + except discord.HTTPException as e: + if e.code == ARCHIVED_THREAD_ERROR: + log.info( + f"Cannot delete message {message_id} in channel {channel_id} because the thread is archived." + ) + else: + log.exception(f"Issue during scheduled deletion of message {message_id} in channel {channel_id}.") + return # Keep the task in Redis on HTTP errors await self.messages_to_tidy.delete(f"{channel_id}:{message_id}") |