You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Discord.js v14自动补全功能报错:Loading Options Failed

解决Discord.js v14自动补全"Loading Options Failed"问题

你的问题核心是没有在交互事件中处理自动补全类型的请求,当前代码只处理了普通斜杠命令的execute逻辑,完全忽略了autocomplete交互的处理流程,导致Discord服务器收不到自动补全的响应,最终显示加载失败。

修复步骤

修改index.js中的InteractionCreate事件处理代码,添加对自动补全交互的判断和处理:

client.on(Events.InteractionCreate, async interaction => {
    // 优先处理自动补全交互
    if (interaction.isAutocomplete()) {
        const command = client.commands.get(interaction.commandName);
        if (!command) return;
        
        try {
            await command.autocomplete(interaction);
        } catch (error) {
            console.error(error);
        }
        return;
    }

    // 处理普通斜杠命令交互
    if (!interaction.isChatInputCommand()) return;

    const command = client.commands.get(interaction.commandName);
    if (!command) return console.log("Command was not found");

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

额外检查点

  • 确认你的deploy-slashcmds.js已将命令的autocomplete配置正确同步到Discord服务器:服务器命令几乎即时生效,全局命令则需要等待约1小时同步时间
  • 确保命令文件中的autocomplete方法参数格式正确(你当前的格式是合规的,每个选项为{name: string, value: string}结构)

内容的提问来源于stack exchange,提问作者Delta Knight

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 00:13:11