added discord rpc

This commit is contained in:
2024-01-14 00:21:33 +01:00
parent f11e84efd7
commit 6369c0e8af
6 changed files with 180 additions and 12 deletions

View File

@@ -0,0 +1,56 @@
const DiscordRPC = require("discord-auto-rpc");
const { appName, appVersion } = require("../../appInfo");
const clientId = "1032772293220384808";
let richPresence;
let currentStatus = {
details: " ",
state: "Idle in Launcher...",
startTimestamp: new Date(),
largeImageKey: "ezppfarm",
largeImageText: `${appName} ${appVersion}`,
smallImageKey: " ",
smallImageText: " ",
buttons: [
{
label: "Download the Launcher",
url: "https://git.ez-pp.farm/EZPPFarm/EZPPLauncher/releases/latest"
},
{
label: "Join EZPPFarm",
url: "https://ez-pp.farm/discord"
}
],
instance: false
}
module.exports = {
connect: () => {
if (!richPresence) {
richPresence = new DiscordRPC.AutoClient({ transport: "ipc" });
richPresence.endlessLogin({ clientId });
richPresence.once("ready", () => {
setInterval(() => {
richPresence.setActivity(currentStatus);
}, 2500)
});
}
},
disconnect: async () => {
if (richPresence) {
await richPresence.clearActivity();
await richPresence.destroy();
richPresence = null;
}
},
updateStatus: ({ state, details }) => {
currentStatus.state = state ?? " ";
currentStatus.details = details ?? " ";
},
updateVersion: (osuVersion) => {
currentStatus.smallImageKey = osuVersion ? "osu" : " ";
currentStatus.smallImageText = osuVersion ? `osu! ${osuVersion}` : " ";
}
}

View File

@@ -353,7 +353,6 @@ async function replaceUIFile(osuPath, revert) {
await fs.promises.rename(oldOsuUIFile, ezppUIFile);
await fs.promises.rename(path.join(osuPath, "osu!ui.dll.bak"), oldOsuUIFile);
}
}
module.exports = { isValidOsuFolder, getUserConfig, getGlobalConfig, getUpdateFiles, getFilesThatNeedUpdate, downloadUpdateFiles, runOsuWithDevServer, getPatcherUpdates, downloadPatcherUpdates, downloadUIFiles, getUIFiles, replaceUIFile };