fix(aurora): convert datetimes to unix timestamps
This commit is contained in:
parent
23eba46948
commit
50c2db80d9
2 changed files with 9 additions and 5 deletions
|
@ -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)
|
||||||
|
|
||||||
|
|
|
@ -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))
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue