Skip to content

Commit a997fae

Browse files
authored
Merge pull request #1239 from Damego/make-sure-http-is-not-a-string
fix: check `Client._http` is not a string before logout
2 parents f052b44 + b34fbfd commit a997fae

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

interactions/client/bot.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,8 @@ async def _stop(self) -> None:
486486
self._websocket._closing_lock.set() # Toggles the "ready-to-shutdown" state for the bot.
487487
# And subsequently, the processes will close itself.
488488

489-
await self._http._req._session.close() # Closes the HTTP session associated with the client.
489+
if isinstance(self._http, HTTPClient):
490+
await self._http._req._session.close() # Closes the HTTP session associated with the client.
490491

491492
async def _login(self) -> None:
492493
"""Makes a login with the Discord API."""
@@ -1638,7 +1639,8 @@ async def request_guild_members(
16381639

16391640
async def _logout(self) -> None:
16401641
await self._websocket.close()
1641-
await self._http._req.close()
1642+
if isinstance(self._http, HTTPClient):
1643+
await self._http._req.close()
16421644

16431645
async def wait_for(
16441646
self,

0 commit comments

Comments
 (0)