fix(aurora): convert datetimes to unix timestamps
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Successful in 21s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 31s

This commit is contained in:
Seaswimmer 2024-05-04 21:06:29 -04:00
parent 23eba46948
commit 50c2db80d9
Signed by: cswimr
GPG key ID: 5D671B5D03D65A7F
2 changed files with 9 additions and 5 deletions

View file

@ -51,6 +51,10 @@ class Moderation(AuroraGuildModel):
def type(self) -> str: def type(self) -> str:
return self.moderation_type return self.moderation_type
@property
def unix_timestamp(self) -> int:
return int(self.timestamp.timestamp())
async def get_moderator(self) -> "PartialUser": async def get_moderator(self) -> "PartialUser":
return await PartialUser.from_id(self.bot, self.moderator_id) return await PartialUser.from_id(self.bot, self.moderator_id)

View file

@ -117,7 +117,7 @@ async def log_factory(
) )
resolved_by = await moderation.get_resolved_by() resolved_by = await moderation.get_resolved_by()
embed.description = f"**Type:** {str.title(moderation.moderation_type)}\n**Target:** {target.name} ({target.id})\n**Moderator:** {moderator.name} ({moderator.id})\n**Timestamp:** <t:{moderation.timestamp}> | <t:{moderation.timestamp}:R>" embed.description = f"**Type:** {str.title(moderation.moderation_type)}\n**Target:** {target.name} ({target.id})\n**Moderator:** {moderator.name} ({moderator.id})\n**Timestamp:** <t:{moderation.unix_timestamp}> | <t:{moderation.unix_timestamp}:R>"
if moderation.duration is not None: if moderation.duration is not None:
duration_embed = ( duration_embed = (
@ -143,12 +143,12 @@ async def log_factory(
title=f"📕 Case #{moderation.id:,}", title=f"📕 Case #{moderation.id:,}",
color=await interaction.client.get_embed_color(interaction.channel), color=await interaction.client.get_embed_color(interaction.channel),
) )
embed.description = f"**Type:** {str.title(moderation.type)}\n**Target:** {target.name} ({target.id})\n**Moderator:** {moderator.name} ({moderator.id})\n**Timestamp:** <t:{moderation.timestamp}> | <t:{moderation.timestamp}:R>" embed.description = f"**Type:** {str.title(moderation.type)}\n**Target:** {target.name} ({target.id})\n**Moderator:** {moderator.name} ({moderator.id})\n**Timestamp:** <t:{moderation.unix_timestamp}> | <t:{moderation.unix_timestamp}:R>"
if moderation.duration: if moderation.duration:
embed.description = ( embed.description = (
embed.description embed.description
+ f"\n**Duration:** {humanize_timedelta(timedelta=moderation.duration)} | <t:{moderation.timestamp}:R>" + f"\n**Duration:** {humanize_timedelta(timedelta=moderation.duration)} | <t:{moderation.unix_timestamp}:R>"
) )
embed.add_field(name="Reason", value=box(moderation.reason), inline=False) embed.add_field(name="Reason", value=box(moderation.reason), inline=False)
@ -169,11 +169,11 @@ async def case_factory(interaction: Interaction, moderation: Moderation) -> Embe
title=f"📕 Case #{moderation.id:,}", title=f"📕 Case #{moderation.id:,}",
color=await interaction.client.get_embed_color(interaction.channel), color=await interaction.client.get_embed_color(interaction.channel),
) )
embed.description = f"**Type:** {str.title(moderation.type)}\n**Target:** {target.name} ({target.id})\n**Moderator:** {moderator.name} ({moderator.id})\n**Resolved:** {moderation.resolved}\n**Timestamp:** <t:{moderation.timestamp}> | <t:{moderation.timestamp}:R>" embed.description = f"**Type:** {str.title(moderation.type)}\n**Target:** {target.name} ({target.id})\n**Moderator:** {moderator.name} ({moderator.id})\n**Resolved:** {moderation.resolved}\n**Timestamp:** <t:{moderation.unix_timestamp}> | <t:{moderation.unix_timestamp}:R>"
if moderation.duration: if moderation.duration:
duration_embed = ( duration_embed = (
f"{humanize_timedelta(timedelta=moderation.duration)} | <t:{moderation.timestamp}:R>" f"{humanize_timedelta(timedelta=moderation.duration)} | <t:{moderation.unix_timestamp}:R>"
if moderation.expired is False if moderation.expired is False
else str(humanize_timedelta(timedelta=moderation.duration)) else str(humanize_timedelta(timedelta=moderation.duration))
) )