From e679e834ef9d2a5c54369209bf7b8530e17c7f65 Mon Sep 17 00:00:00 2001 From: pynappo Date: Sun, 27 Jul 2025 23:41:38 -0700 Subject: [PATCH 1/4] bump discord-rpc to 1.3.0 --- package.json | 2 +- pnpm-lock.yaml | 33 ++++++++++++++------------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index cc9bcbc67b..dcfc4ec1ed 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "@jellybrick/mpris-service": "2.1.5", "@jimp/plugin-color": "1.6.0", "@skyra/jaro-winkler": "1.1.1", - "@xhayper/discord-rpc": "1.2.2", + "@xhayper/discord-rpc": "1.3.0", "async-mutex": "0.5.0", "bgutils-js": "3.2.0", "butterchurn": "3.0.0-beta.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c585f9231f..de907b07fb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -83,8 +83,8 @@ importers: specifier: 1.1.1 version: 1.1.1 '@xhayper/discord-rpc': - specifier: 1.2.2 - version: 1.2.2(bufferutil@4.0.9)(utf-8-validate@6.0.5) + specifier: 1.3.0 + version: 1.3.0(bufferutil@4.0.9)(utf-8-validate@6.0.5) async-mutex: specifier: 0.5.0 version: 0.5.0 @@ -484,8 +484,8 @@ packages: resolution: {integrity: sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==} engines: {node: '>=18'} - '@discordjs/rest@2.5.0': - resolution: {integrity: sha512-PWhchxTzpn9EV3vvPRpwS0EE2rNYB9pvzDU/eLLW3mByJl0ZHZjHI2/wA8EbH2gRMQV7nu+0FoDF84oiPl8VAQ==} + '@discordjs/rest@2.5.1': + resolution: {integrity: sha512-Tg9840IneBcbrAjcGaQzHUJWFNq1MMWZjTdjJ0WS/89IffaNKc++iOvffucPxQTF/gviO9+9r8kEPea1X5J2Dw==} engines: {node: '>=18'} '@discordjs/util@1.1.1': @@ -1580,8 +1580,8 @@ packages: resolution: {integrity: sha512-RaI5qZo6D2CVS6sTHFKg1v5Ohq/+Bo2LZ5gzUEwZ/WkHhwtGTCB/sVLw8ijOkAUxasZ+WshN/Rzj4ywsABJ5ZA==} engines: {node: '>=v14.0.0', npm: '>=7.0.0'} - '@xhayper/discord-rpc@1.2.2': - resolution: {integrity: sha512-P3+uF2Hb7zVNEtk2ZleV7FF2cj1lCZ0Caa82RECwa5oaPNCF12CDhsx8GdBqFaD0zRRVrkheP3LJn0dmbd0KoA==} + '@xhayper/discord-rpc@1.3.0': + resolution: {integrity: sha512-0NmUTiODl7u3UEjmO6y0Syp3dmgVLAt2EHrH4QKTQcXRwtF8Wl7Eipdn/GSSZ8HkDwxQFvcDGJMxT9VWB0pH8g==} engines: {node: '>=18.20.7'} '@xmldom/xmldom@0.8.10': @@ -2216,9 +2216,6 @@ packages: dir-compare@4.2.0: resolution: {integrity: sha512-2xMCmOoMrdQIPHdsTawECdNPwlVFB9zGcz3kuhmBO6U3oU+UQjsue0i8ayLKpgBcm+hcXPMVSGUN9d+pvJ6+VQ==} - discord-api-types@0.37.120: - resolution: {integrity: sha512-7xpNK0EiWjjDFp2nAhHXezE4OUWm7s1zhc/UXXN6hnFFU8dfoPHgV0Hx0RPiCa3ILRpdeh152icc68DGCyXYIw==} - discord-api-types@0.38.17: resolution: {integrity: sha512-/fCx5jdUoR2hBFcj77Qx7Tmx1Ub8V/QpyS6uorjFvxRLcJJ348QxMFml9QW/eXh3i46eO4Ve8qGVepStpInEPg==} @@ -4659,8 +4656,8 @@ packages: resolution: {integrity: sha512-zICwjrDrcrUE0pyyJc1I2QzBkLM8FINsgOrt6WjA+BgajVq9Nxu2PbFFXUrAggLfDXlZGZBVZYw7WNV5KiBiBA==} engines: {node: '>=14.0'} - undici@6.21.1: - resolution: {integrity: sha512-q/1rj5D0/zayJB2FraXdaWxbhWiNKDvu8naDT2dl1yTlvJp4BLtOcp2a5BvgGNQpYYJzau7tf1WgKv3b+7mqpQ==} + undici@6.21.3: + resolution: {integrity: sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw==} engines: {node: '>=18.17'} unicorn-magic@0.3.0: @@ -5092,7 +5089,7 @@ snapshots: '@discordjs/collection@2.1.1': {} - '@discordjs/rest@2.5.0': + '@discordjs/rest@2.5.1': dependencies: '@discordjs/collection': 2.1.1 '@discordjs/util': 1.1.1 @@ -5102,7 +5099,7 @@ snapshots: discord-api-types: 0.38.17 magic-bytes.js: 1.10.0 tslib: 2.8.1 - undici: 6.21.1 + undici: 6.21.3 '@discordjs/util@1.1.1': {} @@ -6232,11 +6229,11 @@ snapshots: '@vladfrangu/async_event_emitter@2.4.6': {} - '@xhayper/discord-rpc@1.2.2(bufferutil@4.0.9)(utf-8-validate@6.0.5)': + '@xhayper/discord-rpc@1.3.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)': dependencies: - '@discordjs/rest': 2.5.0 + '@discordjs/rest': 2.5.1 '@vladfrangu/async_event_emitter': 2.4.6 - discord-api-types: 0.37.120 + discord-api-types: 0.38.17 ws: 8.18.3(bufferutil@4.0.9)(utf-8-validate@6.0.5) transitivePeerDependencies: - bufferutil @@ -6991,8 +6988,6 @@ snapshots: minimatch: 3.1.2 p-limit: 3.1.0 - discord-api-types@0.37.120: {} - discord-api-types@0.38.17: {} dmg-builder@26.0.12(electron-builder-squirrel-windows@26.0.12): @@ -9719,7 +9714,7 @@ snapshots: dependencies: '@fastify/busboy': 2.1.1 - undici@6.21.1: {} + undici@6.21.3: {} unicorn-magic@0.3.0: {} From eb2b12be38af3c6d46847939fee850d956a750a9 Mon Sep 17 00:00:00 2001 From: pynappo Date: Mon, 28 Jul 2025 01:37:10 -0700 Subject: [PATCH 2/4] Add configuration for Discord status text --- src/i18n/resources/en.json | 10 +++++++++- src/plugins/discord/constants.ts | 10 ++++++++++ src/plugins/discord/discord-service.ts | 2 ++ src/plugins/discord/index.ts | 6 ++++++ src/plugins/discord/menu.ts | 20 ++++++++++++++++++++ 5 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/i18n/resources/en.json b/src/i18n/resources/en.json index 4843203f75..2b186ebd19 100644 --- a/src/i18n/resources/en.json +++ b/src/i18n/resources/en.json @@ -437,7 +437,15 @@ "hide-duration-left": "Hide duration left", "hide-github-button": "Hide GitHub link Button", "play-on-youtube-music": "Play on YouTube Music", - "set-inactivity-timeout": "Set inactivity timeout" + "set-inactivity-timeout": "Set inactivity timeout", + "set-status-display-type": { + "label": "Status text", + "submenu": { + "youtube-music": "Listening to YouTube Music", + "artist": "Listening to {artist}", + "title": "Listening to {song title}" + } + } }, "name": "Discord Rich Presence", "prompt": { diff --git a/src/plugins/discord/constants.ts b/src/plugins/discord/constants.ts index c2abcc022a..4e995e348b 100644 --- a/src/plugins/discord/constants.ts +++ b/src/plugins/discord/constants.ts @@ -23,3 +23,13 @@ export enum TimerKey { UpdateTimeout = 'updateTimeout', // Timer for throttled activity updates DiscordConnectRetry = 'discordConnectRetry', // Timer for Discord connection retries } + +/** + * An enum for Discord's activity.status_display_type field, governing which field of the activity should be used after + * "Listening to..." in the user's Discord status. + */ +export const DiscordStatusDisplayType = { + YOUTUBE_MUSIC : 0, + ARTIST: 1, + TITLE: 2, +} as const; diff --git a/src/plugins/discord/discord-service.ts b/src/plugins/discord/discord-service.ts index 4cdc3ab7aa..4076802d87 100644 --- a/src/plugins/discord/discord-service.ts +++ b/src/plugins/discord/discord-service.ts @@ -98,7 +98,9 @@ export class DiscordService { const activityInfo: SetActivity = { type: ActivityType.Listening, + statusDisplayType: config.statusDisplayType, details: truncateString(songInfo.title, 128), // Song title + detailsUrl: songInfo.url ?? undefined, state: truncateString(songInfo.artist, 128), // Artist name largeImageKey: songInfo.imageSrc ?? undefined, largeImageText: songInfo.album diff --git a/src/plugins/discord/index.ts b/src/plugins/discord/index.ts index 6fefbdc9ca..c993545917 100644 --- a/src/plugins/discord/index.ts +++ b/src/plugins/discord/index.ts @@ -2,6 +2,7 @@ import { createPlugin } from '@/utils'; import { backend } from './main'; import { onMenu } from './menu'; import { t } from '@/i18n'; +import { DiscordStatusDisplayType } from './constants'; export type DiscordPluginConfig = { enabled: boolean; @@ -33,6 +34,10 @@ export type DiscordPluginConfig = { * Hide the "duration left" in the rich presence */ hideDurationLeft: boolean; + /** + * Hide the "duration left" in the rich presence + */ + statusDisplayType: (typeof DiscordStatusDisplayType)[keyof typeof DiscordStatusDisplayType]; }; export default createPlugin({ @@ -47,6 +52,7 @@ export default createPlugin({ playOnYouTubeMusic: true, hideGitHubButton: false, hideDurationLeft: false, + statusDisplayType: DiscordStatusDisplayType.ARTIST, } as DiscordPluginConfig, menu: onMenu, backend, diff --git a/src/plugins/discord/menu.ts b/src/plugins/discord/menu.ts index 25a34fe3a4..bcdf68d95e 100644 --- a/src/plugins/discord/menu.ts +++ b/src/plugins/discord/menu.ts @@ -12,11 +12,18 @@ import type { MenuContext } from '@/types/contexts'; import type { DiscordPluginConfig } from './index'; import type { MenuTemplate } from '@/menu'; +import { DiscordStatusDisplayType } from './constants'; const registerRefreshOnce = singleton((refreshMenu: () => void) => { discordService?.registerRefreshCallback(refreshMenu); }); +const DiscordStatusDisplayTypeLabels = { + [DiscordStatusDisplayType.YOUTUBE_MUSIC]: "plugins.discord.menu.set-status-display-type.submenu.youtube-music", + [DiscordStatusDisplayType.ARTIST]: "plugins.discord.menu.set-status-display-type.submenu.artist", + [DiscordStatusDisplayType.TITLE]: "plugins.discord.menu.set-status-display-type.submenu.title", +} + export const onMenu = async ({ window, getConfig, @@ -92,6 +99,19 @@ export const onMenu = async ({ label: t('plugins.discord.menu.set-inactivity-timeout'), click: () => setInactivityTimeout(window, config), }, + { + label: t('plugins.discord.menu.set-status-display-type.label'), + submenu: Object.values(DiscordStatusDisplayType).map((statusDisplayType) => ({ + label: t(DiscordStatusDisplayTypeLabels[statusDisplayType]), + type: 'radio', + checked: config.statusDisplayType == statusDisplayType, + click() { + setConfig({ + statusDisplayType + }); + }, + })), + }, ]; }; From bd12c1dd8cf3148b24214c4d2a1a91dd8e188c21 Mon Sep 17 00:00:00 2001 From: pynappo Date: Mon, 28 Jul 2025 09:41:25 -0700 Subject: [PATCH 3/4] Update src/plugins/discord/index.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/plugins/discord/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/discord/index.ts b/src/plugins/discord/index.ts index c993545917..c76e0eace6 100644 --- a/src/plugins/discord/index.ts +++ b/src/plugins/discord/index.ts @@ -35,7 +35,7 @@ export type DiscordPluginConfig = { */ hideDurationLeft: boolean; /** - * Hide the "duration left" in the rich presence + * Controls which field is displayed in the Discord status text */ statusDisplayType: (typeof DiscordStatusDisplayType)[keyof typeof DiscordStatusDisplayType]; }; From 3ee67aaf46542ff6856b6fa619c467d26c7d7e04 Mon Sep 17 00:00:00 2001 From: pynappo Date: Mon, 28 Jul 2025 09:41:33 -0700 Subject: [PATCH 4/4] Update src/plugins/discord/constants.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/plugins/discord/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/discord/constants.ts b/src/plugins/discord/constants.ts index 4e995e348b..e66c92ca4a 100644 --- a/src/plugins/discord/constants.ts +++ b/src/plugins/discord/constants.ts @@ -29,7 +29,7 @@ export enum TimerKey { * "Listening to..." in the user's Discord status. */ export const DiscordStatusDisplayType = { - YOUTUBE_MUSIC : 0, + YOUTUBE_MUSIC: 0, ARTIST: 1, TITLE: 2, } as const;