Reputation: 25
My discord bot has a command to lookup data from an API and sometimes it takes time so I want my bot to tell the user that.
The initial message is: message.channel.send({embed: { color: 0x80ff00, description: "Looking for data"}})
How can I make the bot edit the message with the data after the data embed is ready?
Upvotes: 1
Views: 1975
Reputation: 2785
Using .then:
message.channel.send({embed: { color: 0x80ff00, description: "Looking for data"}})
.then(msg => {
msg.edit('Something');
});
Using async await:
const msg = await message.channel.send({embed: { color: 0x80ff00, description: "Looking for data"}});
msg.edit('data');
Upvotes: 1
Reputation: 7963
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}});
});
});
See TextChannel#send and Message#edit.
Upvotes: 1