This commit is contained in:
Bxio 2025-04-05 11:22:52 +01:00
parent c84ecb7f72
commit affe3ba1eb
2 changed files with 10 additions and 17 deletions

View File

@ -19,17 +19,6 @@ module.exports = {
{ 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;

View File

@ -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);