diff options
Diffstat (limited to 'src/Troffman.js')
| -rw-r--r-- | src/Troffman.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/Troffman.js b/src/Troffman.js new file mode 100644 index 0000000..2b8860c --- /dev/null +++ b/src/Troffman.js @@ -0,0 +1,35 @@ +const Eris = require('eris'); +const toml = require('toml'); +const fs = require('fs'); + +const RegexFramework = require('./RegexFramework'); +const Events = require('./Events'); +const CommandLoader = require('./CommandLoader'); +const TroffmanDatabase = require('./TroffmanDatabase'); + +module.exports = class Troffman extends Eris { + constructor(configPath, options) { + if (!fs.existsSync(configPath)) { + fs.copyFileSync("./config.def.toml", configPath); + process.exit(0); + } + let c = toml.parse(fs.readFileSync(configPath)); + super(c.token, options); + this.config = c; + if (!this.config.sudoers) { + this.config.sudoers = ['']; + } + else if (!Array.isArray(this.config.sudoers)) { + this.config.sudoers = ['']; + } + else if (this.config.sudoers.length <= 0) { + this.config.sudoers = ['']; + } + this._ds = Array.from(this.config.sudoers); + this.db = new TroffmanDatabase(c.database); + this.handler = new RegexFramework(); + Events(this); + CommandLoader(this); + this.db.sync(); + } +}; |
