🏷️ replace IPluginData with ICommand

This commit is contained in:
Axel Olausson Holtenäs 2022-05-28 14:32:35 +02:00
parent ee57233499
commit e3e054122e
No known key found for this signature in database
GPG key ID: 7BF6826B76382CBA
3 changed files with 18 additions and 14 deletions

View file

@ -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<RESTPostAPIApplicationCommandsJSONBody> = [];
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}`

View file

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

View file

@ -0,0 +1,7 @@
import { SlashCommandBuilder } from "@discordjs/builders";
export interface ICommand {
modules: any;
builder: SlashCommandBuilder;
execute: Promise<void>;
}