fix: update rich presence methods to use async/await for improved reliability
This commit is contained in:
@@ -34,23 +34,22 @@ module.exports = {
|
||||
if (!richPresence) {
|
||||
richPresence = new DiscordRPC.AutoClient({ transport: "ipc" });
|
||||
richPresence.endlessLogin({ clientId });
|
||||
richPresence.once("ready", () => {
|
||||
richPresence.once("ready", async () => {
|
||||
console.log(
|
||||
"connected presence with user " + richPresence.user.username,
|
||||
);
|
||||
richPresence.setActivity(currentStatus);
|
||||
intervalId = setInterval(() => {
|
||||
richPresence.setActivity(currentStatus);
|
||||
}, 2500);
|
||||
await richPresence.setActivity(currentStatus);
|
||||
intervalId = setInterval(() => richPresence.setActivity(currentStatus), 2500);
|
||||
});
|
||||
}
|
||||
},
|
||||
disconnect: async () => {
|
||||
if (richPresence) {
|
||||
clearInterval(intervalId);
|
||||
await richPresence.clearActivity();
|
||||
await richPresence.destroy();
|
||||
const presence = richPresence;
|
||||
richPresence = null;
|
||||
clearInterval(intervalId);
|
||||
await presence.clearActivity();
|
||||
await presence.destroy();
|
||||
}
|
||||
},
|
||||
updateStatus: ({ state, details, largeImageKey }) => {
|
||||
@@ -62,9 +61,9 @@ module.exports = {
|
||||
currentStatus.smallImageKey = id ? `https://a.ez-pp.farm/${id}` : " ";
|
||||
currentStatus.smallImageText = username ?? " ";
|
||||
},
|
||||
update: () => {
|
||||
update: async () => {
|
||||
if (richPresence && richPresence.user) {
|
||||
richPresence.setActivity(currentStatus);
|
||||
await richPresence.setActivity(currentStatus);
|
||||
}
|
||||
},
|
||||
hasPresence: () => richPresence != undefined,
|
||||
|
Reference in New Issue
Block a user