Estou utilizando o venom.js para envio de mensagens pelo whatsapp, ele funciona perfeitamente, desde que o cliente envie a primeira interação, ou seja quando eu tento enviar algum texto básico, no primeiro momento ele envia, mas na segunda vez que rodo o código ele, aparece um erro de Promise no puppeteer, já procurei na internet algo que fale a respeito mas sem êxito; Tentei utilizar o Sulla, mas o problema é o mesmo, Segue o código e logo abaixo o erro, desde já agradeço ao pessoal do fórum, por ceder o valioso tempo para nos responder;
const venom = require('venom-bot');
venom.create().then((client) => start(client));
async function start(client) {
// Send basic text
await client
.sendText('5531999999999@c.us', 'Olá Sou um Robô!')
.then((result) => {
console.log('Result: ', result.status);
})
.catch((erro) => {
console.error('Error no Processo: ', erro.status); //return object error
});
}
Tentei com o async/await ou sem, mas só funciona uma vez, talvez seja um detalhe, mas preciso que funcione constantemente, pois irei colocar dados de um setInterval e todas vez que outra api receber uma resposta irá chamar o VenomJs para que possa enviar para o Whatsapp;
(node:5420) UnhandledPromiseRejectionWarning: Error: Evaluation failed: ReferenceError: WAPI is not defined
at __puppeteer_evaluation_script__:3:45
at ExecutionContext._evaluateInternal (C:\wamp64\www\apiplug\desktop_dev\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async ExecutionContext.evaluate (C:\wamp64\www\apiplug\desktop_dev\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
(node:5420) 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: 1)
(node:5420) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.