mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 09:33:32 +01:00
cleanup(Client): guard emitting GMU and PU on user updates (#5655)
This commit is contained in:
@@ -346,6 +346,29 @@ class GuildMember extends Base {
|
||||
return this.guild.members.fetch({ user: this.id, cache: true, force });
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this guild member equals another guild member. It compares all properties, so for most
|
||||
* comparison it is advisable to just compare `member.id === member2.id` as it is significantly faster
|
||||
* and is often what most users need.
|
||||
* @param {GuildMember} member The member to compare with
|
||||
* @returns {boolean}
|
||||
*/
|
||||
equals(member) {
|
||||
return (
|
||||
member instanceof this.constructor &&
|
||||
this.id === member.id &&
|
||||
this.partial === member.partial &&
|
||||
this.guild.id === member.guild.id &&
|
||||
this.joinedTimestamp === member.joinedTimestamp &&
|
||||
this.lastMessageID === member.lastMessageID &&
|
||||
this.lastMessageChannelID === member.lastMessageChannelID &&
|
||||
this.nickname === member.nickname &&
|
||||
this.pending === member.pending &&
|
||||
(this._roles === member._roles ||
|
||||
(this._roles.length === member._roles.length && this._roles.every((role, i) => role === member._roles[i])))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* When concatenated with a string, this automatically returns the user's mention instead of the GuildMember object.
|
||||
* @returns {string}
|
||||
|
||||
Reference in New Issue
Block a user