Browse Source

Give members their server as an attribute.

pull/1/head
Rapptz 10 years ago
parent
commit
52852f4fd2
  1. 7
      discord/client.py
  2. 4
      discord/server.py

7
discord/client.py

@ -172,7 +172,7 @@ class Client(object):
for presence in guild['presences']:
user_id = presence['user']['id']
member = next((m for m in members if member.id == user_id), None)
member = next((m for m in members if m.id == user_id), None)
if member is not None:
member.status = presence['status']
member.game_id = presence['game_id']
@ -184,6 +184,11 @@ class Client(object):
members.remove(member)
server = Server(**guild)
# give all the members their proper server
for member in server.members:
member.server = server
for channel in guild['channels']:
changed_roles = []
permission_overwrites = channel['permission_overwrites']

4
discord/server.py

@ -76,6 +76,9 @@ class Member(User):
.. attribute:: game_id
The game ID that the user is currently playing. Could be None if no game is being played.
.. attribute:: server
The :class:`Server` that the member belongs to.
"""
def __init__(self, deaf, joined_at, user, roles, mute):
@ -86,6 +89,7 @@ class Member(User):
self.roles = roles
self.status = 'offline'
self.game_id = None
self.server = None
class Server(object):
"""Represents a Discord server.

Loading…
Cancel
Save