add all events to Client#events Collection<Function>

merge-requests/11/merge
Matthew 2020-05-06 19:32:20 -04:00
parent 387983cece
commit 946568a230
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
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 commands: Collection<Command>;
public events: Collection<Function>;
public intervals: Collection<NodeJS.Timeout>; public intervals: Collection<NodeJS.Timeout>;
public util: Util; public util: Util;
@ -21,6 +23,7 @@ export default class Client extends eris.Client {
constructor(token: string, options?: eris.ClientOptions) { constructor(token: string, options?: eris.ClientOptions) {
super(token, options); super(token, options);
this.commands = new Collection<Command>(); this.commands = new Collection<Command>();
this.events = new Collection<Function>();
this.intervals = new Collection<NodeJS.Timeout>(); this.intervals = new Collection<NodeJS.Timeout>();
this.db = { member: Member, moderation: Moderation, redirect: Redirect }; this.db = { member: Member, moderation: Moderation, redirect: Redirect };
} }
@ -52,6 +55,7 @@ export default class Client extends eris.Client {
if (file === 'index.js') return; if (file === 'index.js') return;
// eslint-disable-next-line // eslint-disable-next-line
const event = new (require(`${__dirname}/../events/${file}`).default)(this); const event = new (require(`${__dirname}/../events/${file}`).default)(this);
this.events.add(eventName, event);
this.on(eventName, (...args) => event.run(...args)); this.on(eventName, (...args) => event.run(...args));
this.util.signale.success(`Successfully loaded event: ${eventName}`); this.util.signale.success(`Successfully loaded event: ${eventName}`);
delete require.cache[require.resolve(`${__dirname}/../events/${file}`)]; delete require.cache[require.resolve(`${__dirname}/../events/${file}`)];