fix(aurora): fixed a keyerror
This commit is contained in:
parent
94f6d6c3b5
commit
6eeab9ed96
1 changed files with 2 additions and 2 deletions
|
@ -118,14 +118,14 @@ class Change(AuroraBaseModel):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, bot: Red, data: dict) -> "Change":
|
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(':'))
|
hours, minutes, seconds = map(int, data["duration"].split(':'))
|
||||||
duration = timedelta(hours=hours, minutes=minutes, seconds=seconds)
|
duration = timedelta(hours=hours, minutes=minutes, seconds=seconds)
|
||||||
else:
|
else:
|
||||||
duration = None
|
duration = None
|
||||||
data.update({
|
data.update({
|
||||||
"timestamp": datetime.fromtimestamp(data["timestamp"]),
|
"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
|
"duration": duration
|
||||||
})
|
})
|
||||||
return cls(bot=bot, **data)
|
return cls(bot=bot, **data)
|
||||||
|
|
Loading…
Reference in a new issue