feat: RichPresence#setPlatform

This commit is contained in:
Elysia
2024-07-04 19:12:47 +07:00
parent f63b1528d4
commit 516d8917bd
5 changed files with 50 additions and 18 deletions

View File

@@ -167,6 +167,11 @@ class Presence extends Base {
* * **`desktop`**
* * **`samsung`** - playing on Samsung Galaxy
* * **`xbox`** - playing on Xbox Live
* * **`ios`**
* * **`android`**
* * **`embedded`**
* * **`ps4`**
* * **`ps5`**
* @typedef {string} ActivityPlatform
*/
@@ -239,7 +244,7 @@ class Activity {
*/
this.sessionId = data.session_id;
} else {
this.sessionId = null;
this.sessionId = this.presence.client?.sessionId;
}
if ('platform' in data) {
@@ -407,10 +412,10 @@ class Activity {
}
toJSON(...props) {
return {
return Util.clearNullOrUndefinedObject({
...Util.flatten(this, ...props),
type: typeof this.type === 'number' ? this.type : ActivityTypes[this.type],
};
});
}
}
@@ -883,6 +888,16 @@ class RichPresence extends Activity {
return this;
}
/**
* The platform the activity is being played on
* @param {ActivityPlatform | null} platform Any platform
* @returns {RichPresence}
*/
setPlatform(platform) {
this.platform = platform;
return this;
}
/**
* Secrets for rich presence joining and spectating (send-only)
* @param {?string} join Secrets for rich presence joining
@@ -1074,10 +1089,7 @@ class SpotifyRPC extends RichPresence {
}
toJSON() {
return {
...super.toJSON({ id: false, emoji: false, platform: false, buttons: false }),
session_id: this.presence.client.sessionId,
};
return super.toJSON({ id: false, emoji: false, platform: false, buttons: false });
}
}