diff options
| -rw-r--r-- | bot/exts/moderation/infraction/_utils.py | 13 | ||||
| -rw-r--r-- | bot/exts/moderation/infraction/infractions.py | 9 | 
2 files changed, 16 insertions, 6 deletions
diff --git a/bot/exts/moderation/infraction/_utils.py b/bot/exts/moderation/infraction/_utils.py index adbc641fa..dd427e413 100644 --- a/bot/exts/moderation/infraction/_utils.py +++ b/bot/exts/moderation/infraction/_utils.py @@ -143,15 +143,20 @@ async def get_active_infraction(          # Checks to see if the moderator should be told there is an active infraction          if send_msg:              log.trace(f"{user} has active infractions of type {infr_type}.") -            await ctx.send( -                f":x: According to my records, this user already has a {infr_type} infraction. " -                f"See infraction **#{active_infractions[0]['id']}**." -            ) +            await send_active_infraction_message(ctx, active_infractions[0])          return active_infractions[0]      else:          log.trace(f"{user} does not have active infractions of type {infr_type}.") +async def send_active_infraction_message(ctx: Context, infraction: Infraction) -> None: +    """Send a message stating that the given infraction is active.""" +    await ctx.send( +        f":x: According to my records, this user already has a {infraction['type']} infraction. " +        f"See infraction **#{infraction['id']}**." +    ) + +  async def notify_infraction(          user: UserObject,          infr_type: str, diff --git a/bot/exts/moderation/infraction/infractions.py b/bot/exts/moderation/infraction/infractions.py index f19323c7c..1b1414ec7 100644 --- a/bot/exts/moderation/infraction/infractions.py +++ b/bot/exts/moderation/infraction/infractions.py @@ -280,8 +280,13 @@ class Infractions(InfractionScheduler, commands.Cog):      async def apply_mute(self, ctx: Context, user: Member, reason: t.Optional[str], **kwargs) -> None:          """Apply a mute infraction with kwargs passed to `post_infraction`.""" -        if await _utils.get_active_infraction(ctx, user, "mute"): -            return +        if active := await _utils.get_active_infraction(ctx, user, "mute", send_msg=False): +            if active["actor"] != self.bot.user.id: +                await _utils.send_active_infraction_message(ctx, active) +                return + +            # Let the current mute attempt override an automatically triggered mute. +            await self.deactivate_infraction(active)          infraction = await _utils.post_infraction(ctx, user, "mute", reason, active=True, **kwargs)          if infraction is None:  |