misc(aurora): convert Change.from_dict() to use utils.timedelta_from_string()

This commit is contained in:
Seaswimmer 2024-06-04 23:52:35 -04:00
parent 8591649465
commit 0d64e3f652
Signed by untrusted user: cswimr
GPG key ID: 5D671B5D03D65A7F

View file

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