Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const DiscordRPC = require("discord-rpc");
- const fs = require('fs');
- const ClientId = '513142289510694912';
- DiscordRPC.register(ClientId);
- const rpc = new DiscordRPC.Client({ transport: 'ipc' });
- let currentMeters = 1700;
- let currentLevel = 2;
- let currentState = "Forest of Temptation"
- function saveState() {
- fs.writeFile("state.dat", currentMeters.toString(), function(err) {
- if(err) {
- return console.log(err);
- }
- });
- }
- function loadState() {
- try {
- loadState();
- console.log("loaded state")
- }
- catch (error) {
- console.log("no saved state, starting from beginning");
- }
- fs.readFile('state.dat', 'utf8', function(err, contents) {
- currentMeters = parseInt(contents);
- });
- }
- function numberWithCommas(x) {
- return Math.round(x).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
- }
- function setStates() {
- if (1351 < currentMeters < 2600) {
- currentLevel = 2;
- currentState = "Forest of Temptation";
- }
- else if (2601 < currentMeters < 7000) {
- currentLevel = 3;
- currentState = "Great Fault";
- }
- else if (7001 < currentMeters < 12000) {
- currentLevel = 4;
- currentState = "The Goblets of Giants";
- }
- else if (12001 < currentMeters < 13000) {
- currentLevel = 5;
- currentState = "Sea of Corpses";
- }
- else if (13001 < currentMeters < 15500) {
- currentLevel = 6;
- currentState = "The Capital of the Unreturned";
- }
- else if (15501 < currentMeters < 20000) {
- currentLevel = 7;
- currentState = "The Final Maelstrom";
- }
- else {
- currentLevel = 8;
- currentState = "The Deepest Point";
- }
- }
- function doRPC() {
- setStates();
- rpc.setActivity({
- details: "Level " + currentLevel + " | " + numberWithCommas(currentMeters) + " meters",
- state: currentState,
- largeImageKey: 'made-in-abyss-riko',
- largeImageText: 'Riko',
- smallImageKey: 'white-whitle-large',
- smallImageText: 'White Whistle',
- instance: true,
- });
- }
- rpc.on('ready', () => {
- console.log("ready");
- try {
- loadState();
- }
- catch (error) {
- console.log("no saved state, starting from beginning");
- }
- doRPC();
- });
- console.log("logging in");
- rpc.login(ClientId).catch(console.error);
- console.log("logged in");
- setInterval(() => {
- console.log("updating rpc...")
- currentMeters += (Math.random() * 101);
- doRPC();
- console.log("updated rpc! | Level " + currentLevel + " | " + numberWithCommas(currentMeters) + " meters");
- saveState();
- }, 300000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement