From 068d953b42cbcb31db0d12a52842171223f8895d Mon Sep 17 00:00:00 2001
From: CraftSpider <runetynan@gmail.com>
Date: Sat, 1 Dec 2018 22:45:37 -0500
Subject: [PATCH] Add override to `close()` method to the websocket subclass.

This makes it so that _keep_alive is stopped no matter which closing
method is called
---
 discord/gateway.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/discord/gateway.py b/discord/gateway.py
index 35d92fe67..803c8c255 100644
--- a/discord/gateway.py
+++ b/discord/gateway.py
@@ -510,6 +510,12 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol):
         log.debug('Updating our voice state to %s.', payload)
         await self.send_as_json(payload)
 
+    async def close(self, code=1000, reason=''):
+        if self._keep_alive:
+            self._keep_alive.stop()
+
+        await super().close(code, reason)
+
     async def close_connection(self, *args, **kwargs):
         if self._keep_alive:
             self._keep_alive.stop()