check if rpc is connected

This commit is contained in:
HorizonCode 2024-03-11 17:34:36 +01:00
parent 0b679d320f
commit 8d2024aa0a

View File

@ -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);
}
},