aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar vivekashok1221 <[email protected]>2022-12-30 19:29:00 +0400
committerGravatar Vivek Ashokkumar <[email protected]>2023-02-14 02:49:22 +0530
commit46a7b9785902729da8e7de01935f0af3d53384ca (patch)
treedf30b09fd5d5703006580ebe1b8de7920951c647
parentMerge pull request #2396 from shtlrs/bump-bot-core-to-9-4-1 (diff)
Display message link in infraction log
-rw-r--r--bot/exts/moderation/infraction/_utils.py9
-rw-r--r--bot/exts/moderation/infraction/management.py6
2 files changed, 14 insertions, 1 deletions
diff --git a/bot/exts/moderation/infraction/_utils.py b/bot/exts/moderation/infraction/_utils.py
index 2cf7f8efb..0343709fa 100644
--- a/bot/exts/moderation/infraction/_utils.py
+++ b/bot/exts/moderation/infraction/_utils.py
@@ -6,11 +6,12 @@ from discord.ext.commands import Context
from pydis_core.site_api import ResponseCodeError
import bot
-from bot.constants import Colours, Icons
+from bot.constants import Categories, Colours, Icons
from bot.converters import DurationOrExpiry, MemberOrUser
from bot.errors import InvalidInfractedUserError
from bot.log import get_logger
from bot.utils import time
+from bot.utils.channel import is_in_category
from bot.utils.time import unpack_duration
log = get_logger(__name__)
@@ -94,6 +95,11 @@ async def post_infraction(
current_time = arrow.utcnow()
+ if is_in_category(ctx.channel, Categories.modmail):
+ jump_url_text = "Infraction issued in a ModMail channel."
+ else:
+ jump_url_text = f"[Click here]({ctx.message.jump_url})"
+
payload = {
"actor": ctx.author.id, # Don't use ctx.message.author; antispam only patches ctx.author.
"hidden": hidden,
@@ -102,6 +108,7 @@ async def post_infraction(
"user": user.id,
"active": active,
"dm_sent": dm_sent,
+ "jump_url_text": jump_url_text,
"inserted_at": current_time.isoformat(),
"last_applied": current_time.isoformat(),
}
diff --git a/bot/exts/moderation/infraction/management.py b/bot/exts/moderation/infraction/management.py
index 6ef382119..bcbacf085 100644
--- a/bot/exts/moderation/infraction/management.py
+++ b/bot/exts/moderation/infraction/management.py
@@ -390,6 +390,7 @@ class ModManagement(commands.Cog):
applied = time.discord_timestamp(last_applied)
duration_edited = arrow.get(last_applied) > arrow.get(inserted_at)
dm_sent = infraction["dm_sent"]
+ jump_url_text = infraction["jump_url_text"]
# Format the user string.
if user_obj := self.bot.get_user(user["id"]):
@@ -420,6 +421,10 @@ class ModManagement(commands.Cog):
else:
dm_sent_text = "Yes" if dm_sent else "No"
+ if jump_url_text == "":
+ # Infraction was issued prior to jump urls being stored in the database.
+ jump_url_text = "N/A"
+
lines = textwrap.dedent(f"""
{"**===============**" if active else "==============="}
Status: {"__**Active**__" if active else "Inactive"}
@@ -432,6 +437,7 @@ class ModManagement(commands.Cog):
Duration: {duration}
Actor: <@{infraction["actor"]["id"]}>
ID: `{infraction["id"]}`
+ Jump Url: {jump_url_text}
Reason: {infraction["reason"] or "*None*"}
{"**===============**" if active else "==============="}
""")