Add on_disconnect event.
I assume this is where it has to be. Fix #1937
This commit is contained in:
		| @@ -409,6 +409,7 @@ class Client: | |||||||
|                     websockets.InvalidHandshake, |                     websockets.InvalidHandshake, | ||||||
|                     websockets.WebSocketProtocolError) as exc: |                     websockets.WebSocketProtocolError) as exc: | ||||||
|  |  | ||||||
|  |                 self.dispatch('disconnect') | ||||||
|                 if not reconnect: |                 if not reconnect: | ||||||
|                     await self.close() |                     await self.close() | ||||||
|                     if isinstance(exc, ConnectionClosed) and exc.code == 1000: |                     if isinstance(exc, ConnectionClosed) and exc.code == 1000: | ||||||
|   | |||||||
| @@ -103,6 +103,14 @@ to handle it, which defaults to print a traceback and ignoring the exception. | |||||||
|  |  | ||||||
|     The warnings on :func:`on_ready` also apply. |     The warnings on :func:`on_ready` also apply. | ||||||
|  |  | ||||||
|  | .. function:: on_disconnect() | ||||||
|  |  | ||||||
|  |     Called when the client has disconnected from Discord. This could happen either through | ||||||
|  |     the internet being disconnect, explicit calls to logout, or Discord terminating the connection | ||||||
|  |     one way or the other. | ||||||
|  |  | ||||||
|  |     This function can be called many times. | ||||||
|  |  | ||||||
| .. function:: on_ready() | .. function:: on_ready() | ||||||
|  |  | ||||||
|     Called when the client is done preparing the data received from Discord. Usually after login is successful |     Called when the client is done preparing the data received from Discord. Usually after login is successful | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user