Skip to content

Commit b99dca5

Browse files
authored
Merge pull request #47 from calebephrem/main
refactor!: migrate all bot responses from embeds to discord component v2 containers
2 parents 2225714 + 886f862 commit b99dca5

36 files changed

Lines changed: 2586 additions & 1439 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Changed
66

77
- Replaced the previous score/regex-based estimator with a dedicated `analyzeComplexity` utility that properly tracks loop nesting depth, classifies recursion (linear / logarithmic / exponential / factorial / memoized), and produces structured indicators + reasoning. ([#41](https://github.com/open-devhub/quillbot/issues/41))
8+
- Migrated all bot responses from embeds to Discord Components V2 containers ([#45](https://github.com/open-devhub/quillbot/issues/45))
89

910
## `v1.1.1` - 2026-07-13
1011

src/commands/!misc/resolve.ts

Lines changed: 93 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { EmbedBuilder } from "discord.js";
1+
import { MessageFlags } from "discord.js";
22
import { getEntry, removeEntry } from "../../firestore/support.ts";
33
import type { CommandCallbackOpts } from "../../types/command.ts";
44
import type { Log } from "../../types/log.ts";
55
import type { SupportDoc } from "../../types/support.ts";
6+
import { buildComponents } from "../../utils/components/buildComponents.ts";
7+
import { buildErrorComponent } from "../../utils/components/buildError.ts";
68
import { log } from "../../utils/discord/log.ts";
79

810
export default {
@@ -13,83 +15,120 @@ export default {
1315
async callback({ message, args }: CommandCallbackOpts) {
1416
try {
1517
if (!args[0]) {
16-
return message.reply("Please provide a report ID to resolve.");
18+
return message.reply({
19+
flags: MessageFlags.IsComponentsV2,
20+
components: buildErrorComponent({
21+
title: "❌ Missing Report ID",
22+
description: "Please provide a report ID to resolve.",
23+
}),
24+
});
1725
}
18-
const report = (await getEntry(args[0])) as SupportDoc | null;
26+
27+
const reportId = args[0];
28+
const report = (await getEntry(reportId)) as SupportDoc | null;
29+
1930
if (!report) {
20-
return message.reply("No report found with that ID.");
31+
return message.reply({
32+
flags: MessageFlags.IsComponentsV2,
33+
components: buildErrorComponent({
34+
title: "❌ Report Not Found",
35+
description: "No report found with that ID.",
36+
}),
37+
});
2138
}
22-
const reportId = args[0];
39+
2340
await removeEntry(reportId);
2441

2542
const type = report.type;
43+
const isBug = type === "report";
44+
const title = isBug ? "✅ Bug Fixed" : "✅ Suggestion Applied";
45+
const label = isBug ? "Report" : "Request";
2646

27-
const reportEmbed = new EmbedBuilder()
28-
.setTitle(type === "report" ? "✅ Bug Fixed" : "✅ Suggestion Applied")
29-
.setDescription(
30-
`Your ${type === "report" ? "bug report" : "feature request"} has been resolved:\n\`\`\`${report.description.slice(0, 2000)}\`\`\`\nThank you for your contribution!`,
31-
)
32-
.addFields(
33-
{
34-
name: `${type === "report" ? "Report" : "Request"} ID`,
35-
value: `\`${reportId}\``,
36-
},
37-
{
38-
name: "Resolved by",
39-
value: `${message.author.tag} (${message.author.id})`,
40-
},
41-
)
42-
.setColor(0x2ecc71)
43-
.setTimestamp();
47+
const userComponents = buildComponents([
48+
{
49+
type: "container",
50+
accentColor: 0x2ecc71,
51+
components: [
52+
{ type: "text", content: `### ${title}` },
53+
{
54+
type: "text",
55+
content: `Your ${isBug ? "bug report" : "feature request"} has been resolved:\n\`\`\`${report.description.slice(0, 2000)}\`\`\`\nThank you for your contribution!`,
56+
},
57+
{ type: "separator", spacing: "small", divider: false },
58+
{
59+
type: "text",
60+
content: [
61+
`**${label} ID**: \`${reportId}\``,
62+
`**Resolved by**: ${message.author.tag}`,
63+
].join("\n"),
64+
},
65+
],
66+
},
67+
]);
4468

45-
// dm the user who submitted the report
46-
const user = await message.client.users.fetch(report.user.id);
47-
if (user) {
48-
await user.send({
49-
embeds: [reportEmbed],
50-
});
69+
// DM the user who submitted the report
70+
try {
71+
const user = await message.client.users.fetch(report.user.id);
72+
if (user) {
73+
await user.send({
74+
flags: MessageFlags.IsComponentsV2,
75+
components: userComponents,
76+
});
77+
}
78+
} catch {
79+
// User may have DMs closed
5180
}
5281

53-
const logContent = {
54-
title:
55-
type === "report"
56-
? "🐛 Bug Report Resolved"
57-
: "💻 Feature Request Resolved",
82+
log({
83+
title: isBug ? "🐛 Bug Report Resolved" : "💻 Feature Request Resolved",
5884
description: `\`\`\`${report.description.slice(0, 2000)}\`\`\``,
5985
fields: [
60-
{
61-
name: `${type === "report" ? "Report" : "Request"} ID`,
62-
value: `\`${reportId}\``,
63-
},
86+
{ name: `${label} ID`, value: `\`${reportId}\`` },
6487
{
6588
name: "Resolved by",
6689
value: `${message.author.tag} (${message.author.id})`,
6790
},
6891
],
69-
thumbnail: user?.displayAvatarURL({ size: 256 }),
7092
color: 0x2ecc71,
7193
timestamp: true,
72-
};
73-
74-
log(logContent as Log);
94+
} as Log);
7595

7696
return message.reply({
77-
embeds: [
78-
new EmbedBuilder()
79-
.setTitle(logContent.title)
80-
.setDescription(
81-
"The support report has been resolved successfully.",
82-
)
83-
.setFields(logContent.fields)
84-
.setColor(logContent.color)
85-
.setTimestamp(),
86-
],
97+
flags: MessageFlags.IsComponentsV2,
98+
components: buildComponents([
99+
{
100+
type: "container",
101+
accentColor: 0x2ecc71,
102+
components: [
103+
{
104+
type: "text",
105+
content: `### ${isBug ? "🐛 Bug Report Resolved" : "💻 Feature Request Resolved"}`,
106+
},
107+
{
108+
type: "text",
109+
content: "The support report has been resolved successfully.",
110+
},
111+
{ type: "separator", spacing: "small", divider: false },
112+
{
113+
type: "text",
114+
content: [
115+
`**${label} ID**: \`${reportId}\``,
116+
`**Resolved by**: ${message.author.tag}`,
117+
].join("\n"),
118+
},
119+
],
120+
},
121+
]),
87122
});
88123
} catch (err) {
89124
console.error("Error resolving support report:", err);
90-
return message.reply(
91-
"An error occurred while resolving the support report.",
92-
);
125+
return message.reply({
126+
flags: MessageFlags.IsComponentsV2,
127+
components: buildErrorComponent({
128+
title: "❌ Error Resolving Report",
129+
description: "An error occurred while resolving the support report.",
130+
}),
131+
});
93132
}
94133
},
95134
};

0 commit comments

Comments
 (0)