diff options
| author | Rapptz <[email protected]> | 2017-01-07 21:55:47 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-01-07 23:19:39 -0500 |
| commit | 20041ea756305f20c86a621232639932c50f107c (patch) | |
| tree | fc9be7da66b1dffd274d96f85dd1cb7c605e56c2 /discord/guild.py | |
| parent | Fix variable shadowing in READY parsing. (diff) | |
| download | discord.py-20041ea756305f20c86a621232639932c50f107c.tar.xz discord.py-20041ea756305f20c86a621232639932c50f107c.zip | |
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.
Diffstat (limited to 'discord/guild.py')
| -rw-r--r-- | discord/guild.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/discord/guild.py b/discord/guild.py index 0f37a214..2255c297 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -325,6 +325,14 @@ class Guild(Hashable): 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.""" return utils.snowflake_time(self.id) |