feat: discord rich presence

Client 1.3.0 shows "Playing Burrow" on the player's Discord profile while
the game is open: where they are (the game's ajPresence, dens and player
parties never named), the time since they started and a button to the
download page. It goes through the Discord app's local IPC socket (no
packages; Windows pipe, Linux and macOS sockets, Flatpak and Snap too) and
retries quietly while Discord is not running. The server names its Discord
application in its flashvars (discordAppId); none, no presence.
This commit is contained in:
Burrowdev committed 2026-10-18 18:52:34 +03:00
1 parent 164e2e8adc
commit 92c5042c5e
5 files changed
+218

No files matched your search

+18
View File
@@ -1058,7 +1058,20 @@
}
};
// Discord rich presence (discord.js), while the game is open: the
// server's Discord application (flashvars discordAppId), where the
// player is and since when they have played.
const showPresence = state => {
if (!session || !session.flashVars || !session.flashVars.discordAppId) {
return;
}
session.presenceState = state || session.presenceState || "";
window.client.presence({appId: session.flashVars.discordAppId, state: session.presenceState,
start: session.since || Date.now(), url: session.flashVars.presenceUrl});
};
const closeGame = message => {
window.client.presence(null);
$("fps").textContent = "";
if (webview) {
webview.remove();
@@ -1153,6 +1166,10 @@
// main.js opens http and https addresses only
window.client.openPage(String(event.args[0]));
}
else if (event.channel === "presence") {
// where the player is now (the game's AJClient.presenceRoom)
showPresence(String(event.args[0] || ""));
}
});
$("loading").hidden = false;
clearTimeout(loadingTimer);
@@ -1176,6 +1193,7 @@
session = await login();
setStatus("", false, statusId);
openGame();
showPresence("");
}
catch (err) {
$("log-in").disabled = false;