whatsapp-chatgpt icon indicating copy to clipboard operation
whatsapp-chatgpt copied to clipboard

Error: Evaluation failed: TypeError: window.Store.DownloadManager.downloadAndDecrypt is not a function

Open ImmortalMan01 opened this issue 1 year ago • 11 comments

It crashes when someone sends audio.

C:\Users\Ogulc\Desktop\Yeni klasör (4)\whatsapp-chatgpt-master\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221 throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails)); ^

Error: Evaluation failed: TypeError: window.Store.DownloadManager.downloadAndDecrypt is not a function at puppeteer_evaluation_script:20:75 at ExecutionContext._evaluateInternal (C:\Users\Ogulc\Desktop\Yeni klasör (4)\whatsapp-chatgpt-master\node_modules\whatsapp-web.js\node_modules\puppeteer\src\common\ExecutionContext.ts:273:13) at processTicksAndRejections (node:internal/process/task_queues:95:5) at ExecutionContext.evaluate (C:\Users\Ogulc\Desktop\Yeni klasör (4)\whatsapp-chatgpt-master\node_modules\whatsapp-web.js\node_modules\puppeteer\src\common\ExecutionContext.ts:140:12) at Message.downloadMedia (C:\Users\Ogulc\Desktop\Yeni klasör (4)\whatsapp-chatgpt-master\node_modules\whatsapp-web.js\src\structures\Message.js:387:24) at Module.handleIncomingMessage (C:\Users\Ogulc\Desktop\Yeni klasör (4)\whatsapp-chatgpt-master\src\handlers\message.ts:39:19) at Client. (C:\Users\Ogulc\Desktop\Yeni klasör (4)\whatsapp-chatgpt-master\src\index.ts:57:5)

Node.js v18.13.0

ImmortalMan01 avatar Mar 16 '23 06:03 ImmortalMan01

I temporarily found the problem myself and came up with a solution. When I delete the "session" folder and open it again, the problem is fixed, but I have to do this every time I open and close the bot or it crashes. I need a permanent solution can you please help?

ImmortalMan01 avatar Mar 16 '23 17:03 ImmortalMan01

same, help pls

doofzoff avatar Mar 16 '23 19:03 doofzoff

same when use TRANSCRIPTION_MODE=openai, and when use !dalle ,also shows the error .

loliuy avatar Mar 17 '23 04:03 loliuy

It crashes when they send pictures, not just audio files.

ImmortalMan01 avatar Mar 17 '23 15:03 ImmortalMan01

It crashes when they send pictures, not just audio files.

yep, or if somebody send stickers, video, photo, gif and more

doofzoff avatar Mar 17 '23 16:03 doofzoff

It also seems to be crashing with !dalle prompt. Only text prompts seems to be working for me. Deleted the sessions folder and relinked whatsapp, but still same error.

[DALL-E] Received prompt from [REDACED]: clouds, anime style
  [DALL-E] Answer to [REDACED] | OpenAI request took 8343ms
E:\Temp\whatsapp-chatgpt\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221
            throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
                  ^

Error: Evaluation failed: TypeError: window.Store.MediaPrep.prepRawMedia is not a function
    at Object.window.WWebJS.processMediaData (__puppeteer_evaluation_script__:235:50)
    at async Object.window.WWebJS.sendMessage (__puppeteer_evaluation_script__:19:19)
    at async __puppeteer_evaluation_script__:10:25
    at ExecutionContext._evaluateInternal (E:\Temp\whatsapp-chatgpt\node_modules\whatsapp-web.js\node_modules\puppeteer\src\common\ExecutionContext.ts:273:13)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at ExecutionContext.evaluate (E:\Temp\whatsapp-chatgpt\node_modules\whatsapp-web.js\node_modules\puppeteer\src\common\ExecutionContext.ts:140:12)
    at Client.sendMessage (E:\Temp\whatsapp-chatgpt\node_modules\whatsapp-web.js\src\Client.js:686:28)

Node.js v18.14.2

rikuddo91 avatar Mar 17 '23 19:03 rikuddo91

I fix it

declare for window.Store.DownloadManager.downloadAndDecrypt function name change at window.Store.DownloadManager.downloadAndMaybeDecrypt

\node_modules\whatsapp-web.js\src\structures\Message.js line 406

renancunhasousa avatar Mar 17 '23 21:03 renancunhasousa

I change also Injected.js // window.Store.MediaPrep = window.mR.findModule('MediaPrep')[0]; window.Store.MediaPrep = window.mR.findModule('prepRawMedia')[0]; Thank You It's working.

renancunhasousa avatar Mar 17 '23 21:03 renancunhasousa

I change also Injected.js // window.Store.MediaPrep = window.mR.findModule('MediaPrep')[0]; window.Store.MediaPrep = window.mR.findModule('prepRawMedia')[0]; Thank You It's working.

sorry,but where is the injected.js?

loliuy avatar Mar 18 '23 05:03 loliuy

I change also Injected.js // window.Store.MediaPrep = window.mR.findModule('MediaPrep')[0]; window.Store.MediaPrep = window.mR.findModule('prepRawMedia')[0]; Thank You It's working.

sorry,but where is the injected.js?

node_modules/whatsapp-web.js/src/util

GreenerX avatar Mar 18 '23 05:03 GreenerX

Go to the dowloadMedia function and find the following line: const decryptedMedia = await window.Store.DownloadManager.downloadAndDecrypt

Replace with this:

const decryptedMedia = await window.Store.DownloadManager.downloadAndMaybeDecrypt

RyanBrayan avatar Mar 20 '23 12:03 RyanBrayan

It works thank you all

cce15 avatar Mar 21 '23 08:03 cce15

Shoule be fixed with the latest version of whatsapp-web.js I think.

navopw avatar Mar 27 '23 07:03 navopw

change to in the package.json to "whatsapp-web.js": "1.21.1-alpha.1"

guerra2fernando avatar Aug 09 '23 18:08 guerra2fernando