fix: Activity & Presence

#584
This commit is contained in:
Elysia
2024-07-04 20:02:20 +07:00
parent 516d8917bd
commit 3bf0d44184
2 changed files with 17 additions and 14 deletions

View File

@@ -9,6 +9,9 @@ module.exports = (client, { d: data }, shard) => {
// Check // Check
USER_REQUIRED_ACTION(client, { d: data }); USER_REQUIRED_ACTION(client, { d: data });
// Overwrite ClientPresence
client.presence.userId = data.user.id;
if (client.user) { if (client.user) {
client.user._patch(data.user); client.user._patch(data.user);
} else { } else {

View File

@@ -229,12 +229,12 @@ class Activity {
this.url = null; this.url = null;
} }
if ('created_at' in data) { if ('created_at' in data || 'createdTimestamp' in data) {
/** /**
* Creation date of the activity * Creation date of the activity
* @type {number} * @type {number}
*/ */
this.createdTimestamp = data.created_at; this.createdTimestamp = data.created_at || data.createdTimestamp;
} }
if ('session_id' in data) { if ('session_id' in data) {
@@ -277,12 +277,12 @@ class Activity {
this.timestamps = null; this.timestamps = null;
} }
if ('application_id' in data) { if ('application_id' in data || 'applicationId' in data) {
/** /**
* The id of the application associated with this activity * The id of the application associated with this activity
* @type {?Snowflake} * @type {?Snowflake}
*/ */
this.applicationId = data.application_id; this.applicationId = data.application_id || data.applicationId;
} else { } else {
this.applicationId = null; this.applicationId = null;
} }
@@ -307,12 +307,12 @@ class Activity {
this.state = null; this.state = null;
} }
if ('sync_id' in data) { if ('sync_id' in data || 'syncId' in data) {
/** /**
* The Spotify song's id * The Spotify song's id
* @type {?string} * @type {?string}
*/ */
this.syncId = data.sync_id; this.syncId = data.sync_id || data.syncId;
} else { } else {
this.syncId = null; this.syncId = null;
} }
@@ -436,42 +436,42 @@ class RichPresenceAssets {
} }
_patch(assets = {}) { _patch(assets = {}) {
if ('large_text' in assets) { if ('large_text' in assets || 'largeText' in assets) {
/** /**
* Hover text for the large image * Hover text for the large image
* @type {?string} * @type {?string}
*/ */
this.largeText = assets.large_text; this.largeText = assets.large_text || assets.largeText;
} else { } else {
this.largeText = null; this.largeText = null;
} }
if ('small_text' in assets) { if ('small_text' in assets || 'smallText' in assets) {
/** /**
* Hover text for the small image * Hover text for the small image
* @type {?string} * @type {?string}
*/ */
this.smallText = assets.small_text; this.smallText = assets.small_text || assets.smallText;
} else { } else {
this.smallText = null; this.smallText = null;
} }
if ('large_image' in assets) { if ('large_image' in assets || 'largeImage' in assets) {
/** /**
* The large image asset's id * The large image asset's id
* @type {?Snowflake} * @type {?Snowflake}
*/ */
this.largeImage = assets.large_image; this.largeImage = assets.large_image || assets.largeImage;
} else { } else {
this.largeImage = null; this.largeImage = null;
} }
if ('small_image' in assets) { if ('small_image' in assets || 'smallImage' in assets) {
/** /**
* The small image asset's id * The small image asset's id
* @type {?Snowflake} * @type {?Snowflake}
*/ */
this.smallImage = assets.small_image; this.smallImage = assets.small_image || assets.smallImage;
} else { } else {
this.smallImage = null; this.smallImage = null;
} }