🚑 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));
}
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}`
);
})
);
});
};

View file

@ -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);
});

View file

@ -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}`);
});
}
};