Browse Source

Add Guild.chunked property.

pull/447/head
Rapptz 8 years ago
parent
commit
d93067ca0f
  1. 18
      discord/guild.py

18
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'])
@ -324,6 +323,21 @@ class Guild(Hashable):
"""Returns the true member count regardless of it being loaded fully or not."""
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."""

Loading…
Cancel
Save