javascript - Discord.js V13 : How to edit Message Object of Interaction?

标签 javascript discord discord.js bots

我正在尝试将我的不和谐机器人更新到新版本的 discord.js (v13)。我有一个带有嵌入和两个按钮的消息,一个用于上一页,一个用于下一页。当用户单击按钮时,我正在尝试编辑嵌入以显示其他内容。但后来我得到一个

TypeError: interaction.message.edit() is not a function.


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

最佳答案

您可以使用 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] })
})

关于javascript - Discord.js V13 : How to edit Message Object of Interaction?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68782435/

相关文章:

javascript - 使用 Javascript/jQuery 的同步 GET 请求

javascript - 为什么代理在浏览器中不起作用(NuxtJS+Axios)?

javascript - 根据使用的邀请码为新成员分配角色

node.js - 如何用变量替换全部?

javascript - 你如何编写清除命令

javascript - 与 discord bot 通信的 HTML/PHP 网站

javascript - 在 .js 文件中访问 Nuxt 插件

javascript - 如何使用 Javascript 禁用功能键?

python - Discord.py 服务器统计命令

java - 如何在 JDA 中编辑嵌入