javascript js 13.8.1延迟回复

xwbd5t1u  于 2023-01-04  发布在  Java
关注(0)|答案(1)|浏览(100)

我想在您单击按钮后编辑邮件,但出现问题。
我的代码完全按照它应该的方式工作,但是每次它都说“这个交互失败了”,因为没有响应。你怎么能推迟回复那个交互而不实际回复呢?或者这甚至是可能的吗?
我只想举一个例子,说明如何做到这一点,如果不可能,又如何避免这种情况
我将其编辑为消息:

interaction.channel.messages.fetch(/*here is a message id from buttons custom id*/).then(
   async ms => {
      return ms.edit({ content: 'an edited responce to interaction reply' })
   }
)

按钮交互无响应,显示This interaction failed

yruzcnhs

yruzcnhs1#

你可以使用ButtonInteraction#deferUpdate。这个方法将延迟更新并重置组件的加载状态,而不会抛出This interaction failed错误。

interaction.channel.messages.fetch(/*here is a message id from buttons custom id*/).then(
   interaction.deferUpdate();
   async ms => {
      return ms.edit({ content: 'an edited responce to interaction reply' })
   }
)

相关问题