Guild Sharding support
This commit is contained in:
parent
c34eb5f6dd
commit
abf9be5f7d
@ -101,6 +101,10 @@ class Client:
|
|||||||
connector : aiohttp.BaseConnector
|
connector : aiohttp.BaseConnector
|
||||||
The `connector`_ to use for connection pooling. Useful for proxies, e.g.
|
The `connector`_ to use for connection pooling. Useful for proxies, e.g.
|
||||||
with a `ProxyConnector`_.
|
with a `ProxyConnector`_.
|
||||||
|
shard_id : Optional[int]
|
||||||
|
Integer starting at 0 and less than shard_count.
|
||||||
|
shard_count : Optional[int]
|
||||||
|
The total number of shards.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
-----------
|
-----------
|
||||||
@ -133,6 +137,8 @@ class Client:
|
|||||||
self.loop = asyncio.get_event_loop() if loop is None else loop
|
self.loop = asyncio.get_event_loop() if loop is None else loop
|
||||||
self._listeners = []
|
self._listeners = []
|
||||||
self.cache_auth = options.get('cache_auth', True)
|
self.cache_auth = options.get('cache_auth', True)
|
||||||
|
self.shard_id = options.get('shard_id')
|
||||||
|
self.shard_count = options.get('shard_count')
|
||||||
|
|
||||||
max_messages = options.get('max_messages')
|
max_messages = options.get('max_messages')
|
||||||
if max_messages is None or max_messages < 100:
|
if max_messages is None or max_messages < 100:
|
||||||
|
@ -178,6 +178,8 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol):
|
|||||||
ws._connection = client.connection
|
ws._connection = client.connection
|
||||||
ws._dispatch = client.dispatch
|
ws._dispatch = client.dispatch
|
||||||
ws.gateway = gateway
|
ws.gateway = gateway
|
||||||
|
ws.shard_id = client.shard_id
|
||||||
|
ws.shard_count = client.shard_count
|
||||||
|
|
||||||
client.connection._update_references(ws)
|
client.connection._update_references(ws)
|
||||||
|
|
||||||
@ -250,6 +252,9 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol):
|
|||||||
if not self._connection.is_bot:
|
if not self._connection.is_bot:
|
||||||
payload['d']['synced_guilds'] = []
|
payload['d']['synced_guilds'] = []
|
||||||
|
|
||||||
|
if self.shard_id is not None and self.shard_count is not None:
|
||||||
|
payload['d']['shard'] = [self.shard_id, self.shard_count]
|
||||||
|
|
||||||
yield from self.send_as_json(payload)
|
yield from self.send_as_json(payload)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
Loading…
x
Reference in New Issue
Block a user