orkestral / venom

Venom is a high-performance system developed with JavaScript to create a bot for WhatsApp, support for creating any interaction, such as customer service, media sending, sentence recognition based on artificial intelligence and all types of design architecture for WhatsApp.
https://orkestral.io
Apache License 2.0
6.1k stars 1.2k forks source link

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined #711

Closed textarea closed 3 years ago

textarea commented 3 years ago

Description

Sometimes getting the following error in errors log. Don't know how to reproduce.

Environment

Log Output

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined at new NodeError (node:internal/errors:329:5) at validateString (node:internal/validators:129:11) at Object.extname (node:path:1273:5) at Object.filenameFromMimeType (/var/www/node_modules/venom-bot/dist/api/helpers/filename-from-mimetype.js:61:34) at Whatsapp. (/var/www/node_modules/venom-bot/dist/api/layers/sender.layer.js:301:73) at step (/var/www/node_modules/venom-bot/dist/api/layers/sender.layer.js:48:23) at Object.next (/var/ww/node_modules/venom-bot/dist/api/layers/sender.layer.js:29:53) at /var/www/node_modules/venom-bot/dist/api/layers/sender.layer.js:23:71 at new Promise () at __awaiter (/var/www/node_modules/venom-bot/dist/api/layers/sender.layer.js:19:12)

jonalan7 commented 3 years ago

Which function is giving this error? Could you give more details of your problem?

ghifar1 commented 3 years ago

@jonalan7 in my cases is sendImage and sendImageFromBase64

textarea commented 3 years ago

Sorry, I don't have now more details, It could be in sendImageFromBase64 also for me

PedroBorba commented 3 years ago

@textarea I have found the problem. in my case, i tried to use the sendImageFromBase64 ... if you inspect that method, you will see the method Promises a SendFileResult that it's a interface requiring the filename parameter.

Solution: is just pass a filename parameter to the sendImageFromBase64 or sendImage.

I will put my solution here:

  let image = '<base64_image>';
  let filename = '<filename>';
    client.sendImageFromBase64('<your_number>@c.us', image, filename).then(result => {
        console.log("Image Sended!")
    }).catch(err => {
        console.log("Something goes wrong ...")
        console.log(err)
    })