Browse Source

Remove Member related handling in PRESENCE_UPDATE

pull/6701/head
Rapptz 4 years ago
parent
commit
7d79b4ba55
  1. 11
      discord/member.py
  2. 16
      discord/state.py

11
discord/member.py

@ -262,17 +262,6 @@ class Member(discord.abc.Messageable, _BaseUser):
member_data['user'] = data
return cls(data=member_data, guild=guild, state=state)
@classmethod
def _from_presence_update(cls, *, data, guild, state):
clone = cls(data=data, guild=guild, state=state)
to_return = cls(data=data, guild=guild, state=state)
to_return._client_status = {
sys.intern(key): sys.intern(value)
for key, value in data.get('client_status', {}).items()
}
to_return._client_status[None] = sys.intern(data['status'])
return to_return, clone
@classmethod
def _copy(cls, member):
self = cls.__new__(cls) # to bypass __init__

16
discord/state.py

@ -602,17 +602,13 @@ class ConnectionState:
member_id = int(user['id'])
member = guild.get_member(member_id)
if member is None:
if 'username' not in user:
# sometimes we receive 'incomplete' member data post-removal.
# skip these useless cases.
return
log.debug('PRESENCE_UPDATE referencing an unknown member ID: %s. Discarding', member_id)
return
member, old_member = Member._from_presence_update(guild=guild, data=data, state=self)
else:
old_member = Member._copy(member)
user_update = member._presence_update(data=data, user=user)
if user_update:
self.dispatch('user_update', user_update[0], user_update[1])
old_member = Member._copy(member)
user_update = member._presence_update(data=data, user=user)
if user_update:
self.dispatch('user_update', user_update[0], user_update[1])
self.dispatch('member_update', old_member, member)

Loading…
Cancel
Save