WIP: Refactor Aurora (3.0.0) #29

Draft
cswimr wants to merge 347 commits from aurora-pydantic into main
3 changed files with 7 additions and 6 deletions
Showing only changes of commit 027144f35d - Show all commits

View file

@ -116,7 +116,7 @@ class ImportAuroraView(ui.View):
database=database,
return_obj=False
)
except Exception as e:
except Exception as e: # pylint: disable=broad-exception-caught
failed_cases.append(str(case["moderation_id"]) + f": {e}")
await interaction.edit_original_response(content="Import complete.")

View file

@ -299,7 +299,7 @@ class Moderation(AuroraGuildModel):
changes: list | None = None,
metadata: dict | None = None,
return_obj: bool = True,
) -> Union["Moderation", None]:
) -> Union["Moderation", int]:
from ..utilities.database import connect
from ..utilities.json import dumps
if not timestamp:
@ -325,7 +325,7 @@ class Moderation(AuroraGuildModel):
if reason == "NULL":
reason = None
if resolved_by == "NULL" or resolved_by == '?':
if resolved_by in ["NULL", "?"]:
resolved_by = None
if resolved_reason == "NULL":
@ -393,3 +393,4 @@ class Moderation(AuroraGuildModel):
if return_obj:
return cls.find_by_id(bot=bot, moderation_id=moderation_id, guild_id=guild_id)
return moderation_id

View file

@ -199,10 +199,10 @@ def timedelta_from_string(string: str) -> timedelta:
hours, minutes, seconds = map(int, string.split(":"))
return timedelta(hours=hours, minutes=minutes, seconds=seconds)
def timedelta_to_string(timedelta: timedelta) -> str:
def timedelta_to_string(td: timedelta) -> str:
"""Converts a timedelta object to a string."""
days = timedelta.days * 24
hours, remainder = divmod(timedelta.seconds, 3600)
days = td.days * 24
hours, remainder = divmod(td.seconds, 3600)
minutes, seconds = divmod(remainder, 60)
return f"{days + hours}:{minutes:02}:{seconds:02}"