diff options
Diffstat (limited to '')
| -rw-r--r-- | bot/exts/moderation/infraction/_utils.py | 46 | ||||
| -rw-r--r-- | tests/bot/exts/moderation/infraction/test_utils.py | 12 | 
2 files changed, 32 insertions, 26 deletions
diff --git a/bot/exts/moderation/infraction/_utils.py b/bot/exts/moderation/infraction/_utils.py index e766c1e5c..a98b4828b 100644 --- a/bot/exts/moderation/infraction/_utils.py +++ b/bot/exts/moderation/infraction/_utils.py @@ -22,7 +22,6 @@ INFRACTION_ICONS = {      "voice_ban": (Icons.voice_state_red, Icons.voice_state_green),  }  RULES_URL = "https://pythondiscord.com/pages/rules" -APPEALABLE_INFRACTIONS = ("ban", "mute", "voice_ban")  # Type aliases  UserObject = t.Union[discord.Member, discord.User] @@ -31,8 +30,12 @@ Infraction = t.Dict[str, t.Union[str, int, bool]]  APPEAL_EMAIL = "[email protected]" -INFRACTION_TITLE = f"Please review our rules over at {RULES_URL}" -INFRACTION_APPEAL_FOOTER = f"To appeal this infraction, send an e-mail to {APPEAL_EMAIL}" +INFRACTION_TITLE = "Please review our rules" +INFRACTION_APPEAL_EMAIL_FOOTER = f"To appeal this infraction, send an e-mail to {APPEAL_EMAIL}" +INFRACTION_APPEAL_MODMAIL_FOOTER = ( +    'If you would like to discuss or appeal this infraction, ' +    'send a message to the ModMail bot' +)  INFRACTION_AUTHOR_NAME = "Infraction information"  INFRACTION_DESCRIPTION_TEMPLATE = ( @@ -71,13 +74,13 @@ async def post_user(ctx: Context, user: UserSnowflake) -> t.Optional[dict]:  async def post_infraction( -    ctx: Context, -    user: UserSnowflake, -    infr_type: str, -    reason: str, -    expires_at: datetime = None, -    hidden: bool = False, -    active: bool = True +        ctx: Context, +        user: UserSnowflake, +        infr_type: str, +        reason: str, +        expires_at: datetime = None, +        hidden: bool = False, +        active: bool = True  ) -> t.Optional[dict]:      """Posts an infraction to the API."""      if isinstance(user, (discord.Member, discord.User)) and user.bot: @@ -150,11 +153,11 @@ async def get_active_infraction(  async def notify_infraction( -    user: UserObject, -    infr_type: str, -    expires_at: t.Optional[str] = None, -    reason: t.Optional[str] = None, -    icon_url: str = Icons.token_removed +        user: UserObject, +        infr_type: str, +        expires_at: t.Optional[str] = None, +        reason: t.Optional[str] = None, +        icon_url: str = Icons.token_removed  ) -> bool:      """DM a user about their new infraction and return True if the DM is successful."""      log.trace(f"Sending {user} a DM about their {infr_type} infraction.") @@ -178,17 +181,18 @@ async def notify_infraction(      embed.title = INFRACTION_TITLE      embed.url = RULES_URL -    if infr_type in APPEALABLE_INFRACTIONS: -        embed.set_footer(text=INFRACTION_APPEAL_FOOTER) +    embed.set_footer( +        text=INFRACTION_APPEAL_EMAIL_FOOTER if infr_type == 'Ban' else INFRACTION_APPEAL_MODMAIL_FOOTER +    )      return await send_private_embed(user, embed)  async def notify_pardon( -    user: UserObject, -    title: str, -    content: str, -    icon_url: str = Icons.user_verified +        user: UserObject, +        title: str, +        content: str, +        icon_url: str = Icons.user_verified  ) -> bool:      """DM a user about their pardoned infraction and return True if the DM is successful."""      log.trace(f"Sending {user} a DM about their pardoned infraction.") diff --git a/tests/bot/exts/moderation/infraction/test_utils.py b/tests/bot/exts/moderation/infraction/test_utils.py index 5b62463e0..ee9ff650c 100644 --- a/tests/bot/exts/moderation/infraction/test_utils.py +++ b/tests/bot/exts/moderation/infraction/test_utils.py @@ -146,7 +146,7 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):                      name=utils.INFRACTION_AUTHOR_NAME,                      url=utils.RULES_URL,                      icon_url=Icons.token_removed -                ).set_footer(text=utils.INFRACTION_APPEAL_FOOTER), +                ).set_footer(text=utils.INFRACTION_APPEAL_MODMAIL_FOOTER),                  "send_result": True              },              { @@ -164,9 +164,11 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):                      name=utils.INFRACTION_AUTHOR_NAME,                      url=utils.RULES_URL,                      icon_url=Icons.token_removed -                ), +                ).set_footer(text=utils.INFRACTION_APPEAL_MODMAIL_FOOTER),                  "send_result": False              }, +            # Note that this test case asserts that the DM that *would* get sent to the user is formatted +            # correctly, even though that message is deliberately never sent.              {                  "args": (self.user, "note", None, None, Icons.defcon_denied),                  "expected_output": Embed( @@ -182,7 +184,7 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):                      name=utils.INFRACTION_AUTHOR_NAME,                      url=utils.RULES_URL,                      icon_url=Icons.defcon_denied -                ), +                ).set_footer(text=utils.INFRACTION_APPEAL_MODMAIL_FOOTER),                  "send_result": False              },              { @@ -200,7 +202,7 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):                      name=utils.INFRACTION_AUTHOR_NAME,                      url=utils.RULES_URL,                      icon_url=Icons.defcon_denied -                ).set_footer(text=utils.INFRACTION_APPEAL_FOOTER), +                ).set_footer(text=utils.INFRACTION_APPEAL_MODMAIL_FOOTER),                  "send_result": False              },              { @@ -218,7 +220,7 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):                      name=utils.INFRACTION_AUTHOR_NAME,                      url=utils.RULES_URL,                      icon_url=Icons.defcon_denied -                ).set_footer(text=utils.INFRACTION_APPEAL_FOOTER), +                ).set_footer(text=utils.INFRACTION_APPEAL_MODMAIL_FOOTER),                  "send_result": True              }          ]  |