import pingCommand from '../commands/ping.js'; import colorCommand from '../commands/color.js'; import roleIDCommand from '../commands/role_id.js' const commands = { ping: pingCommand, color: colorCommand, 'role-id': roleIDCommand, // 문자열로 키 작성 }; export default async function interactionCreateEvent(interaction) { if (!interaction.isChatInputCommand()) return; // 대괄호 표기법으로 명령어 찾기 const command = commands[interaction.commandName]; if (command) { try { await command.execute(interaction); } catch (error) { console.error(`Error executing ${interaction.commandName}:`, error); await interaction.reply({ content: '명령어 실행 중 오류가 발생했습니다!', ephemeral: true, }); } } else { await interaction.reply({ content: '알 수 없는 명령어입니다!', ephemeral: true, }); } }