From 3d54eff654cbdafa591074d70fdf0a43651c338d Mon Sep 17 00:00:00 2001 From: seeyebe Date: Mon, 2 Jun 2025 04:43:45 +0300 Subject: [PATCH] Replace text confirmation with button-based confirmation in delete case command --- .../commands/deletecase/actualDeleteCaseCmd.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/backend/src/plugins/ModActions/commands/deletecase/actualDeleteCaseCmd.ts b/backend/src/plugins/ModActions/commands/deletecase/actualDeleteCaseCmd.ts index 6d01afa9..dc494c54 100644 --- a/backend/src/plugins/ModActions/commands/deletecase/actualDeleteCaseCmd.ts +++ b/backend/src/plugins/ModActions/commands/deletecase/actualDeleteCaseCmd.ts @@ -1,8 +1,8 @@ import { ChatInputCommandInteraction, GuildMember, Message } from "discord.js"; -import { GuildPluginData, helpers } from "knub"; +import { GuildPluginData } from "knub"; import { Case } from "../../../../data/entities/Case.js"; -import { getContextChannel, sendContextResponse } from "../../../../pluginUtils.js"; -import { SECONDS, renderUsername } from "../../../../utils.js"; +import { getContextChannel } from "../../../../pluginUtils.js"; +import { confirm, renderUsername } from "../../../../utils.js"; import { CasesPlugin } from "../../../Cases/CasesPlugin.js"; import { LogsPlugin } from "../../../Logs/LogsPlugin.js"; import { TimeAndDatePlugin } from "../../../TimeAndDate/TimeAndDatePlugin.js"; @@ -43,15 +43,13 @@ export async function actualDeleteCaseCmd( const cases = pluginData.getPlugin(CasesPlugin); const embedContent = await cases.getCaseEmbed(theCase); - sendContextResponse(context, { + + const confirmed = await confirm(context, author.id, { ...embedContent, - content: "Delete the following case? Answer 'Yes' to continue, 'No' to cancel.", + content: "Delete the following case?", }); - const reply = await helpers.waitForReply(pluginData.client, channel, author.id, 15 * SECONDS); - const normalizedReply = (reply?.content || "").toLowerCase().trim(); - if (normalizedReply !== "yes" && normalizedReply !== "y") { - sendContextResponse(context, "Cancelled. Case was not deleted."); + if (!confirmed) { cancelled++; continue; }