mirror of
https://github.com/JonnyBro/JaBa.git
synced 2025-01-20 01:13:47 +05:00
fix(eventhandler): first we check for required parameters, then everything else
This commit is contained in:
parent
eb78c29c90
commit
8a4256159d
1 changed files with 9 additions and 2 deletions
|
@ -33,9 +33,16 @@ export class EventHandler {
|
||||||
const eventFilePaths = (await getFilePaths(eventPath, true)).filter(path => path.endsWith(".js") || path.endsWith(".ts"));
|
const eventFilePaths = (await getFilePaths(eventPath, true)).filter(path => path.endsWith(".js") || path.endsWith(".ts"));
|
||||||
|
|
||||||
for (const eventFilePath of eventFilePaths) {
|
for (const eventFilePath of eventFilePaths) {
|
||||||
const { data, run } = await import(toFileURL(eventFilePath));
|
const eventModule = await import(toFileURL(eventFilePath));
|
||||||
|
|
||||||
if (!data || !data.name) {
|
if (!("data" in eventModule) || !("run" in eventModule)) {
|
||||||
|
logger.warn(`Event ${eventFilePath} does not have a data object or name`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data, run } = eventModule;
|
||||||
|
|
||||||
|
if (!data.name) {
|
||||||
logger.warn(`Event ${eventFilePath} does not have a data object or name`);
|
logger.warn(`Event ${eventFilePath} does not have a data object or name`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue