From d93067ca0f748f6f2e1e68c99b8caa9963787268 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 8 Jan 2017 01:28:15 -0500 Subject: [PATCH] Add Guild.chunked property. --- discord/guild.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/discord/guild.py b/discord/guild.py index 2255c297c..841e5167a 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 ''.format(self, chunked) + return ''.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."""