This commit is contained in:
parent
c84ecb7f72
commit
affe3ba1eb
@ -18,18 +18,7 @@ module.exports = {
|
|||||||
{ name: 'Mike', value: '1' },
|
{ name: 'Mike', value: '1' },
|
||||||
{ name: 'Totem', value: '3' }
|
{ 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) {
|
async execute(interaction, client) {
|
||||||
const guildId = interaction.guild.id;
|
const guildId = interaction.guild.id;
|
||||||
|
|||||||
@ -7,22 +7,26 @@ module.exports = {
|
|||||||
if (interaction.isChatInputCommand()) {
|
if (interaction.isChatInputCommand()) {
|
||||||
const command = client.commands.get(interaction.commandName);
|
const command = client.commands.get(interaction.commandName);
|
||||||
if (!command) return;
|
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()) {
|
if (interaction.isAutocomplete()) {
|
||||||
const focusedValue = interaction.options.getFocused();
|
const focusedValue = interaction.options.getFocused();
|
||||||
if (interaction.commandName === 'add' && interaction.options.getSubcommand(false) === null) {
|
if (interaction.commandName === 'add') {
|
||||||
try {
|
try {
|
||||||
const [rows] = await conn.execute(
|
const [rows] = await conn.execute(
|
||||||
'SELECT nome FROM choices WHERE nome LIKE ? LIMIT 25',
|
'SELECT nome FROM Choices WHERE nome LIKE ? LIMIT 25',
|
||||||
[`%${focusedValue}%`]
|
[`%${focusedValue}%`]
|
||||||
);
|
);
|
||||||
|
|
||||||
const suggestions = rows.map(row => ({
|
const suggestions = rows.map(row => ({
|
||||||
name: row.nome,
|
name: row.nome,
|
||||||
value: row.value, // ou um ID se preferires
|
value: row.nome,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
await interaction.respond(suggestions);
|
await interaction.respond(suggestions);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user