This commit is contained in:
parent
c84ecb7f72
commit
affe3ba1eb
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user