diff --git a/quart_discord/client.py b/quart_discord/client.py index 6bd7063..9e1bb86 100644 --- a/quart_discord/client.py +++ b/quart_discord/client.py @@ -213,21 +213,27 @@ async def fetch_connections() -> list: return await models.UserConnection.fetch_from_api() @staticmethod - async def fetch_guilds() -> list: + async def fetch_guilds(use_cache=True) -> list: """This method returns list of guild objects from internal cache if it exists otherwise makes an API call to do so. + Parameters + ---------- + use_cache : bool, optional + can be set to False to avoid using the cache. + Returns ------- list List of :py:class:`quart_discord.models.Guild` objects. """ - user = models.User.get_from_cache() - try: - if user.guilds is not None: - return user.guilds - except AttributeError: - pass + if use_cache: + user = models.User.get_from_cache() + try: + if user.guilds is not None: + return user.guilds + except AttributeError: + pass return await models.Guild.fetch_from_api()