From 1c32186d0b213c5fd90ea83586706eb260661750 Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Wed, 19 May 2021 18:10:15 +0200 Subject: [PATCH] Fix logging and handle NotFound exception in Case.edit() (#4975) --- redbot/core/modlog.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/redbot/core/modlog.py b/redbot/core/modlog.py index 6e2e4f10a..e2cdaefa9 100644 --- a/redbot/core/modlog.py +++ b/redbot/core/modlog.py @@ -374,8 +374,19 @@ class Case: except discord.Forbidden: log.info( "Modlog failed to edit the Discord message for" - " the case #%s from guild with ID due to missing permissions." + " the case #%s from guild with ID %s due to missing permissions.", + self.case_number, + self.guild.id, ) + except discord.NotFound: + log.info( + "Modlog failed to edit the Discord message for" + " the case #%s from guild with ID %s as it no longer exists." + " Clearing the message ID from case data...", + self.case_number, + self.guild.id, + ) + await self.edit({"message": None}) except Exception: # `finally` with `return` suppresses unexpected exceptions log.exception( "Modlog failed to edit the Discord message for"