From 789bfba759092886d6337f0e704401c0a00a4b2c Mon Sep 17 00:00:00 2001 From: Siwoo Jeon Date: Mon, 30 Sep 2024 22:05:40 +0900 Subject: [PATCH] feat: Add deleteLearn's cancel --- package.json | 2 +- src/Commands/deleteLearn.ts | 9 ++++++++- src/interaction-handlers/deleteLearn.ts | 14 +++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 095572e..773043f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "muffinbot", - "version": "3.1.0-cake.r240928a", + "version": "3.2.0-cake.r240930a", "main": "dist/index.js", "private": true, "dependencies": { diff --git a/src/Commands/deleteLearn.ts b/src/Commands/deleteLearn.ts index 3318e44..2037bd3 100644 --- a/src/Commands/deleteLearn.ts +++ b/src/Commands/deleteLearn.ts @@ -69,7 +69,14 @@ class DeleteLearnCommand extends Command { type: ComponentType.StringSelect, customId: `${CUSTOM_ID}@${msg.author.id}`, placeholder: '지울 데이터를 선택해ㅈ주세요', - options, + options: [ + ...options, + { + label: '❌ 취소', + description: '아무것도 삭제하지 않아요.', + value: `${CUSTOM_ID}-cancel`, + }, + ], }, ], }, diff --git a/src/interaction-handlers/deleteLearn.ts b/src/interaction-handlers/deleteLearn.ts index a0c42f8..49efc52 100644 --- a/src/interaction-handlers/deleteLearn.ts +++ b/src/interaction-handlers/deleteLearn.ts @@ -32,6 +32,18 @@ class DeleteLearnHandler extends InteractionHandler { const db = this.container.database const decimalRegexp = /^[0-9]/g + if (id === 'cancel') + return interaction.editReply({ + embeds: [ + { + title: '삭제', + description: '아무것도 삭제하지 않았어요.', + color: 0x00ff00, + }, + ], + components: [], + }) + const itemId = interaction.component.options.map(item => item.value.endsWith(id) ? item.label.match(decimalRegexp)![0] : null, ) @@ -42,7 +54,7 @@ class DeleteLearnHandler extends InteractionHandler { embeds: [ { title: '삭제', - description: `${Number(itemId!)}번을 정상적으로 삭제하ㅇ였어요.`, + description: `${Number(itemId[0]!)}번을 정상적으로 삭제하ㅇ였어요.`, timestamp: new Date().toISOString(), }, ],