diff --git a/discord-bot/commands/q.ts b/discord-bot/commands/q.ts index cc399be8a..afec1560f 100644 --- a/discord-bot/commands/q.ts +++ b/discord-bot/commands/q.ts @@ -91,13 +91,45 @@ const COMMAND_NAME = "q"; export const questionCommand: BotCommand = { name: COMMAND_NAME, - builder: new SlashCommandBuilder() - .setName(COMMAND_NAME) - .setDescription("wohoo"), + builder: addSubcommands( + new SlashCommandBuilder() + .setName(COMMAND_NAME) + .setDescription("Find a link") + ), execute: async ({ interaction }) => { return interaction.reply("Pong!"); }, }; + +function addSubcommands(builder: SlashCommandBuilder) { + for (const [key, value] of Object.entries(groupedLinks)) { + builder.addSubcommand((subcommand) => { + const result = subcommand + .setName(key) + .setDescription(`TODO: explanation for ${key} command`); + + if (typeof value !== "string") { + result.addStringOption((option) => + option + .setName("name") + .setDescription("TODO: subname desc") + .setRequired(true) + .addChoices( + ...Object.keys(value).map((key) => ({ + name: key.toUpperCase(), + value: key, + })) + ) + ); + } + + return result; + }); + } + + return builder; +} + // const questionCommand: BotCommand = { // name: "add", // description: "Gives you the specified role", diff --git a/discord-bot/types.ts b/discord-bot/types.ts index 376034914..eb3ce6ddb 100644 --- a/discord-bot/types.ts +++ b/discord-bot/types.ts @@ -1,4 +1,7 @@ -import type { SlashCommandBuilder } from "@discordjs/builders"; +import type { + SlashCommandBuilder, + SlashCommandSubcommandsOnlyBuilder, +} from "@discordjs/builders"; import type { CommandInteraction } from "discord.js"; export interface BotCommand { @@ -6,7 +9,7 @@ export interface BotCommand { // description: string; // /** ID's of guilds where this command will be set */ // guilds: string[]; - builder: SlashCommandBuilder; + builder: SlashCommandBuilder | SlashCommandSubcommandsOnlyBuilder; execute: (commandParameters: { interaction: CommandInteraction; }) => Promise;