24 lines
517 B
Python
24 lines
517 B
Python
|
from typing import Union
|
||
|
|
||
|
from attrs import define
|
||
|
from bson import ObjectId
|
||
|
|
||
|
from modules.database import col_users
|
||
|
|
||
|
|
||
|
@define
|
||
|
class PyroUser:
|
||
|
"""Dataclass of DB entry of a user"""
|
||
|
|
||
|
_id: ObjectId
|
||
|
id: int
|
||
|
locale: Union[str, None]
|
||
|
|
||
|
async def update_locale(self, locale: str) -> None:
|
||
|
"""Change user's locale stored in the database
|
||
|
|
||
|
### Args:
|
||
|
* locale (`str`): New locale to be set
|
||
|
"""
|
||
|
col_users.update_one({"_id": self._id}, {"$set": {"locale": locale}})
|