WIP: Refactor Aurora (3.0.0) #29

Draft
cswimr wants to merge 347 commits from aurora-pydantic into main
Showing only changes of commit 0d64e3f652 - Show all commits

View file

@ -4,6 +4,7 @@ from typing import Literal, Optional
from redbot.core.bot import Red from redbot.core.bot import Red
from ..utilities.utils import timedelta_from_string
from .base import AuroraBaseModel from .base import AuroraBaseModel
from .partials import PartialUser from .partials import PartialUser
@ -31,8 +32,7 @@ class Change(AuroraBaseModel):
if isinstance(data, str): if isinstance(data, str):
data = json.loads(data) data = json.loads(data)
if "duration" in data and data["duration"] and not isinstance(data["duration"], timedelta) and not data["duration"] == "NULL": if "duration" in data and data["duration"] and not isinstance(data["duration"], timedelta) and not data["duration"] == "NULL":
hours, minutes, seconds = map(int, data["duration"].split(':')) duration = timedelta_from_string(data["duration"])
duration = timedelta(hours=hours, minutes=minutes, seconds=seconds)
elif "duration" in data and isinstance(data["duration"], timedelta): elif "duration" in data and isinstance(data["duration"], timedelta):
duration = data["duration"] duration = data["duration"]
else: else: