aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-01-08 01:28:15 -0500
committerRapptz <[email protected]>2017-01-08 01:28:15 -0500
commitd93067ca0f748f6f2e1e68c99b8caa9963787268 (patch)
tree2cc5e10cad369b267d4c8565b361fad5d57bc0de
parentImplement AutoShardedClient for transparent sharding. (diff)
downloaddiscord.py-d93067ca0f748f6f2e1e68c99b8caa9963787268.tar.xz
discord.py-d93067ca0f748f6f2e1e68c99b8caa9963787268.zip
Add Guild.chunked property.
-rw-r--r--discord/guild.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/discord/guild.py b/discord/guild.py
index 2255c297..841e5167 100644
--- a/discord/guild.py
+++ b/discord/guild.py
@@ -143,8 +143,7 @@ class Guild(Hashable):
return self.name
def __repr__(self):
- chunked = getattr(self, '_member_count', None) == len(self._members)
- return '<Guild id={0.id} name={0.name!r} chunked={1}>'.format(self, chunked)
+ return '<Guild id={0.id} name={0.name!r} chunked={0.chunked}>'.format(self)
def _update_voice_state(self, data, channel_id):
user_id = int(data['user_id'])
@@ -325,6 +324,21 @@ class Guild(Hashable):
return self._member_count
@property
+ def chunked(self):
+ """Returns a boolean indicating if the guild is "chunked".
+
+ A chunked guild means that :attr:`member_count` is equal to the
+ number of members stored in the internal :attr:`members` cache.
+
+ If this value returns ``False``, then you should request for
+ offline members.
+ """
+ count = getattr(self, '_member_count', None)
+ if count is None:
+ return False
+ return count == len(self._members)
+
+ @property
def shard_id(self):
"""Returns the shard ID for this guild if applicable."""
count = self._state.shard_count