aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Karlis S <[email protected]>2020-07-06 14:24:55 +0000
committerGravatar Karlis S <[email protected]>2020-07-06 14:24:55 +0000
commit604c6a7a09d7826870fb384b98e0a6d1463721b4 (patch)
treed0f664a591659e0e4ec02c5c94ee79203f90b681
parentRemove unnecessary if statement from send_private_embed test (diff)
Restore newlines for `notify_infraction` embed description
Truncate reason instead full content to avoid removing newlines
-rw-r--r--bot/cogs/moderation/utils.py6
-rw-r--r--tests/bot/cogs/moderation/test_utils.py22
2 files changed, 14 insertions, 14 deletions
diff --git a/bot/cogs/moderation/utils.py b/bot/cogs/moderation/utils.py
index 8b36210be..95820404a 100644
--- a/bot/cogs/moderation/utils.py
+++ b/bot/cogs/moderation/utils.py
@@ -35,7 +35,7 @@ INFRACTION_APPEAL_FOOTER = f"To appeal this infraction, send an e-mail to {APPEA
INFRACTION_AUTHOR_NAME = "Infraction information"
INFRACTION_DESCRIPTION_TEMPLATE = (
- "\n**Type:** {type}\n"
+ "**Type:** {type}\n"
"**Expires:** {expires}\n"
"**Reason:** {reason}\n"
)
@@ -157,11 +157,11 @@ async def notify_infraction(
text = INFRACTION_DESCRIPTION_TEMPLATE.format(
type=infr_type.capitalize(),
expires=expires_at or "N/A",
- reason=reason or "No reason provided."
+ reason=textwrap.shorten(reason, 1000, placeholder="...") if reason else "No reason provided."
)
embed = discord.Embed(
- description=textwrap.shorten(text, width=2048, placeholder="..."),
+ description=text,
colour=Colours.soft_red
)
diff --git a/tests/bot/cogs/moderation/test_utils.py b/tests/bot/cogs/moderation/test_utils.py
index 029719669..c9a4e4040 100644
--- a/tests/bot/cogs/moderation/test_utils.py
+++ b/tests/bot/cogs/moderation/test_utils.py
@@ -136,11 +136,11 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):
"args": (self.user, "ban", "2020-02-26 09:20 (23 hours and 59 minutes)"),
"expected_output": Embed(
title=utils.INFRACTION_TITLE,
- description=textwrap.shorten(utils.INFRACTION_DESCRIPTION_TEMPLATE.format(
+ description=utils.INFRACTION_DESCRIPTION_TEMPLATE.format(
type="Ban",
expires="2020-02-26 09:20 (23 hours and 59 minutes)",
reason="No reason provided."
- ), width=2048, placeholder="..."),
+ ),
colour=Colours.soft_red,
url=utils.RULES_URL
).set_author(
@@ -154,11 +154,11 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):
"args": (self.user, "warning", None, "Test reason."),
"expected_output": Embed(
title=utils.INFRACTION_TITLE,
- description=textwrap.shorten(utils.INFRACTION_DESCRIPTION_TEMPLATE.format(
+ description=utils.INFRACTION_DESCRIPTION_TEMPLATE.format(
type="Warning",
expires="N/A",
reason="Test reason."
- ), width=2048, placeholder="..."),
+ ),
colour=Colours.soft_red,
url=utils.RULES_URL
).set_author(
@@ -172,11 +172,11 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):
"args": (self.user, "note", None, None, Icons.defcon_denied),
"expected_output": Embed(
title=utils.INFRACTION_TITLE,
- description=textwrap.shorten(utils.INFRACTION_DESCRIPTION_TEMPLATE.format(
+ description=utils.INFRACTION_DESCRIPTION_TEMPLATE.format(
type="Note",
expires="N/A",
reason="No reason provided."
- ), width=2048, placeholder="..."),
+ ),
colour=Colours.soft_red,
url=utils.RULES_URL
).set_author(
@@ -190,11 +190,11 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):
"args": (self.user, "mute", "2020-02-26 09:20 (23 hours and 59 minutes)", "Test", Icons.defcon_denied),
"expected_output": Embed(
title=utils.INFRACTION_TITLE,
- description=textwrap.shorten(utils.INFRACTION_DESCRIPTION_TEMPLATE.format(
+ description=utils.INFRACTION_DESCRIPTION_TEMPLATE.format(
type="Mute",
expires="2020-02-26 09:20 (23 hours and 59 minutes)",
reason="Test"
- ), width=2048, placeholder="..."),
+ ),
colour=Colours.soft_red,
url=utils.RULES_URL
).set_author(
@@ -208,11 +208,11 @@ class ModerationUtilsTests(unittest.IsolatedAsyncioTestCase):
"args": (self.user, "mute", None, "foo bar" * 4000, Icons.defcon_denied),
"expected_output": Embed(
title=utils.INFRACTION_TITLE,
- description=textwrap.shorten(utils.INFRACTION_DESCRIPTION_TEMPLATE.format(
+ description=utils.INFRACTION_DESCRIPTION_TEMPLATE.format(
type="Mute",
expires="N/A",
- reason="foo bar" * 4000
- ), width=2048, placeholder="..."),
+ reason=textwrap.shorten("foo bar" * 4000, 1000, placeholder="...")
+ ),
colour=Colours.soft_red,
url=utils.RULES_URL
).set_author(