fix(aurora): fixed a keyerror

This commit is contained in:
Seaswimmer 2024-05-04 21:17:03 -04:00
parent 94f6d6c3b5
commit 6eeab9ed96
Signed by untrusted user: cswimr
GPG key ID: 5D671B5D03D65A7F

View file

@ -118,14 +118,14 @@ class Change(AuroraBaseModel):
@classmethod
def from_dict(cls, bot: Red, data: dict) -> "Change":
if data["duration"] is not None:
if "duration" in data and data["duration"] is not None:
hours, minutes, seconds = map(int, data["duration"].split(':'))
duration = timedelta(hours=hours, minutes=minutes, seconds=seconds)
else:
duration = None
data.update({
"timestamp": datetime.fromtimestamp(data["timestamp"]),
"end_timestamp": datetime.fromtimestamp(data["end_timestamp"]) if data["end_timestamp"] else None,
"end_timestamp": datetime.fromtimestamp(data["end_timestamp"]) if "end_timestamp" in data and data["end_timestamp"] else None,
"duration": duration
})
return cls(bot=bot, **data)