let import error by itself

This commit is contained in:
Erik 2024-01-17 18:09:00 +02:00
parent 918e8aa941
commit 7547e6af57

View File

@ -171,9 +171,7 @@ class Controller extends EventEmitter
this.#commands = []; this.#commands = [];
for (const file of files) for (const file of files)
{ {
const imported = await import(`file://${file}`).catch(() => null); const imported = await import(`file://${file}`);
if (!imported)
throw new Error(`Invalid file ${file}`);
const cmd = imported.default; const cmd = imported.default;
if (typeof cmd !== 'function') if (typeof cmd !== 'function')
return void this.#logger.warn(`Attempted to load an invalid command: ${file}`); return void this.#logger.warn(`Attempted to load an invalid command: ${file}`);