치명적인 이슈 해결 #6
3 changed files with 16 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "muffinbot",
|
"name": "muffinbot",
|
||||||
"version": "3.0.1-cake.r240815b",
|
"version": "3.0.2-cake.r240924a",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import { type LearnData } from '../modules'
|
||||||
})
|
})
|
||||||
class DeleteLearnCommand extends Command {
|
class DeleteLearnCommand extends Command {
|
||||||
public async messageRun(msg: Message, args: Args) {
|
public async messageRun(msg: Message, args: Args) {
|
||||||
|
const CUSTOM_ID = 'maa$deleteLearn'
|
||||||
const command = await args.rest('string').catch(() => null)
|
const command = await args.rest('string').catch(() => null)
|
||||||
const options: SelectMenuComponentOptionData[] = []
|
const options: SelectMenuComponentOptionData[] = []
|
||||||
const db = this.container.database
|
const db = this.container.database
|
||||||
|
@ -46,7 +47,7 @@ class DeleteLearnCommand extends Command {
|
||||||
console.log(data)
|
console.log(data)
|
||||||
options.push({
|
options.push({
|
||||||
label: `${data.id}번`,
|
label: `${data.id}번`,
|
||||||
value: `maa$deleteLearn-${data.id}`,
|
value: `${CUSTOM_ID}-${data.id}`,
|
||||||
description: data.result.slice(0, 100),
|
description: data.result.slice(0, 100),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -68,7 +69,7 @@ class DeleteLearnCommand extends Command {
|
||||||
components: [
|
components: [
|
||||||
{
|
{
|
||||||
type: ComponentType.StringSelect,
|
type: ComponentType.StringSelect,
|
||||||
customId: 'maa$deleteLearn',
|
customId: `${CUSTOM_ID}@${msg.author.id}`,
|
||||||
placeholder: '지울 데이터를 선택해ㅈ주세요',
|
placeholder: '지울 데이터를 선택해ㅈ주세요',
|
||||||
options,
|
options,
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,15 +10,25 @@ import { ApplyOptions } from '@sapphire/decorators'
|
||||||
interactionHandlerType: InteractionHandlerTypes.SelectMenu,
|
interactionHandlerType: InteractionHandlerTypes.SelectMenu,
|
||||||
})
|
})
|
||||||
class DeleteLearnHandler extends InteractionHandler {
|
class DeleteLearnHandler extends InteractionHandler {
|
||||||
|
private readonly _CUSTOM_ID = 'maa$deleteLearn'
|
||||||
|
|
||||||
public async parse(interaction: StringSelectMenuInteraction) {
|
public async parse(interaction: StringSelectMenuInteraction) {
|
||||||
if (interaction.customId !== 'maa$deleteLearn') return this.none()
|
if (!interaction.customId.startsWith(this._CUSTOM_ID)) return this.none()
|
||||||
|
const userId = interaction.customId.slice(`${this._CUSTOM_ID}@`.length)
|
||||||
|
if (interaction.user.id !== userId) {
|
||||||
|
await interaction.reply({
|
||||||
|
ephemeral: true,
|
||||||
|
content: '당신은 이 지ㅅ식을 안 가르쳐 주셨어요.',
|
||||||
|
})
|
||||||
|
return this.none()
|
||||||
|
}
|
||||||
return this.some()
|
return this.some()
|
||||||
}
|
}
|
||||||
|
|
||||||
public async run(interaction: StringSelectMenuInteraction) {
|
public async run(interaction: StringSelectMenuInteraction) {
|
||||||
await interaction.deferUpdate()
|
await interaction.deferUpdate()
|
||||||
|
|
||||||
const id = interaction.values[0].slice('maa$deleteLearn-'.length)
|
const id = interaction.values[0].slice(`${this._CUSTOM_ID}-`.length)
|
||||||
const db = this.container.database
|
const db = this.container.database
|
||||||
|
|
||||||
await db.learn.delete(id)
|
await db.learn.delete(id)
|
||||||
|
|
Loading…
Reference in a new issue