Autocomplete not working

const { SlashCommandBuilder , ButtonBuilder , ButtonStyle , ActionRowBuilder , EmbedBuilder, messageLink, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');


module.exports = {
data:
new SlashCommandBuilder()
.setName('create')
.setDescription('Cria uma ficha de Breed')
.addStringOption(option =>
option.setName('dinoname')
.setDescription('Dino que sera breedado')
.setRequired(true)
.setAutocomplete(true)),
async autocomplete(interaction){
const focusedValue = interaction.options.getFocused();
const choices = ['Giga', 'Stego', 'Charca', 'Carbo', 'Tape', 'Velona', 'Snow', 'Barionyx', 'Tuso', 'Desmodus', 'Shadow', 'Astro', 'Theri', 'Stalker', 'Racer', 'Rex', 'Basilo', 'FjordHawk', 'Andrewsarchus', 'Amargasaurus', 'Noglin', 'Basilisk',
'Griffin', 'Daeodon', 'Thyla', 'Mantis', 'Voidwyrm', 'Deino', 'Yutirannus', 'LightWyvern']
const filtered = choices.filter(choice => choice.startsWith(focusedValue));
await interaction.respond(
filtered.map(choice => ({ name: choice, value: choice })),
);
},
const { SlashCommandBuilder , ButtonBuilder , ButtonStyle , ActionRowBuilder , EmbedBuilder, messageLink, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');


module.exports = {
data:
new SlashCommandBuilder()
.setName('create')
.setDescription('Cria uma ficha de Breed')
.addStringOption(option =>
option.setName('dinoname')
.setDescription('Dino que sera breedado')
.setRequired(true)
.setAutocomplete(true)),
async autocomplete(interaction){
const focusedValue = interaction.options.getFocused();
const choices = ['Giga', 'Stego', 'Charca', 'Carbo', 'Tape', 'Velona', 'Snow', 'Barionyx', 'Tuso', 'Desmodus', 'Shadow', 'Astro', 'Theri', 'Stalker', 'Racer', 'Rex', 'Basilo', 'FjordHawk', 'Andrewsarchus', 'Amargasaurus', 'Noglin', 'Basilisk',
'Griffin', 'Daeodon', 'Thyla', 'Mantis', 'Voidwyrm', 'Deino', 'Yutirannus', 'LightWyvern']
const filtered = choices.filter(choice => choice.startsWith(focusedValue));
await interaction.respond(
filtered.map(choice => ({ name: choice, value: choice })),
);
},
6 Replies
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Ashura
Ashura•2y ago
const { CommandInteraction, ApplicationCommandAutoComplete , InteractionType} = require("discord.js");

module.exports = {
name: "interactionCreate",

async execute(interaction, client) {
if(interaction.type == InteractionType.ApplicationCommandAutoComplete){
const {commands} = client;
const {commandName} = interaction;
const command = commands.get(commandName);
if (!command) return;

try {
await command.autocomplete(interaction, client)
} catch (err){
console.error(error);
}
}
},
};
const { CommandInteraction, ApplicationCommandAutoComplete , InteractionType} = require("discord.js");

module.exports = {
name: "interactionCreate",

async execute(interaction, client) {
if(interaction.type == InteractionType.ApplicationCommandAutoComplete){
const {commands} = client;
const {commandName} = interaction;
const command = commands.get(commandName);
if (!command) return;

try {
await command.autocomplete(interaction, client)
} catch (err){
console.error(error);
}
}
},
};
heres my intecartion create interaction create*
Ashura
Ashura•2y ago
ReferenceError: error is not defined at Object.execute (C:\Users\luizs\Documents\Discord Bot\Events\Interactions\interactionCreate.js:16:27) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Emitted 'error' event on Client instance at: at emitUnhandledRejectionOrErr (node:events:394:10) at process.processTicksAndRejections (node:internal/process/task_queues:84:21) got this error now
MrMythical
MrMythical•2y ago
🤔
d.js docs
d.js docs•2y ago
• ReferenceError: "x" is not defined: learn more • TypeError: Cannot read properties of undefined/null (reading "x"): learn more