fix(eventhandler): first we check for required parameters, then everything else

This commit is contained in:
Slincnik 2025-01-14 16:47:56 +03:00
parent eb78c29c90
commit 8a4256159d
No known key found for this signature in database

View file

@ -33,9 +33,16 @@ export class EventHandler {
const eventFilePaths = (await getFilePaths(eventPath, true)).filter(path => path.endsWith(".js") || path.endsWith(".ts"));
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`);
continue;
}