我正在尝试创建一个具有自动完成功能但适用于超过 25 个选择的选项,我已经看到其他机器人这样做了,我只是不知道如何才能做到这一点。我已经有了基本的自动完成设置,但它不允许我添加超过 25 个选择。我正在使用discord.js v14(我添加了28个选项,但它只适用于25个。提前Ty!)
if (interaction.options.getSubcommand() === "botanical" ) {
const focusedOption = interaction.options.getFocused(true);
let choices;
if (focusedOption.name === 'search') {
choices = ['agrimony', 'allspice', 'almond', 'aloe', 'anise', 'apple', 'avocado', 'basil', 'bayLaurel', 'bergamot', 'birch', 'calendula', 'cardamom', 'chamomile', 'cinnamon', 'comfrey', 'hemp', 'lavender', 'mint', 'motherwort', 'mugwort', 'rose', 'rosemary', 'sage', 'thyme', 'valerian', 'vervain', 'yarrow', 'valerian', 'vervain', 'yarrow'];
}
const filtered = choices.filter(choice => choice.startsWith(focusedOption.value));
await interaction.respond(
filtered.map(choice => ({ name: choice, value: choice })),
);
}
Run Code Online (Sandbox Code Playgroud)