add all events to Client#events Collection<Function>

merge-requests/12/head
Matthew 2020-05-06 19:32:20 -04:00 committed by Bsian
parent 049136adda
commit 8589cd2068
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
1 changed files with 4 additions and 0 deletions

View File

@ -9,6 +9,8 @@ export default class Client extends eris.Client {
public commands: Collection<Command>;
public events: Collection<Function>;
public intervals: Collection<NodeJS.Timeout>;
public util: Util;
@ -21,6 +23,7 @@ export default class Client extends eris.Client {
constructor(token: string, options?: eris.ClientOptions) {
super(token, options);
this.commands = new Collection<Command>();
this.events = new Collection<Function>();
this.intervals = new Collection<NodeJS.Timeout>();
this.db = { member: Member, moderation: Moderation, redirect: Redirect };
}
@ -52,6 +55,7 @@ export default class Client extends eris.Client {
if (file === 'index.js') return;
// eslint-disable-next-line
const event = new (require(`${__dirname}/../events/${file}`).default)(this);
this.events.add(eventName, event);
this.on(eventName, (...args) => event.run(...args));
this.util.signale.success(`Successfully loaded event: ${eventName}`);
delete require.cache[require.resolve(`${__dirname}/../events/${file}`)];