简体   繁体   English

DiscordAPIError [40060]:交互已被确认。 与按钮交互 discord.js V14

[英]DiscordAPIError[40060]: Interaction has already been acknowledged. with buttons interactions discord.js V14

I 'am getting this error in all my buttons some times it do what in the code sometimes the errors come early我的所有按钮有时都会出现此错误,有时它会执行代码中的操作,有时错误会提前出现

DiscordAPIError[40060]: Interaction has already been acknowledged.
    at SequentialHandler.runRequest (C:\Users\ryuuo\Desktop\ryuu\node_modules\@discordjs\rest\dist\index.js:659:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.queueRequest (C:\Users\ryuuo\Desktop\ryuu\node_modules\@discordjs\rest\dist\index.js:458:14)
    at async REST.request (C:\Users\ryuuo\Desktop\ryuu\node_modules\@discordjs\rest\dist\index.js:902:22)
    at async ButtonInteraction.deferReply (C:\Users\ryuuo\Desktop\ryuu\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:69:5)        
    at async Object.execute (C:\Users\ryuuo\Desktop\ryuu\Buttons\languague.js:11:5) {
  requestBody: { files: undefined, json: { type: 5, data: { flags: 64 } } },
  rawError: {
    message: 'Interaction has already been acknowledged.',
    code: 40060
  },
  code: 40060,
  status: 400,
  method: 'POST',
  url: 'https://discord.com/api/v10/interactions/1037980437043236884/aW50ZXJhY3Rpb246MTAzNzk4MDQzNzA0MzIzNjg4NDpteWUxWkVidG8xY1VsUkpOU3Jxb3JJSnp2b2JwSlFtUUVqVnFEb0FNeEg4UUZqc1JNMWdyMkYxU3JNMDdPR2RDMEV2U3Q0TzByMkMzY1lQTk1kS09SVHh5SjEwR1daOHF6OVhWbEh0bDJYd1B6UFpIYXdMYktwczF3RXRxNVFFTA/callback'
}

I 'am using: Discord.js Version 14.6.0 Node.js Version 18.11.0我正在使用: Discord.js 版本 14.6.0 Node.js 版本 18.11.0

I tried with a simple reply like我尝试了一个简单的回复,比如

client.on(Events.InteractionCreate, async(interaction) => {
    if(!interaction.isButton()) return;
    if(interaction.customId === "test")
    await interaction.reply({
      content: "Test worked",
      ephemeral: true
    });
  });

and getting the same error after the bot reply I tried also with a buttons handler and same并在机器人回复后得到相同的错误我也尝试使用按钮处理程序和相同的

I solved it it seems that the problem was from the handler I edited the interaction filter from this我解决了,看来问题出在我编辑交互过滤器的处理程序上

 if (!interaction.isChatInputCommand) return;

to this对此

 if (!interaction.isChatInputCommand || 
      interaction.isButton() ||
      interaction.isModalSubmit()) return;

and it works fine它工作正常

Check if you have duplicated events, and maybe turn if(interaction.customId === "test") into if(interaction.customId !== "test") return , that should work.检查您是否有重复的事件,也许将if(interaction.customId === "test")转换为if(interaction.customId !== "test") return ,这应该有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM