AutoComplete Problem

before:-
    async autocomplete(interaction: AutocompleteInteraction) {
        const focusedValue = interaction.options.getFocused();
   
                try {
                    const choices = Docs.filter((tag: TagData) => tag.name.startsWith(focusedValue));
              
                    await interaction.respond(
                      choices.map((choice: TagData) => ({ name: choice.name, value: choice.name }))
                    );
                } catch (error) {
                    await interaction.respond([{ name: "Error loading tags", value: "" }]);
                }
    },


after code:-
    async autocomplete(interaction: AutocompleteInteraction) {
        const focusedValue = interaction.options.getFocused(true);
        switch (focusedValue.name) {
            case "tag":
                try {
                    const choices = Docs.filter((tag: TagData) => tag.name.startsWith(focusedValue.name));
              
                    await interaction.respond(
                      choices.map((choice: TagData) => ({ name: choice.name, value: choice.name }))
                    );
                } catch (error) {
                    await interaction.respond([{ name: "Error loading tags", value: "" }]);
                }
                break;
            case "hidden":
                const choices = ["True", "False"];

                await interaction.respond(
                  choices.map((choice) => ({ name: choice, value: choice }))
                );
                break;
            default:
                break;
        }
    },


the autocomplete option named tag does not show any options, it used to show earlier but then i added the hidden option and a switch statement then it stopped working
Was this page helpful?