feat: Add ephemeral in learn command

This commit is contained in:
Siwoo Jeon 2025-03-02 15:53:46 +09:00
parent adba4ed48e
commit c5211c06d4
Signed by: migan
GPG key ID: 036E9A8C5E8E48DA
2 changed files with 13 additions and 8 deletions

View file

@ -1,7 +1,12 @@
import { Learn } from '../lib/databases' import { Learn } from '../lib/databases'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
import { Args, Command } from '@sapphire/framework' import { Args, Command } from '@sapphire/framework'
import { ChatInputCommandInteraction, EmbedBuilder, Message } from 'discord.js' import {
ChatInputCommandInteraction,
EmbedBuilder,
Message,
MessageFlags,
} from 'discord.js'
import { josa } from 'es-hangul' import { josa } from 'es-hangul'
@ApplyOptions<Command.Options>({ @ApplyOptions<Command.Options>({
@ -57,12 +62,7 @@ export default class LearnCommand extends Command {
let result: string | undefined let result: string | undefined
if (typeof this.detailedDescription === 'string') return if (typeof this.detailedDescription === 'string') return
if (ctx instanceof ChatInputCommandInteraction) { if (ctx instanceof Message) {
await ctx.deferReply()
command = ctx.options.getString('단어', true)
result = ctx.options.getString('대답', true)
} else {
if (!args) return if (!args) return
command = (await args.pick('string').catch(() => undefined))?.replaceAll( command = (await args.pick('string').catch(() => undefined))?.replaceAll(
'_', '_',
@ -72,6 +72,11 @@ export default class LearnCommand extends Command {
'_', '_',
' ', ' ',
) )
} else {
await ctx.deferReply({ flags: MessageFlags.Ephemeral })
command = ctx.options.getString('단어', true)
result = ctx.options.getString('대답', true)
} }
if (!command || !result) if (!command || !result)

View file

@ -26,7 +26,7 @@ declare module '@sapphire/framework' {
container.dbDisconnect = async () => await disconnect() container.dbDisconnect = async () => await disconnect()
container.config = new Config() container.config = new Config()
container.prefix = container.config.bot.prefix container.prefix = container.config.bot.prefix
container.version = '5.0.0-newMuffin.e250301a' container.version = '5.0.0-newMuffin.e250302a'
container.embedColors = { container.embedColors = {
default: 0xaddb87, default: 0xaddb87,
fail: 0xff0000, fail: 0xff0000,