🚑 deployCommands should work

This commit is contained in:
Axel Olausson Holtenäs 2022-04-14 00:44:22 +02:00
parent 3d8d9c43bd
commit 0054d6439b
No known key found for this signature in database
GPG key ID: 9347A5E873995701
3 changed files with 29 additions and 22 deletions

View file

@ -11,13 +11,18 @@ export default async (client: Client) => {
return logger?.error(new Error(error)); return logger?.error(new Error(error));
} }
await plugins?.map(async (pluginName: any) => { await Promise.all(
const plugin = await import(`../plugins/${pluginName}`); plugins?.map(async (pluginName: any) => {
const plugin = await import(`../plugins/${pluginName}`);
await client?.commands?.set(plugin?.default?.data?.name, plugin?.default); await client?.commands?.set(
logger?.debug( plugin?.default?.data?.name,
`Successfully loaded plugin: ${plugin?.default?.data?.name} from ${plugin.default?.metadata?.author}` plugin?.default
); );
}); logger?.debug(
`Successfully loaded plugin: ${plugin?.default?.data?.name} from ${plugin.default?.metadata?.author}`
);
})
);
}); });
}; };

View file

@ -15,15 +15,17 @@ export default async () => {
const pluginList = [] as any; const pluginList = [] as any;
await plugins?.map(async (pluginName: any) => { await Promise.all(
const plugin = await import(`../plugins/${pluginName}`); 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( logger?.debug(
`Successfully deployed plugin: ${plugin?.default?.data?.name} from ${plugin.default?.metadata?.author}` `Successfully deployed plugin: ${plugin?.default?.data?.name} from ${plugin.default?.metadata?.author}`
); );
}); })
);
const rest = new REST({ version: "9" }).setToken(token); const rest = new REST({ version: "9" }).setToken(token);
@ -31,9 +33,9 @@ export default async () => {
.put(Routes.applicationCommands(clientId), { .put(Routes.applicationCommands(clientId), {
body: pluginList, body: pluginList,
}) })
.then(async () => .then(async () => {
logger.info("Successfully registered application commands.") logger.info("Successfully registered application commands.");
) })
.catch(async (err: any) => { .catch(async (err: any) => {
logger.error(err); logger.error(err);
}); });

View file

@ -7,9 +7,9 @@ import logger from "@logger";
import { devMode, guildId } from "@config/other"; import { devMode, guildId } from "@config/other";
export default async (client: Client) => { export default async (client: Client) => {
// if (!devMode) { if (!devMode) {
// client?.application?.commands?.set([], guildId).then(async () => { client?.application?.commands?.set([], guildId).then(async () => {
// logger.verbose(`Removed all guild based commands from ${guildId}`); logger.verbose(`Removed all guild based commands from ${guildId}`);
// }); });
// } }
}; };