This commit is contained in:
2025-05-06 20:16:44 +02:00
parent d1498f38e9
commit 96c1314234
5 changed files with 33 additions and 199 deletions

View File

@@ -79,59 +79,18 @@ class PycordGuild(BaseCacheable):
async def _set(self, cache: Optional[Cache] = None, **kwargs: Any) -> None:
await super()._set(cache, **kwargs)
# for key, value in kwargs.items():
# if not hasattr(self, key):
# raise AttributeError()
#
# setattr(self, key, value)
#
# await self.__collection__.update_one({"_id": self._id}, {"$set": kwargs})
#
# self._update_cache(cache)
#
# logger.info("Set attributes of guild %s to %s", self.id, kwargs)
async def _remove(self, *args: str, cache: Optional[Cache] = None) -> None:
await super()._remove(*args, cache=cache)
# attributes: Dict[str, Any] = {}
#
# for key in args:
# if not hasattr(self, key):
# raise AttributeError()
#
# default_value: Any = self.get_default_value(key)
#
# setattr(self, key, default_value)
#
# attributes[key] = default_value
#
# await self.__collection__.update_one({"_id": self._id}, {"$set": attributes})
#
# self._update_cache(cache)
#
# logger.info("Reset attributes %s of guild %s to default values", args, self.id)
def _get_cache_key(self) -> str:
return f"{self.__short_name__}_{self.id}"
def _update_cache(self, cache: Optional[Cache] = None) -> None:
super()._update_cache(cache)
# if cache is None:
# return
#
# object_dict: Dict[str, Any] = self.to_dict(json_compatible=True)
#
# if object_dict is not None:
# cache.set_json(self._get_cache_key(), object_dict)
# else:
# self._delete_cache(cache)
def _delete_cache(self, cache: Optional[Cache] = None) -> None:
super()._delete_cache(cache)
# if cache is None:
# return
#
# cache.delete(self._get_cache_key())
@staticmethod
def _entry_to_cache(db_entry: Dict[str, Any]) -> Dict[str, Any]:
@@ -217,11 +176,6 @@ class PycordGuild(BaseCacheable):
await super().reset(*args, cache=cache)
async def purge(self, cache: Optional[Cache] = None) -> None:
"""Completely remove guild data from database. Currently only removes the guild record from guilds collection.
Args:
cache (:obj:`Cache`, optional): Cache engine to write the update into
"""
await super().purge(cache)
def is_configured(self) -> bool: