Changing command options doesn't update autocomplete

I have a bt with some commands that take 3 arguments (for example /help [category] [subcategory]) when selecting a category, subcategories will be displayed depending on what category the user has picked by using autocompletion. However, if the user goes back and changes the category to something else, the subcategories won't update according to the new category the user has selected. Is there a way to fix this? I'm not sure if this is a discord issue or a coding issue. My code looks something like this:
@SlashChoice(...tabletAreas)
@SlashOption({
type: ApplicationCommandOptionType.String,
name: "area",
description: "The area of the Lore Tablet",
required: true,
})
area: string,
@SlashOption({
autocomplete: async (interaction: AutocompleteInteraction) => {
const ChosenArea = interaction.options.getString("area");
const tabletNameAutocomplete: { name: string; value: string; }[] = [];
for (const tabletName of tabletList) {
if (tabletName.area === ChosenArea) {
tabletNameAutocomplete.push({ name: tabletName.name, value: tabletName.name });
}
}
const filtered = tabletNameAutocomplete.filter((c: { name: string; }) => capitalize(c.name).startsWith(capitalize(interaction.options.getFocused())));
await interaction.respond(
filtered.map(choice => ({ name: choice.name, value: choice.name })).slice(0, 25)
);
},
type: ApplicationCommandOptionType.String,
name: "name",
description: "The name of the Lore Tablet",
required: true,
})
@SlashChoice(...tabletAreas)
@SlashOption({
type: ApplicationCommandOptionType.String,
name: "area",
description: "The area of the Lore Tablet",
required: true,
})
area: string,
@SlashOption({
autocomplete: async (interaction: AutocompleteInteraction) => {
const ChosenArea = interaction.options.getString("area");
const tabletNameAutocomplete: { name: string; value: string; }[] = [];
for (const tabletName of tabletList) {
if (tabletName.area === ChosenArea) {
tabletNameAutocomplete.push({ name: tabletName.name, value: tabletName.name });
}
}
const filtered = tabletNameAutocomplete.filter((c: { name: string; }) => capitalize(c.name).startsWith(capitalize(interaction.options.getFocused())));
await interaction.respond(
filtered.map(choice => ({ name: choice.name, value: choice.name })).slice(0, 25)
);
},
type: ApplicationCommandOptionType.String,
name: "name",
description: "The name of the Lore Tablet",
required: true,
})
2 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Araraura
ArarauraOP2y ago
this code uses some ts decorators from discordx but i don't think it affects the important parts
Want results from more Discord servers?
Add your server