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);
|
if (!user._equals(data.user)) this.client.actions.UserUpdate.handle(data.user);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shet, user not received guild_id
|
const guild = this.client.guilds.cache.get(data.guild_id);
|
||||||
let emited = false;
|
|
||||||
for (const guild of this.client.guilds.cache.map(g => g)) {
|
if (guild) {
|
||||||
if (!guild.members.cache.get(user.id)) continue;
|
|
||||||
const oldPresence = guild.presences.cache.get(user.id)?._clone() ?? null;
|
|
||||||
let member = guild.members.cache.get(user.id);
|
let member = guild.members.cache.get(user.id);
|
||||||
if (!member && data.status !== 'offline') {
|
if (!member && data.status !== 'offline') {
|
||||||
member = guild.members._add({
|
member = guild.members._add({
|
||||||
@ -27,8 +25,13 @@ class PresenceUpdateAction extends Action {
|
|||||||
});
|
});
|
||||||
this.client.emit(Events.GUILD_MEMBER_AVAILABLE, member);
|
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) {
|
|
||||||
|
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.
|
* Emitted whenever a guild member's presence (e.g. status, activity) is changed.
|
||||||
* @event Client#presenceUpdate
|
* @event Client#presenceUpdate
|
||||||
@ -36,8 +39,6 @@ class PresenceUpdateAction extends Action {
|
|||||||
* @param {Presence} newPresence The presence after the update
|
* @param {Presence} newPresence The presence after the update
|
||||||
*/
|
*/
|
||||||
this.client.emit(Events.PRESENCE_UPDATE, oldPresence, newPresence);
|
this.client.emit(Events.PRESENCE_UPDATE, oldPresence, newPresence);
|
||||||
emited = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user