Skip to content

Commit

Permalink
feat(Activity): add missing fields (#4984)
Browse files Browse the repository at this point in the history
Co-authored-by: Jan <66554238+Vaporox@users.noreply.github.com>
  • Loading branch information
advaith1 and vaporoxx committed Apr 6, 2021
1 parent 599f0f5 commit 63ff6a0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
40 changes: 39 additions & 1 deletion src/structures/Presence.js
Expand Up @@ -138,6 +138,14 @@ class Presence {
}
}

/**
* The platform of this activity:
* * **`desktop`**
* * **`samsung`** - playing on Samsung Galaxy
* * **`xbox`** - playing on Xbox Live
* @typedef {string} ActivityPlatform
*/

/**
* Represents an activity that is part of a user's presence.
*/
Expand All @@ -146,7 +154,13 @@ class Activity {
Object.defineProperty(this, 'presence', { value: presence });

/**
* The name of the activity being played
* The ID of the activity
* @type {string}
*/
this.id = data.id;

/**
* The name of the activity
* @type {string}
*/
this.name = data.name;
Expand Down Expand Up @@ -194,6 +208,18 @@ class Activity {
}
: null;

/**
* The ID of the song on Spotify
* @type {?string}
*/
this.syncID = data.sync_id ?? null;

/**
* The platform the game is being played on
* @type {?ActivityPlatform}
*/
this.platform = data.platform ?? null;

/**
* Party of the activity
* @type {?Object}
Expand Down Expand Up @@ -222,6 +248,18 @@ class Activity {
*/
this.emoji = data.emoji ? new Emoji(presence.client, data.emoji) : null;

/**
* The ID of the game or Spotify session
* @type {?string}
*/
this.sessionID = data.session_id ?? null;

/**
* The labels of the buttons of this rich presence
* @type {string[]}
*/
this.buttons = data.buttons ?? [];

/**
* Creation date of the activity
* @type {number}
Expand Down
7 changes: 7 additions & 0 deletions typings/index.d.ts
Expand Up @@ -30,17 +30,22 @@ declare module 'discord.js' {
constructor(presence: Presence, data?: object);
public applicationID: Snowflake | null;
public assets: RichPresenceAssets | null;
public buttons: string[];
public readonly createdAt: Date;
public createdTimestamp: number;
public details: string | null;
public emoji: Emoji | null;
public flags: Readonly<ActivityFlags>;
public id: string;
public name: string;
public party: {
id: string | null;
size: [number, number];
} | null;
public platform: ActivityPlatform | null;
public sessionID: string | null;
public state: string | null;
public syncID: string | null;
public timestamps: {
start: Date | null;
end: Date | null;
Expand Down Expand Up @@ -2170,6 +2175,8 @@ declare module 'discord.js' {
shardID?: number | readonly number[];
}

type ActivityPlatform = 'desktop' | 'samsung' | 'xbox';

type ActivityType = 'PLAYING' | 'STREAMING' | 'LISTENING' | 'WATCHING' | 'CUSTOM_STATUS' | 'COMPETING';

interface AddGuildMemberOptions {
Expand Down

0 comments on commit 63ff6a0

Please sign in to comment.