Closed Diego-Schmidt closed 3 years ago
All the commands of example.js are running ok.
You haven't required MessageMedia!!!!!!
const {Client, **MessageMedia**} = require("./index.js");
add that bit to the code, you will find
const {Client} = require("./index.js");
something like this on the top of your code, add the comma and MessageMedia.
Useful Links:
Best regards,
Closing this issue, you are welcome to open it again if you think this was done in error.
Best regards,
The MEssagemedia not defined problem is solved, but i have "ReferenceError: chat is not defined" when i use !sendpic , should I add Chat to the line? I have added Chat to the const line but it is not working. By the way, thanks for answer my noob questions.
const { Client, Location, MessageMedia, Chat} = require('./index');
Solved, changed the code
chat.sendMessage(media);
To
client.sendMessage(msg.from, media);
and then it worked.
Bug description
Unable to send media on NodeJS 14 , windows 10 , using v1.12.6 source zip and example.js
Reproduction steps
Added code to example.js to send a test picture "picture.jpg" on command !sendpic
Expected behavior
Bot responding to !sendpic command and sending picture.jpg to the user
Relevant code
Added
To example.js
Environment (please complete the following information):
WhatsApp
await client.getWWebVersion()
]: 2.2123.7Library
node -v
): v14.16.0npm -v
): 6.14.11Additional context
Error on console
(node:16328) UnhandledPromiseRejectionWarning: ReferenceError: MessageMedia is not defined at Client. (C:\Users\user\Downloads\bot\whatsapp-web.js-1.12.6\paya.js:49:23)
at Client.emit (events.js:315:20)
at C:\Users\user\Downloads\bot\whatsapp-web.js-1.12.6\src\Client.js:238:18
at Page._onBindingCalled (C:\Users\user\Downloads\bot\whatsapp-web.js-1.12.6\node_modules\puppeteer\lib\cjs\puppeteer\common\Page.js:717:62)
at C:\Users\user\Downloads\bot\whatsapp-web.js-1.12.6\node_modules\puppeteer\lib\cjs\puppeteer\common\Page.js:151:60
at C:\Users\user\Downloads\bot\whatsapp-web.js-1.12.6\node_modules\puppeteer\lib\cjs\vendor\mitt\src\index.js:51:62
at Array.map ()
at Object.emit (C:\Users\user\Downloads\bot\whatsapp-web.js-1.12.6\node_modules\puppeteer\lib\cjs\vendor\mitt\src\index.js:51:43)
at CDPSession.emit (C:\Users\user\Downloads\bot\whatsapp-web.js-1.12.6\node_modules\puppeteer\lib\cjs\puppeteer\common\EventEmitter.js:72:22)
at CDPSession._onMessage (C:\Users\user\Downloads\bot\whatsapp-web.js-1.12.6\node_modules\puppeteer\lib\cjs\puppeteer\common\Connection.js:225:18)
(Use
node --trace-warnings ...
to show where the warning was created) (node:16328) 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:16328) [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.