aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/exts/moderation/infraction/_utils.py34
-rw-r--r--tests/bot/exts/moderation/infraction/test_utils.py10
2 files changed, 31 insertions, 13 deletions
diff --git a/bot/exts/moderation/infraction/_utils.py b/bot/exts/moderation/infraction/_utils.py
index 1bd5c5d5f..baeb971e4 100644
--- a/bot/exts/moderation/infraction/_utils.py
+++ b/bot/exts/moderation/infraction/_utils.py
@@ -39,17 +39,26 @@ INFRACTION_APPEAL_MODMAIL_FOOTER = (
"\nIf you would like to discuss or appeal this infraction, "
f"send a message to the ModMail bot (<@{MODMAIL_ACCOUNT_ID}>)."
)
+INFRACTION_MODMAIL_FOOTER = (
+ "\nIf you would like to discuss this infraction, "
+ f"send a message to the ModMail bot (<@{MODMAIL_ACCOUNT_ID}>)."
+)
INFRACTION_AUTHOR_NAME = "Infraction information"
LONGEST_EXTRAS = max(len(INFRACTION_APPEAL_SERVER_FOOTER), len(INFRACTION_APPEAL_MODMAIL_FOOTER))
-INFRACTION_DESCRIPTION_TEMPLATE = (
+INFRACTION_DESCRIPTION_NOT_WARNING_TEMPLATE = (
"**Type:** {type}\n"
"**Duration:** {duration}\n"
"**Expires:** {expires}\n"
"**Reason:** {reason}\n"
)
+INFRACTION_DESCRIPTION_WARNING_TEMPLATE = (
+ "**Type:** Warning\n"
+ "**Reason:** {reason}\n"
+)
+
async def post_user(ctx: Context, user: MemberOrUser) -> dict | None:
"""
@@ -213,18 +222,27 @@ async def notify_infraction(
if reason is None:
reason = infraction["reason"]
- text = INFRACTION_DESCRIPTION_TEMPLATE.format(
- type=infr_type.title(),
- expires=expires_at,
- duration=duration,
- reason=reason or "No reason provided."
- )
+ if infraction["type"] == "warning":
+ text = INFRACTION_DESCRIPTION_WARNING_TEMPLATE.format(
+ reason=reason or "No reason provided."
+ )
+ else:
+ text = INFRACTION_DESCRIPTION_NOT_WARNING_TEMPLATE.format(
+ type=infr_type.title(),
+ expires=expires_at,
+ duration=duration,
+ reason=reason or "No reason provided."
+ )
# For case when other fields than reason is too long and this reach limit, then force-shorten string
if len(text) > 4096 - LONGEST_EXTRAS:
text = f"{text[:4093-LONGEST_EXTRAS]}..."
- text += INFRACTION_APPEAL_SERVER_FOOTER if infraction["type"] == "ban" else INFRACTION_APPEAL_MODMAIL_FOOTER
+ text += (
+ INFRACTION_APPEAL_SERVER_FOOTER if infraction["type"] == "ban"
+ else INFRACTION_MODMAIL_FOOTER if infraction["type"] == "warning"
+ else INFRACTION_APPEAL_MODMAIL_FOOTER
+ )
embed = discord.Embed(
description=text,
diff --git a/tests/bot/exts/moderation/infraction/test_utils.py b/tests/bot/exts/moderation/infraction/test_utils.py
index 25337673e..e2a7bad9f 100644
--- a/tests/bot/exts/moderation/infraction/test_utils.py
+++ b/tests/bot/exts/moderation/infraction/test_utils.py
@@ -142,7 +142,7 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):
),
"expected_output": Embed(
title=utils.INFRACTION_TITLE,
- description=utils.INFRACTION_DESCRIPTION_TEMPLATE.format(
+ description=utils.INFRACTION_DESCRIPTION_NOT_WARNING_TEMPLATE.format(
type="Ban",
expires="2020-02-26 09:20 (23 hours and 59 minutes)",
reason="No reason provided."
@@ -160,7 +160,7 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):
"args": (dict(id=0, type="warning", reason="Test reason.", expires_at=None), self.user),
"expected_output": Embed(
title=utils.INFRACTION_TITLE,
- description=utils.INFRACTION_DESCRIPTION_TEMPLATE.format(
+ description=utils.INFRACTION_DESCRIPTION_NOT_WARNING_TEMPLATE.format(
type="Warning",
expires="N/A",
reason="Test reason."
@@ -180,7 +180,7 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):
"args": (dict(id=0, type="note", reason=None, expires_at=None), self.user),
"expected_output": Embed(
title=utils.INFRACTION_TITLE,
- description=utils.INFRACTION_DESCRIPTION_TEMPLATE.format(
+ description=utils.INFRACTION_DESCRIPTION_NOT_WARNING_TEMPLATE.format(
type="Note",
expires="N/A",
reason="No reason provided."
@@ -201,7 +201,7 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):
),
"expected_output": Embed(
title=utils.INFRACTION_TITLE,
- description=utils.INFRACTION_DESCRIPTION_TEMPLATE.format(
+ description=utils.INFRACTION_DESCRIPTION_NOT_WARNING_TEMPLATE.format(
type="Mute",
expires="2020-02-26 09:20 (23 hours and 59 minutes)",
reason="Test"
@@ -219,7 +219,7 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):
"args": (dict(id=0, type="mute", reason="foo bar" * 4000, expires_at=None), self.user),
"expected_output": Embed(
title=utils.INFRACTION_TITLE,
- description=utils.INFRACTION_DESCRIPTION_TEMPLATE.format(
+ description=utils.INFRACTION_DESCRIPTION_NOT_WARNING_TEMPLATE.format(
type="Mute",
expires="N/A",
reason="foo bar" * 4000