diff --git a/src/handlers/deployCommands.ts b/src/handlers/deployCommands.ts index 4ca0923..7883abd 100644 --- a/src/handlers/deployCommands.ts +++ b/src/handlers/deployCommands.ts @@ -1,24 +1,19 @@ -// @ts-ignore import { token, clientId } from "@config/discord"; -// @ts-ignore import { devMode, guildId } from "@config/other"; import logger from "../logger"; import { Client } from "@root/types/common/discord"; import { REST } from "@discordjs/rest"; import { Routes } from "discord-api-types/v9"; -import { SlashCommandBuilder } from "@discordjs/builders"; import { RESTPostAPIApplicationCommandsJSONBody } from "discord-api-types/v10"; +import { ICommand } from "@interface/Command"; + export default async (client: Client) => { const pluginList: Array = []; - interface IPluginData { - builder: SlashCommandBuilder; - } - await Promise.all( - client.commands.map(async (pluginData: IPluginData) => { + client.commands.map(async (pluginData: ICommand) => { pluginList.push(pluginData.builder.toJSON()); logger.verbose( `Plugin is ready for deployment: ${pluginData.builder.name}` diff --git a/src/helpers/getCommandMetadata/index.ts b/src/helpers/getCommandMetadata/index.ts index 7894c00..fe7784b 100644 --- a/src/helpers/getCommandMetadata/index.ts +++ b/src/helpers/getCommandMetadata/index.ts @@ -1,12 +1,14 @@ import { CommandInteraction } from "discord.js"; +import { ICommand } from "@interface/Command"; -export default async (interaction: CommandInteraction, currentCommand: any) => { +export default async ( + interaction: CommandInteraction, + currentCommand: ICommand +) => { const subcommand = interaction.options.getSubcommand(); const subcommandGroup = interaction.options.getSubcommandGroup(false); - if (!subcommandGroup) { - return currentCommand.modules[subcommand].metadata; - } - - return currentCommand.modules[subcommandGroup].modules[subcommand].metadata; + return subcommandGroup + ? currentCommand.modules[subcommandGroup].modules[subcommand].metadata + : currentCommand.modules[subcommand].metadata; }; diff --git a/src/interfaces/Command.ts b/src/interfaces/Command.ts new file mode 100644 index 0000000..34585d9 --- /dev/null +++ b/src/interfaces/Command.ts @@ -0,0 +1,7 @@ +import { SlashCommandBuilder } from "@discordjs/builders"; + +export interface ICommand { + modules: any; + builder: SlashCommandBuilder; + execute: Promise; +}