complain if expected files are not created instead of big confusing error

This commit is contained in:
2025-11-09 20:19:41 -05:00
parent 10dd9fb3cf
commit 743337cead
2 changed files with 17 additions and 4 deletions

View File

@@ -3,8 +3,14 @@ const fs = require('fs');
const path = require('node:path');
const torn = require('./torn.js');
const config = require('./config.json');
const state = require('./state.json');
let config, state;
try {
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");
process.exit(1);
}
// the basic discord setup stuff yoinked from their guide
const { Client, Collection, Events, GatewayIntentBits, EmbedBuilder, Partials, MessageFlags } = require('discord.js');
@@ -22,11 +28,11 @@ const client = new Client({
});
client.once(Events.ClientReady, readyClient => {
console.log(`Discord: Connected as ${readyClient.user.tag}`);
torn.readyCheck(config.torn);
});
client.login(config.token);
client.commands = new Collection();
torn.readyCheck(config.torn);
let task = {};
fs.readdir('./tasks/', (err, files) => {

View File

@@ -1,4 +1,11 @@
const config = require('./config')
let config;
try {
config = require('./config')
} catch {
return
}
module.exports = () => {};
module.exports.readyCheck = async (key) => {
const url = `https://api.torn.com/user/?selections=basic&key=${key}`