fix(PresenceUpdate): use added presence over nullable getter (#6077)

Co-authored-by: Jan <66554238+vaporox@users.noreply.github.com>
Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
SpaceEEC
2021-07-08 22:43:48 +02:00
committed by GitHub
parent 6301728d35
commit 637c8e0fdf

View File

@@ -26,15 +26,15 @@ class PresenceUpdateAction extends Action {
});
this.client.emit(Events.GUILD_MEMBER_AVAILABLE, member);
}
guild.presences._add(Object.assign(data, { guild }));
if (this.client.listenerCount(Events.PRESENCE_UPDATE) && member && !member.presence.equals(oldPresence)) {
const newPresence = guild.presences._add(Object.assign(data, { guild }));
if (this.client.listenerCount(Events.PRESENCE_UPDATE) && !newPresence.equals(oldPresence)) {
/**
* Emitted whenever a guild member's presence (e.g. status, activity) is changed.
* @event Client#presenceUpdate
* @param {?Presence} oldPresence The presence before the update, if one at all
* @param {Presence} newPresence The presence after the update
*/
this.client.emit(Events.PRESENCE_UPDATE, oldPresence, member.presence);
this.client.emit(Events.PRESENCE_UPDATE, oldPresence, newPresence);
}
}
}