wip: add button row to bug messaegs
willow hai@wlo.moe
Sun, 09 Nov 2025 17:20:09 +0000
4 files changed,
333 insertions(+),
18 deletions(-)
M
src/interactions/commands/bug/index.ts
→
src/interactions/commands/bug/index.ts
@@ -1,7 +1,18 @@
import config from "@/config.ts"; import type { ICommand } from "@/types.ts"; -import { type ApplicationCommandData, SlashCommandBuilder } from "discord.js"; +import { + type ApplicationCommandData, + type ButtonInteraction, + type Client, + SlashCommandBuilder, +} from "discord.js"; import { buttonCommand } from "./button.ts"; +import { + handleCloseButton, + handleDeleteButton, + handleEditButton, + handleOpenButton, +} from "./buttons.ts"; import { reportCommand } from "./report.ts"; const commandData = new SlashCommandBuilder()@@ -22,6 +33,30 @@ .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) => {@@ -44,6 +79,5 @@ });
} }, modalExecute: reportCommand.modalExecute, - // buttonExecute: reportCommand.buttonExecute, - // selectMenuExecute: reportCommand.selectMenuExecute, + buttonExecute, } satisfies ICommand;
M
src/interactions/commands/bug/report.ts
→
src/interactions/commands/bug/report.ts
@@ -28,6 +28,8 @@ TextInputBuilder,
TextInputStyle, ThumbnailBuilder, } from "discord.js"; + +import { buildButtonRow } from "./buttons.ts"; import { PROJECT_MAP, logger as lily } from "./shared.ts"; const logger = lily.child("report");@@ -63,15 +65,6 @@ totalSize: number;
} // utils -function buildTrelloUrl(title: string, url: string): string { - const params = new URLSearchParams({ - name: title, - url: url, - idBoard: config.data?.trelloBoardId || "", - }); - return `https://trello.com/addCard?${params.toString()}`; -} - function formatFileSize(bytes: number): string { return `${(bytes / (1024 * 1024)).toFixed(2)} MB`; }@@ -153,7 +146,7 @@ : { label: project.displayName, value: key },
) as ProjectChoice<T>[]; } -// Modal builders +// modal builders function buildReportModal(): ModalBuilder { const terminology = config.data.terminology; const capitalizedTerminology =@@ -210,7 +203,7 @@ .setTitle("Report a Bug")
.setLabelComponents(gameLabel, titleLabel, descriptionLabel, mediaLabel); } -// Validation +// validation async function validateGuildSetup(interaction: ModalSubmitInteraction) { if (!interaction.guild) { throw new Error("This command can only be used in a server.");@@ -413,12 +406,17 @@ "Use this space to discuss the bug, provide additional details, or ask questions.",
}); await thread.members.add(interaction.user.id); - // Update bug with message and thread IDs + // update bug with message and thread IDs, add buttons bug.message_id = message.id; bug.thread_id = thread.id; await bug.save(); - // Final success message + const buttonRow = buildButtonRow(bugId, message.url, title, false); + await message.edit({ + components: [container, buttonRow], + }); + + // final success message await interaction.editReply({ content: `✅ Bug report #${bugId} has been submitted successfully! Check <#${channel.id}> for your report.`, });
M
src/utils/permissions.ts
→
src/utils/permissions.ts
@@ -1,8 +1,8 @@
-import type { APIGuildMember, GuildMember } from "discord.js"; +import type { GuildMember } from "discord.js"; import { GuildModel } from "../database/schemas.ts"; export async function hasManagerPermissions( - member: GuildMember | APIGuildMember, + member: GuildMember, ): Promise<boolean> { if ( member.permissions.has("ManageGuild") ||