feat: add 'add to trello' button to bug reports
willow hai@wlo.moe
Wed, 28 May 2025 00:01:43 +0100
2 files changed,
23 insertions(+),
1 deletions(-)
M
src/config.ts
→
src/config.ts
@@ -24,6 +24,7 @@ const schema = z.object({
discord: discordSchema, mongodb: mongodbSchema, projects: projectSchema, + trelloBoardId: z.string().optional(), }); function validateConfig() {
M
src/interactions/commands/bug/report.ts
→
src/interactions/commands/bug/report.ts
@@ -1,3 +1,4 @@
+import config from "@/config.ts"; import { ActionRowBuilder, ButtonBuilder,@@ -181,6 +182,17 @@ .setTimestamp();
if (projectInfo.iconURL) embed.setThumbnail(projectInfo.iconURL); + const trelloUrlParts = [ + "https://trello.com/addCard?name=", + encodeURIComponent(title), + "&url=", + encodeURIComponent( + interaction.message?.url || "https://example.com", + ), + "&idBoard=", + config.data?.trelloBoardId || "", + ]; + const buttons = new ActionRowBuilder<ButtonBuilder>().addComponents( new ButtonBuilder() .setCustomId(`bug:close:${bugId}`)@@ -196,6 +208,10 @@ .setCustomId(`bug:delete:${bugId}`)
.setLabel("delete") .setStyle(ButtonStyle.Danger), new ButtonBuilder() + .setStyle(ButtonStyle.Link) + .setLabel("add to trello") + .setURL(trelloUrlParts.join("")), + new ButtonBuilder() .setCustomId("bug:new") .setLabel("new bug") .setStyle(ButtonStyle.Success),@@ -214,7 +230,12 @@ });
await thread.members.add(interaction.user.id); await thread.send({ - content: `thread created for bug #${bugId} affecting ${projectInfo.displayName}. use this space to discuss the bug report, provide additional details, or ask questions.`, + content: + `thread created for bug #${bugId} affecting ${projectInfo.displayName}. + use this space to discuss the bug report, provide additional + details, or ask questions.` + .replace(/\s+/g, " ") + .trim(), }); bug.thread_id = thread.id;