🏷️ replace IPluginData with ICommand
This commit is contained in:
parent
ee57233499
commit
e3e054122e
3 changed files with 18 additions and 14 deletions
|
@ -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}`
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
7
src/interfaces/Command.ts
Normal file
7
src/interfaces/Command.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||
|
||||
export interface ICommand {
|
||||
modules: any;
|
||||
builder: SlashCommandBuilder;
|
||||
execute: Promise<void>;
|
||||
}
|
Loading…
Add table
Reference in a new issue