2020-04-08 18:08:46 +02:00
|
|
|
const { Client } = require('discord.js');
|
|
|
|
|
2020-04-09 16:30:52 +02:00
|
|
|
const options = require('../../options.json');
|
|
|
|
|
2020-04-09 23:08:28 +02:00
|
|
|
const Registry = require('./Registry.js')
|
2020-04-08 18:08:46 +02:00
|
|
|
const EventHooker = require('./EventHooker.js');
|
|
|
|
const Dispatcher = require('./Dispatcher.js')
|
|
|
|
const Resolver = require('./Resolver.js');
|
2020-04-09 16:30:52 +02:00
|
|
|
const Transporter = require('./Transporter.js');
|
2020-04-08 18:08:46 +02:00
|
|
|
|
|
|
|
const { Guild, User, Message } = require('../../structure/extensions/');
|
2020-04-09 23:08:28 +02:00
|
|
|
const { Command, Observer, Inhibitor, Setting } = require('../../structure/interfaces/');
|
2020-04-08 18:08:46 +02:00
|
|
|
|
|
|
|
class DiscordClient extends Client {
|
|
|
|
|
2020-04-09 16:30:52 +02:00
|
|
|
constructor(options) {
|
2020-04-08 18:08:46 +02:00
|
|
|
|
2020-04-09 16:30:52 +02:00
|
|
|
super(options.bot.clientOptions);
|
|
|
|
|
2020-04-09 23:08:28 +02:00
|
|
|
this.registry = new Registry(this);
|
2020-04-08 18:08:46 +02:00
|
|
|
this.eventHooker = new EventHooker(this);
|
|
|
|
this.dispatcher = new Dispatcher(this);
|
|
|
|
this.resolver = new Resolver(this);
|
2020-04-09 16:30:52 +02:00
|
|
|
this.transporter = new Transporter(this);
|
2020-04-08 18:08:46 +02:00
|
|
|
|
|
|
|
this._options = options;
|
|
|
|
this._built = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
async build() {
|
|
|
|
|
2020-04-09 23:08:28 +02:00
|
|
|
if(this._built) return undefined;
|
|
|
|
|
2020-04-09 16:30:52 +02:00
|
|
|
await super.login(this._options.bot.token);
|
|
|
|
|
2020-04-09 23:08:28 +02:00
|
|
|
await this.registry.loadComponents('components/commands/', Command);
|
|
|
|
await this.registry.loadComponents('components/observers', Observer);
|
2020-04-09 16:30:52 +02:00
|
|
|
|
2020-04-09 23:08:28 +02:00
|
|
|
await this.dispatcher.dispatch();
|
2020-04-08 18:08:46 +02:00
|
|
|
|
|
|
|
this._built = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = DiscordClient;
|
|
|
|
|
2020-04-09 16:30:52 +02:00
|
|
|
const client = new DiscordClient(options);
|
2020-04-08 18:08:46 +02:00
|
|
|
client.build();
|