galactic-bot/Manager.js

47 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-04-08 16:01:31 +02:00
const { EventEmitter } = require('events');
2020-04-08 16:27:34 +02:00
2020-04-08 18:08:46 +02:00
const ShardManager = require('./middleware/ShardManager.js');
const StorageManager = require('./storage/StorageManager.js');
2020-04-09 16:30:52 +02:00
const Registry = require('./Registry.js');
const Intercom = require('./Intercom.js');
const Logger = require('./Logger.js');
2020-04-08 16:27:34 +02:00
2020-04-08 18:08:46 +02:00
const { Command, Setting, Inhibitor } = require('./structure/interfaces/');
2020-04-08 16:01:31 +02:00
class Manager extends EventEmitter {
2020-04-08 16:27:34 +02:00
constructor(options) {
2020-04-09 16:30:52 +02:00
super();
2020-04-08 16:27:34 +02:00
this.registry = new Registry(this);
2020-04-09 16:30:52 +02:00
this.shardManager = new ShardManager('./middleware/client/DiscordClient.js', options);
2020-04-08 16:27:34 +02:00
this.storageManager = new StorageManager(this, options.storage)
.initialize();
2020-04-09 16:30:52 +02:00
this.intercom = new Intercom(this, this.shardManager);
2020-04-08 16:27:34 +02:00
this.logger = new Logger(this);
this._built = false;
}
async build() {
2020-04-09 16:30:52 +02:00
try {
await this.shardManager.spawn();
}catch(e) {
console.log(e);
}
2020-04-08 16:27:34 +02:00
await this.registry.loadComponents('components/commands/', Command);
2020-04-09 16:30:52 +02:00
2020-04-08 16:27:34 +02:00
this._built = true;
}
2020-04-08 16:01:31 +02:00
}
2020-04-08 16:27:34 +02:00
2020-04-08 16:01:31 +02:00
module.exports = Manager;