aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-01-25 05:50:35 -0500
committerRapptz <[email protected]>2017-01-25 05:50:35 -0500
commitc80cbf1931a9c4da73029ea2cd914d0a77b7e042 (patch)
tree64f52d3a2bc5e20553243f8d74e91ca6afe75ace
parentOptimise attribute access when dispatching. (diff)
downloaddiscord.py-c80cbf1931a9c4da73029ea2cd914d0a77b7e042.tar.xz
discord.py-c80cbf1931a9c4da73029ea2cd914d0a77b7e042.zip
Remove Client.__getattr__ and Client.__setattr__ shims.
We should use properties instead.
-rw-r--r--discord/client.py53
1 files changed, 28 insertions, 25 deletions
diff --git a/discord/client.py b/discord/client.py
index c93a4972..209b5bfe 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -104,20 +104,6 @@ class Client:
Attributes
-----------
- user : Optional[:class:`ClientUser`]
- Represents the connected client. None if not logged in.
- 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: List[:class:`Guild`]
- The guilds that the connected client is a member of.
- 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
- guilds and private messages. The number of messages stored in this
- deque is controlled by the ``max_messages`` parameter.
email
The email used to login. This is only set if login is successful,
otherwise it's None.
@@ -234,18 +220,35 @@ class Client:
return m.group(1)
return invite
- def __getattr__(self, name):
- if name in ('user', 'guilds', 'private_channels', 'messages', 'voice_clients'):
- return getattr(self.connection, name)
- else:
- msg = "'{}' object has no attribute '{}'"
- raise AttributeError(msg.format(self.__class__, name))
+ @property
+ def user(self):
+ """Optional[:class:`ClientUser`]: Represents the connected client. None if not logged in."""
+ return self.connection.user
- def __setattr__(self, name, value):
- if name in ('user', 'guilds', 'private_channels', 'messages', 'voice_clients'):
- return setattr(self.connection, name, value)
- else:
- object.__setattr__(self, name, value)
+ @property
+ def guilds(self):
+ """List[:class:`Guild`]: The guilds that the connected client is a member of."""
+ return self.connection.guilds
+
+ @property
+ def private_channels(self):
+ """List[:class:`abc.PrivateChannel`]: The private channels that the connected client is participating on."""
+ return self.connection.private_channels
+
+ @property
+ def messages(self):
+ """A deque_ of :class:`Message` that the client has received from all
+ guilds and private messages.
+
+ The number of messages stored in this deque is controlled by the
+ ``max_messages`` parameter.
+ """
+ return self.connection.messages
+
+ @property
+ def voice_clients(self):
+ """List[:class:`VoiceClient`]: Represents a list of voice connections."""
+ return self.connection.voice_clients
@asyncio.coroutine
def _run_event(self, coro, event_name, *args, **kwargs):