xyter/src/commands/manage/groups/counters/index.ts
Vermium Sifell 3c079943b0 refactor: 🧑‍💻 modules are called subcommands and groups
It makes more sense to use subcommands and groups as names instead of modules
2022-12-19 20:44:17 +01:00

41 lines
940 B
TypeScript

// Dependencies
import {
ChatInputCommandInteraction,
SlashCommandSubcommandGroupBuilder,
} from "discord.js";
// Modules
import {
builder as AddBuilder,
execute as AddExecute,
} from "./subcommands/add";
import {
builder as RemoveBuilder,
execute as RemoveExecute,
} from "./subcommands/remove";
export const builder = (group: SlashCommandSubcommandGroupBuilder) => {
return group
.setName("counters")
.setDescription("Manage guild counters.")
.addSubcommand(AddBuilder)
.addSubcommand(RemoveBuilder);
};
export const execute = async (interaction: ChatInputCommandInteraction) => {
const { options } = interaction;
switch (options.getSubcommand()) {
case "add": {
await AddExecute(interaction);
break;
}
case "remove": {
await RemoveExecute(interaction);
break;
}
default: {
throw new Error("Could not found a module for that command.");
}
}
};