Discord.js V13:如何编辑互动消息对象?

5
我正在尝试将我的Discord机器人更新到新版本的discord.js(v13)。我有一个带有嵌入式和两个按钮的消息,一个用于上一页,另一个用于下一页。当用户点击按钮时,我试图编辑嵌入以显示其他内容。但是我会收到以下错误:

TypeError:interaction.message.edit()不是函数。

我可以打印出 interaction.message,并显示消息对象,但无法调用该函数。我正在使用 interactionCreate 事件。

提前感谢!

1个回答

7
你可以使用 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: [aDifferentEmbed] })
})

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接