mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix(GuildMember): mark joined as nullable and fix fetching for these cases
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user