aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/cogs/moderation/infractions.py11
-rw-r--r--bot/cogs/watchchannels/bigbrother.py23
2 files changed, 21 insertions, 13 deletions
diff --git a/bot/cogs/moderation/infractions.py b/bot/cogs/moderation/infractions.py
index 0545f43bc..c242a3000 100644
--- a/bot/cogs/moderation/infractions.py
+++ b/bot/cogs/moderation/infractions.py
@@ -230,7 +230,11 @@ class Infractions(InfractionScheduler, commands.Cog):
@respect_role_hierarchy()
async def apply_ban(self, ctx: Context, user: UserSnowflake, reason: str, **kwargs) -> None:
- """Apply a ban infraction with kwargs passed to `post_infraction`."""
+ """
+ Apply a ban infraction with kwargs passed to `post_infraction`.
+
+ Will also remove the banned user from the Big Brother watch list if applicable.
+ """
if await utils.has_active_infraction(ctx, user, "ban"):
return
@@ -243,7 +247,6 @@ class Infractions(InfractionScheduler, commands.Cog):
action = ctx.guild.ban(user, reason=reason, delete_message_days=0)
await self.apply_infraction(ctx, infraction, user, action)
- # Remove perma banned users from the 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
@@ -256,9 +259,7 @@ class Infractions(InfractionScheduler, commands.Cog):
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.")
+ await bb_cog.apply_unwatch(ctx, user, bb_reason, send_message=False)
# endregion
# region: Base pardon functions
diff --git a/bot/cogs/watchchannels/bigbrother.py b/bot/cogs/watchchannels/bigbrother.py
index fbc779bcc..903c87f85 100644
--- a/bot/cogs/watchchannels/bigbrother.py
+++ b/bot/cogs/watchchannels/bigbrother.py
@@ -105,7 +105,7 @@ class BigBrother(WatchChannel, Cog, name="Big Brother"):
await ctx.send(msg)
- async def apply_unwatch(self, ctx: Context, user: FetchedMember, reason: str, banned: bool = False) -> None:
+ async def apply_unwatch(self, ctx: Context, user: FetchedMember, reason: str, send_message: bool = True) -> None:
"""
Remove `user` from watched users and mark their infraction as inactive with `reason`.
@@ -130,13 +130,20 @@ 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)
+
+ if not send_message: # Prevents a message being sent to the channel if part of a permanent ban
+ log.debug(f"Perma-banned user {user} was unwatched.")
+ return
+ log.trace("User is not banned. Sending message to channel")
+ message = f":white_check_mark: Messages sent by {user} will no longer be relayed."
+
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.")
+ if not send_message: # Prevents a message being sent to the channel if part of a permanent ban
+ log.debug(f"{user} was not on the watch list; no removal necessary.")
+ return
+ log.trace("User is not perma banned. Send the error message.")
+ message = ":x: The specified user is currently not being watched."
+
+ await ctx.send(message)