WIP: Refactor Aurora (3.0.0) #29

Draft
cswimr wants to merge 347 commits from aurora-pydantic into main
2 changed files with 8 additions and 1 deletions
Showing only changes of commit 0a207b66e4 - Show all commits

View file

@ -10,6 +10,7 @@ from discord import NotFound
from redbot.core.bot import Red from redbot.core.bot import Red
from ..utilities.logger import logger from ..utilities.logger import logger
from ..utilities.utils import timedelta_to_string
from .base import AuroraGuildModel from .base import AuroraGuildModel
from .change import Change from .change import Change
from .partials import PartialChannel, PartialRole, PartialUser from .partials import PartialChannel, PartialRole, PartialUser
@ -348,7 +349,7 @@ class Moderation(AuroraGuildModel):
"target_id": target_id, "target_id": target_id,
"moderator_id": moderator_id, "moderator_id": moderator_id,
"role_id": role_id, "role_id": role_id,
"duration": str(duration) if duration else None, "duration": timedelta_to_string(duration) if duration else None,
"end_timestamp": end_timestamp.timestamp() if end_timestamp else None, "end_timestamp": end_timestamp.timestamp() if end_timestamp else None,
"reason": reason, "reason": reason,
"resolved": resolved, "resolved": resolved,

View file

@ -194,6 +194,12 @@ def timedelta_from_relativedelta(relativedelta: rd) -> timedelta:
then = now - relativedelta then = now - relativedelta
return now - then return now - then
def timedelta_to_string(timedelta: timedelta) -> str:
"""Converts a timedelta object to a string."""
hours, remainder = divmod(timedelta.seconds, 3600)
minutes, seconds = divmod(remainder, 60)
return f"{hours}:{minutes}:{seconds}s"
def get_footer_image(coginstance: commands.Cog) -> File: def get_footer_image(coginstance: commands.Cog) -> File:
"""Returns the footer image for the embeds.""" """Returns the footer image for the embeds."""
image_path = data_manager.bundled_data_path(coginstance) / "arrow.png" image_path = data_manager.bundled_data_path(coginstance) / "arrow.png"