#autocomplete on interaction create

1 messages · Page 1 of 1 (latest)

fast fulcrum

I'm trying to add a command that uses autocomplete, i think it's not working because of this code. how can i make it so that it checks if a command is autocomplete and then runs it?

client.on(Events.InteractionCreate, async interaction => {
    if (!interaction.isChatInputCommand()) return;

    const command = client.commands.get(interaction.commandName);

    if (!command) return;

    try {
        await command.execute(interaction);
    } catch (error) {
        console.error(error);
        if (interaction.replied || interaction.deferred) {
            await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
        } else {
            await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
        }
    }
});