Implement AutoShardedClient for transparent sharding.

This allows people to run their >2,500 guild bot in a single process
without the headaches of IPC/RPC or much difficulty.
This commit is contained in:
Rapptz
2017-01-07 21:55:47 -05:00
parent d54d7f7ac0
commit 20041ea756
9 changed files with 341 additions and 31 deletions

View File

@@ -324,6 +324,14 @@ class Guild(Hashable):
"""Returns the true member count regardless of it being loaded fully or not."""
return self._member_count
@property
def shard_id(self):
"""Returns the shard ID for this guild if applicable."""
count = self._state.shard_count
if count is None:
return None
return (self.id >> 22) % count
@property
def created_at(self):
"""Returns the guild's creation time in UTC."""