some error handling here as well

This commit is contained in:
Joonas 2023-02-11 14:16:55 +02:00
parent e0d1796e5c
commit c831a14caa
1 changed files with 7 additions and 3 deletions

View File

@ -7,9 +7,13 @@ function getCommands() {
.map((file) => file.replace(".js", ""));
for (let file of commandFiles) {
import(`../commands/${file}.js`).then((cmd) =>
commands.push((commands[file] = cmd.command))
);
import(`../commands/${file}.js`)
.then((cmd) => commands.push((commands[file] = cmd.command)))
.catch((err) =>
console.error(
`Error when trying to read command file ${file}: ${err.message}`
)
);
}
return commands;