diff --git a/discord/client.py b/discord/client.py index 466445464..b760ee832 100644 --- a/discord/client.py +++ b/discord/client.py @@ -114,13 +114,13 @@ class Client: ----------- user : Optional[:class:`User`] Represents the connected client. None if not logged in. - voice_clients : iterable of :class:`VoiceClient` + voice_clients: List[:class:`VoiceClient`] Represents a list of voice connections. To connect to voice use :meth:`join_voice_channel`. To query the voice connection state use :meth:`is_voice_connected`. - guilds : iterable of :class:`Guild` + guilds: List[:class:`Guild`] The guilds that the connected client is a member of. - private_channels : iterable of :class:`PrivateChannel` + private_channels: List[:class:`abc.PrivateChannel`] The private channels that the connected client is participating on. messages A deque_ of :class:`Message` that the client has received from all diff --git a/discord/guild.py b/discord/guild.py index 5bb7ca66f..c293b077b 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -67,7 +67,7 @@ class Guild(Hashable): roles A list of :class:`Role` that the guild has available. emojis - A list of :class:`Emoji` that the guild owns. + A tuple of :class:`Emoji` that the guild owns. region: :class:`GuildRegion` The region the guild belongs on. There is a chance that the region will be a ``str`` if the value is not recognised by the enumerator. @@ -75,10 +75,6 @@ class Guild(Hashable): The timeout to get sent to the AFK channel. afk_channel: :class:`Channel` The channel that denotes the AFK channel. None if it doesn't exist. - members - An iterable of :class:`Member` that are currently on the guild. - channels - An iterable of :class:`Channel` that are currently on the guild. icon: str The guild's icon. id: int @@ -128,14 +124,6 @@ class Guild(Hashable): self._state = state self._from_data(data) - @property - def channels(self): - return self._channels.values() - - def get_channel(self, channel_id): - """Returns a :class:`Channel` with the given ID. If not found, returns None.""" - return self._channels.get(channel_id) - def _add_channel(self, channel): self._channels[channel.id] = channel @@ -145,14 +133,6 @@ class Guild(Hashable): def _voice_state_for(self, user_id): return self._voice_states.get(user_id) - @property - def members(self): - return self._members.values() - - def get_member(self, user_id): - """Returns a :class:`Member` with the given ID. If not found, returns None.""" - return self._members.get(user_id) - def _add_member(self, member): self._members[member.id] = member @@ -285,6 +265,34 @@ class Guild(Hashable): self._add_channel(channel) + @property + def channels(self): + """List[:class:`abc.GuildChannel`]: A list of channels that belongs to this guild.""" + return list(self._channels.values()) + + @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)] + + @property + def text_channels(self): + """List[:class:`TextChannel`]: A list of text channels that belongs to this guild.""" + return [ch for ch in self._channels.values() if isinstance(ch, TextChannel)] + + def get_channel(self, channel_id): + """Returns a :class:`Channel` with the given ID. If not found, returns None.""" + return self._channels.get(channel_id) + + @property + def members(self): + """List[:class:`Member`]: A list of members that belongs to this guild.""" + return list(self._members.values()) + + def get_member(self, user_id): + """Returns a :class:`Member` with the given ID. If not found, returns None.""" + return self._members.get(user_id) + @utils.cached_slot_property('_default_role') def default_role(self): """Gets the @everyone role that all members have by default.""" diff --git a/discord/state.py b/discord/state.py index 9df9f3658..222e54cad 100644 --- a/discord/state.py +++ b/discord/state.py @@ -114,7 +114,7 @@ class ConnectionState: @property def voice_clients(self): - return self._voice_clients.values() + return list(self._voice_clients.values()) def _get_voice_client(self, guild_id): return self._voice_clients.get(guild_id) @@ -148,7 +148,7 @@ class ConnectionState: @property def guilds(self): - return self._guilds.values() + return list(self._guilds.values()) def _get_guild(self, guild_id): return self._guilds.get(guild_id) @@ -161,7 +161,7 @@ class ConnectionState: @property def private_channels(self): - return self._private_channels.values() + return list(self._private_channels.values()) def _get_private_channel(self, channel_id): return self._private_channels.get(channel_id)