我的discord机器人有一个命令可以从API查找数据,有时这需要时间,所以我希望我的机器人告诉用户。
初始消息为:message.channel.send({embed: { color: 0x80ff00, description: "Looking for data"}})
在数据嵌入准备好后,如何让机器人用数据编辑消息?
答案 0 :(得分:0)
message.channel
.send({embed: { color: 0x80ff00, description: "Looking for data"}})
.then(embed => {
// here `embed` is the message that was sent to the channel
someAsyncOperation().then(data => {
embed.edit({embed: {description: "Found the data: " + data}});
});
});
答案 1 :(得分:0)
使用.then:
message.channel.send({embed: { color: 0x80ff00, description: "Looking for data"}})
.then(msg => {
msg.edit('Something');
});
使用异步等待:
const msg = await message.channel.send({embed: { color: 0x80ff00, description: "Looking for data"}});
msg.edit('data');