From 7240d170c1bfe9851faaa2d17f00e6bc195108b3 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Wed, 27 Feb 2019 06:23:08 -0500 Subject: Update Member.joined_at on MESSAGE_CREATE and document it can be None. Fixes #1638 --- discord/member.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'discord/member.py') diff --git a/discord/member.py b/discord/member.py index 1c0b19df..57de6d22 100644 --- a/discord/member.py +++ b/discord/member.py @@ -138,9 +138,9 @@ class Member(discord.abc.Messageable, _BaseUser): Attributes ---------- - joined_at: `datetime.datetime` + joined_at: Optional[:class:`datetime.datetime`] A datetime object that specifies the date and time in UTC that the member joined the guild for - the first time. + the first time. In certain cases, this can be ``None``. activities: Tuple[Union[:class:`Game`, :class:`Streaming`, :class:`Spotify`, :class:`Activity`]] The activities that the user is currently doing. guild: :class:`Guild` @@ -179,6 +179,16 @@ class Member(discord.abc.Messageable, _BaseUser): def __hash__(self): return hash(self._user) + @classmethod + def _from_message(cls, *, message, data): + author = message.author + data['user'] = { + attr: getattr(author, attr) + for attr in author.__slots__ + if attr[0] != '_' + } + return cls(data=data, guild=message.guild, state=message._state) + @classmethod def _copy(cls, member): self = cls.__new__(cls) # to bypass __init__ -- cgit v1.2.3