aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve C <[email protected]>2021-04-14 22:10:47 -0400
committerRapptz <[email protected]>2021-05-01 10:24:40 -0400
commit4d47436b027992ad5271c80c5bb7a115a609fab0 (patch)
treecf5382ee4f01f412d3ff7f971fb43eff876878ba
parentAdd note to member docs about Spotify limitation (diff)
downloaddiscord.py-4d47436b027992ad5271c80c5bb7a115a609fab0.tar.xz
discord.py-4d47436b027992ad5271c80c5bb7a115a609fab0.zip
Fix guild.chunk() not working on evicted guilds
If you're trying to chunk a guild that the bot is not in, it'll just hang on the chunk coro forever. It's weird, I know.
-rw-r--r--discord/guild.py3
-rw-r--r--discord/state.py3
2 files changed, 5 insertions, 1 deletions
diff --git a/discord/guild.py b/discord/guild.py
index 3b848b20..c8754ffb 100644
--- a/discord/guild.py
+++ b/discord/guild.py
@@ -2223,7 +2223,8 @@ class Guild(Hashable):
if not self._state._intents.members:
raise ClientException('Intents.members must be enabled to use this.')
- return await self._state.chunk_guild(self, cache=cache)
+ if not self._state.is_guild_evicted(self):
+ return await self._state.chunk_guild(self, cache=cache)
async def query_members(self, query=None, *, limit=5, user_ids=None, presences=False, cache=True):
"""|coro|
diff --git a/discord/state.py b/discord/state.py
index 00ccb83d..da1212c1 100644
--- a/discord/state.py
+++ b/discord/state.py
@@ -827,6 +827,9 @@ class ConnectionState:
return self._add_guild_from_data(data)
+ def is_guild_evicted(self, guild) -> bool:
+ return guild.id not in self._guilds
+
async def chunk_guild(self, guild, *, wait=True, cache=None):
cache = cache or self.member_cache_flags.joined
request = self._chunk_requests.get(guild.id)