feat: Add slash command ephemeral

This commit is contained in:
Siwoo Jeon 2024-10-01 15:17:25 +09:00
parent e0e82d44f8
commit 0c334c6bd1
Signed by: migan
GPG key ID: 036E9A8C5E8E48DA
3 changed files with 14 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{
"name": "muffinbot",
"version": "4.0.0-pudding.e241001a",
"version": "4.0.0-pudding.e241001b",
"main": "dist/index.js",
"private": true,
"dependencies": {

View file

@ -49,6 +49,8 @@ class DeleteLearnCommand extends Command {
user = ctx.user
}
const ephemeral =
ctx instanceof ChatInputCommandInteraction ? { ephemeral: true } : null
const CUSTOM_ID = 'maa$deleteLearn'
const options: SelectMenuComponentOptionData[] = []
const deleteDataList: string[] = []
@ -66,7 +68,10 @@ class DeleteLearnCommand extends Command {
})
if (!deleteDatas) {
return await ctx.reply('해당하는 걸 찾ㅈ을 수 없어요.')
return await ctx.reply({
...ephemeral,
content: '해당하는 걸 찾ㅈ을 수 없어요.',
})
}
for (let i = 1; i <= deleteDatas.length; i++) {
@ -79,6 +84,7 @@ class DeleteLearnCommand extends Command {
}
await ctx.reply({
...ephemeral,
embeds: [
{
title: '삭제',

View file

@ -19,6 +19,8 @@ class ListCommand extends Command {
private async _run(ctx: Message | ChatInputCommandInteraction) {
const user = ctx instanceof Message ? ctx.author : ctx.user
const ephemeral =
ctx instanceof ChatInputCommandInteraction ? { ephemeral: true } : null
const db = this.container.database
const data = await db.learn.findMany({
where: {
@ -28,7 +30,10 @@ class ListCommand extends Command {
const list: string[] = []
if (!data[0]) {
return await ctx.reply('당신ㄴ은 단어를 가르쳐준 기억이 없ㅅ는데요.')
return await ctx.reply({
...ephemeral,
content: '당신ㄴ은 단어를 가르쳐준 기억이 없ㅅ는데요.',
})
}
for (const listData of data) {