add all events to Client#events Collection<Function>
parent
049136adda
commit
8589cd2068
|
@ -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}`)];
|
||||||
|
|
Loading…
Reference in New Issue