import { type ButtonInteraction, type ChatInputCommandInteraction, type Client, type ModalSubmitInteraction, SlashCommandBuilder, } from "discord.js"; import { buildReportModal } from "./_shared"; import { handleCloseButton, handleDeleteButton, handleEditButton, handleOpenButton, handleTrelloButton, } from "./buttons"; import { handleEditModal, handleNewBugModal } from "./modals"; const commandData = new SlashCommandBuilder() .setName("bug") .setDescription("Make a bug report") .addSubcommand((subcommand) => subcommand.setName("report").setDescription("Report a new bug"), ) .addSubcommand((subcommand) => subcommand .setName("help") .setDescription("Help a user report a bug") .addUserOption((option) => option .setName("user") .setDescription("The user to send the button to") .setRequired(true), ), ); async function execute( _client: Client, interaction: ChatInputCommandInteraction, ) { if (!interaction.isChatInputCommand()) return; const subcommand = interaction.options.getSubcommand(); switch (subcommand) { case "report": await interaction.showModal(buildReportModal()); break; case "help": // await helpCommand.execute(client, interaction); break; default: await interaction.reply({ content: "❌ Unknown subcommand.", flags: ["Ephemeral"], }); } } async function buttonExecute(client: Client, interaction: ButtonInteraction) { const [, action] = interaction.customId.split(":"); switch (action) { case "close": await handleCloseButton(client, interaction); break; case "open": await handleOpenButton(client, interaction); break; case "edit": await handleEditButton(client, interaction); break; case "delete": await handleDeleteButton(client, interaction); break; case "trello": await handleTrelloButton(client, interaction); break; default: await interaction.reply({ content: "❌ Unknown button action.", flags: ["Ephemeral"], }); } } async function modalExecute( client: Client, interaction: ModalSubmitInteraction, ) { const [, action] = interaction.customId.split(":"); switch (action) { case "edit": await handleEditModal(client, interaction); break; case "report": await handleNewBugModal(client, interaction); break; default: await interaction.reply({ content: "❌ Unknown modal action.", flags: ["Ephemeral"], }); } } export default { data: commandData, buttonExecute, modalExecute, execute, };