Autocomplete Error!

CommandHandler
module.exports = class Command {
    constructor(client, meta = {}) {
        this.client = client;
        this.data = meta.data;
        this.contextDescription = meta.contextDescription || null;
        this.usage = meta.usage || this.name;
        this.category = meta.category || 'Info';
        this.permissions = meta.permissions || ['Use Application Commands', 'Send Messages', 'Embed Links'];
    }
    async autocomplete() {
        throw new Error(`The Slash Command ${this.name} Doesn't Have Any Autocomplete Method.`);
    }
    async run() {
        throw new Error(`The Slash Command ${this.name} Doesn't Have Any Run Method.`);
    }
};


Command
const Command = require('../../structures/CommandClass');

module.exports = class Akinator extends Command {
    constructor(client) {
        super(client, {
            data: new SlashCommandBuilder()
                .setName('akinator')
                .setDescription('akinator.')
                .setDMPermission(true)
                .addStringOption(option =>
                    option.setName(`language`)
                        .setDescription(`option`)
                        .setRequired(true)
                        .setAutocomplete(true)),
            usage: 'akinator',
            category: 'akinator',
            permissions: ['Use Application Commands', 'Send Messages', 'Embed Links'],
        });
    }
    async autocomplete(client, interaction) {
        const focusedValue = interaction.options.getFocused();
        const choices = ['Popular Topics: Threads', 'Sharding: Getting started', 'Library: Voice Connections', 'Interactions: Replying to slash commands', 'Popular Topics: Embed preview'];
        const filtered = choices.filter(choice => choice.startsWith(focusedValue));
        await interaction.respond(
            filtered.map(choice => ({ name: choice, value: choice })),
        );
    }
    async run(client, interaction) {
        // Your run logic here
    }
};
Was this page helpful?