Add shard related connection and resume events.

These include:
* on_shard_resumed
* on_shard_connect
* on_shard_disconnect
This commit is contained in:
Rapptz
2020-04-11 22:35:07 -04:00
parent 80cc5b5edb
commit 8070d39a23
4 changed files with 41 additions and 0 deletions

View File

@ -104,6 +104,7 @@ class Shard:
async def _handle_disconnect(self, e):
self._dispatch('disconnect')
self._dispatch('shard_disconnect', self.id)
if not self._reconnect:
self._queue.put_nowait(EventItem(EventType.close, self, e))
return
@ -136,6 +137,7 @@ class Shard:
async def reidentify(self, exc):
self._cancel_task()
self._dispatch('disconnect')
self._dispatch('shard_disconnect', self.id)
log.info('Got a request to %s the websocket at Shard ID %s.', exc.op, self.id)
try:
coro = DiscordWebSocket.from_client(self._client, resume=exc.resume, shard_id=self.id,