diff options
| author | jack1142 <[email protected]> | 2020-07-24 13:11:45 +0200 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2020-07-25 09:59:40 -0400 |
| commit | bd9821320ec2288a4c3cfada980a85e78630f94f (patch) | |
| tree | 2ddd6b39b8961e56f56b008668fe2bff26f7d9ff /discord/gateway.py | |
| parent | Update message references in AutoShardedConnectionState (diff) | |
| download | discord.py-bd9821320ec2288a4c3cfada980a85e78630f94f.tar.xz discord.py-bd9821320ec2288a4c3cfada980a85e78630f94f.zip | |
Use a subclass rather than monkey-patching for the websocket
Diffstat (limited to 'discord/gateway.py')
| -rw-r--r-- | discord/gateway.py | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/discord/gateway.py b/discord/gateway.py index 56c1be9e..d54ab597 100644 --- a/discord/gateway.py +++ b/discord/gateway.py @@ -164,14 +164,9 @@ class VoiceKeepAliveHandler(KeepAliveHandler): self.latency = ack_time - self._last_send self.recent_ack_latencies.append(self.latency) -# Monkey patch certain things from the aiohttp websocket code -# Check this whenever we update dependencies. -OLD_CLOSE = aiohttp.ClientWebSocketResponse.close - -async def _new_ws_close(self, *, code: int = 4000, message: bytes = b'') -> bool: - return await OLD_CLOSE(self, code=code, message=message) - -aiohttp.ClientWebSocketResponse.close = _new_ws_close +class DiscordClientWebSocketResponse(aiohttp.ClientWebSocketResponse): + async def close(self, *, code: int = 4000, message: bytes = b'') -> bool: + return await super().close(code=code, message=message) class DiscordWebSocket: """Implements a WebSocket for Discord's gateway v6. |