Browse Source

Make Guild.large a property instead of an attribute.

pull/1278/head
Rapptz 8 years ago
parent
commit
b2ffeac297
  1. 24
      discord/guild.py

24
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. 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. 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 mfa_level: int
Indicates the guild's two factor authorisation level. If this value is 0 then 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 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', __slots__ = ('afk_timeout', 'afk_channel', '_members', '_channels', 'icon',
'name', 'id', 'unavailable', 'name', 'region', '_state', 'name', 'id', 'unavailable', 'name', 'region', '_state',
'_default_role', 'roles', '_member_count', 'large', '_default_role', 'roles', '_member_count', '_large',
'owner_id', 'mfa_level', 'emojis', 'features', 'owner_id', 'mfa_level', 'emojis', 'features',
'verification_level', 'splash', '_voice_states' ) 'verification_level', 'splash', '_voice_states' )
@ -213,7 +209,7 @@ class Guild(Hashable):
self._add_member(member) self._add_member(member)
self._sync(guild) 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.owner_id = utils._get_as_snowflake(guild, 'owner_id')
self.afk_channel = self.get_channel(utils._get_as_snowflake(guild, 'afk_channel_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): def _sync(self, data):
try: try:
self.large = data['large'] self._large = data['large']
except KeyError: except KeyError:
pass pass
@ -250,6 +246,20 @@ class Guild(Hashable):
"""List[:class:`abc.GuildChannel`]: A list of channels that belongs to this guild.""" """List[:class:`abc.GuildChannel`]: A list of channels that belongs to this guild."""
return list(self._channels.values()) 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 @property
def voice_channels(self): def voice_channels(self):
"""List[:class:`VoiceChannel`]: A list of voice channels that belongs to this guild.""" """List[:class:`VoiceChannel`]: A list of voice channels that belongs to this guild."""

Loading…
Cancel
Save