diff options
Diffstat (limited to '')
-rw-r--r-- | src/Shulker.ts | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/Shulker.ts b/src/Shulker.ts index d9373ee..517d1e2 100644 --- a/src/Shulker.ts +++ b/src/Shulker.ts @@ -1,7 +1,9 @@ +import fs from 'fs' + import DiscordClient from './Discord' import Handler, { LogLine } from './MinecraftHandler' -import { Config } from './Config' +import type { Config } from './Config' class Shulker { config: Config @@ -14,10 +16,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 } |