#How to wait on Client.on("message")

6 messages · Page 1 of 1 (latest)

paper tide
#

lets say i have this
Bot.on("message", (msg) => { if (msg.body.startsWith("!")) { doSomething(msg); } else { console.log("this is not command"); } });

and let say the doSomething is a promise;

how do i wait for do something to finish then start listening on message again (Bot.on("message") ?

why i want to achive this?
sometime user send command and the same time and Bot proceed the doSomething simultaneusly, i want it to process the first command first then after it finish, process the second command

lucid vessel
#
Bot.on("message", async (msg) => {
    if (msg.body.startsWith("!")) {
      await doSomething(msg);
    } else {
      console.log("this is not command");
    }
  });```
wintry tendon
wintry tendon
# paper tide lets say i have this `Bot.on("message", (msg) => { if (msg.body.startsWith("...

From what I understand, he wants to make a waiting list so that it stores user interactions and responds 1 to 1 like a queue

This way, if 10 users send a message at the same time, it will respond to 10 people simultaneously

Even though it is an asynchronous call (with await), each call is made independently

It is you who needs to implement this logic.
What you want to do has nothing to do with the library
There is no method that creates the queue you want.

spark burrow
strange wyvern
#

Node is thread safe