Astolfo Discord Rich Presence || Fixed the exe


catch
 Share

Recommended Posts

So I finally got around to making a self updating discord rpc. For this to work, you need Astolfo to output to a latest.log file. The attatched file named "overlayfix.exe" is made by @Boomz, the creator of bwstats overlay and showes you how to create a latest.log file.
 

This is created with nodejs. The attached zip file is a packaged exe. The other is the source code.
 

const client = require('discord-rich-presence')('795673937295835177');
const fs = require('fs');
let currentRpc = undefined;
let gameTypes = [
  "skywars",
  "bedwars",
  "pit",
  "uhc",
  "limbo",
]
let user = process.env.HOME;
let oldLogs = fs.readFileSync(`${user}/AppData/Roaming/.minecraft/logs/latest.log`, 'utf-8');
function getNewLogs() {
  return fs.readFileSync(`${user}/AppData/Roaming/.minecraft/logs/latest.log`, 'utf-8');
};
function doLoop() {
  let logs = getNewLogs();
  logs = logs.replace(oldLogs, '');
  for (i = 0; i < gameTypes.length; i++) {
    if (logs.toLowerCase().includes(gameTypes[i]) && currentRpc !== gameTypes[i]) {
      currentRpc = gameTypes[i];
      update(gameTypes[i].toUpperCase());
      break;
    };
  };
  oldLogs = getNewLogs();
  setTimeout(() => {
    doLoop();
  }, 500);
};
function update(gameMode) {
  console.log("updated");
  client.updatePresence({
    state: gameMode,
    details: "Hypixel.net",
    startTimestamp: Date.now(),
    largeImageKey: "logo",
    instance: true,
    largeImageText: "https://astolfo.lgbt"
  });
};
doLoop();

To run this from source, create a new folder, and then run the command:
npm install
This will install the discord-rich-presence dependancy.

There's still things I wanna add to the script in future, but I thought I'd share it.
Edit: 3/4/2021
I replaced the index.js and executable file. They should work now.

overlayfix.exe package.json

index.js astolfoRpc.zip

Edited by catch
  • Like 1

Share this post


Link to post
Share on other sites

  • catch changed the title to Astolfo Discord Rich Presence || Fixed the exe
  • 4 months later...
  • 4 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share