From a183c4f75264a67015b6cbd6969b3e44397aa2bf Mon Sep 17 00:00:00 2001 From: Rapptz Date: Thu, 17 Sep 2020 02:45:53 -0400 Subject: [PATCH] Completely update member references from message inner members. Fixes #5819 --- discord/member.py | 8 +++++++- discord/message.py | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/discord/member.py b/discord/member.py index 1fb11e638..b9d1ffa7f 100644 --- a/discord/member.py +++ b/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 diff --git a/discord/message.py b/discord/message.py index 7e8440f4c..c7de78d18 100644 --- a/discord/message.py +++ b/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