aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-02-24 17:51:27 -0500
committerRapptz <[email protected]>2017-02-24 17:51:27 -0500
commitb2ffeac2976654691f0a9ed5b748dc94e5422e4b (patch)
treeac0c718282841271fdd294357d056d65fba85bb1
parentAdd info logging for close codes we cannot handle. (diff)
downloaddiscord.py-b2ffeac2976654691f0a9ed5b748dc94e5422e4b.tar.xz
discord.py-b2ffeac2976654691f0a9ed5b748dc94e5422e4b.zip
Make Guild.large a property instead of an attribute.
-rw-r--r--discord/guild.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/discord/guild.py b/discord/guild.py
index 89d5fb63..878ceb03 100644
--- a/discord/guild.py
+++ b/discord/guild.py
@@ -91,10 +91,6 @@ class Guild(Hashable):
all be None. It is best to not do anything with the guild if it is unavailable.
Check the :func:`on_guild_unavailable` and :func:`on_guild_available` events.
- large: bool
- Indicates if the guild is a 'large' guild. A large guild is defined as having
- more than ``large_threshold`` count members, which for this library is set to
- the maximum of 250.
mfa_level: int
Indicates the guild's two factor authorisation level. If this value is 0 then
the guild does not require 2FA for their administrative members. If the value is
@@ -114,7 +110,7 @@ class Guild(Hashable):
__slots__ = ('afk_timeout', 'afk_channel', '_members', '_channels', 'icon',
'name', 'id', 'unavailable', 'name', 'region', '_state',
- '_default_role', 'roles', '_member_count', 'large',
+ '_default_role', 'roles', '_member_count', '_large',
'owner_id', 'mfa_level', 'emojis', 'features',
'verification_level', 'splash', '_voice_states' )
@@ -213,7 +209,7 @@ class Guild(Hashable):
self._add_member(member)
self._sync(guild)
- self.large = None if member_count is None else self._member_count >= 250
+ self._large = None if member_count is None else self._member_count >= 250
self.owner_id = utils._get_as_snowflake(guild, 'owner_id')
self.afk_channel = self.get_channel(utils._get_as_snowflake(guild, 'afk_channel_id'))
@@ -223,7 +219,7 @@ class Guild(Hashable):
def _sync(self, data):
try:
- self.large = data['large']
+ self._large = data['large']
except KeyError:
pass
@@ -251,6 +247,20 @@ class Guild(Hashable):
return list(self._channels.values())
@property
+ def large(self):
+ """bool: Indicates if the guild is a 'large' guild.
+
+ A large guild is defined as having more than ``large_threshold`` count
+ members, which for this library is set to the maximum of 250.
+ """
+ if self._large is None:
+ try:
+ return self._member_count >= 250
+ except AttributeError:
+ return len(self._members) >= 250
+ return self._large
+
+ @property
def voice_channels(self):
"""List[:class:`VoiceChannel`]: A list of voice channels that belongs to this guild."""
return [ch for ch in self._channels.values() if isinstance(ch, VoiceChannel)]