feat: create threads on new bug reports
willow hai@wlo.moe
Sun, 25 May 2025 00:49:42 +0100
2 files changed,
20 insertions(+),
6 deletions(-)
M
src/database/schemas.ts
→
src/database/schemas.ts
@@ -30,6 +30,7 @@ title: z.string(),
description: z.string(), sent: z.boolean().default(false), message_id: z.string().optional(), + thread_id: z.string().optional(), }); export const mediaSchema = z.object({@@ -76,6 +77,7 @@ game: { type: String, enum: ["wft", "gw", "ab"], required: true },
description: { type: String, required: true }, sent: { type: Boolean, default: false }, message_id: String, + thread_id: String, }, { timestamps: true }, );
M
src/interactions/commands/bug.ts
→
src/interactions/commands/bug.ts
@@ -288,24 +288,36 @@ .setEmoji("🔒"),
new ButtonBuilder() .setCustomId(`bug:edit:${bugId}`) .setLabel("edit") - .setStyle(ButtonStyle.Primary) - .setEmoji("✏️"), + .setStyle(ButtonStyle.Primary), new ButtonBuilder() .setCustomId(`bug:delete:${bugId}`) .setLabel("delete") - .setStyle(ButtonStyle.Danger) - .setEmoji("🗑️"), + .setStyle(ButtonStyle.Danger), new ButtonBuilder() .setCustomId("bug:new") .setLabel("new bug") - .setStyle(ButtonStyle.Success) - .setEmoji("🐛"), + .setStyle(ButtonStyle.Success), ); const message = await channel.send({ embeds: [embed], components: [buttons], }); + + try { + const thread = await message.startThread({ + name: `#${bugId}: ${title.substring(0, 50)}${title.length > 50 ? "..." : ""}`, + reason: `bug report thread for bug #${bugId}`, + }); + + await thread.members.add(interaction.user.id); + await thread.send({ + content: `thread created for bug #${bugId}. use this space to discuss the bug report, provide additional details, or ask questions.`, + }); + + bug.thread_id = thread.id; + await bug.save(); + } catch (error) {} msgUrl = message.url;