Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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);
});
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading