From 1beb1730586c3d2b808e6f00f9508a335ea51d66 Mon Sep 17 00:00:00 2001 From: Helloyunho Date: Sat, 17 Jun 2023 20:29:17 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20fix:=20presence=20doesn't=20acce?= =?UTF-8?q?pt=20data=20even=20if=20the=20data=20is=20not=20empty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/structures/presence.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/structures/presence.ts b/src/structures/presence.ts index dab5ede5..43935d07 100644 --- a/src/structures/presence.ts +++ b/src/structures/presence.ts @@ -61,16 +61,21 @@ export class ClientPresence { constructor(data?: ClientActivity | StatusPayload | ActivityGame) { if (data !== undefined) { - if ((data as ClientActivity).activity !== undefined) { - Object.assign(this, data) - } else if ((data as StatusPayload).activities !== undefined) { - this.parse(data as StatusPayload) - } else if ((data as ActivityGame).name !== undefined) { + if (['name', 'type', 'url'].some((k) => k in data)) { + // ActivityGame if (this.activity === undefined) { this.activity = data as ActivityGame } else if (this.activity instanceof Array) { this.activity.push(data as ActivityGame) } else this.activity = [this.activity, data as ActivityGame] + } else if (['client_status', 'activities'].some((k) => k in data)) { + // StatusPayload + this.parse(data as StatusPayload) + } else if ( + ['since', 'activity', 'status', 'afk'].some((k) => k in data) + ) { + // ClientActivity + Object.assign(this, data) } } }