Fix: Discord RPC not Stoping #26

This commit is contained in:
MasterAcnolo
2026-01-25 17:32:29 +01:00
parent 29ca2ea496
commit dedf10c6b3
2 changed files with 24 additions and 22 deletions

View File

@@ -17,7 +17,7 @@ function startRPC() {
details: `Open Source Download Tools - ${config.version}`,
state: "masteracnolo.github.io/FreedomLoader",
};
rpc.clearActivity()
rpc.setActivity(presence);
// Met à jour la présence toutes les 15s
@@ -26,27 +26,26 @@ function startRPC() {
}, 15000);
});
async function cleanExit() {
try {
if (intervalId) clearInterval(intervalId);
if (rpc && rpc.transport) {
await rpc.destroy();
}
} catch (err) {
logger.error("Error while closing the RPC:", err);
} finally {
process.exit();
}
}
process.on("exit", cleanExit);
process.on("SIGINT", cleanExit);
process.on("SIGTERM", cleanExit);
rpc.login({ clientId }).catch(err => {
logger.error("Unable to connect to the RPC:", err);
});
}
module.exports = { startRPC };
async function stopRPC(){
try {
if (intervalId) clearInterval(intervalId);
if (rpc && rpc.transport) {
await rpc.clearActivity()
await rpc.destroy();
} else{
logger.error("Not Able to close RPC")
}
} catch (err) {
logger.error("Error while closing the RPC:", err);
}
}
module.exports = { startRPC, stopRPC};