diff options
| author | 2020-03-12 13:30:41 -0500 | |
|---|---|---|
| committer | 2020-03-12 13:30:41 -0500 | |
| commit | 96639bca024f5b22b7e44b59de0d75aebe9c7f20 (patch) | |
| tree | 632820c2b038ba1f36b0f50329e8d8c37e45b09c | |
| parent | Merge remote-tracking branch 'origin/hemlock-perma-ban-watch-removal' into he... (diff) | |
Corrected expiration check logic and cog loading
Bugs fixed:
- Previously, the code would check to see if `'expires_at'` was in the kwargs, which after testing I came to find out that it is regardless of the duration of the ban. It has sense been changed to use a `.get()` in order to do a proper comparison.
- Code previously attempted to load from the `"BigBrother"` cog which is the incorrect spelling. Changed it to `"Big Brother"` to correct this.
Logging Added:
- Additional trace logs added to both the `infractions.py` file as well as `bigbrother.py` to assist with future debugging or testing.
Signed-off-by: Daniel Brown <[email protected]>
| -rw-r--r-- | bot/cogs/moderation/infractions.py | 7 | ||||
| -rw-r--r-- | bot/cogs/watchchannels/bigbrother.py | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/bot/cogs/moderation/infractions.py b/bot/cogs/moderation/infractions.py index 9bab38e23..3ea185d29 100644 --- a/bot/cogs/moderation/infractions.py +++ b/bot/cogs/moderation/infractions.py @@ -244,15 +244,18 @@ class Infractions(InfractionScheduler, commands.Cog): await self.apply_infraction(ctx, infraction, user, action) # Remove perma banned users from the watch list - if 'expires_at' not in kwargs: - bb_cog = self.bot.get_cog("BigBrother") + 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.") # endregion # region: Base pardon functions diff --git a/bot/cogs/watchchannels/bigbrother.py b/bot/cogs/watchchannels/bigbrother.py index 75b66839e..caae793bb 100644 --- a/bot/cogs/watchchannels/bigbrother.py +++ b/bot/cogs/watchchannels/bigbrother.py @@ -110,6 +110,7 @@ class BigBrother(WatchChannel, Cog, name="Big Brother"): ) ) if active_watches: + log.trace("Active watches for user found. Attempting to remove.") [infraction] = active_watches await self.bot.api_client.patch( @@ -120,9 +121,12 @@ class BigBrother(WatchChannel, Cog, name="Big Brother"): await post_infraction(ctx, user, 'watch', f"Unwatched: {reason}", hidden=True, active=False) if not banned: # Prevents a message being sent to the channel if part of a permanent ban + log.trace("User is not banned. Sending message to channel") await ctx.send(f":white_check_mark: Messages sent by {user} will no longer be relayed.") self._remove_user(user.id) else: + log.trace("No active watches found for user.") if not banned: # Prevents a message being sent to the channel if part of a permanent ban + log.trace("User is not perma banned. Send the error message.") await ctx.send(":x: The specified user is currently not being watched.") |