diff options
| author | 2020-12-02 17:55:33 +0200 | |
|---|---|---|
| committer | 2020-12-02 17:55:33 +0200 | |
| commit | 8a2865651556a598b5e96447c6ed4231829c46cf (patch) | |
| tree | 24a7abcf205dba8366500446a8a49a77a66832fc | |
| parent | Merge branch 'master' into bug-fixes (diff) | |
Merge NotFound caching with HttpException caching with status code
| -rw-r--r-- | bot/exts/moderation/infraction/_scheduler.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/bot/exts/moderation/infraction/_scheduler.py b/bot/exts/moderation/infraction/_scheduler.py index 6efa5b1e0..5726a5879 100644 --- a/bot/exts/moderation/infraction/_scheduler.py +++ b/bot/exts/moderation/infraction/_scheduler.py @@ -76,11 +76,9 @@ class InfractionScheduler: # Allowing mod log since this is a passive action that should be logged. try: await apply_coro - except discord.NotFound: - # When user joined and then right after this left again before action completed, this can't add roles - log.info(f"Can't reapply {infraction['type']} to user {infraction['user']} because user left again.") except discord.HTTPException as e: - if e.code == 10007: + # When user joined and then right after this left again before action completed, this can't apply roles + if e.code == 10007 or e.status == 404: log.info(f"Can't reapply {infraction['type']} to user {infraction['user']} because user left again.") else: log.warning( @@ -170,8 +168,6 @@ class InfractionScheduler: if expiry: # Schedule the expiration of the infraction. self.schedule_expiration(infraction) - except discord.NotFound: - log.info(f"Can't apply {infraction['type']} to user {infraction['user']} because user left from guild.") except discord.HTTPException as e: # Accordingly display that applying the infraction failed. # Don't use ctx.message.author; antispam only patches ctx.author. @@ -183,7 +179,7 @@ class InfractionScheduler: log_msg = f"Failed to apply {' '.join(infr_type.split('_'))} infraction #{id_} to {user}" if isinstance(e, discord.Forbidden): log.warning(f"{log_msg}: bot lacks permissions.") - elif e.code == 10007: + elif e.code == 10007 or e.status == 404: log.info( f"Can't apply {infraction['type']} to user {infraction['user']} because user left from guild." ) @@ -358,10 +354,8 @@ class InfractionScheduler: log.warning(f"Failed to deactivate infraction #{id_} ({type_}): bot lacks permissions.") log_text["Failure"] = "The bot lacks permissions to do this (role hierarchy?)" log_content = mod_role.mention - except discord.NotFound: - log.info(f"Can't pardon {infraction['type']} for user {infraction['user']} because user left from guild.") except discord.HTTPException as e: - if e.code == 10007: + if e.code == 10007 or e.status == 404: log.info( f"Can't pardon {infraction['type']} for user {infraction['user']} because user left from guild." ) |