mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-12-28 22:33:02 +05:00
fix(event): fixed not loading events
This commit is contained in:
parent
3d91b7fa9b
commit
dc7bef73ee
2 changed files with 20 additions and 14 deletions
|
@ -12,6 +12,8 @@ export class ExtendedClient extends Client {
|
|||
}
|
||||
|
||||
async init() {
|
||||
this.login(config.token).then(async () => await Promise.all([initCommands(), initEvents()]).catch(console.error));
|
||||
return this.login(config.token)
|
||||
.then(async () => await Promise.all([initCommands(), initEvents()]))
|
||||
.catch(console.error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,22 +11,26 @@ export const init = async () => {
|
|||
};
|
||||
|
||||
const buildEvents = async () => {
|
||||
const eventFilePaths = (await getFilePaths("./newEvents", true)).filter(path => path.endsWith(".js"));
|
||||
try {
|
||||
const eventFilePaths = (await getFilePaths("./newEvents", true)).filter(path => path.endsWith(".js"));
|
||||
|
||||
for (const eventFilePath of eventFilePaths) {
|
||||
const { data, run } = await import(toFileURL(eventFilePath));
|
||||
for (const eventFilePath of eventFilePaths) {
|
||||
const { data, run } = await import(toFileURL(eventFilePath));
|
||||
|
||||
if (!data || !data.name) {
|
||||
console.warn(`Event ${eventFilePath} does not have a data object or name`);
|
||||
continue;
|
||||
if (!data || !data.name) {
|
||||
console.warn(`Event ${eventFilePath} does not have a data object or name`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof run !== "function") {
|
||||
console.warn(`Event ${eventFilePath} does not have a run function or it is not a function`);
|
||||
continue;
|
||||
}
|
||||
|
||||
events.push({ data, run });
|
||||
}
|
||||
|
||||
if (typeof run !== "function") {
|
||||
console.warn(`Event ${eventFilePath} does not have a run function or it is not a function`);
|
||||
continue;
|
||||
}
|
||||
|
||||
events.push({ data, run });
|
||||
} catch (error) {
|
||||
console.error("Error build events: ", error);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue