Closed HysMX closed 1 year ago
Downgraded to 1.0.2 and worked just fine
This is a really weird issue. The diff between 1.0.2..1.0.3 only includes changes for template.ts (ignoring the modified .md files), so your code shouldn't be affected by the update...
I will test your snippet in a few hours and try to find the solution.
Thanks!
I managed to replicate the issue, and to my surprise it's REALLY weird.
Given this snippet:
const image = new Image("https://i.imgur.com/RZ1MmvC.png");
console.log(image);
The obtained output on 1.0.2 is:
{ link: 'https://i.imgur.com/RZ1MmvC.png' }
However, on 1.0.3 (and v2), the terminal logs the following:
{
id: undefined,
link: 'https://i.imgur.com/RZ1MmvC.png',
caption: undefined
}
Which is really annoying, because the library uses the keyword in
to check if the class contains such property. Although undefined, the property is in the object, hence throwing the error as it thinks the image contains a caption.
My only guess for this issue is a breaking dev dependecy update. I will try to find out which one and see if it's intentional or not. IIRC, esbuild had a mid version update, so maybe the issue is there.
This is why people write unit tests :)
Thanks for opening the issue.
I unfortunately found the broken dependecy: esbuild@18
https://github.com/Secreto31126/whatsapp-api-js/pull/166 https://github.com/evanw/esbuild/issues/2993 https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#the-usedefineforclassfields-flag-and-the-declare-property-modifier
There's an easy solution, which would be setting useDefineForClassFields
to true
on tsconfig, but I'm not certain it's the right answer.
Hi, I just published 1.0.4 to npm with a bug fix.
Let me know if it works!
The error persists on 1.0.4 its weird because logging the image object only returns the URL
Image Object
Code:
const image = new Image("https://i.imgur.com/CFpN5kh.png");
console.log(JSON.stringify(image), "imagen 2")
const button = new Interactive(
new ActionButtons(
new Button("button_menu_seller", "Vendedor"),
new Button("button_menu_buyer", "Comprador")
),
new Body(`¡Bienvenido de nuevo ${customer.name}! ¿Qué menu deseas visualizar?`),
new Header(image)
);
await Whatsapp.sendMessage(PHONE_ID as string,message.from, button);
That's unfortunate. Seems like a full update will be necessary. I will do it later today.
Thank you, pibe, where can i send you a tip? 😋 con eso de que el dólar está por las nubes en argentina
Obtener Outlook para iOShttps://aka.ms/o0ukef
De: Tomás Raiti @.> Enviado: Thursday, August 24, 2023 3:57:16 AM Para: Secreto31126/whatsapp-api-js @.> Cc: Omar @.>; Author @.> Asunto: Re: [Secreto31126/whatsapp-api-js] Error sending message: Error: Header image must not have a caption (Issue #198)
That's unfortunate. Seems like a full update will be necessary. I will do it later today.
— Reply to this email directly, view it on GitHubhttps://github.com/Secreto31126/whatsapp-api-js/issues/198#issuecomment-1691460044, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AL63AXP55FVIDHMA7YYLVBLXW4XQZANCNFSM6AAAAAA3TAKV4M. You are receiving this because you authored the thread.Message ID: @.***>
Wow, eso sería increíble. Si realmente creés que vale la pena, podés usar Patreon:
https://patreon.com/Secreto31126
Muchísimas gracias 😁.
(Sí, el dólar es un caos acá 😂)
I just did a full rewrite of the property checks and published to the beta tag (npm i whatsapp-api-js@beta
), let me know if the issue is fixed for you!
Based on my white box tests I believe the issue is fixed, so I will publish to npm and close the issue.
Thanks for reporting!
Describe the bug An error in console while trying to send a broadcast message
To Reproduce Steps to reproduce the behavior:
Expected behavior Send the message with the image header
It was sending the message just fine until i updated the library to the latest version, the code is unmodified