fix(PresenceUpdate): Event not emit

This commit is contained in:
March 7th 2022-07-09 20:14:18 +07:00
parent 536a86a5f3
commit 2d78b2437e
4 changed files with 35 additions and 24 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "discord.js-selfbot-v13", "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]", "description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
"main": "./src/index.js", "main": "./src/index.js",
"types": "./typings/index.d.ts", "types": "./typings/index.d.ts",

View File

@ -13,28 +13,31 @@ 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);
} }
const guild = this.client.guilds.cache.get(data.guild_id); // Shet, user not received guild_id
if (!guild) return; let emited = false;
for (const guild of this.client.guilds.cache.map(g => g)) {
const oldPresence = guild.presences.cache.get(user.id)?._clone() ?? null; if (!guild.members.cache.get(user.id)) continue;
let member = guild.members.cache.get(user.id); const oldPresence = guild.presences.cache.get(user.id)?._clone() ?? null;
if (!member && data.status !== 'offline') { let member = guild.members.cache.get(user.id);
member = guild.members._add({ if (!member && data.status !== 'offline') {
user, member = guild.members._add({
deaf: false, user,
mute: false, deaf: false,
}); mute: false,
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)) { 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 * Emitted whenever a guild member's presence (e.g. status, activity) is changed.
* @param {?Presence} oldPresence The presence before the update, if one at all * @event Client#presenceUpdate
* @param {Presence} newPresence The presence after the update * @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); */
this.client.emit(Events.PRESENCE_UPDATE, oldPresence, newPresence);
emited = true;
}
} }
} }
} }

View File

@ -110,6 +110,14 @@ class Presence extends Base {
this.clientStatus ??= null; this.clientStatus ??= null;
} }
if ('last_modified' in data) {
/**
* The timestamp this presence was last updated
* @type {number}
*/
this.lastModified = data.last_modified;
}
return this; return this;
} }