Skip to content

Commit 219d923

Browse files
committed
feat(moderation): add case creation timestamp to embed messages
- Introduced a timestamp for case embeds to reflect the case creation time accurately. - Ensured the timestamp is UTC-aware, addressing potential issues with naive datetime objects returned from the database. - Updated the embed creation logic to include the new timestamp parameter, enhancing the information displayed in moderation cases.
1 parent 15f5099 commit 219d923

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/tux/modules/moderation/cases.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77

88
import contextlib
9-
from datetime import UTC
9+
from datetime import UTC, datetime
1010
from types import SimpleNamespace
1111
from typing import Any, Protocol
1212

@@ -689,9 +689,20 @@ async def _send_case_embed(
689689
EmbedType.ACTIVE_CASE if case.case_status else EmbedType.INACTIVE_CASE
690690
)
691691

692+
# Set embed timestamp to case creation time
693+
# Ensure UTC-aware datetime (database stores as UTC but returns naive)
694+
case_timestamp: datetime | None = None
695+
if case.created_at:
696+
case_timestamp = (
697+
case.created_at.replace(tzinfo=UTC)
698+
if case.created_at.tzinfo is None
699+
else case.created_at
700+
)
701+
692702
embed = EmbedCreator.create_embed(
693703
embed_type=embed_type,
694704
custom_author_text=f"Case #{case.case_number} ({case.case_type.value if case.case_type else 'UNKNOWN'}) {action}",
705+
message_timestamp=case_timestamp,
695706
)
696707

697708
# Add fields to embed

0 commit comments

Comments
 (0)