From ecf1db11307ee284957797f96b7f5237ab6ebf3b Mon Sep 17 00:00:00 2001 From: Maroxy Date: Sat, 11 Dec 2021 13:28:10 +0100 Subject: [PATCH] Configure Discord RPC --- src/ts/index.ts | 5 +++-- src/ts/lib/DiscordRPC.ts | 3 ++- src/ts/settings.ts | 18 +++++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/ts/index.ts b/src/ts/index.ts index d83c187..9c0f1b4 100644 --- a/src/ts/index.ts +++ b/src/ts/index.ts @@ -203,10 +203,11 @@ $(() => { if (DiscordRPC.isActive()) { DiscordRPC.setActivity({ - details: 'In-Game', + details: LauncherLib.getConfig('rpcsettings.ingame.details'), + state: LauncherLib.getConfig('rpcsettings.ingame.state') ? LauncherLib.getConfig('rpcsettings.ingame.state') : undefined, largeImageKey: 'game', largeImageText: 'An Anime Game', - startTimestamp: Date.now() + startTimestamp: LauncherLib.getConfig('rpcsettings.ingame.elapsed') ? Date.now() : undefined }); } diff --git a/src/ts/lib/DiscordRPC.ts b/src/ts/lib/DiscordRPC.ts index 17f5d49..1dd4456 100644 --- a/src/ts/lib/DiscordRPC.ts +++ b/src/ts/lib/DiscordRPC.ts @@ -1,4 +1,5 @@ import discordRpc, { Client, Presence } from 'discord-rpc'; +import LauncherLib from './LauncherLib'; export default class DiscordRPC { @@ -14,7 +15,7 @@ export default class DiscordRPC this.rpc.on('ready', () => { this.rpc.setActivity({ - details: 'Preparing to launch', + details: LauncherLib.getConfig('rpcsettings.launcher'), largeImageKey: 'launcher', largeImageText: 'An Anime Game' }); diff --git a/src/ts/settings.ts b/src/ts/settings.ts index 52c92fc..6d28de3 100644 --- a/src/ts/settings.ts +++ b/src/ts/settings.ts @@ -230,24 +230,24 @@ $(() => { }); $('#rpc-launch-details').on('change', () => { - if ($('#rpc-launch-details').val() == "") + if ($('#rpc-launch-details').val() == " ") LauncherLib.updateConfig('rpcsettings.launcher', 'Preparing to launch'); - - LauncherLib.updateConfig('rpcsettings.launcher', $('#rpc-launch-details').val() as string); + else + LauncherLib.updateConfig('rpcsettings.launcher', $('#rpc-launch-details').val() as string); }); $('#rpc-game-details').on('change', () => { - if ($('#rpc-game-details').val() == "") + if ($('#rpc-game-details').val() == " ") LauncherLib.updateConfig('rpcsettings.ingame.details', 'In-Game'); - - LauncherLib.updateConfig('rpcsettings.ingame.details', $('#rpc-game-details').val() as string); + else + LauncherLib.updateConfig('rpcsettings.ingame.details', $('#rpc-game-details').val() as string); }); $('#rpc-game-state').on('change', () => { - if ($('#rpc-game-state').val() == "") + if ($('#rpc-game-state').val() == " ") LauncherLib.updateConfig('rpcsettings.ingame.state', null); - - LauncherLib.updateConfig('rpcsettings.ingame.state', $('#rpc-game-state').val() as string); + else + LauncherLib.updateConfig('rpcsettings.ingame.state', $('#rpc-game-state').val() as string); }); $('#rpc-game-elapsed').on('classChange', () => {