open-wa / wa-automate-nodejs

💬 🤖 The most reliable tool for chatbots with advanced features. Be sure to 🌟 this repository for updates!
https://docs.openwa.dev/
Other
3.15k stars 600 forks source link

Bug on client.sendMessage #2236

Closed justClizz closed 3 years ago

justClizz commented 3 years ago

Are you using the latest version of the library?

Current Behavior

I just set the code:

   client.onMessage(async message => {
if (message.body === `#ping`) {
    client.reply(message.from, `PONG! Bot ready!`, message.id);
}
});

And some error show on the console, the code:

(node:460) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)

Expected Behavior

client.sendText work

Steps To Reproduce

  1. I run the code
  2. Send #ping to bot
  3. See error on console

Mode

My own code

create() code

create({
  sessionId: "mosuSession",
  authTimeout: 60, //wait only 60 seconds to get a connection with the host account device
  blockCrashLogs: true,
  disableSpins: true,
  headless: true,
  multiDevice: true,
  useChrome: true,
  hostNotificationLang: 'id-id',
  logConsole: false,
  popup: true,
  qrTimeout: 0, //0 means it will wait forever for you to scan the qr code
}).then(client => start(client));

DEBUG INFO

{
  "WA_VERSION": "2.2140.12",
  "PAGE_UA": "WhatsApp/2.2108.8 Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36",
  "WA_AUTOMATE_VERSION": "4.23.3",
  "BROWSER_VERSION": "HeadlessChrome/91.0.4472.101",
  "OS": "Linux 5.11",
  "START_TS": 1634970885386
}

Environment

- OS: Linux
- Node: 14.17.1
- npm: 6.14.15

Screenshots

No response

Anything else?

No response

justClizz commented 3 years ago

Ok fixed, i just change something