diff options
| author | 2022-01-21 21:30:41 +0000 | |
|---|---|---|
| committer | 2022-01-25 09:44:09 +0000 | |
| commit | 61d652a32ce23373e67bb0e1cf985dd4ffc99a18 (patch) | |
| tree | f865431f57f9b30ed23fdfe0a47e70759dcf0cf3 | |
| parent | Remove dev-contrib and bot-commands from features list (diff) | |
Rename voice_ban type to voice_mute
This commit changes all of the back-end so that it is in line with the new site API (see this PR https://github.com/python-discord/site/pull/608).
This comes with no changes to commands, or functions definitions.
| -rw-r--r-- | bot/exts/moderation/infraction/_utils.py | 2 | ||||
| -rw-r--r-- | bot/exts/moderation/infraction/infractions.py | 20 | ||||
| -rw-r--r-- | bot/exts/moderation/voice_gate.py | 4 | ||||
| -rw-r--r-- | tests/bot/exts/moderation/infraction/test_infractions.py | 8 | 
4 files changed, 17 insertions, 17 deletions
| diff --git a/bot/exts/moderation/infraction/_utils.py b/bot/exts/moderation/infraction/_utils.py index e683c9db4..4df833ffb 100644 --- a/bot/exts/moderation/infraction/_utils.py +++ b/bot/exts/moderation/infraction/_utils.py @@ -21,7 +21,7 @@ INFRACTION_ICONS = {      "note": (Icons.user_warn, None),      "superstar": (Icons.superstarify, Icons.unsuperstarify),      "warning": (Icons.user_warn, None), -    "voice_ban": (Icons.voice_state_red, Icons.voice_state_green), +    "voice_mute": (Icons.voice_state_red, Icons.voice_state_green),  }  RULES_URL = "https://pythondiscord.com/pages/rules" diff --git a/bot/exts/moderation/infraction/infractions.py b/bot/exts/moderation/infraction/infractions.py index e495a94b3..72e09cbf4 100644 --- a/bot/exts/moderation/infraction/infractions.py +++ b/bot/exts/moderation/infraction/infractions.py @@ -27,7 +27,7 @@ class Infractions(InfractionScheduler, commands.Cog):      category_description = "Server moderation tools."      def __init__(self, bot: Bot): -        super().__init__(bot, supported_infractions={"ban", "kick", "mute", "note", "warning", "voice_ban"}) +        super().__init__(bot, supported_infractions={"ban", "kick", "mute", "note", "warning", "voice_mute"})          self.category = "Moderation"          self._muted_role = discord.Object(constants.Roles.muted) @@ -273,7 +273,7 @@ class Infractions(InfractionScheduler, commands.Cog):      @command(aliases=("uvban",))      async def unvoiceban(self, ctx: Context, user: UnambiguousMemberOrUser) -> None:          """Prematurely end the active voice ban infraction for the user.""" -        await self.pardon_infraction(ctx, "voice_ban", user) +        await self.pardon_infraction(ctx, "voice_mute", user)      # endregion      # region: Base apply functions @@ -397,10 +397,10 @@ class Infractions(InfractionScheduler, commands.Cog):      @respect_role_hierarchy(member_arg=2)      async def apply_voice_ban(self, ctx: Context, user: MemberOrUser, reason: t.Optional[str], **kwargs) -> None:          """Apply a voice ban infraction with kwargs passed to `post_infraction`.""" -        if await _utils.get_active_infraction(ctx, user, "voice_ban"): +        if await _utils.get_active_infraction(ctx, user, "voice_mute"):              return -        infraction = await _utils.post_infraction(ctx, user, "voice_ban", reason, active=True, **kwargs) +        infraction = await _utils.post_infraction(ctx, user, "voice_mute", reason, active=True, **kwargs)          if infraction is None:              return @@ -414,7 +414,7 @@ class Infractions(InfractionScheduler, commands.Cog):              if not isinstance(user, Member):                  return -            await user.move_to(None, reason="Disconnected from voice to apply voiceban.") +            await user.move_to(None, reason="Disconnected from voice to apply voice mute.")              await user.remove_roles(self._voice_verified_role, reason=reason)          await self.apply_infraction(ctx, infraction, user, action()) @@ -487,9 +487,9 @@ class Infractions(InfractionScheduler, commands.Cog):                  # DM user about infraction expiration                  notified = await _utils.notify_pardon(                      user=user, -                    title="Voice ban ended", -                    content="You have been unbanned and can verify yourself again in the server.", -                    icon_url=_utils.INFRACTION_ICONS["voice_ban"][1] +                    title="Voice mute ended", +                    content="You have been unmuted and can verify yourself again in the server.", +                    icon_url=_utils.INFRACTION_ICONS["voice_mute"][1]                  )                  log_text["DM"] = "Sent" if notified else "**Failed**" @@ -514,8 +514,8 @@ class Infractions(InfractionScheduler, commands.Cog):              return await self.pardon_mute(user_id, guild, reason, notify=notify)          elif infraction["type"] == "ban":              return await self.pardon_ban(user_id, guild, reason) -        elif infraction["type"] == "voice_ban": -            return await self.pardon_voice_ban(user_id, guild, notify=notify) +        elif infraction["type"] == "voice_mute": +            return await self.pardon_voice_mute(user_id, guild, notify=notify)      # endregion diff --git a/bot/exts/moderation/voice_gate.py b/bot/exts/moderation/voice_gate.py index a382b13d1..42505b8e7 100644 --- a/bot/exts/moderation/voice_gate.py +++ b/bot/exts/moderation/voice_gate.py @@ -30,7 +30,7 @@ FAILED_MESSAGE = (  MESSAGE_FIELD_MAP = {      "joined_at": f"have been on the server for less than {GateConf.minimum_days_member} days", -    "voice_banned": "have an active voice ban infraction", +    "voice_muted": "have an active voice mute infraction",      "total_messages": f"have sent less than {GateConf.minimum_messages} messages",      "activity_blocks": f"have been active for fewer than {GateConf.minimum_activity_blocks} ten-minute blocks",  } @@ -170,7 +170,7 @@ class VoiceGate(Cog):                  ctx.author.joined_at > arrow.utcnow() - timedelta(days=GateConf.minimum_days_member)              ),              "total_messages": data["total_messages"] < GateConf.minimum_messages, -            "voice_banned": data["voice_banned"], +            "voice_muted": data["voice_muted"],              "activity_blocks": data["activity_blocks"] < GateConf.minimum_activity_blocks,          } diff --git a/tests/bot/exts/moderation/infraction/test_infractions.py b/tests/bot/exts/moderation/infraction/test_infractions.py index 4d01e18a5..a796fd049 100644 --- a/tests/bot/exts/moderation/infraction/test_infractions.py +++ b/tests/bot/exts/moderation/infraction/test_infractions.py @@ -89,7 +89,7 @@ class VoiceBanTests(unittest.IsolatedAsyncioTestCase):          """Should call infraction pardoning function."""          self.cog.pardon_infraction = AsyncMock()          self.assertIsNone(await self.cog.unvoiceban(self.cog, self.ctx, self.user)) -        self.cog.pardon_infraction.assert_awaited_once_with(self.ctx, "voice_ban", self.user) +        self.cog.pardon_infraction.assert_awaited_once_with(self.ctx, "voice_mute", self.user)      @patch("bot.exts.moderation.infraction.infractions._utils.post_infraction")      @patch("bot.exts.moderation.infraction.infractions._utils.get_active_infraction") @@ -97,7 +97,7 @@ class VoiceBanTests(unittest.IsolatedAsyncioTestCase):          """Should return early when user already have Voice Ban infraction."""          get_active_infraction.return_value = {"foo": "bar"}          self.assertIsNone(await self.cog.apply_voice_ban(self.ctx, self.user, "foobar")) -        get_active_infraction.assert_awaited_once_with(self.ctx, self.user, "voice_ban") +        get_active_infraction.assert_awaited_once_with(self.ctx, self.user, "voice_mute")          post_infraction_mock.assert_not_awaited()      @patch("bot.exts.moderation.infraction.infractions._utils.post_infraction") @@ -120,7 +120,7 @@ class VoiceBanTests(unittest.IsolatedAsyncioTestCase):          post_infraction_mock.return_value = None          self.assertIsNone(await self.cog.apply_voice_ban(self.ctx, self.user, "foobar", my_kwarg=23))          post_infraction_mock.assert_awaited_once_with( -            self.ctx, self.user, "voice_ban", "foobar", active=True, my_kwarg=23 +            self.ctx, self.user, "voice_mute", "foobar", active=True, my_kwarg=23          )      @patch("bot.exts.moderation.infraction.infractions._utils.post_infraction") @@ -187,7 +187,7 @@ class VoiceBanTests(unittest.IsolatedAsyncioTestCase):          user = MockUser()          await self.cog.voiceban(self.cog, self.ctx, user, reason=None) -        post_infraction_mock.assert_called_once_with(self.ctx, user, "voice_ban", None, active=True, expires_at=None) +        post_infraction_mock.assert_called_once_with(self.ctx, user, "voice_mute", None, active=True, expires_at=None)          apply_infraction_mock.assert_called_once_with(self.cog, self.ctx, infraction, user, ANY)          # Test action | 
