Update PresenceUpdate.js
This commit is contained in:
parent
9af9d94908
commit
11d6cef551
@ -13,11 +13,9 @@ class PresenceUpdateAction extends Action {
|
||||
if (!user._equals(data.user)) this.client.actions.UserUpdate.handle(data.user);
|
||||
}
|
||||
|
||||
// Shet, user not received guild_id
|
||||
let emited = false;
|
||||
for (const guild of this.client.guilds.cache.map(g => g)) {
|
||||
if (!guild.members.cache.get(user.id)) continue;
|
||||
const oldPresence = guild.presences.cache.get(user.id)?._clone() ?? null;
|
||||
const guild = this.client.guilds.cache.get(data.guild_id);
|
||||
|
||||
if (guild) {
|
||||
let member = guild.members.cache.get(user.id);
|
||||
if (!member && data.status !== 'offline') {
|
||||
member = guild.members._add({
|
||||
@ -27,17 +25,20 @@ class PresenceUpdateAction extends Action {
|
||||
});
|
||||
this.client.emit(Events.GUILD_MEMBER_AVAILABLE, member);
|
||||
}
|
||||
const newPresence = guild.presences._add(Object.assign(data, { guild }));
|
||||
if (this.client.listenerCount(Events.PRESENCE_UPDATE) && !newPresence.equals(oldPresence) && !emited) {
|
||||
/**
|
||||
* 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, newPresence);
|
||||
emited = true;
|
||||
}
|
||||
}
|
||||
|
||||
const oldPresence = (guild || this.client).presences.cache.get(user.id)?._clone() ?? null;
|
||||
|
||||
const newPresence = (guild || this.client).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, newPresence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user