diff --git a/discord-presence-updater.ts b/discord-presence-updater.ts new file mode 100644 index 00000000..cb762a05 --- /dev/null +++ b/discord-presence-updater.ts @@ -0,0 +1,84 @@ +import { Client, Presence } from 'discord-rpc'; + +export interface PresenceArgs { + title: string; + artists: string; + smallImageKey?: string; + smallImageText?: string; + largeImageKey?: string; + largeImageText?: string; + shouldSendTimestamps?: boolean; + startTime?: number; +} + +export class DiscordPresenceUpdater { + private clientId: string; + private rpc: Client; + private isReady: boolean; + + constructor(clientId: string) { + this.clientId = clientId; + this.rpc = new Client({ transport: 'ipc' }); + this.isReady = false; + + // Bind event listeners + this.rpc.on('ready', () => { + console.log('Discord RPC is ready!'); + this.isReady = true; + }); + + this.rpc.on('disconnected', () => { + console.warn('Discord RPC disconnected. Attempting to reconnect...'); + this.isReady = false; + this.login(); // Reattempt connection + }); + + // Log in to Discord RPC + this.login(); + } + + private login(): void { + this.rpc + .login({ clientId: this.clientId }) + .then(() => console.log('Successfully logged into Discord RPC')) + .catch((error) => console.error('Failed to log into Discord RPC:', error)); + } + + public setPresence(args: PresenceArgs): void { + if (!this.isReady) { + console.warn('Discord RPC is not ready. Cannot set presence.'); + return; + } + + const presence: Presence = { + details: `Listening to ${args.title}`, + state: `by ${args.artists}`, + largeImageKey: args.largeImageKey, + largeImageText: args.largeImageText, + smallImageKey: args.smallImageKey, + smallImageText: args.smallImageText, + }; + + if (args.shouldSendTimestamps && args.startTime) { + presence.startTimestamp = Math.floor(args.startTime / 1000); + } + + this.rpc.setActivity(presence); + console.log('Rich Presence updated:', presence); + } + + public clearPresence(): void { + if (!this.isReady) { + console.warn('Discord RPC is not ready. Cannot clear presence.'); + return; + } + + this.rpc.clearActivity(); + console.log('Rich Presence cleared.'); + } + + public shutdown(): void { + this.rpc.destroy(); + console.log('Discord RPC client destroyed.'); + } +} diff --git a/main.js b/main.js index dd89cad2..0df61f16 100644 --- a/main.js +++ b/main.js @@ -16,6 +16,7 @@ const Store = require("electron-store"); const path = require("path"); const url = require("url"); const worker_threads_1 = require("worker_threads"); +const discord_presence_updater_1 = require("./discord-presence-updater"); /** * Command line parameters */ @@ -39,6 +40,7 @@ let tray; let isQuitting; let isQuit; let fileProcessingTimeout; +const discordUpdater = new discord_presence_updater_1.DiscordPresenceUpdater('826521040275636325'); // Static folder is not detected correctly in production if (process.env.NODE_ENV !== 'development') { globalAny.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\'); @@ -410,6 +412,9 @@ try { electron_1.app.on('before-quit', () => { isQuit = true; }); + electron_1.app.on('will-quit', () => { + discordUpdater.shutdown(); + }); electron_1.app.whenReady().then(() => { // See: https://github.com/electron/electron/issues/23757 electron_1.protocol.registerFileProtocol('file', (request, callback) => { @@ -518,6 +523,12 @@ try { electron_log_1.default.info('[Main] [clear-file-queue] Clearing file queue'); globalAny.fileQueue = []; }); + electron_1.ipcMain.on('set-discord-presence', (event, arg) => { + discordUpdater.setPresence(arg); + }); + electron_1.ipcMain.on('clear-discord-presence', (event, arg) => { + discordUpdater.clearPresence(); + }); } } catch (e) { diff --git a/main.js.map b/main.js.map index 40936e9d..cf8115e0 100644 --- a/main.js.map +++ b/main.js.map @@ -1 +1 @@ -{"version":3,"file":"main.js","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":";;AAAA,sDAAsD;AACtD,uDAAuD;AACvD,qEAAqE;AACrE,4DAA4D;AAC5D,sDAAsD;AACtD,uDAAuD;AACvD,4DAA4D;AAC5D,+DAA+D;AAC/D,0DAA0D;AAC1D,wDAAwD;AACxD,uCAA0F;AAC1F,+CAA+B;AAC/B,wCAAwC;AACxC,6BAA6B;AAC7B,2BAA2B;AAC3B,mDAAwC;AAExC;;GAEG;AACH,cAAG,CAAC,WAAW,CAAC,YAAY,CAAC,iCAAiC,CAAC,CAAC,CAAC,qCAAqC;AACtG,cAAG,CAAC,WAAW,CAAC,YAAY,CAAC,iBAAiB,EAAE,0BAA0B,CAAC,CAAC,CAAC,oDAAoD;AACjI,cAAG,CAAC,WAAW,CAAC,YAA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AAG,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;YAC1D,SAAS,CAAC,SAAS,GAAG,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;QAEH,kBAAO,CAAC,EAAE,CAAC,sBAAsB,EAAE,CAAC,KAAU,EAAE,GAAiB,EAAE,EAAE;YACjE,cAAc,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QAEH,kBAAO,CAAC,EAAE,CAAC,wBAAwB,EAAE,CAAC,KAAU,EAAE,GAAQ,EAAE,EAAE;YAC1D,cAAc,CAAC,aAAa,EAAE,CAAC;QACnC,CAAC,CAAC,CAAC;KACN;CACJ;AAAC,OAAO,CAAC,EAAE;IACR,sBAAG,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAEhE,MAAM,CAAC,CAAC;CACX"} \ No newline at end of file diff --git a/main.ts b/main.ts index b88147a3..eb4a8254 100644 --- a/main.ts +++ b/main.ts @@ -14,6 +14,7 @@ import * as Store from 'electron-store'; import * as path from 'path'; import * as url from 'url'; import { Worker } from 'worker_threads'; +import { DiscordPresenceUpdater, PresenceArgs } from './discord-presence-updater'; /** * Command line parameters @@ -40,6 +41,7 @@ let tray: Tray; let isQuitting: boolean; let isQuit: boolean; let fileProcessingTimeout: NodeJS.Timeout; +const discordUpdater = new DiscordPresenceUpdater('826521040275636325'); // Static folder is not detected correctly in production if (process.env.NODE_ENV !== 'development') { @@ -480,6 +482,10 @@ try { isQuit = true; }); + app.on('will-quit', () => { + discordUpdater.shutdown(); + }); + app.whenReady().then(() => { // See: https://github.com/electron/electron/issues/23757 protocol.registerFileProtocol('file', (request, callback) => { @@ -607,6 +613,14 @@ try { log.info('[Main] [clear-file-queue] Clearing file queue'); globalAny.fileQueue = []; }); + + ipcMain.on('set-discord-presence', (event: any, arg: PresenceArgs) => { + discordUpdater.setPresence(arg); + }); + + ipcMain.on('clear-discord-presence', (event: any, arg: any) => { + discordUpdater.clearPresence(); + }); } } catch (e) { log.error(`[Main] [Main] Could not start. Error: ${e.message}`); diff --git a/src/app/services/discord/discord.service.ts b/src/app/services/discord/discord.service.ts index b7156412..da36a589 100644 --- a/src/app/services/discord/discord.service.ts +++ b/src/app/services/discord/discord.service.ts @@ -6,6 +6,7 @@ import { SettingsBase } from '../../common/settings/settings.base'; import { PresenceUpdater } from './presence-updater'; import { PlaybackService } from '../playback/playback.service'; import { TranslatorServiceBase } from '../translator/translator.service.base'; +import { IpcProxyBase } from '../../common/io/ipc-proxy.base'; @Injectable({ providedIn: 'root' }) export class DiscordService { @@ -16,6 +17,7 @@ export class DiscordService { private translatorService: TranslatorServiceBase, private presenceUpdater: PresenceUpdater, private dateProxy: DateProxy, + private ipcProxy: IpcProxyBase, private settings: SettingsBase, private logger: Logger, ) {} @@ -27,7 +29,7 @@ export class DiscordService { public setRichPresence(enableRichPresence: boolean): void { if (!enableRichPresence) { this.removeSubscriptions(); - this.presenceUpdater.clearPresence(); + this.clearPresence(); return; } @@ -79,6 +81,10 @@ export class DiscordService { return this.playbackService.progress.progressSeconds * 1000; } + private clearPresence(): void { + this.ipcProxy.sendToMainProcess('clear-discord-presence', undefined); + } + private updatePresence(): void { if (this.playbackService.currentTrack == undefined) { this.logger.info(`No currentTrack was found. Not setting Discord Rich Presence.`, 'DiscordService', 'updatePresence'); @@ -100,15 +106,17 @@ export class DiscordService { smallImageText = this.translatorService.get('playing'); } - this.presenceUpdater.updatePresence( - this.playbackService.currentTrack.title, - this.playbackService.currentTrack.artists, - smallImageKey, - smallImageText, - largeImageKey, - largeImageText, - shouldSendTimestamps, - startTime, - ); + const arg = { + title: this.playbackService.currentTrack.title, + artists: this.playbackService.currentTrack.artists, + smallImageKey: smallImageKey, + smallImageText: smallImageText, + largeImageKey: largeImageKey, + largeImageText: largeImageText, + shouldSendTimestamps: shouldSendTimestamps, + startTime: startTime, + }; + + this.ipcProxy.sendToMainProcess('set-discord-presence', arg); } }