Skip to content

Commit

Permalink
🩹 fix: presence doesn't accept data even if the data is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Helloyunho committed Jun 17, 2023
1 parent 5d3cf6d commit 1beb173
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/structures/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down

0 comments on commit 1beb173

Please sign in to comment.