complain if expected files are not created instead of big confusing error
This commit is contained in:
12
index.js
12
index.js
@@ -3,8 +3,14 @@ const fs = require('fs');
|
|||||||
const path = require('node:path');
|
const path = require('node:path');
|
||||||
const torn = require('./torn.js');
|
const torn = require('./torn.js');
|
||||||
|
|
||||||
const config = require('./config.json');
|
let config, state;
|
||||||
const state = require('./state.json');
|
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
|
// the basic discord setup stuff yoinked from their guide
|
||||||
const { Client, Collection, Events, GatewayIntentBits, EmbedBuilder, Partials, MessageFlags } = require('discord.js');
|
const { Client, Collection, Events, GatewayIntentBits, EmbedBuilder, Partials, MessageFlags } = require('discord.js');
|
||||||
@@ -22,11 +28,11 @@ const client = new Client({
|
|||||||
});
|
});
|
||||||
client.once(Events.ClientReady, readyClient => {
|
client.once(Events.ClientReady, readyClient => {
|
||||||
console.log(`Discord: Connected as ${readyClient.user.tag}`);
|
console.log(`Discord: Connected as ${readyClient.user.tag}`);
|
||||||
|
torn.readyCheck(config.torn);
|
||||||
});
|
});
|
||||||
client.login(config.token);
|
client.login(config.token);
|
||||||
client.commands = new Collection();
|
client.commands = new Collection();
|
||||||
|
|
||||||
torn.readyCheck(config.torn);
|
|
||||||
|
|
||||||
let task = {};
|
let task = {};
|
||||||
fs.readdir('./tasks/', (err, files) => {
|
fs.readdir('./tasks/', (err, files) => {
|
||||||
|
|||||||
9
torn.js
9
torn.js
@@ -1,4 +1,11 @@
|
|||||||
const config = require('./config')
|
let config;
|
||||||
|
try {
|
||||||
|
config = require('./config')
|
||||||
|
} catch {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = () => {};
|
module.exports = () => {};
|
||||||
module.exports.readyCheck = async (key) => {
|
module.exports.readyCheck = async (key) => {
|
||||||
const url = `https://api.torn.com/user/?selections=basic&key=${key}`
|
const url = `https://api.torn.com/user/?selections=basic&key=${key}`
|
||||||
|
|||||||
Reference in New Issue
Block a user