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

Discord.js 14升级后调用react()报TypeError问题求助

解决Discord.js v14中交互回复无法添加表情的问题

问题原因

Discord.js v14里,interaction.reply()和interaction.deferReply()默认返回的是InteractionResponse对象,而非实际的消息(Message)对象,而react()是Message对象的专属方法,直接调用自然会报错。

解决方案

1. 延迟回复(deferReply)后添加表情

调用deferReply()后,需要通过interaction.fetchReply()获取对应的消息对象,再调用react():

await interaction.deferReply();
const waitingMessage = await interaction.fetchReply();
waitingMessage.react('🆗');

2. 直接回复(reply)后添加表情

在reply()的配置选项里设置fetchReply: true,让方法直接返回Message对象:

const msg = await interaction.reply({ 
  embeds: [embed],
  fetchReply: true 
});
msg.react('👍');
msg.react('👎');

额外注意

要确保机器人在目标频道拥有添加反应的权限,否则即使代码逻辑正确,也无法成功添加表情。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 11:05:19