[英]How to reference to a previous bot message? (Discord.js v14)
I want to change a specific message's embed after a while, but I am stuck at fetching the reference to this message correctly.我想在一段时间后更改特定消息的嵌入,但我一直无法正确获取对该消息的引用。 Can someone point me in the right direction?
有人可以指出我正确的方向吗?
I first tried this:我首先尝试了这个:
const msgRef = await interaction.editReply({ embeds: [exampleEmbed_1] });
let todos = []
todos.push(msgRef)
But when I try to use the msgRef object to update the message with another embed:但是当我尝试使用 msgRef object 使用另一个嵌入更新消息时:
const message = todos[0]
await message.edit({ embeds: [exampleEmbed_2] });
I get an error:我收到一个错误:
TypeError: message.edit is not a function
I am bit confused at this point.在这一点上我有点困惑。 How can I properly fetch a specific message's reference to change the content later?
如何正确获取特定消息的引用以稍后更改内容? Is there a way maybe to search for it via a message ID?
有没有办法通过消息 ID 搜索它?
You can fetch it via message ID but you would also need the ID of the channel it was sent in, then you can use the Client.channels.fetch('channel id').messages.fetch('message id')
method which will return the Message object if it exists.您可以通过消息 ID 获取它,但您还需要发送它的频道的 ID,然后您可以使用
Client.channels.fetch('channel id').messages.fetch('message id')
方法如果存在,将返回消息 object。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.