fix(GuildMember): mark joined as nullable and fix fetching for these cases

This commit is contained in:
Lewdcario
2018-06-05 19:50:36 -05:00
parent 46af6e3396
commit 13bfceb83c
2 changed files with 7 additions and 7 deletions

View File

@@ -178,7 +178,7 @@ class GuildMemberStore extends DataStore {
_fetchSingle({ user, cache }) {
const existing = this.get(user);
if (existing) return Promise.resolve(existing);
if (existing && existing.joinedTimestamp) return Promise.resolve(existing);
return this.client.api.guilds(this.guild.id).members(user).get()
.then(data => this.add(data, cache));
}

View File

@@ -65,11 +65,11 @@ class GuildMember extends Base {
if (typeof data.nick !== 'undefined') this.nickname = data.nick;
/**
* The timestamp the member joined the guild at
* @type {number}
* The timestamp the member joined the guild at, if the data was received
* @type {?number}
* @name GuildMember#joinedTimestamp
*/
if (data.joined_at) this.joinedTimestamp = new Date(Number(data.joined_at)).getTime();
if (data.joined_at) this.joinedTimestamp = new Date(data.joined_at).getTime();
if (data.user) this.user = this.guild.client.users.add(data.user);
if (data.roles) this.roles._patch(data.roles);
@@ -147,12 +147,12 @@ class GuildMember extends Base {
get voiceChannelID() { return this.voiceState.channel_id; }
/**
* The time this member joined the guild
* @type {Date}
* The time this member joined the guild, if the data was received
* @type {?Date}
* @readonly
*/
get joinedAt() {
return new Date(this.joinedTimestamp);
return this.joinedTimestamp ? new Date(this.joinedTimestamp) : null;
}
/**