aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2020-05-30 09:53:38 +0300
committerGravatar ks129 <[email protected]>2020-05-30 09:53:38 +0300
commitf42ddf64abfd487fd69eec275d1011112eb76166 (patch)
treea7221e355cc6b893504e2a7c8f09ae655a1ae904
parentScheduler: Remove invalid comment (diff)
Scheduler: Add try-except to infraction deletion
-rw-r--r--bot/cogs/moderation/scheduler.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/bot/cogs/moderation/scheduler.py b/bot/cogs/moderation/scheduler.py
index 7e8455740..dcc0001f8 100644
--- a/bot/cogs/moderation/scheduler.py
+++ b/bot/cogs/moderation/scheduler.py
@@ -172,7 +172,12 @@ class InfractionScheduler(Scheduler):
dm_log_text = "\nDM: **Canceled**"
dm_result = f"{constants.Emojis.failmail} "
log.trace(f"Deleted infraction {infraction['id']} from database because applying infraction failed.")
- await self.bot.api_client.delete(f"bot/infractions/{infraction['id']}")
+ try:
+ await self.bot.api_client.delete(f"bot/infractions/{id_}")
+ except ResponseCodeError as e:
+ confirm_msg += f" and failed to delete"
+ log_title += " and failed to delete"
+ log.error(f"Deletion of {infr_type} infraction #{id_} failed with error code {e.status}.")
infr_message = ""
else:
infr_message = f"**{infr_type}** to {user.mention}{expiry_msg}{end_msg}"