diff --git a/.gitignore b/.gitignore index 7477c52..cba6441 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ config/ node_modules/ +*.log diff --git a/logs.log b/logs.log deleted file mode 100644 index 77809ea..0000000 --- a/logs.log +++ /dev/null @@ -1 +0,0 @@ -[SYSTEM STARTING UP] diff --git a/src/config.js b/src/config.js new file mode 100644 index 0000000..2cbdfaf --- /dev/null +++ b/src/config.js @@ -0,0 +1,34 @@ +const Logger = require('../logger'); +const fs = require('fs'); + +module.exports = class Config { + constructor(path) { + this.path = path; + this.Config = { + token: 'YOUR TOKEN HERE' + }; + } + + load() { + Logger.info('Loading config'); + if (fs.existsSync(this.path)) { + try { + this.Config = JSON.parse(fs.readFileSync(this.path)); + if (!this.Config.token); + + Logger.info('Config loaded successfully'); + } catch (e) { + Logger.panic(`Failed to load config... Invalid JSON: ${e}`); + } + } else { + try { + Logger.error('No config found'); + fs.writeFileSync(this.path, JSON.stringify(this.Config, null, 4)); + Logger.warn(`Created config at: ${this.path}`); + Logger.panic('Config required to be complete'); + } catch (e) { + Logger.panic(`Could not create config: ${e}`); + } + } + } +} diff --git a/src/index.js b/src/index.js index dc8fd05..dfb0858 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ const Logger = require('./logger'); -const Config = require('./config'); +const Config = require('./config/config'); const Discord = require('discord.js'); const client = new Discord.Client(); diff --git a/src/logger.js b/src/logger.js index 98e9547..2ae050d 100644 --- a/src/logger.js +++ b/src/logger.js @@ -2,6 +2,7 @@ const colours = require('colors/safe'); const fs = require('fs'); let LogLevel = 1; +let Dialect = 'SQLITE'; let logPath = 'logs.log'; module.exports = class Logger { @@ -18,6 +19,10 @@ module.exports = class Logger { LogLevel = level; } + static SetDialect(dialect) { + Dialect = dialect; + } + static get VERBOSE_LOGS() {return 0;} static get DEBUG_LOGS() {return 1;} static get INFO_LOGS() {return 2;}