Fix timeout issues with fetching members via query_members

This uses the nonce field to properly disambiguate queries. There's
also some redesigning going on behind the scenes and minor clean-up.
Originally I planned on working on this more to account for the more
widespread chunking changes planned for gateway v7 but I realized that
this would indiscriminately slow down everyone else who isn't planning
on working with intents for now.

I will work on the larger chunking changes in the future, should time
allow for it.
This commit is contained in:
Rapptz
2020-05-10 19:30:46 -04:00
parent 5769511779
commit 13a3f760e6
4 changed files with 42 additions and 58 deletions

View File

@ -223,13 +223,13 @@ class Client:
'ready': self._handle_ready
}
self._connection = ConnectionState(dispatch=self.dispatch, chunker=self._chunker, handlers=self._handlers,
self._connection = ConnectionState(dispatch=self.dispatch, handlers=self._handlers,
syncer=self._syncer, http=self.http, loop=self.loop, **options)
self._connection.shard_count = self.shard_count
self._closed = False
self._ready = asyncio.Event()
self._connection._get_websocket = lambda g: self.ws
self._connection._get_websocket = self._get_websocket
if VoiceClient.warn_nacl:
VoiceClient.warn_nacl = False
@ -237,26 +237,12 @@ class Client:
# internals
def _get_websocket(self, guild_id=None, *, shard_id=None):
return self.ws
async def _syncer(self, guilds):
await self.ws.request_sync(guilds)
async def _chunker(self, guild):
try:
guild_id = guild.id
except AttributeError:
guild_id = [s.id for s in guild]
payload = {
'op': 8,
'd': {
'guild_id': guild_id,
'query': '',
'limit': 0
}
}
await self.ws.send_as_json(payload)
def _handle_ready(self):
self._ready.set()