diff options
| author | Rapptz <[email protected]> | 2020-04-11 17:28:03 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2020-07-25 09:59:39 -0400 |
| commit | 394b514cc927df61828017aa2078ff7dad6821e0 (patch) | |
| tree | c801bdc52f103667ef9b10447d676e76c626a83e /discord/gateway.py | |
| parent | Fix READY not firing for multi-processed AutoShardedClient clusters (diff) | |
| download | discord.py-394b514cc927df61828017aa2078ff7dad6821e0.tar.xz discord.py-394b514cc927df61828017aa2078ff7dad6821e0.zip | |
Add before_identify_hook to have finer control over IDENTIFY syncing
Diffstat (limited to 'discord/gateway.py')
| -rw-r--r-- | discord/gateway.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/discord/gateway.py b/discord/gateway.py index 1f82c9ef..db3c7fd5 100644 --- a/discord/gateway.py +++ b/discord/gateway.py @@ -250,7 +250,7 @@ class DiscordWebSocket: return not self.socket.closed @classmethod - async def from_client(cls, client, *, gateway=None, shard_id=None, session=None, sequence=None, resume=False): + async def from_client(cls, client, *, initial=False, gateway=None, shard_id=None, session=None, sequence=None, resume=False): """Creates a main websocket for Discord from a :class:`Client`. This is for internal use only. @@ -265,6 +265,8 @@ class DiscordWebSocket: ws._discord_parsers = client._connection.parsers ws._dispatch = client.dispatch ws.gateway = gateway + ws.call_hooks = client._connection.call_hooks + ws._initial_identify = initial ws.shard_id = shard_id ws.shard_count = client._connection.shard_count ws.session_id = session @@ -345,6 +347,7 @@ class DiscordWebSocket: 'afk': False } + await self.call_hooks('before_identify', self.shard_id, initial=self._initial_identify) await self.send_as_json(payload) log.info('Shard ID %s has sent the IDENTIFY payload.', self.shard_id) |