From affe3ba1eba35b5e9047a0b440edd61dca540f79 Mon Sep 17 00:00:00 2001 From: Bxio Date: Sat, 5 Apr 2025 11:22:52 +0100 Subject: [PATCH] --- src/commands/Community/testeadd.js | 13 +------------ src/events/handlers/teste.js | 14 +++++++++----- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/commands/Community/testeadd.js b/src/commands/Community/testeadd.js index 9b790ad..a65e763 100644 --- a/src/commands/Community/testeadd.js +++ b/src/commands/Community/testeadd.js @@ -18,18 +18,7 @@ module.exports = { { name: 'Mike', value: '1' }, { name: 'Totem', value: '3' } ) - ) - .addStringOption(option => - option.setName('tipo_sanguinio1') - .setDescription('Escolha uma opção do banco de dados') - .setRequired(true) - .addChoices( - { name: 'Bxio', value: '0' }, - { name: 'TeixLo', value: '0' }, - { name: 'Mike', value: '1' }, - { name: 'Totem', value: '3' } - ) - ), + ) async execute(interaction, client) { const guildId = interaction.guild.id; diff --git a/src/events/handlers/teste.js b/src/events/handlers/teste.js index bf03416..0848ca0 100644 --- a/src/events/handlers/teste.js +++ b/src/events/handlers/teste.js @@ -7,22 +7,26 @@ module.exports = { if (interaction.isChatInputCommand()) { const command = client.commands.get(interaction.commandName); if (!command) return; - await command.execute(interaction, client); + try { + await command.execute(interaction, client); + } catch (error) { + console.error(error); + await interaction.reply({ content: '❌ Ocorreu um erro ao executar o comando.', ephemeral: true }); + } } - // AUTOCOMPLETE if (interaction.isAutocomplete()) { const focusedValue = interaction.options.getFocused(); - if (interaction.commandName === 'add' && interaction.options.getSubcommand(false) === null) { + if (interaction.commandName === 'add') { try { const [rows] = await conn.execute( - 'SELECT nome FROM choices WHERE nome LIKE ? LIMIT 25', + 'SELECT nome FROM Choices WHERE nome LIKE ? LIMIT 25', [`%${focusedValue}%`] ); const suggestions = rows.map(row => ({ name: row.nome, - value: row.value, // ou um ID se preferires + value: row.nome, })); await interaction.respond(suggestions);