Add logout method (#114)
This commit is contained in:
parent
132521fa39
commit
e2061adc55
@ -112,6 +112,10 @@ These options are forwarded to ``HTTPClient`` when it creates the underlying
|
||||
``aiohttp.ClientSession``. You can specify a custom ``connector`` or any other
|
||||
session parameter supported by ``aiohttp``.
|
||||
|
||||
### Logging Out
|
||||
|
||||
Call ``Client.logout`` to disconnect from the Gateway and clear the current bot token while keeping the HTTP session alive. Assign a new token and call ``connect`` or ``run`` to log back in.
|
||||
|
||||
### Default Allowed Mentions
|
||||
|
||||
Specify default mention behaviour for all outgoing messages when constructing the client:
|
||||
|
@ -464,6 +464,14 @@ class Client:
|
||||
self._gateway = None
|
||||
self._ready_event.clear() # No longer ready if gateway is closed
|
||||
|
||||
async def logout(self) -> None:
|
||||
"""Invalidate the bot token and disconnect from the Gateway."""
|
||||
await self.close_gateway()
|
||||
self.token = ""
|
||||
self._http.token = ""
|
||||
self.user = None
|
||||
self.start_time = None
|
||||
|
||||
def is_closed(self) -> bool:
|
||||
"""Indicates if the client has been closed."""
|
||||
return self._closed
|
||||
|
Loading…
x
Reference in New Issue
Block a user