Remove Client.__getattr__ and Client.__setattr__ shims.
We should use properties instead.
This commit is contained in:
parent
234fd5180f
commit
c80cbf1931
@ -104,20 +104,6 @@ class Client:
|
|||||||
|
|
||||||
Attributes
|
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
|
email
|
||||||
The email used to login. This is only set if login is successful,
|
The email used to login. This is only set if login is successful,
|
||||||
otherwise it's None.
|
otherwise it's None.
|
||||||
@ -234,18 +220,35 @@ class Client:
|
|||||||
return m.group(1)
|
return m.group(1)
|
||||||
return invite
|
return invite
|
||||||
|
|
||||||
def __getattr__(self, name):
|
@property
|
||||||
if name in ('user', 'guilds', 'private_channels', 'messages', 'voice_clients'):
|
def user(self):
|
||||||
return getattr(self.connection, name)
|
"""Optional[:class:`ClientUser`]: Represents the connected client. None if not logged in."""
|
||||||
else:
|
return self.connection.user
|
||||||
msg = "'{}' object has no attribute '{}'"
|
|
||||||
raise AttributeError(msg.format(self.__class__, name))
|
|
||||||
|
|
||||||
def __setattr__(self, name, value):
|
@property
|
||||||
if name in ('user', 'guilds', 'private_channels', 'messages', 'voice_clients'):
|
def guilds(self):
|
||||||
return setattr(self.connection, name, value)
|
"""List[:class:`Guild`]: The guilds that the connected client is a member of."""
|
||||||
else:
|
return self.connection.guilds
|
||||||
object.__setattr__(self, name, value)
|
|
||||||
|
@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
|
@asyncio.coroutine
|
||||||
def _run_event(self, coro, event_name, *args, **kwargs):
|
def _run_event(self, coro, event_name, *args, **kwargs):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user