Fix logging and handle NotFound exception in Case.edit() (#4975)

This commit is contained in:
jack1142 2021-05-19 18:10:15 +02:00 committed by GitHub
parent 8a7c4aa48c
commit 1c32186d0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -374,8 +374,19 @@ class Case:
except discord.Forbidden: except discord.Forbidden:
log.info( log.info(
"Modlog failed to edit the Discord message for" "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 except Exception: # `finally` with `return` suppresses unexpected exceptions
log.exception( log.exception(
"Modlog failed to edit the Discord message for" "Modlog failed to edit the Discord message for"