From ad8b47d4ec8300398b16048430f933cdbf6aac5f Mon Sep 17 00:00:00 2001 From: artbiit Date: Fri, 10 Apr 2026 10:25:55 +0900 Subject: [PATCH] feat: add console output to logger and remove redundant deferReply in autorole command --- src/commands/autorole.ts | 1 - src/core/command.ts | 30 ++++++++++++++++++------------ src/utils/logger.ts | 9 ++++++++- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/commands/autorole.ts b/src/commands/autorole.ts index a987073..f86ef3d 100644 --- a/src/commands/autorole.ts +++ b/src/commands/autorole.ts @@ -29,7 +29,6 @@ class AutoRoleCommand extends Command { } protected override async handle(interaction: ChatInputCommandInteraction, locale: SupportedLocale) { - await interaction.deferReply({ ephemeral: true }); const guild = interaction.guild!; const dashboard = await generateAutoRoleDashboard(guild, locale); await interaction.editReply({ diff --git a/src/core/command.ts b/src/core/command.ts index 6c23527..407e50e 100644 --- a/src/core/command.ts +++ b/src/core/command.ts @@ -53,10 +53,12 @@ export async function ensureGuildPaidForTrait( const guildId = interaction.guildId; if (!guildId) { - await interaction.reply({ - content: '이 명령은 서버에서만 사용할 수 있습니다.', - ephemeral: true, - }); + const content = '이 명령은 서버에서만 사용할 수 있습니다.'; + if (interaction.deferred || interaction.replied) { + await interaction.editReply({ content }); + } else { + await interaction.reply({ content, ephemeral: true }); + } return false; } @@ -70,10 +72,12 @@ export async function ensureGuildPaidForTrait( const paid = ownership?.owner?.tier != null && ownership.owner.tier !== SubscriptionTier.FREE; if (!paid) { - await interaction.reply({ - content: '결제가 되지않았습니다', - ephemeral: true, - }); + const content = '결제가 되지않았습니다'; + if (interaction.deferred || interaction.replied) { + await interaction.editReply({ content }); + } else { + await interaction.reply({ content, ephemeral: true }); + } return false; } @@ -193,10 +197,12 @@ export abstract class Command { locale: SupportedLocale, ): Promise { if (this.guildOnly && !interaction.inGuild()) { - await interaction.reply({ - content: 'This command can only be used in a server.', - ephemeral: true, - }); + const content = 'This command can only be used in a server.'; + if (interaction.deferred || interaction.replied) { + await interaction.editReply({ content }); + } else { + await interaction.reply({ content, ephemeral: true }); + } return; } diff --git a/src/utils/logger.ts b/src/utils/logger.ts index ac21e7a..4e4e3cf 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -37,6 +37,13 @@ ensureLogDir(logDir); log4js.configure({ appenders: { + console: { + type: 'stdout', + layout: { + type: 'pattern', + pattern: '%[[%p]%] %m', + }, + }, file: { type: 'dateFile', filename: resolve(logDir, 'kord.log'), @@ -50,7 +57,7 @@ log4js.configure({ }, }, categories: { - default: { appenders: ['file'], level }, + default: { appenders: ['console', 'file'], level }, }, });