mirror of
https://github.com/danbulant/discord.js
synced 2026-05-27 22:11:53 +00:00
fix(GuildMember): mark joined as nullable
This commit is contained in:
parent
caa4104b95
commit
ecf6e2b62d
2 changed files with 11 additions and 8 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue