feat: Add deleteLearn's cancel

This commit is contained in:
Siwoo Jeon 2024-09-30 22:05:40 +09:00
parent ed782a7b96
commit 789bfba759
Signed by: migan
GPG key ID: 036E9A8C5E8E48DA
3 changed files with 22 additions and 3 deletions

View file

@ -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": {

View file

@ -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`,
},
],
},
],
},

View file

@ -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(),
},
],