from dataclasses import dataclass
from typing import Union
from bson import ObjectId
from modules.database import col_users
@dataclass
class PyroUser:
"""Dataclass of DB entry of a user"""
__slots__ = ("_id", "id", "locale")
_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
"""
await col_users.update_one({"_id": self._id}, {"$set": {"locale": locale}})