Closed NyllRE closed 2 years ago
you error is because you are doing this media = await MessageMedia.fromFilePath("./files/" + msg)
try just like this media = await MessageMedia.fromFilePath("./files/")
try just like this
media = await MessageMedia.fromFilePath("./files/")
./files/
directory, if this works it would be weird af,
I'll try to make it a single string then giving it to the functionI tried replacing what I did with media = await MessageMedia.fromFilePath("./files/UserGuid.pdf")
which is a dummy file I made and the same error persists. the error as you can see from what I sent is coming from puppeteer. I reinstalled everything and checked my code carefully and even put try catch arguments and nothing changes. the function is broken
I recently used string interpolation ${msg}
and it works completely fine !
Can you try that for me ?
you mean something like
MessageMedia.fromFilePath(`./files/${msg}`)
because I tried multiple ways of inserting the string. I tried to log the media it retrieves and what I got was:
MessageMedia {
mimetype: 'application/pdf',
data: '',
filename: 'UserGuid.pdf'
}
so the naming is right and everything. it's just not able to send the data pro... hold up. the file I sent was empty. I tried to put in dummy data and it worked... before an update I was able to send an empty file and it worked fine then... something happened in the new update that made it get broken when you send empty files... this wasted hella lot of my time lol.
so the issue is resolved, but there is a secondary issue which is sending empty files. it used to work and now it doesn't work so this should be looked at in the future because it was really confusing.
Error: Evaluation failed: TypeError: window.Store.MediaPrep.prepRawMedia is not a function 0|server | at window.WWebJS.processMediaData (puppeteer_evaluation_script:235:50) 0|server | at async window.WWebJS.sendMessage (puppeteer_evaluation_script:19:19) 0|server | at async puppeteer_evaluation_script:10:25 0|server | at ExecutionContext._evaluateInternal (F:\xampp\htdocs\Whatsapp\node\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19) 0|server | at processTicksAndRejections (internal/process/task_queues.js:95:5) 0|server | at async ExecutionContext.evaluate (F:\xampp\htdocs\Whatsapp\node\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16) 0|server | at async Client.sendMessage (F:\xampp\htdocs\Whatsapp\node\node_modules\whatsapp-web.js\src\Client.js:686:28)
I got this error when i am sending Image.
@digitalsolitario are you sure the image is not empty for testing? when I tried sending empty images for testing it didn't work so make sure you are sending a real image
Is there an existing issue for this?
Describe the bug
I've made code that takes in a link and decides if it is a localfile or a url to send it to the user, the MessageMedia.fromFilePath function seems to not work at all
Expected behavior
expected:
result:
Steps to Reproduce the Bug or Issue
this is the function that returns the media
the function is being called here:
Relevant Code
these are the error messages:
the error seems to be coming from puppeteer
Browser Type
Chromium
WhatsApp Account Type
WhatsApp Business
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
OS: Linux Ubuntu 20.04.4 Phone OS: Android 12 whatsabb-web.js: 1.16.5 NodeJS: v16.14.2
Additional context
the error only happens when a user requests a localfile, the local file is there and I checked the local file's name and even made an exception but puppeteer's errors seem to pass the try argument