Commit 268b9219 authored by Luna's avatar Luna 😻

gateway.websocket: add shards field to ready

see https://github.com/discordapp/discord-api-docs/pull/826
parent 28602dfa
Pipeline #59860564 passed with stage
in 9 minutes and 23 seconds
......@@ -393,17 +393,17 @@ class GatewayWebsocket:
user_id = self.state.user_id
user = await self.storage.get_user(user_id, True)
uready = {}
user_ready = {}
if not self.state.bot:
# user, fetch info
uready = await self._user_ready()
user_ready = await self._user_ready()
private_channels = (
await self.user_storage.get_dms(user_id) +
await self.user_storage.get_gdms(user_id)
)
await self.dispatch('READY', {**{
base_ready = {
'v': 6,
'user': user,
......@@ -411,8 +411,11 @@ class GatewayWebsocket:
'guilds': guilds,
'session_id': self.state.session_id,
'_trace': ['transbian']
}, **uready})
'_trace': ['transbian'],
'shard': self.state.shard,
}
await self.dispatch('READY', {**base_ready, **user_ready})
# async dispatch of guilds
self.ext.loop.create_task(self._guild_dispatch(guilds))
......
......@@ -126,25 +126,30 @@ async def test_ready_fields(test_cli):
}
})
ready = await _json(conn)
assert isinstance(ready, dict)
assert ready['op'] == OP.DISPATCH
assert ready['t'] == 'READY'
data = ready['d']
assert isinstance(data, dict)
# NOTE: change if default gateway changes
assert data['v'] == 6
# make sure other fields exist and are with
# proper types.
assert isinstance(data['user'], dict)
assert isinstance(data['private_channels'], list)
assert isinstance(data['guilds'], list)
assert isinstance(data['session_id'], str)
await _close(conn)
try:
ready = await _json(conn)
assert isinstance(ready, dict)
assert ready['op'] == OP.DISPATCH
assert ready['t'] == 'READY'
data = ready['d']
assert isinstance(data, dict)
# NOTE: change if default gateway changes
assert data['v'] == 6
# make sure other fields exist and are with
# proper types.
assert isinstance(data['user'], dict)
assert isinstance(data['private_channels'], list)
assert isinstance(data['guilds'], list)
assert isinstance(data['session_id'], str)
assert isinstance(data['_trace'], list)
if 'shard' in data:
assert isinstance(data['shard'], list)
finally:
await _close(conn)
@pytest.mark.asyncio
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment