Skip to content

Commit

Permalink
fix(guildmember): make pending nullable (#7401)
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidx committed Feb 9, 2022
1 parent dd751ae commit fe11ff5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions packages/discord.js/src/structures/GuildMember.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class GuildMember extends Base {

/**
* Whether this member has yet to pass the guild's membership gate
* @type {boolean}
* @type {?boolean}
*/
this.pending = false;
this.pending = null;

/**
* The timestamp this member's timeout will be removed
Expand Down Expand Up @@ -81,7 +81,13 @@ class GuildMember extends Base {
this.premiumSinceTimestamp = data.premium_since ? Date.parse(data.premium_since) : null;
}
if ('roles' in data) this._roles = data.roles;
this.pending = data.pending ?? false;

if ('pending' in data) {
this.pending = data.pending;
} else if (!this.partial) {
// See https://github.com/discordjs/discord.js/issues/6546 for more info.
this.pending ??= false;
}

if ('communication_disabled_until' in data) {
this.communicationDisabledUntilTimestamp =
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4715,7 +4715,7 @@ export interface PartialDMChannel extends Partialize<DMChannel, null, null, 'las
lastMessageId: undefined;
}

export interface PartialGuildMember extends Partialize<GuildMember, 'joinedAt' | 'joinedTimestamp'> {}
export interface PartialGuildMember extends Partialize<GuildMember, 'joinedAt' | 'joinedTimestamp' | 'pending'> {}

export interface PartialMessage
extends Partialize<Message, 'type' | 'system' | 'pinned' | 'tts', 'content' | 'cleanContent' | 'author'> {}
Expand Down

0 comments on commit fe11ff5

Please sign in to comment.