From c76c34189c307afa1b295159b0a2f44aea44314a Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Sun, 14 Aug 2022 22:50:44 +0700 Subject: [PATCH] fix(ClientPresence): Set Activity Type fixed #251 --- src/structures/ClientPresence.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/structures/ClientPresence.js b/src/structures/ClientPresence.js index 42cc6b7..819acfc 100644 --- a/src/structures/ClientPresence.js +++ b/src/structures/ClientPresence.js @@ -2,7 +2,7 @@ const { Presence } = require('./Presence'); const { TypeError } = require('../errors'); -const { Opcodes } = require('../util/Constants'); +const { Opcodes, ActivityTypes } = require('../util/Constants'); /** * Represents the client's presence. @@ -50,14 +50,18 @@ class ClientPresence extends Presence { for (const [i, activity] of activities.entries()) { if (typeof activity.name !== 'string') throw new TypeError('INVALID_TYPE', `activities[${i}].name`, 'string'); activity.type ??= 0; - data.activities.push(activity); + data.activities.push( + Object.assign(activity, { + type: typeof activity.type === 'number' ? activity.type : ActivityTypes[activity.type], + }), + ); } } else if (!activities && (status || afk || since) && this.activities.length) { data.activities.push( ...this.activities.map(a => Object.assign(a, { name: a.name, - type: a.type, + type: ActivityTypes[a.type], url: a.url ?? undefined, }), ),