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 = [];
for (const file of files)
{
const imported = await import(`file://${file}`).catch(() => null);
if (!imported)
throw new Error(`Invalid file ${file}`);
const imported = await import(`file://${file}`);
const cmd = imported.default;
if (typeof cmd !== 'function')
return void this.#logger.warn(`Attempted to load an invalid command: ${file}`);