Browse Source

Remove no_offline_members option

pull/1/head
Rapptz 10 years ago
parent
commit
197e7c2861
  1. 26
      discord/client.py

26
discord/client.py

@ -61,8 +61,6 @@ class Client(object):
A number of options can be passed to the :class:`Client` via keyword arguments.
:param int max_length: The maximum number of messages to store in :attr:`messages`. Defaults to 5000.
:param bool no_offline_members: If this is set to True, then the :attr:`Server.member` lists
will only have members that are online. Defaults to False.
Instance attributes:
@ -89,7 +87,6 @@ class Client(object):
self.private_channels = []
self.token = ''
self.messages = deque([], maxlen=kwargs.get('max_length', 5000))
self.no_offline_members = kwargs.get('no_offline_members', False)
self.events = {
'on_ready': _null_event,
'on_disconnect': _null_event,
@ -177,11 +174,6 @@ class Client(object):
member.status = presence['status']
member.game_id = presence['game_id']
# prune offline lists if wanted
if self.no_offline_members:
pruned = filter(lambda m: m.status == 'offline', members)
for member in pruned:
members.remove(member)
server = Server(**guild)
@ -265,20 +257,12 @@ class Client(object):
if server is not None:
status = data.get('status')
member_id = data['user']['id']
# check to see if the member is in our server list of members
member = next((u for u in server.members if u.id == member_id), None)
if member is None:
# create the member if it doesn't exist
member = Member(**data)
if status == 'online':
server.members.append(member)
elif status == 'offline' and self.no_offline_members:
server.members.remove(member)
# call the event now
self._invoke_event('on_status', member)
if member is not None:
member.status = data.get('status')
member.game_id = data.get('game_id')
# call the event now
self._invoke_event('on_status', member)
elif event == 'USER_UPDATE':
self.user = User(**data)
elif event == 'CHANNEL_DELETE':

Loading…
Cancel
Save