fix(GuildMember): mark joined as nullable

This commit is contained in:
Lewdcario
2018-06-09 15:15:08 -05:00
parent caa4104b95
commit ecf6e2b62d
2 changed files with 11 additions and 8 deletions

View File

@@ -567,7 +567,8 @@ class Guild {
fetchMember(user, cache = true) {
user = this.client.resolver.resolveUser(user);
if (!user) return Promise.reject(new Error('Invalid or uncached id provided.'));
if (this.members.has(user.id)) return Promise.resolve(this.members.get(user.id));
const member = this.members.get(user.id);
if (member && member.joinedTimestamp) return Promise.resolve(member);
return this.client.rest.methods.getGuildMember(this, user, cache);
}

View File

@@ -2,7 +2,7 @@ const TextBasedChannel = require('./interfaces/TextBasedChannel');
const Role = require('./Role');
const Permissions = require('../util/Permissions');
const Collection = require('../util/Collection');
const Presence = require('./Presence').Presence;
const { Presence } = require('./Presence');
const util = require('util');
/**
@@ -31,6 +31,12 @@ class GuildMember {
*/
this.user = {};
/**
* The timestamp this member joined the guild at
* @type {number}
*/
this.joinedTimestamp = null;
this._roles = [];
if (data) this.setup(data);
@@ -96,11 +102,7 @@ class GuildMember {
*/
this.nickname = data.nick || null;
/**
* The timestamp this member joined the guild at
* @type {number}
*/
this.joinedTimestamp = new Date(data.joined_at).getTime();
if (data.joined_at) this.joinedTimestamp = new Date(data.joined_at).getTime();
this.user = data.user;
this._roles = data.roles;
@@ -112,7 +114,7 @@ class GuildMember {
* @readonly
*/
get joinedAt() {
return new Date(this.joinedTimestamp);
return this.joinedTimestamp ? new Date(this.joinedTimestamp) : null;
}
/**