0

I'm running a whatsapp bot and everything works fine until I get a message

at /root/bot/node_modules/@adiwajshing/baileys/lib/Utils/generics.js:157:32
(node:26706)
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: 21)

I tried to search for some answers on the ChatGPT bot but that's not working, maybe someone can help me to fix this issue. Here is the code

    // Create a promise that rejects in <ms> milliseconds
    const { delay, cancel } = (0, exports.delayCancellable)(ms);
    const p = new Promise((resolve, reject) => {
        delay
            .then(() => reject(new boom_1.Boom('Timed Out', {
            statusCode: Types_1.DisconnectReason.timedOut,
            data: {
                stack
            }
        })))
            .catch(err => reject(err));
        promise(resolve, reject);
    })
        .finally(cancel);
    return p;
}

Note: code at

root/bot/node_modules/@adiwajshing/baileys/lib/Utils/generics.js:157

is

.then(() => reject(new boom_1.Boom('Timed Out', {
  • Please be aware that the usage of ChatGPT to generate content in posts on Stack Overflow [is currently banned](https://meta.stackoverflow.com/questions/421831/temporary-policy-chatgpt-is-banned). That applies both to copy-pasting from ChatGPT into answers, *and also* asking questions about code generated by ChatGPT. Since ChatGPT is optimized for generating coherent human-like speech (as it is a chat bot), it does not know how to write code and produces only low-quality output. Trying to fix/improve such code is therefore futile. – Cody Gray - on strike Feb 01 '23 at 04:53
  • I'm not using ChatGPT to generate content, I'm just searching for an answer but don't find anything because I'm hew here – Gabriel Dimas Eka Jaya Feb 01 '23 at 04:56
  • `.catch(err => reject(err))` is totally redundant – Phil Feb 01 '23 at 05:33

0 Answers0