WIP: Refactor Aurora (3.0.0) #29
2 changed files with 13 additions and 8 deletions
|
@ -22,6 +22,12 @@ class Change(AuroraBaseModel):
|
||||||
def unix_timestamp(self) -> int:
|
def unix_timestamp(self) -> int:
|
||||||
return int(self.timestamp.timestamp())
|
return int(self.timestamp.timestamp())
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unix_end_timestamp(self) -> Optional[int]:
|
||||||
|
if self.end_timestamp:
|
||||||
|
return int(self.end_timestamp.timestamp())
|
||||||
|
return None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.type} {self.user_id} {self.reason}"
|
return f"{self.type} {self.user_id} {self.reason}"
|
||||||
|
|
||||||
|
|
|
@ -261,19 +261,18 @@ async def changes_factory(interaction: Interaction, moderation: Moderation) -> E
|
||||||
user: PartialUser = memory_dict[str(change.user_id)]
|
user: PartialUser = memory_dict[str(change.user_id)]
|
||||||
|
|
||||||
timestamp = f"<t:{change.unix_timestamp}> | <t:{change.unix_timestamp}:R>"
|
timestamp = f"<t:{change.unix_timestamp}> | <t:{change.unix_timestamp}:R>"
|
||||||
end_timestamp = f"<t:{change.end_timestamp}> | <t:{change.end_timestamp}:R>" if change.end_timestamp else None
|
end_timestamp = f"<t:{change.unix_end_timestamp}> | <t:{change.unix_end_timestamp}:R>" if change.end_timestamp else None
|
||||||
|
|
||||||
change_str = [
|
change_str = [
|
||||||
f"{bold('User:')} {inline(user.name)} ({user.id})",
|
f"{bold('User:')} {inline(user.name)} ({user.id})",
|
||||||
f"{bold('Reason:')} {change.reason}" if change.reason else "",
|
f"{bold('Reason:')} {change.reason}" if change.reason else None,
|
||||||
f"{bold('Duration:')} {humanize_timedelta(timedelta=change.duration)}" if change.duration else "",
|
f"{bold('Duration:')} {humanize_timedelta(timedelta=change.duration)}" if change.duration else None,
|
||||||
f"{bold('End Timestamp:')} {end_timestamp}" if end_timestamp else "",
|
f"{bold('End Timestamp:')} {end_timestamp}" if end_timestamp else None,
|
||||||
f"{bold('Timestamp')} {timestamp}",
|
f"{bold('Timestamp')} {timestamp}",
|
||||||
]
|
]
|
||||||
try:
|
for string in change_str:
|
||||||
change_str.remove("")
|
if string is None:
|
||||||
except ValueError:
|
change_str.remove(string)
|
||||||
pass
|
|
||||||
|
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name=change.type.title(),
|
name=change.type.title(),
|
||||||
|
|
Loading…
Reference in a new issue