mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-22 00:34:06 +00:00
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
|
||||
-----------
|
||||
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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user