fix(aurora): fixed an error with timedelta formatting
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Successful in 28s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 43s

This commit is contained in:
Seaswimmer 2024-06-04 15:22:50 -04:00
parent 5151f65317
commit 0a207b66e4
Signed by: cswimr
GPG key ID: 5D671B5D03D65A7F
2 changed files with 8 additions and 1 deletions

View file

@ -10,6 +10,7 @@ from discord import NotFound
from redbot.core.bot import Red
from ..utilities.logger import logger
from ..utilities.utils import timedelta_to_string
from .base import AuroraGuildModel
from .change import Change
from .partials import PartialChannel, PartialRole, PartialUser
@ -348,7 +349,7 @@ class Moderation(AuroraGuildModel):
"target_id": target_id,
"moderator_id": moderator_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,
"reason": reason,
"resolved": resolved,

View file

@ -194,6 +194,12 @@ def timedelta_from_relativedelta(relativedelta: rd) -> timedelta:
then = now - relativedelta
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:
"""Returns the footer image for the embeds."""
image_path = data_manager.bundled_data_path(coginstance) / "arrow.png"