Incident archive msg improvements#2031
Conversation
c86c2a1 to
1e0c0cf
Compare
There was a problem hiding this comment.
I like the idea of the proposed UI, but I think it can be improved. Thoughts?
- Simplified time of report (less clutter, straight to the point)
- Relative action time in footer (per @MarkKoz here)
- Absolute action time as footer timestamp
crude suggestion diff
diff --git a/bot/exts/moderation/incidents.py b/bot/exts/moderation/incidents.py
index bd9e5b88..f1ad6a59 100644
--- a/bot/exts/moderation/incidents.py
+++ b/bot/exts/moderation/incidents.py
@@ -1,18 +1,20 @@
import asyncio
import re
+from datetime import datetime, timezone
from enum import Enum
from typing import Optional
import discord
from async_rediscache import RedisCache
from discord.ext.commands import Cog, Context, MessageConverter, MessageNotFound
+from dateutil.relativedelta import relativedelta
from bot.bot import Bot
from bot.constants import Channels, Colours, Emojis, Guild, Roles, Webhooks
from bot.log import get_logger
from bot.utils import scheduling
from bot.utils.messages import format_user, sub_clyde
-from bot.utils.time import TimestampFormats, discord_timestamp
+from bot.utils.time import TimestampFormats, discord_timestamp, humanize_delta
log = get_logger(__name__)
@@ -90,17 +92,19 @@ async def make_embed(incident: discord.Message, outcome: Signal, actioned_by: di
"""
log.trace(f"Creating embed for {incident.id=}")
+ relative_action_time = humanize_delta(
+ relativedelta(datetime.now(timezone.utc), incident.created_at), max_units=1
+ )
if outcome is Signal.ACTIONED:
colour = Colours.soft_green
- footer = f"Actioned by {actioned_by}"
+ footer = f"Actioned by {actioned_by} after {relative_action_time}"
else:
colour = Colours.soft_red
- footer = f"Rejected by {actioned_by}"
+ footer = f"Rejected by {actioned_by} after {relative_action_time}"
- day_timestamp = discord_timestamp(incident.created_at, TimestampFormats.DATE)
- time_timestamp = discord_timestamp(incident.created_at, TimestampFormats.TIME)
+ datetime_timestamp = discord_timestamp(incident.created_at, TimestampFormats.DATE_TIME)
relative_timestamp = discord_timestamp(incident.created_at, TimestampFormats.RELATIVE)
- reported_on_msg = f"__*Reported {day_timestamp} at {time_timestamp} ({relative_timestamp}).*__"
+ reported_on_msg = f"Reported {datetime_timestamp} ({relative_timestamp})."
# If the description will be too long (>4096 total characters), truncate the incident content
if len(incident.content) > (allowed_content_chars := 4096-len(reported_on_msg)-2): # -2 for the newlines
@@ -110,6 +114,7 @@ async def make_embed(incident: discord.Message, outcome: Signal, actioned_by: di
embed = discord.Embed(
description=description,
+ timestamp=datetime.utcnow(),
colour=colour,
)
embed.set_footer(text=footer, icon_url=actioned_by.display_avatar.url)
I discussed this with one of the core devs (I believe in a mod channel) and we decided we don't want this statistic, as it's often not particularly accurate (people forgetting to action, or an incident taking a long time to resolve due to a ModMail thread etc.) and causes extra pressure on Moderators to action incidents sooner, which isn't wanted.
For this I refer back to this PR's description: "... and no longer displays when the incident was actioned as it's the same as the incident-archive message timestamp." This isn't needed. EDIT: I suppose there is a case here; when multiple reports by the same user are actioned. In this scenario, only the first will have the timestamp. You can know it was actioned within a few minutes of the previous; is this accurate enough or do we want to re-add the timestamp for precision?
I do agree with this point; it definitely looks much nicer so will change. |
Sure, makes sense.
In compact mode, if I want to see the date an incident was actioned, I would have to scroll to the first incident of that day, so adding the timestamp to the footer helps. Although, in practice the action time shouldn't be too distant from the report time, so the information is technically in the embed already. |
I mean there are multiple instances where it's several hours after, simply because we're unfortunately not a 24/7 taskforce. Then there's the odd case of it being days later (due to being delayed by a ModMail thread etc.). I think supported with your compact mode comment, that's enough rationale for re-adding the timestamp. |
- Use the more concise DATETIME timestamp instead of both a DATE and a TIME timestamp. - Remove underline from the "Reported ..." section at the bottom of the embed. - Re-add time of action/rejection timestamp to footer of embed.
|
This latest commit is untested as I'm on holiday, so have added the "do not merge" tag to make sure it doesn't get merged before confirming it all works as planned. |
Turns out I forgot to push the commit where I fixed the tests 😅 |


Closes #1059
Incident archive messages now show when the incident was made and no longer displays when the incident was actioned as it's the same as the message timestamp.
Also removed some redundant escapes in the discord message link regex.