'Get the message id of a message a bot sent in response
I don't have any code to share as I am just stumped. I know how to get the message id of the message a user sent; for example, if I did !test, I could do message.id to get that id.
But I want to get the id of the message a bot replied with, so if I did !test and a bot replied with "working", I want to get the id of that "working" message. Any ideas?
Solution 1:[1]
You can wait for the message to be sent and grab its ID. send() returns the message, so the following will work:
client.on('messageCreate', async (message) => {
if (message.author.bot) return;
let sentMessage = await message.channel.send('It works');
console.log(sentMessage.id);
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Zsolt Meszaros |
