bootbot icon indicating copy to clipboard operation
bootbot copied to clipboard

When does the `captured` is set ? Or what is the flow order?

Open efleurine opened this issue 7 years ago • 1 comments

I have those two pieces of codes

1 - In index.js

bot.on("message", (payload, chat, data) => {
  const { text } = payload.message;
  console.log("in on ", new Date(), data); // 1
  chat.say(`Echo: ${text}`); // line 2
});

bot.module(generalModule);

and in module

 bot.hear("/about", (payload, chat, data) => {
    // Send Help Menu to the user...
    console.log("in general", data); // line 3
    chat.say(answer["/about"]); // line 4 awswer["/about"] = 'something'
  });

I try it many times and most of the times the on message would appear first. But sometimes the hear message would appear before it (happen rarely but happen). I tried to register the module first but this does not change anything. So Is there a way to enforce a particular order ?

efleurine avatar Jul 21 '18 08:07 efleurine

I think it happen disorder because async feature of javascript

HellCatVN avatar Aug 12 '18 08:08 HellCatVN