From 328eec0cd4fff00f19e734cc7e9b54124ab44cf5 Mon Sep 17 00:00:00 2001 From: destruc7i0n <6181960+destruc7i0n@users.noreply.github.com> Date: Fri, 24 Dec 2021 17:51:26 -0500 Subject: updated to discord.js v13 (#77) * updated to discord.js v13 * update loading of config * updated debug lines * rcon cleanup * more code cleanup * bump version * message about node.js requirement Co-authored-by: destruc7i0n --- src/Shulker.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/Shulker.ts') diff --git a/src/Shulker.ts b/src/Shulker.ts index 4c79c78..df635ad 100644 --- a/src/Shulker.ts +++ b/src/Shulker.ts @@ -1,3 +1,6 @@ +import path from 'path' +import fs from 'fs' + import DiscordClient from './Discord' import Handler, { LogLine } from './MinecraftHandler' @@ -12,10 +15,16 @@ class Shulker { } loadConfig () { - const configFile = (process.argv.length > 2) ? process.argv[2] : '../config.json' + const configFile = process.argv.length > 2 ? process.argv[2] : './config.json' + if (!fs.existsSync(configFile)) { + console.log('[ERROR] Could not find config file!') + return false + } console.log('[INFO] Using configuration file:', configFile) - this.config = require(configFile) - if (!this.config) { + + try { + this.config = JSON.parse(fs.readFileSync(configFile, 'utf8')) + } catch (e) { console.log('[ERROR] Could not load config file!') return false } -- cgit 1.4.1