From 0054d6439b3844f993a6d78aa5420c339e30d429 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Thu, 14 Apr 2022 00:44:22 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20deployCommands=20should=20work?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/commands.ts | 19 ++++++++++++------- src/handlers/deployCommands.ts | 22 ++++++++++++---------- src/helpers/devMode.ts | 10 +++++----- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/handlers/commands.ts b/src/handlers/commands.ts index 0e657b8..4645c10 100644 --- a/src/handlers/commands.ts +++ b/src/handlers/commands.ts @@ -11,13 +11,18 @@ export default async (client: Client) => { return logger?.error(new Error(error)); } - await plugins?.map(async (pluginName: any) => { - const plugin = await import(`../plugins/${pluginName}`); + await Promise.all( + plugins?.map(async (pluginName: any) => { + const plugin = await import(`../plugins/${pluginName}`); - await client?.commands?.set(plugin?.default?.data?.name, plugin?.default); - logger?.debug( - `Successfully loaded plugin: ${plugin?.default?.data?.name} from ${plugin.default?.metadata?.author}` - ); - }); + await client?.commands?.set( + plugin?.default?.data?.name, + plugin?.default + ); + logger?.debug( + `Successfully loaded plugin: ${plugin?.default?.data?.name} from ${plugin.default?.metadata?.author}` + ); + }) + ); }); }; diff --git a/src/handlers/deployCommands.ts b/src/handlers/deployCommands.ts index 2d134e5..d58e5af 100644 --- a/src/handlers/deployCommands.ts +++ b/src/handlers/deployCommands.ts @@ -15,15 +15,17 @@ export default async () => { const pluginList = [] as any; - await plugins?.map(async (pluginName: any) => { - const plugin = await import(`../plugins/${pluginName}`); + await Promise.all( + plugins?.map(async (pluginName: any) => { + const plugin = await import(`../plugins/${pluginName}`); - pluginList.push(plugin.default.data.toJSON()); + pluginList.push(plugin.default.data.toJSON()); - logger?.debug( - `Successfully deployed plugin: ${plugin?.default?.data?.name} from ${plugin.default?.metadata?.author}` - ); - }); + logger?.debug( + `Successfully deployed plugin: ${plugin?.default?.data?.name} from ${plugin.default?.metadata?.author}` + ); + }) + ); const rest = new REST({ version: "9" }).setToken(token); @@ -31,9 +33,9 @@ export default async () => { .put(Routes.applicationCommands(clientId), { body: pluginList, }) - .then(async () => - logger.info("Successfully registered application commands.") - ) + .then(async () => { + logger.info("Successfully registered application commands."); + }) .catch(async (err: any) => { logger.error(err); }); diff --git a/src/helpers/devMode.ts b/src/helpers/devMode.ts index abdba7e..708481b 100644 --- a/src/helpers/devMode.ts +++ b/src/helpers/devMode.ts @@ -7,9 +7,9 @@ import logger from "@logger"; import { devMode, guildId } from "@config/other"; export default async (client: Client) => { - // if (!devMode) { - // client?.application?.commands?.set([], guildId).then(async () => { - // logger.verbose(`Removed all guild based commands from ${guildId}`); - // }); - // } + if (!devMode) { + client?.application?.commands?.set([], guildId).then(async () => { + logger.verbose(`Removed all guild based commands from ${guildId}`); + }); + } };