From 20041ea756305f20c86a621232639932c50f107c Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 7 Jan 2017 21:55:47 -0500 Subject: 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. --- discord/guild.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'discord/guild.py') diff --git a/discord/guild.py b/discord/guild.py index 0f37a214..2255c297 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -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.""" -- cgit v1.2.3