From 84facc8e6fec1cc75cd3f94fe20537cfa58655f7 Mon Sep 17 00:00:00 2001 From: Siwoo Jeon Date: Fri, 4 Oct 2024 21:30:41 +0900 Subject: [PATCH] fix: If command or result's null, bot Can't send the message --- package.json | 2 +- src/Commands/learn.ts | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 5ead1fa..12a0e94 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "muffinbot", - "version": "4.0.0-pudding.d241004a", + "version": "4.0.0-pudding.d241004b", "main": "dist/index.js", "private": true, "dependencies": { diff --git a/src/Commands/learn.ts b/src/Commands/learn.ts index 467bcc2..3946505 100644 --- a/src/Commands/learn.ts +++ b/src/Commands/learn.ts @@ -45,32 +45,32 @@ class LearnCommand extends Command { const DI_MSG = '해당 단ㅇ어는 개발자님이 특별히 금지하였ㅇ어요.' const SUCCESS_MSG = '을/를 배웠ㅇ어요.' - let command: string - let result: string + let command: string | undefined + let result: string | undefined 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 { command = 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 aliases: string[] = []