File tree Expand file tree Collapse file tree
bot/exts/moderation/infraction Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828
2929AUTOMATED_TIDY_UP_HOURS = 8
3030
31+ # Error when trying to delete a message in an archived thread.
32+ ARCHIVED_THREAD_ERROR = 50083
3133
3234class InfractionScheduler :
3335 """Handles the application, pardoning, and expiration of infractions."""
@@ -122,9 +124,14 @@ async def _delete_infraction_message(
122124 log .warning (f"Channel or message { message_id } not found in channel { channel_id } ." )
123125 except discord .Forbidden :
124126 log .info (f"Bot lacks permissions to delete message { message_id } in channel { channel_id } ." )
125- except discord .HTTPException :
126- log .exception (f"Issue during scheduled deletion of message { message_id } in channel { channel_id } ." )
127- return # Keep the task in Redis on HTTP errors
127+ except discord .HTTPException as e :
128+ if e .code == ARCHIVED_THREAD_ERROR :
129+ log .info (
130+ f"Cannot delete message { message_id } in channel { channel_id } because the thread is archived."
131+ )
132+ else :
133+ log .exception (f"Issue during scheduled deletion of message { message_id } in channel { channel_id } ." )
134+ return # Keep the task in Redis on HTTP errors
128135
129136 await self .messages_to_tidy .delete (f"{ channel_id } :{ message_id } " )
130137
You can’t perform that action at this time.
0 commit comments