fix: If command or result's null, bot Can't send the message

This commit is contained in:
Siwoo Jeon 2024-10-04 21:30:41 +09:00
parent cc3c627683
commit 84facc8e6f
Signed by: migan
GPG key ID: 036E9A8C5E8E48DA
2 changed files with 14 additions and 14 deletions

View file

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

View file

@ -45,32 +45,32 @@ class LearnCommand extends Command {
const DI_MSG = '해당 단ㅇ어는 개발자님이 특별히 금지하였ㅇ어요.' const DI_MSG = '해당 단ㅇ어는 개발자님이 특별히 금지하였ㅇ어요.'
const SUCCESS_MSG = '을/를 배웠ㅇ어요.' const SUCCESS_MSG = '을/를 배웠ㅇ어요.'
let command: string let command: string | undefined
let result: string let result: string | undefined
if (ctx instanceof Message) { if (ctx instanceof Message) {
command = (await args!.pick('string').catch(() => null))!.replaceAll( command = (await args?.pick('string').catch(() => null))?.replaceAll(
'_', '_',
' ', ' ',
) )
result = (await args!.pick('string').catch(() => null))!.replaceAll( result = (await args?.pick('string').catch(() => null))?.replaceAll(
'_', '_',
' ', ' ',
) )
if (!command || !result)
return await ctx.reply(
codeBlock(
'md',
`사용법: ${this.detailedDescription}
예시: ${this.detailedDescription.examples?.map(example => example).join('\n')}`,
),
)
} else { } else {
command = ctx.options.getString('단어', true) command = ctx.options.getString('단어', true)
result = ctx.options.getString('대답', true) result = ctx.options.getString('대답', true)
} }
if (!command || !result)
return await ctx.reply(
codeBlock(
'md',
`사용법: ${this.detailedDescription.usage}\n` +
`예시: ${this.detailedDescription.examples?.map(example => example).join('\n')}`,
),
)
const commands: string[] = [] const commands: string[] = []
const aliases: string[] = [] const aliases: string[] = []