fix(PresenceUpdate): Event not emit
This commit is contained in:
parent
536a86a5f3
commit
2d78b2437e
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "discord.js-selfbot-v13",
|
||||
"version": "2.3.67",
|
||||
"version": "2.3.68",
|
||||
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
|
||||
"main": "./src/index.js",
|
||||
"types": "./typings/index.d.ts",
|
||||
|
@ -13,9 +13,10 @@ class PresenceUpdateAction extends Action {
|
||||
if (!user._equals(data.user)) this.client.actions.UserUpdate.handle(data.user);
|
||||
}
|
||||
|
||||
const guild = this.client.guilds.cache.get(data.guild_id);
|
||||
if (!guild) return;
|
||||
|
||||
// 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;
|
||||
let member = guild.members.cache.get(user.id);
|
||||
if (!member && data.status !== 'offline') {
|
||||
@ -27,7 +28,7 @@ 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)) {
|
||||
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
|
||||
@ -35,6 +36,8 @@ class PresenceUpdateAction extends Action {
|
||||
* @param {Presence} newPresence The presence after the update
|
||||
*/
|
||||
this.client.emit(Events.PRESENCE_UPDATE, oldPresence, newPresence);
|
||||
emited = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,6 +110,14 @@ class Presence extends Base {
|
||||
this.clientStatus ??= null;
|
||||
}
|
||||
|
||||
if ('last_modified' in data) {
|
||||
/**
|
||||
* The timestamp this presence was last updated
|
||||
* @type {number}
|
||||
*/
|
||||
this.lastModified = data.last_modified;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user