mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +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 }) {
|
_fetchSingle({ user, cache }) {
|
||||||
const existing = this.get(user);
|
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()
|
return this.client.api.guilds(this.guild.id).members(user).get()
|
||||||
.then(data => this.add(data, cache));
|
.then(data => this.add(data, cache));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,11 +65,11 @@ class GuildMember extends Base {
|
|||||||
if (typeof data.nick !== 'undefined') this.nickname = data.nick;
|
if (typeof data.nick !== 'undefined') this.nickname = data.nick;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The timestamp the member joined the guild at
|
* The timestamp the member joined the guild at, if the data was received
|
||||||
* @type {number}
|
* @type {?number}
|
||||||
* @name GuildMember#joinedTimestamp
|
* @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.user) this.user = this.guild.client.users.add(data.user);
|
||||||
if (data.roles) this.roles._patch(data.roles);
|
if (data.roles) this.roles._patch(data.roles);
|
||||||
@@ -147,12 +147,12 @@ class GuildMember extends Base {
|
|||||||
get voiceChannelID() { return this.voiceState.channel_id; }
|
get voiceChannelID() { return this.voiceState.channel_id; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The time this member joined the guild
|
* The time this member joined the guild, if the data was received
|
||||||
* @type {Date}
|
* @type {?Date}
|
||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
get joinedAt() {
|
get joinedAt() {
|
||||||
return new Date(this.joinedTimestamp);
|
return this.joinedTimestamp ? new Date(this.joinedTimestamp) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user