Browse Source

Completely update member references from message inner members.

Fixes #5819
pull/5833/head
Rapptz 5 years ago
parent
commit
a183c4f752
  1. 8
      discord/member.py
  2. 3
      discord/message.py

8
discord/member.py

@ -199,6 +199,12 @@ class Member(discord.abc.Messageable, _BaseUser):
data['user'] = author._to_minimal_user_json()
return cls(data=data, guild=message.guild, state=message._state)
def _update_from_message(self, data):
self.joined_at = utils.parse_time(data.get('joined_at'))
self.premium_since = utils.parse_time(data.get('premium_since'))
self._update_roles(data)
self.nick = data.get('nick', None)
@classmethod
def _try_upgrade(cls, *, data, guild, state):
# A User object with a 'member' key
@ -433,7 +439,7 @@ class Member(discord.abc.Messageable, _BaseUser):
guild = self.guild
if len(self._roles) == 0:
return guild.default_role
return max(guild.get_role(rid) or guild.default_role for rid in self._roles)
@property

3
discord/message.py

@ -476,8 +476,7 @@ class Message:
author = self.author
try:
# Update member reference
if author.joined_at is None:
author.joined_at = utils.parse_time(member.get('joined_at'))
author._update_from_message(member)
except AttributeError:
# It's a user here
# TODO: consider adding to cache here

Loading…
Cancel
Save