Fixed wrong string conversions during caching on PycordUser
This commit is contained in:
@@ -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)}
|
||||
)
|
||||
|
||||
|
@@ -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(),
|
||||
|
@@ -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:
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user