From a8ea776bed6a6b7e9973e758c7175cc05c5b1252 Mon Sep 17 00:00:00 2001 From: Cesium Date: Tue, 11 Nov 2025 14:10:45 -0500 Subject: [PATCH] automatically creating state.json so it doesnt epic fail (new epic fail, the json start text is hardcoded) --- index.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index b3525c2..8efd310 100644 --- a/index.js +++ b/index.js @@ -4,13 +4,26 @@ const path = require('node:path'); const torn = require('./torn.js'); let config, state; -try { +try { + console.debug("Core: Loading config") config = require('./config.json'); - state = require('./state.json'); } catch { - console.error("Fatal: Unable to load config.json or state.json. Please follow the instructions in README.md"); + console.error("Fatal: Unable to load config.json. Please follow the instructions in README.md"); process.exit(1); } +try { + console.debug("Core: Loading state") + state = require('./state.json'); +} catch { + console.log("Core: No state file found, creating one.") + state = { + "ocAlertLast": "2025-01-01T00:00:00.000Z", + "payoutAlertLast": "2025-01-01T00:00:00.000Z", + "itemAlertLast": "2025-01-01T00:00:00.000Z" + } + fs.writeFileSync('./state.json', JSON.stringify(state)); +} + // the basic discord setup stuff yoinked from their guide const { Client, Collection, Events, GatewayIntentBits, EmbedBuilder, Partials, MessageFlags } = require('discord.js');