File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
bot/exts/moderation/infraction Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 28
28
29
29
AUTOMATED_TIDY_UP_HOURS = 8
30
30
31
+ # Error when trying to delete a message in an archived thread.
32
+ ARCHIVED_THREAD_ERROR = 50083
31
33
32
34
class InfractionScheduler :
33
35
"""Handles the application, pardoning, and expiration of infractions."""
@@ -122,9 +124,14 @@ async def _delete_infraction_message(
122
124
log .warning (f"Channel or message { message_id } not found in channel { channel_id } ." )
123
125
except discord .Forbidden :
124
126
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
128
135
129
136
await self .messages_to_tidy .delete (f"{ channel_id } :{ message_id } " )
130
137
You can’t perform that action at this time.
0 commit comments