Change event loading logic
This commit is contained in:
parent
776043393d
commit
75674f5beb
1 changed files with 5 additions and 5 deletions
10
shard.js
10
shard.js
|
@ -45,12 +45,12 @@ class Shard extends BaseClusterWorker {
|
||||||
log("info", "Finished loading commands.");
|
log("info", "Finished loading commands.");
|
||||||
|
|
||||||
// register events
|
// register events
|
||||||
const events = await readdir("./events/");
|
log("info", `Attempting to load events...`);
|
||||||
log("info", `Attempting to load ${events.length} events...`);
|
for await (const file of this.getFiles("./events/")) {
|
||||||
for (const file of events) {
|
|
||||||
log("log", `Loading event from ${file}...`);
|
log("log", `Loading event from ${file}...`);
|
||||||
const eventName = file.split(".")[0];
|
const eventArray = file.split("/");
|
||||||
const { default: event } = await import(`./events/${file}`);
|
const eventName = eventArray[eventArray.length - 1].split(".")[0];
|
||||||
|
const { default: event } = await import(`./${file}`);
|
||||||
this.bot.on(eventName, event.bind(null, this.bot, this.clusterID, this.workerID, this.ipc));
|
this.bot.on(eventName, event.bind(null, this.bot, this.clusterID, this.workerID, this.ipc));
|
||||||
}
|
}
|
||||||
log("info", "Finished loading events.");
|
log("info", "Finished loading events.");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue