Update Member.joined_at on MESSAGE_CREATE and document it can be None.

Fixes #1638
This commit is contained in:
Rapptz
2019-02-27 06:23:08 -05:00
parent 757584e651
commit 7240d170c1
2 changed files with 28 additions and 3 deletions

View File

@ -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__