diff options
| author | 2020-10-10 09:05:00 +0300 | |
|---|---|---|
| committer | 2020-10-10 09:05:00 +0300 | |
| commit | 8ed147c402a3a6b5e98b29c3ed385460f3216efd (patch) | |
| tree | 8dc3646042646121c189179e3ecdc78b29f56d42 | |
| parent | Use done callback instead of plain try-except inside function (diff) | |
Catch HTTPException when muting user
| -rw-r--r-- | bot/exts/moderation/infraction/infractions.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/bot/exts/moderation/infraction/infractions.py b/bot/exts/moderation/infraction/infractions.py index ccddd4530..b638f4dc6 100644 --- a/bot/exts/moderation/infraction/infractions.py +++ b/bot/exts/moderation/infraction/infractions.py @@ -242,8 +242,13 @@ class Infractions(InfractionScheduler, commands.Cog): async def action() -> None: try: await user.add_roles(self._muted_role, reason=reason) - except discord.NotFound: - log.info(f"User {user} ({user.id}) left from guild. Can't give Muted role.") + except discord.HTTPException as e: + if e.code == 10007: + log.info(f"User {user} ({user.id}) left from guild. Can't give Muted role.") + else: + log.warning( + f"Got response {e.code} (HTTP {e.status}) while giving muted role to {user} ({user.id})." + ) else: log.trace(f"Attempting to kick {user} from voice because they've been muted.") await user.move_to(None, reason=reason) |