Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Changed

- 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))
- Migrated all bot responses from embeds to Discord Components V2 containers ([#45](https://github.com/open-devhub/quillbot/issues/45))

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

Expand Down
147 changes: 93 additions & 54 deletions src/commands/!misc/resolve.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { EmbedBuilder } from "discord.js";
import { MessageFlags } from "discord.js";
import { getEntry, removeEntry } from "../../firestore/support.ts";
import type { CommandCallbackOpts } from "../../types/command.ts";
import type { Log } from "../../types/log.ts";
import type { SupportDoc } from "../../types/support.ts";
import { buildComponents } from "../../utils/components/buildComponents.ts";
import { buildErrorComponent } from "../../utils/components/buildError.ts";
import { log } from "../../utils/discord/log.ts";

export default {
Expand All @@ -13,83 +15,120 @@ export default {
async callback({ message, args }: CommandCallbackOpts) {
try {
if (!args[0]) {
return message.reply("Please provide a report ID to resolve.");
return message.reply({
flags: MessageFlags.IsComponentsV2,
components: buildErrorComponent({
title: "❌ Missing Report ID",
description: "Please provide a report ID to resolve.",
}),
});
}
const report = (await getEntry(args[0])) as SupportDoc | null;

const reportId = args[0];
const report = (await getEntry(reportId)) as SupportDoc | null;

if (!report) {
return message.reply("No report found with that ID.");
return message.reply({
flags: MessageFlags.IsComponentsV2,
components: buildErrorComponent({
title: "❌ Report Not Found",
description: "No report found with that ID.",
}),
});
}
const reportId = args[0];

await removeEntry(reportId);

const type = report.type;
const isBug = type === "report";
const title = isBug ? "✅ Bug Fixed" : "✅ Suggestion Applied";
const label = isBug ? "Report" : "Request";

const reportEmbed = new EmbedBuilder()
.setTitle(type === "report" ? "✅ Bug Fixed" : "✅ Suggestion Applied")
.setDescription(
`Your ${type === "report" ? "bug report" : "feature request"} has been resolved:\n\`\`\`${report.description.slice(0, 2000)}\`\`\`\nThank you for your contribution!`,
)
.addFields(
{
name: `${type === "report" ? "Report" : "Request"} ID`,
value: `\`${reportId}\``,
},
{
name: "Resolved by",
value: `${message.author.tag} (${message.author.id})`,
},
)
.setColor(0x2ecc71)
.setTimestamp();
const userComponents = buildComponents([
{
type: "container",
accentColor: 0x2ecc71,
components: [
{ type: "text", content: `### ${title}` },
{
type: "text",
content: `Your ${isBug ? "bug report" : "feature request"} has been resolved:\n\`\`\`${report.description.slice(0, 2000)}\`\`\`\nThank you for your contribution!`,
},
{ type: "separator", spacing: "small", divider: false },
{
type: "text",
content: [
`**${label} ID**: \`${reportId}\``,
`**Resolved by**: ${message.author.tag}`,
].join("\n"),
},
],
},
]);

// dm the user who submitted the report
const user = await message.client.users.fetch(report.user.id);
if (user) {
await user.send({
embeds: [reportEmbed],
});
// DM the user who submitted the report
try {
const user = await message.client.users.fetch(report.user.id);
if (user) {
await user.send({
flags: MessageFlags.IsComponentsV2,
components: userComponents,
});
}
} catch {
// User may have DMs closed
}

const logContent = {
title:
type === "report"
? "🐛 Bug Report Resolved"
: "💻 Feature Request Resolved",
log({
title: isBug ? "🐛 Bug Report Resolved" : "💻 Feature Request Resolved",
description: `\`\`\`${report.description.slice(0, 2000)}\`\`\``,
fields: [
{
name: `${type === "report" ? "Report" : "Request"} ID`,
value: `\`${reportId}\``,
},
{ name: `${label} ID`, value: `\`${reportId}\`` },
{
name: "Resolved by",
value: `${message.author.tag} (${message.author.id})`,
},
],
thumbnail: user?.displayAvatarURL({ size: 256 }),
color: 0x2ecc71,
timestamp: true,
};

log(logContent as Log);
} as Log);

return message.reply({
embeds: [
new EmbedBuilder()
.setTitle(logContent.title)
.setDescription(
"The support report has been resolved successfully.",
)
.setFields(logContent.fields)
.setColor(logContent.color)
.setTimestamp(),
],
flags: MessageFlags.IsComponentsV2,
components: buildComponents([
{
type: "container",
accentColor: 0x2ecc71,
components: [
{
type: "text",
content: `### ${isBug ? "🐛 Bug Report Resolved" : "💻 Feature Request Resolved"}`,
},
{
type: "text",
content: "The support report has been resolved successfully.",
},
{ type: "separator", spacing: "small", divider: false },
{
type: "text",
content: [
`**${label} ID**: \`${reportId}\``,
`**Resolved by**: ${message.author.tag}`,
].join("\n"),
},
],
},
]),
});
} catch (err) {
console.error("Error resolving support report:", err);
return message.reply(
"An error occurred while resolving the support report.",
);
return message.reply({
flags: MessageFlags.IsComponentsV2,
components: buildErrorComponent({
title: "❌ Error Resolving Report",
description: "An error occurred while resolving the support report.",
}),
});
}
},
};
Loading
Loading