diff --git a/classes/pycord_event.py b/classes/pycord_event.py index ca3b576..beaa142 100644 --- a/classes/pycord_event.py +++ b/classes/pycord_event.py @@ -11,7 +11,6 @@ from libbot.cache.classes import Cache from pymongo import DESCENDING from pymongo.results import InsertOneResult -from classes.abstract import Cacheable from classes.base.base_cacheable import BaseCacheable from classes.errors import EventNotFoundError from modules.database import col_events @@ -86,7 +85,7 @@ class PycordEvent(BaseCacheable): if cached_entry is not None: return cls(**cls._entry_from_cache(cached_entry)) - db_entry = await cls.__collection__.find_one( + db_entry: Dict[str, Any] | None = await cls.__collection__.find_one( {"_id": event_id if isinstance(event_id, ObjectId) else ObjectId(event_id)} ) diff --git a/classes/pycord_event_stage.py b/classes/pycord_event_stage.py index 5f03180..b9ae846 100644 --- a/classes/pycord_event_stage.py +++ b/classes/pycord_event_stage.py @@ -64,7 +64,7 @@ class PycordEventStage(BaseCacheable): if cached_entry is not None: return cls(**cls._entry_from_cache(cached_entry)) - db_entry = await cls.__collection__.find_one( + db_entry: Dict[str, Any] | None = await cls.__collection__.find_one( {"_id": stage_id if isinstance(stage_id, ObjectId) else ObjectId(stage_id)} ) @@ -155,7 +155,11 @@ class PycordEventStage(BaseCacheable): """ return { "_id": self._id if not json_compatible else str(self._id), - "event_id": self.event_id if not json_compatible else str(self.event_id), + "event_id": ( + self.event_id + if not json_compatible + else (None if self.event_id is None else str(self.event_id)) + ), "guild_id": self.guild_id, "sequence": self.sequence, "created": self.created if not json_compatible else self.created.isoformat(), diff --git a/classes/pycord_guild.py b/classes/pycord_guild.py index 6af35e7..ac30b14 100644 --- a/classes/pycord_guild.py +++ b/classes/pycord_guild.py @@ -60,7 +60,7 @@ class PycordGuild(BaseCacheable): if cached_entry is not None: return cls(**cls._entry_from_cache(cached_entry)) - db_entry = await cls.__collection__.find_one({"id": guild_id}) + db_entry: Dict[str, Any] | None = await cls.__collection__.find_one({"id": guild_id}) if db_entry is None: if not allow_creation: diff --git a/classes/pycord_user.py b/classes/pycord_user.py index 56641dc..516e0ce 100644 --- a/classes/pycord_user.py +++ b/classes/pycord_user.py @@ -86,7 +86,9 @@ class PycordUser(BaseCacheable): if cached_entry is not None: return cls(**cls._entry_from_cache(cached_entry)) - db_entry = await cls.__collection__.find_one({"id": user_id, "guild_id": guild_id}) + db_entry: Dict[str, Any] | None = await cls.__collection__.find_one( + {"id": user_id, "guild_id": guild_id} + ) if db_entry is None: if not allow_creation: @@ -119,10 +121,14 @@ class PycordUser(BaseCacheable): "event_channels": self.event_channels, "is_jailed": self.is_jailed, "current_event_id": ( - self.current_event_id if not json_compatible else str(self.current_event_id) + self.current_event_id + if not json_compatible + else (None if self.current_event_id is None else str(self.current_event_id)) ), "current_stage_id": ( - self.current_stage_id if not json_compatible else str(self.current_stage_id) + self.current_stage_id + if not json_compatible + else (None if self.current_stage_id is None else str(self.current_stage_id)) ), "registered_event_ids": ( self.registered_event_ids