diff options
| author | 2020-03-16 13:23:04 -0500 | |
|---|---|---|
| committer | 2020-03-16 13:23:04 -0500 | |
| commit | e32d89ebd1df005046ca2a2a10e413d0a57cd453 (patch) | |
| tree | e5d98a44cb69d1d785bc14ae2e090da2968b8ef9 | |
| parent | Update bot/cogs/moderation/infractions.py (diff) | |
Nesting reduced, logging cleaned up and made clearer
Co-Authored-By: Mark <[email protected]>
Diffstat (limited to '')
| -rw-r--r-- | bot/cogs/moderation/infractions.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/bot/cogs/moderation/infractions.py b/bot/cogs/moderation/infractions.py index f68f8ba9a..0545f43bc 100644 --- a/bot/cogs/moderation/infractions.py +++ b/bot/cogs/moderation/infractions.py @@ -244,18 +244,21 @@ class Infractions(InfractionScheduler, commands.Cog): await self.apply_infraction(ctx, infraction, user, action) # Remove perma banned users from the watch list - if infraction.get('expires_at') is None: - log.trace("Ban was a permanent one. Attempt to remove from watched list.") - bb_cog = self.bot.get_cog("Big Brother") - if bb_cog: - log.trace("Cog loaded. Attempting to remove from list.") - await bb_cog.apply_unwatch( - ctx, - user, - "User has been permanently banned from the server. Automatically removed.", - banned=True - ) - log.debug("Perma banned user removed from watch list.") + if infraction.get('expires_at') is not None: + log.trace(f"Ban isn't permanent; user {user} won't be unwatched by Big Brother.") + return + + bb_cog = self.bot.get_cog("Big Brother") + if not bb_cog: + log.trace(f"Big Brother cog not loaded; perma-banned user {user} won't be unwatched.") + return + + log.trace(f"Big Brother cog loaded; attempting to unwatch perma-banned user {user}.") + + bb_reason = "User has been permanently banned from the server. Automatically removed." + await bb_cog.apply_unwatch(ctx, user, bb_reason banned=True) + + log.debug(f"Perma-banned user {user} was unwatched.") # endregion # region: Base pardon functions |