🥅 error handling in command handler
This commit is contained in:
parent
527a482b6c
commit
61ae59847d
1 changed files with 12 additions and 6 deletions
|
@ -1,18 +1,18 @@
|
|||
import fs from "fs"; // fs
|
||||
import { Collection } from "discord.js"; // discord.js
|
||||
import { Client } from "../types/common/discord";
|
||||
import logger from "../logger";
|
||||
import { Client } from "@root/types/common/discord";
|
||||
import logger from "@logger";
|
||||
|
||||
export default async (client: Client) => {
|
||||
client.commands = new Collection();
|
||||
|
||||
fs.readdir("./src/plugins", async (error, plugins) => {
|
||||
if (error) {
|
||||
return logger?.error(`Error reading plugins: ${error}`);
|
||||
return logger.error(`Error reading plugins: ${error}`);
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
plugins?.map(async (pluginName) => {
|
||||
plugins.map(async (pluginName) => {
|
||||
const plugin = await import(`../plugins/${pluginName}`);
|
||||
|
||||
await client?.commands?.set(
|
||||
|
@ -20,8 +20,14 @@ export default async (client: Client) => {
|
|||
plugin?.default
|
||||
);
|
||||
|
||||
logger?.verbose(`Loaded plugin: ${pluginName}`);
|
||||
logger.verbose(`Loaded plugin: ${pluginName}`);
|
||||
})
|
||||
);
|
||||
)
|
||||
.then(async () => {
|
||||
logger.debug("Successfully loaded plugins.");
|
||||
})
|
||||
.catch(async (err) => {
|
||||
logger.error(err);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue