diff --git a/classes/pyrouser.py b/classes/pyrouser.py index ef7d286..abb4a50 100644 --- a/classes/pyrouser.py +++ b/classes/pyrouser.py @@ -71,6 +71,15 @@ class PyroUser: return cls(**db_entry) + @classmethod + async def from_dict(cls, **kwargs): + if "location" in kwargs: + try: + kwargs["location"] = await Location.get(kwargs["location"]) # type: ignore + except ValueError: + kwargs["location"] = None # type: ignore + return cls(**kwargs) + async def update_locale(self, locale: Union[str, None]) -> None: """Change user's locale stored in the database.