diff --git a/src/structures/ClientPresence.js b/src/structures/ClientPresence.js index 088e513..bb947a3 100644 --- a/src/structures/ClientPresence.js +++ b/src/structures/ClientPresence.js @@ -24,15 +24,7 @@ class ClientPresence extends Presence { const packet = this._parse(presence); this._patch(packet); packet.activities = this.activities.map(a => a.toJSON()); - if (typeof presence.shardId === 'undefined') { - this.client.ws.broadcast({ op: Opcodes.STATUS_UPDATE, d: packet }); - } else if (Array.isArray(presence.shardId)) { - for (const shardId of presence.shardId) { - this.client.ws.shards.get(shardId).send({ op: Opcodes.STATUS_UPDATE, d: packet }); - } - } else { - this.client.ws.shards.get(presence.shardId).send({ op: Opcodes.STATUS_UPDATE, d: packet }); - } + this.client.ws.broadcast({ op: Opcodes.STATUS_UPDATE, d: packet }); return this; } @@ -45,8 +37,8 @@ class ClientPresence extends Presence { _parse({ status, since, afk, activities }) { const data = { activities: [], - afk: typeof afk === 'boolean' ? afk : false, - since: typeof since === 'number' && !Number.isNaN(since) ? since : 0, + afk: typeof afk === 'boolean' ? afk : this.afk, + since: typeof since === 'number' && !Number.isNaN(since) ? this.since : 0, status: status ?? this.status, }; if (activities?.length) { diff --git a/src/structures/Presence.js b/src/structures/Presence.js index 50051b0..4c052d9 100644 --- a/src/structures/Presence.js +++ b/src/structures/Presence.js @@ -130,6 +130,18 @@ class Presence extends Base { this.lastModified = data.last_modified; } + if ('afk' in data) { + this.afk = data.afk; + } else { + this.afk ??= false; + } + + if ('since' in data) { + this.since = data.since; + } else { + this.since ??= 0; + } + return this; } diff --git a/src/util/Options.js b/src/util/Options.js index d8f50cb..c8979ec 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -171,7 +171,7 @@ class Options extends null { restTimeOffset: 500, restSweepInterval: 60, failIfNotExists: true, - presence: { status: 'online', since: 0, activities: [], afk: false }, + presence: { status: 'online', since: 0, activities: [], afk: true }, sweepers: {}, ws: { capabilities: 0, // https://discord-userdoccers.vercel.app/topics/gateway#gateway-capabilities