aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/cogs/moderation/infractions.py13
-rw-r--r--bot/cogs/watchchannels/bigbrother.py22
2 files changed, 28 insertions, 7 deletions
diff --git a/bot/cogs/moderation/infractions.py b/bot/cogs/moderation/infractions.py
index 9ea17b2b3..9bab38e23 100644
--- a/bot/cogs/moderation/infractions.py
+++ b/bot/cogs/moderation/infractions.py
@@ -67,7 +67,7 @@ class Infractions(InfractionScheduler, commands.Cog):
@command()
async def ban(self, ctx: Context, user: FetchedMember, *, reason: str = None) -> None:
- """Permanently ban a user for the given reason."""
+ """Permanently ban a user for the given reason. Also removes them from the BigBrother watch list."""
await self.apply_ban(ctx, user, reason)
# endregion
@@ -243,6 +243,17 @@ 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 'expires_at' not in kwargs:
+ bb_cog = self.bot.get_cog("BigBrother")
+ if bb_cog:
+ await bb_cog.apply_unwatch(
+ ctx,
+ user,
+ "User has been permanently banned from the server. Automatically removed.",
+ banned=True
+ )
+
# endregion
# region: Base pardon functions
diff --git a/bot/cogs/watchchannels/bigbrother.py b/bot/cogs/watchchannels/bigbrother.py
index c601e0d4d..75b66839e 100644
--- a/bot/cogs/watchchannels/bigbrother.py
+++ b/bot/cogs/watchchannels/bigbrother.py
@@ -52,6 +52,16 @@ class BigBrother(WatchChannel, Cog, name="Big Brother"):
A `reason` for adding the user to Big Brother is required and will be displayed
in the header when relaying messages of this user to the watchchannel.
"""
+ await self.apply_watch(ctx, user, reason)
+
+ @bigbrother_group.command(name='unwatch', aliases=('uw',))
+ @with_role(*MODERATION_ROLES)
+ async def unwatch_command(self, ctx: Context, user: FetchedMember, *, reason: str) -> None:
+ """Stop relaying messages by the given `user`."""
+ await self.apply_unwatch(ctx, user, reason)
+
+ async def apply_watch(self, ctx: Context, user: FetchedMember, reason: str) -> None:
+ """Handles adding a user to the watch list."""
if user.bot:
await ctx.send(f":x: I'm sorry {ctx.author}, I'm afraid I can't do that. I only watch humans.")
return
@@ -90,10 +100,8 @@ class BigBrother(WatchChannel, Cog, name="Big Brother"):
await ctx.send(msg)
- @bigbrother_group.command(name='unwatch', aliases=('uw',))
- @with_role(*MODERATION_ROLES)
- async def unwatch_command(self, ctx: Context, user: FetchedMember, *, reason: str) -> None:
- """Stop relaying messages by the given `user`."""
+ async def apply_unwatch(self, ctx: Context, user: FetchedMember, reason: str, banned: bool = False) -> None:
+ """Handles the actual user removal from the watch list."""
active_watches = await self.bot.api_client.get(
self.api_endpoint,
params=ChainMap(
@@ -111,8 +119,10 @@ class BigBrother(WatchChannel, Cog, name="Big Brother"):
await post_infraction(ctx, user, 'watch', f"Unwatched: {reason}", hidden=True, active=False)
- await ctx.send(f":white_check_mark: Messages sent by {user} will no longer be relayed.")
+ if not banned: # Prevents a message being sent to the channel if part of a permanent ban
+ await ctx.send(f":white_check_mark: Messages sent by {user} will no longer be relayed.")
self._remove_user(user.id)
else:
- await ctx.send(":x: The specified user is currently not being watched.")
+ if not banned: # Prevents a message being sent to the channel if part of a permanent ban
+ await ctx.send(":x: The specified user is currently not being watched.")