SendMessage issue when send media file
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Describe the bug
Hi,
I have checked the documentation and other examples on internet and I believe that my code is ok. It’s working fine when I try to send a text, but it doesn’t work for media (image).
I have tried to use MessageMedia.fromFilePath and MessageMedia.fromUrl and both return the image ok, but when I send the message nothing happens and there is no error.
Please, could you check if it is a bug or I am missing something?
Thanks in advance
Expected behavior
As a user, I expect to send the message using media files
Steps to Reproduce the Bug or Issue
Execute the code that I have provided with any image file
Relevant Code
client.on('ready', () => {
console.log('READY');
client.getChats().then((chats) => {
client.sendMessage('34664547621@c.us', "test");
//const media = MessageMedia.fromFilePath('coloured-lab-symbol-white.png');
const media = MessageMedia.fromUrl('https://colouredlab.com/assets/coloured-lab-symbol-white.png');
//console.log(media);
client.sendMessage("34664547621@c.us", media, {caption: "image" } );
})
});
Browser Type
Chromium
WhatsApp Account Type
Standard
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
OS: Windows 11 Pro Phone OS: IOS 15.4.1 (I don’t if is relevant, because I am testing using the vscode + node my-code.js that opens a chromium with puppeter) whatsapp-web.js version 1.17.0 WhatsApp Web version 2.2222.11 Node.js Version v14.17.3
Additional context
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:11 (2 by maintainers)
Top GitHub Comments
@remomfurlanetto In my case I had the same problem, and the problem was that for some rason on the final part of my code the
client.destroy();
was executing before that the sendMessage finish the process, and the temporary solution was remove the client.destroy(); line. (put it inside a condition or in a setTime())No, I didn’t. Everything that I tried regarding this functionality didn’t work. The message was never being delivered
On Wed, 21 Sept 2022 at 01:34, andresmv94 @.***> wrote:
– Sent from Gmail Mobile