From 50c2db80d9f3df344399d9ea0477ca04fcb5d759 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Sat, 4 May 2024 21:06:29 -0400 Subject: [PATCH] fix(aurora): convert datetimes to unix timestamps --- aurora/models.py | 4 ++++ aurora/utilities/factory.py | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/aurora/models.py b/aurora/models.py index b336d3a..ab8bd3d 100644 --- a/aurora/models.py +++ b/aurora/models.py @@ -51,6 +51,10 @@ class Moderation(AuroraGuildModel): def type(self) -> str: return self.moderation_type + @property + def unix_timestamp(self) -> int: + return int(self.timestamp.timestamp()) + async def get_moderator(self) -> "PartialUser": return await PartialUser.from_id(self.bot, self.moderator_id) diff --git a/aurora/utilities/factory.py b/aurora/utilities/factory.py index fdc4126..63e8f03 100644 --- a/aurora/utilities/factory.py +++ b/aurora/utilities/factory.py @@ -117,7 +117,7 @@ async def log_factory( ) 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:** | " + embed.description = f"**Type:** {str.title(moderation.moderation_type)}\n**Target:** {target.name} ({target.id})\n**Moderator:** {moderator.name} ({moderator.id})\n**Timestamp:** | " if moderation.duration is not None: duration_embed = ( @@ -143,12 +143,12 @@ async def log_factory( title=f"📕 Case #{moderation.id:,}", 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:** | " + embed.description = f"**Type:** {str.title(moderation.type)}\n**Target:** {target.name} ({target.id})\n**Moderator:** {moderator.name} ({moderator.id})\n**Timestamp:** | " if moderation.duration: embed.description = ( embed.description - + f"\n**Duration:** {humanize_timedelta(timedelta=moderation.duration)} | " + + f"\n**Duration:** {humanize_timedelta(timedelta=moderation.duration)} | " ) 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:,}", 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:** | " + 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:** | " if moderation.duration: duration_embed = ( - f"{humanize_timedelta(timedelta=moderation.duration)} | " + f"{humanize_timedelta(timedelta=moderation.duration)} | " if moderation.expired is False else str(humanize_timedelta(timedelta=moderation.duration)) )