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

Discord.js V13报DiscordAPIError: Unknown Interaction错误如何解决

错误根因

你遇到的DiscordAPIError: 10062 Unknown interaction是Discord的内置规则导致:所有组件交互(下拉菜单、按钮等)必须在触发后3秒内做出响应,超过3秒Discord服务端会直接将该交互标记为无效,此时再调用reply()、deferReply()等方法都会抛出该错误。
你之前尝试deferUpdate()/deferReply()无效大概率是调用时机晚于3秒阈值,或者是在同一次交互上重复调用了响应方法。

修复方案

优先在交互触发的第一时间完成延迟响应,把响应时限拉长到15分钟,后续再编辑回复内容即可,修正后的代码如下:

let filter1 = (i) => i.user.id === message.author.id;

const col = msg.createMessageComponentCollector({
    filter: filter1,
    componentType: "SELECT_MENU",
    time: 600000
})

col.on('collect', async i => {
    // 先判断交互状态,避免重复响应报错
    if (!i.replied && !i.deferred) {
        // 提前延迟响应,因为你的回复是私密的,ephemeral参数要和后续回复一致
        await i.deferReply({ ephemeral: true });
    }
    if (i.values[0] === 'etitle') {
        // 用editReply替换原有的reply方法发送实际内容
        await i.editReply({
            content: `La opción **Titulo** fue seleccionada. Por favor, introduce un titulo para el embed.`
        })
        let t1 = await message.channel.awaitMessages({
            filter: filter2,
            max: 1
        })

        let title = t1.first().content;
        pre.setTitle(title)
        result.setTitle(title)
        t1.first().delete().catch(err => null)
        preview.edit({
            content: `**Vista previa:**`,
            embeds: [pre]
        })
    }
})

额外排查点

如果修改后仍有报错,可以检查两个场景:

  • 是否有其他监听逻辑同时处理同一次下拉菜单交互,已经先一步调用了响应方法导致冲突
  • 检查filter2的定义是否正确,避免awaitMessages出现未捕获的超时错误阻塞逻辑

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.05 14:48:01