【问题标题】:Discord.js V13: How to edit Message Object of Interaction?Discord.js V13:如何编辑交互的消息对象?
【发布时间】:2021-10-17 07:13:46
【问题描述】:
我正在尝试将我的 discord 机器人更新到新版本的 discord.js (v13)。我有一条带有嵌入和两个按钮的消息,一个用于上一页,一个用于下一页。当用户单击按钮时,我正在尝试编辑嵌入以显示其他内容。但后来我得到了一个
TypeError:interaction.message.edit() 不是函数。
我可以打印出interaction.message 并显示消息对象,但无法调用该函数。我正在使用interactionCreate 事件。
提前致谢!
【问题讨论】:
标签:
javascript
discord
discord.js
bots
【解决方案1】:
您可以使用interaction.update() 方法:
// send a message
message.channel.send({ embeds: [embed], components: [buttons] })
/*
listen for the "interactionCreate" event or use any other method
of detecting an interaction like interaction collectors or awaitMessageComponent
*/
client.on("interactionCreate", (interaction) => {
interaction.update({ embeds: [aDiffrentEmbed] })
})