// events/interactionCreate.js const conn = require('../../../database/db'); // Ajusta o caminho module.exports = { name: 'interactionCreate', async execute(interaction, client) { if (interaction.isChatInputCommand()) { const command = client.commands.get(interaction.commandName); if (!command) return; try { await command.execute(interaction, client); } catch (error) { console.error(error); await interaction.reply({ content: '❌ Ocorreu um erro ao executar o comando.', ephemeral: true }); } } if (interaction.isAutocomplete()) { const focusedValue = interaction.options.getFocused(); if (interaction.commandName === 'wdd') { try { const [rows] = await conn.execute( 'SELECT nome FROM Choices WHERE nome LIKE ? LIMIT 25', [`%${focusedValue}%`] ); const suggestions = rows.map(row => ({ name: row.nome, value: row.nome, })); await interaction.respond(suggestions); } catch (err) { console.error('Erro ao buscar sugestões:', err); await interaction.respond([]); } } } }, };