catch

Beta
  • Posts

    151
  • Joined

  • Last visited

  • Days Won

    10

Posts posted by catch

  1. 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

    • Like 1