From f68aae9968b068219f37b141e0de01fb1fb1cf93 Mon Sep 17 00:00:00 2001 From: Advaith Date: Fri, 6 Nov 2020 20:18:47 -0800 Subject: [PATCH 1/7] feat(Activity): add id and platform --- src/structures/Presence.js | 21 ++++++++++++++++++++- typings/index.d.ts | 4 ++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/structures/Presence.js b/src/structures/Presence.js index 2ae6b8c0d99f..f7da7e0ec5d0 100644 --- a/src/structures/Presence.js +++ b/src/structures/Presence.js @@ -138,6 +138,13 @@ class Presence { } } +/** + * The platform of this activity: + * * **`xbox`** - playing on Xbox Live + * * **`samsung`** - playing on Samsung Galaxy + * @typedef {string} ActivityPlatform + */ + /** * Represents an activity that is part of a user's presence. */ @@ -146,7 +153,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; @@ -194,6 +207,12 @@ class Activity { } : null; + /** + * The platform the game is being played on + * @type {?ActivityPlatform} + */ + this.platform = data.platform || null; + /** * Party of the activity * @type {?Object} diff --git a/typings/index.d.ts b/typings/index.d.ts index 7322dc62f184..14c73a556344 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -21,6 +21,8 @@ declare module 'discord.js' { //#region Classes + type ActivityPlatform = 'xbox' | 'samsung'; + export class Activity { constructor(presence: Presence, data?: object); public applicationID: Snowflake | null; @@ -30,11 +32,13 @@ declare module 'discord.js' { public details: string | null; public emoji: Emoji | null; public flags: Readonly; + public id: string; public name: string; public party: { id: string | null; size: [number, number]; } | null; + public platform: ActivityPlatform; public state: string | null; public timestamps: { start: Date | null; From b539aff3f7c7b583188a228fa8309e6f6886b541 Mon Sep 17 00:00:00 2001 From: Advaith Date: Sat, 7 Nov 2020 15:18:31 -0800 Subject: [PATCH 2/7] mark as nullable in typings Co-authored-by: Jan <66554238+Vaporox@users.noreply.github.com> --- typings/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 14c73a556344..b9bb8f5bac87 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -38,7 +38,7 @@ declare module 'discord.js' { id: string | null; size: [number, number]; } | null; - public platform: ActivityPlatform; + public platform: ActivityPlatform | null; public state: string | null; public timestamps: { start: Date | null; From b911481c6ca4af1d5f8930c9d20771db9d5a3c3b Mon Sep 17 00:00:00 2001 From: Advaith Date: Tue, 10 Nov 2020 20:41:42 -0800 Subject: [PATCH 3/7] add syncID and sessionID --- src/structures/Presence.js | 12 ++++++++++++ typings/index.d.ts | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/structures/Presence.js b/src/structures/Presence.js index f7da7e0ec5d0..2584dde52d5b 100644 --- a/src/structures/Presence.js +++ b/src/structures/Presence.js @@ -207,6 +207,12 @@ 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} @@ -241,6 +247,12 @@ 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; + /** * Creation date of the activity * @type {number} diff --git a/typings/index.d.ts b/typings/index.d.ts index b9bb8f5bac87..1c002f76c51a 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -39,7 +39,9 @@ declare module 'discord.js' { 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; From 38805f29939ab82ea9ac2713599c4fce38743783 Mon Sep 17 00:00:00 2001 From: Advaith Date: Tue, 17 Nov 2020 14:02:15 -0800 Subject: [PATCH 4/7] move ActivityPlatform type --- typings/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 1c002f76c51a..d8cbed35b442 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -21,8 +21,6 @@ declare module 'discord.js' { //#region Classes - type ActivityPlatform = 'xbox' | 'samsung'; - export class Activity { constructor(presence: Presence, data?: object); public applicationID: Snowflake | null; @@ -2131,6 +2129,8 @@ declare module 'discord.js' { shardID?: number | readonly number[]; } + type ActivityPlatform = 'xbox' | 'samsung'; + type ActivityType = 'PLAYING' | 'STREAMING' | 'LISTENING' | 'WATCHING' | 'CUSTOM_STATUS' | 'COMPETING'; interface AddGuildMemberOptions { From d6416b44f6a4528d401c6016846de17fcf2e18c7 Mon Sep 17 00:00:00 2001 From: Advaith Date: Tue, 22 Dec 2020 02:03:29 -0800 Subject: [PATCH 5/7] add desktop platform --- src/structures/Presence.js | 3 ++- typings/index.d.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/structures/Presence.js b/src/structures/Presence.js index 2584dde52d5b..0ad7f39b29e8 100644 --- a/src/structures/Presence.js +++ b/src/structures/Presence.js @@ -140,8 +140,9 @@ class Presence { /** * The platform of this activity: - * * **`xbox`** - playing on Xbox Live + * * **`desktop`** * * **`samsung`** - playing on Samsung Galaxy + * * **`xbox`** - playing on Xbox Live * @typedef {string} ActivityPlatform */ diff --git a/typings/index.d.ts b/typings/index.d.ts index d8cbed35b442..6e725b3bc40a 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2129,7 +2129,7 @@ declare module 'discord.js' { shardID?: number | readonly number[]; } - type ActivityPlatform = 'xbox' | 'samsung'; + type ActivityPlatform = 'desktop' | 'samsung' | 'xbox'; type ActivityType = 'PLAYING' | 'STREAMING' | 'LISTENING' | 'WATCHING' | 'CUSTOM_STATUS' | 'COMPETING'; From f3416e9d2351057d72a5058ae31ace02a5f41126 Mon Sep 17 00:00:00 2001 From: Advaith Date: Wed, 23 Dec 2020 13:35:44 -0800 Subject: [PATCH 6/7] ?? Co-authored-by: Jan <66554238+Vaporox@users.noreply.github.com> --- src/structures/Presence.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/structures/Presence.js b/src/structures/Presence.js index 0ad7f39b29e8..bf8527cd3d77 100644 --- a/src/structures/Presence.js +++ b/src/structures/Presence.js @@ -212,13 +212,13 @@ class Activity { * The ID of the song on Spotify * @type {?string} */ - this.syncID = data.sync_id || null; + this.syncID = data.sync_id ?? null; /** * The platform the game is being played on * @type {?ActivityPlatform} */ - this.platform = data.platform || null; + this.platform = data.platform ?? null; /** * Party of the activity @@ -252,7 +252,7 @@ class Activity { * The ID of the game or Spotify session * @type {?string} */ - this.sessionID = data.session_id || null; + this.sessionID = data.session_id ?? null; /** * Creation date of the activity From 0ccee4d922ecf51ade00b50014ff89cfa037feed Mon Sep 17 00:00:00 2001 From: Advaith Date: Wed, 23 Dec 2020 13:53:18 -0800 Subject: [PATCH 7/7] add buttons --- src/structures/Presence.js | 6 ++++++ typings/index.d.ts | 1 + 2 files changed, 7 insertions(+) diff --git a/src/structures/Presence.js b/src/structures/Presence.js index 9a4b144c0688..bf75118ae169 100644 --- a/src/structures/Presence.js +++ b/src/structures/Presence.js @@ -254,6 +254,12 @@ class Activity { */ 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} diff --git a/typings/index.d.ts b/typings/index.d.ts index 8a88eb26f285..f12eb78b64b2 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -25,6 +25,7 @@ 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;