From 13a3f760e6de8aa251f06bbe2a746e5f92deafd2 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 10 May 2020 19:30:46 -0400 Subject: 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. --- discord/gateway.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'discord/gateway.py') diff --git a/discord/gateway.py b/discord/gateway.py index 9b0f1d81..15368d56 100644 --- a/discord/gateway.py +++ b/discord/gateway.py @@ -535,15 +535,19 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol): } await self.send_as_json(payload) - async def request_chunks(self, guild_id, query, limit): + async def request_chunks(self, guild_id, query, limit, *, nonce=None): payload = { 'op': self.REQUEST_MEMBERS, 'd': { - 'guild_id': str(guild_id), + 'guild_id': guild_id, 'query': query, 'limit': limit } } + + if nonce: + payload['d']['nonce'] = nonce + await self.send_as_json(payload) async def voice_state(self, guild_id, channel_id, self_mute=False, self_deaf=False): -- cgit v1.2.3