Repository: python-discord/bot

Issue:
Show purgebanned in the feedback message of pban 
Current when a user is banned or purgebanned this feedback message will be sent:
> :incoming_envelope: :ok_hand: applied **ban** to USER permanently.

It would be nice to have `purgeban` instead of `ban` in the message. 

To achieve that, we can add a `purge: True` entry to the `infraction` dictionary in
https://github.com/python-discord/bot/blob/bafa6a9dbf61ae30ef235537408f0b073a88dd19/bot/exts/moderation/infraction/infractions.py#L327

And append `purge` at the beginning of `infr_type` if `infraction.get('purge')` is True
https://github.com/python-discord/bot/blob/bafa6a9dbf61ae30ef235537408f0b073a88dd19/bot/exts/moderation/infraction/_scheduler.py#L237


Discussion:
I'll be yoinking this one.

Resolving patch:
diff --git a/bot/exts/moderation/infraction/_scheduler.py b/bot/exts/moderation/infraction/_scheduler.py
--- a/bot/exts/moderation/infraction/_scheduler.py
+++ b/bot/exts/moderation/infraction/_scheduler.py
@@ -173,6 +173,8 @@ async def apply_infraction(
             total = len(infractions)
             end_msg = f" (#{id_} ; {total} infraction{ngettext('', 's', total)} total)"
 
+        purge = infraction['purge']
+
         # Execute the necessary actions to apply the infraction on Discord.
         if action_coro:
             log.trace(f"Awaiting the infraction #{id_} application action coroutine.")
@@ -210,7 +212,7 @@ async def apply_infraction(
                 log.error(f"Deletion of {infr_type} infraction #{id_} failed with error code {e.status}.")
             infr_message = ""
         else:
-            infr_message = f" **{' '.join(infr_type.split('_'))}** to {user.mention}{expiry_msg}{end_msg}"
+            infr_message = f" **{purge}{' '.join(infr_type.split('_'))}** to {user.mention}{expiry_msg}{end_msg}"
 
         # Send a confirmation message to the invoking context.
         log.trace(f"Sending infraction #{id_} confirmation message.")
@@ -234,7 +236,7 @@ async def apply_infraction(
             footer=f"ID {infraction['id']}"
         )
 
-        log.info(f"Applied {infr_type} infraction #{id_} to {user}.")
+        log.info(f"Applied {purge}{infr_type} infraction #{id_} to {user}.")
         return not failed
 
     async def pardon_infraction(
diff --git a/bot/exts/moderation/infraction/infractions.py b/bot/exts/moderation/infraction/infractions.py
--- a/bot/exts/moderation/infraction/infractions.py
+++ b/bot/exts/moderation/infraction/infractions.py
@@ -318,6 +318,8 @@ async def apply_ban(
         if infraction is None:
             return
 
+        infraction["purge"] = "purge " if purge_days else ""
+
         self.mod_log.ignore(Event.member_remove, user.id)
 
         if reason:


Test patch:
diff --git a/tests/bot/exts/moderation/infraction/test_infractions.py b/tests/bot/exts/moderation/infraction/test_infractions.py
--- a/tests/bot/exts/moderation/infraction/test_infractions.py
+++ b/tests/bot/exts/moderation/infraction/test_infractions.py
@@ -39,7 +39,7 @@ async def test_apply_ban_reason_truncation(self, post_infraction_mock, get_activ
             delete_message_days=0
         )
         self.cog.apply_infraction.assert_awaited_once_with(
-            self.ctx, {"foo": "bar"}, self.target, self.ctx.guild.ban.return_value
+            self.ctx, {"foo": "bar", "purge": ""}, self.target, self.ctx.guild.ban.return_value
         )
 
     @patch("bot.exts.moderation.infraction._utils.post_infraction")