diff --git a/src/classes/Handler.ts b/src/classes/Handler.ts index 8f338e3..9cda38f 100644 --- a/src/classes/Handler.ts +++ b/src/classes/Handler.ts @@ -2,6 +2,7 @@ import { ChatInputCommandInteraction, Collection } from "discord.js"; import { readdirSync } from "node:fs"; import { Command } from "../types/Command"; import { COMMAND_PATH, COMMANDS_PATH } from "../utils/Config"; +import { Logger } from "../utils/Logger"; export class Handler { public commands: Collection = new Collection(); @@ -28,6 +29,9 @@ export class Handler { const command = this.commands.get(commandName); if (!command) return; - if (command.slashRun) command.slashRun(interaction); + if (!command.slashRun) return; + Promise.resolve(command.slashRun(interaction)).catch((err) => { + Logger.error(`[명령어] /${commandName} 실행 오류: ${String(err)}`); + }); } } \ No newline at end of file diff --git a/src/commands/signature.ts b/src/commands/signature.ts index 44ff7da..1e23e27 100644 --- a/src/commands/signature.ts +++ b/src/commands/signature.ts @@ -25,7 +25,7 @@ export default class implements Command { if (message.channel?.type !== ChannelType.GuildText) return; return await message.channel.send({ embeds: [ client.mkembed({ title: "시그니처 사이트", - url: "https:sig.tkrmagid.kr", + url: "https://sig.tkrmagid.kr", }) ] }).then(m => client.msgDelete(m, 5)); } } \ No newline at end of file diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 1ca11c4..2a2963f 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -31,7 +31,11 @@ export const messageCreate = async (message: Message): Promise => { cmdErr(message, commandName); return client.msgDelete(message, 0, true); } - command.messageRun(message, args); + // messageRun은 async라 여기 try/catch로 잡히지 않는다. 거부된 promise가 + // unhandled rejection으로 프로세스 전체를 죽이지 않도록 따로 처리한다. + Promise.resolve(command.messageRun(message, args)).catch((err) => { + Logger.error(`[명령어] ${commandName} 실행 오류: ${String(err)}`); + }); client.msgDelete(message, 0, true); } catch(err: any) { if (Config.debug) Logger.error(err);