src/interactions/commands/bug/index.ts (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
import type { ICommand } from "@/types.ts";
import {
type ApplicationCommandData,
type ButtonInteraction,
type Client,
SlashCommandBuilder,
} from "discord.js";
import {
handleCloseButton,
handleDeleteButton,
handleEditButton,
handleOpenButton,
} from "./buttons.ts";
import { helpCommand } from "./help.ts";
import { reportCommand } from "./report.ts";
const commandData = new SlashCommandBuilder()
.setName("bug")
.setDescription("bug report management")
.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 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;
default:
await interaction.reply({
content: "❌ Unknown button action.",
flags: ["Ephemeral"],
});
}
}
export default {
data: commandData.toJSON() as ApplicationCommandData,
execute: async (client, interaction) => {
if (!interaction.isChatInputCommand()) return;
const subcommand = interaction.options.getSubcommand();
switch (subcommand) {
case "report":
await reportCommand.execute(client, interaction);
break;
case "button":
await helpCommand.execute(client, interaction);
break;
default:
await interaction.reply({
content: "❌ unknown subcommand.",
flags: ["Ephemeral"],
});
}
},
modalExecute: reportCommand.modalExecute,
buttonExecute,
} satisfies ICommand;
|