aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2016-11-16 21:34:27 -0500
committerRapptz <[email protected]>2017-01-03 09:51:59 -0500
commit2c50c18ca3ffdc25c0785b8329044ac81a883905 (patch)
tree7a44af21fcbb49431063a99c61e32e91c3ee0170
parentRe-add support for embeds. (diff)
downloaddiscord.py-2c50c18ca3ffdc25c0785b8329044ac81a883905.tar.xz
discord.py-2c50c18ca3ffdc25c0785b8329044ac81a883905.zip
Change dict value views into lists.
-rw-r--r--discord/client.py6
-rw-r--r--discord/guild.py50
-rw-r--r--discord/state.py6
3 files changed, 35 insertions, 27 deletions
diff --git a/discord/client.py b/discord/client.py
index 46644546..b760ee83 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 5bb7ca66..c293b077 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 9df9f365..222e54ca 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)