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

Discord.js v14出现DiscordAPIError[40060]错误,命令无法运行求助

DiscordAPIError[40060] 错误解决指南

错误本质

DiscordAPIError[40060] 对应「交互已被确认」,即你对同一个Discord交互发起了多次响应操作(比如重复调用deferReply或reply)。

你的代码问题

你注册了两个独立的InteractionCreate事件监听器,虽然看似各处理各的命令,但如果逻辑触发异常(比如某个交互被多个监听器同时处理),就会导致重复确认交互,触发错误。此外,若wait函数不是标准异步实现,也可能打乱响应顺序引发异常。

修复方案

1. 合并事件监听器

将所有命令处理逻辑整合到同一个InteractionCreate监听器中,避免重复监听事件:

client.on(Events.InteractionCreate, async interaction => {
    if (!interaction.isChatInputCommand()) return;

    if (interaction.commandName === 'help') {
        await interaction.deferReply();
        await wait(800);
        await interaction.editReply({ embeds: [helpEmbed] });
    } else if (interaction.commandName === 'wombat') {
        await interaction.deferReply();
        await wait(800);
        await interaction.editReply({ embeds: [embed] });
    }
});

2. 确保wait函数为异步实现

如果你的wait函数未正确返回Promise,添加以下定义:

const wait = (ms) => new Promise(resolve => setTimeout(resolve, ms));

3. 排查重复响应逻辑

检查代码中是否有其他地方(比如中间件、前置处理函数)已经对交互进行了reply或deferReply操作,确保同一个交互只被响应一次。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.09 10:30:50