From 8d2024aa0af5a83cd115c51631c0640eb3c53a79 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Mon, 11 Mar 2024 17:34:36 +0100 Subject: [PATCH] check if rpc is connected --- electron/richPresence.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/electron/richPresence.js b/electron/richPresence.js index 4489d34..9529733 100644 --- a/electron/richPresence.js +++ b/electron/richPresence.js @@ -2,7 +2,10 @@ const DiscordRPC = require("discord-auto-rpc"); const { appName, appVersion } = require("./appInfo.js"); const clientId = "1032772293220384808"; + +/** @type {DiscordRPC.AutoClient} */ let richPresence; + let intervalId; let currentStatus = { @@ -32,6 +35,7 @@ module.exports = { richPresence = new DiscordRPC.AutoClient({ transport: "ipc" }); richPresence.endlessLogin({ clientId }); richPresence.once("ready", () => { + console.log("connected presence with user " + richPresence.user.username); richPresence.setActivity(currentStatus); intervalId = setInterval(() => { richPresence.setActivity(currentStatus); @@ -56,7 +60,7 @@ module.exports = { currentStatus.smallImageText = osuVersion ? `osu! ${osuVersion}` : " "; }, update: () => { - if (richPresence) { + if (richPresence && richPresence.user) { richPresence.setActivity(currentStatus); } },