W
W
WayneWayne2020-04-25 19:35:52
JavaScript
WayneWayne, 2020-04-25 19:35:52

How to get the ID of a post for further use in discord.js?

Hello. I am new to discord.js bot writing.
Let's get down to business: I need to get the message ID using the bot and have it remember it.
Source:

client.on('message', message => {
    if (message.content.toLowerCase()==config.prefix + "sms") {
        {
        message.reply(" скажи мне "привет")
        }
      const filter = m => (m.content.includes('привет') && m.author.id != client.user.id);
      const channel = message.channel;
      const collector = channel.createMessageCollector(filter, {max: 1, time: 10000 });
      console.log("Сбор сообщений начат.");
      collector.on('collect', m => console.log(`Collected ${m.content}`));
      collector.on('end', collected => console.log(`Collected ${collected.size} items`));
    }
});

What can my code currently do? The !sms command asks the user to text him "hello" with a timer of 10 seconds. Once the message has been written it stops collecting the message.
What I need? The bot must get the ID of the message it received (in this case "hello") and enter it into some database.
As for the database, I'll try to figure it out myself, there are suggestions how to do it, but the break of the entire World Wide Web could not find a way to get the message ID by the bot.
Please explain about the ID and optionally correct the errors in my code (if any) and send possible solutions to my questions. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
2
2CHEVSKII, 2020-04-25
@WayneWayne

What can my code currently do?

Can't do anything, it's invalid due to unescaped quotes.
explain about ID

To explain, discord.js has some great docks that you should check out first.
Here's your ID
Don't forget to mark it as a solution.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question