diff --git a/README.md b/README.md index 31d55ae35..b4c15ec74 100644 --- a/README.md +++ b/README.md @@ -374,6 +374,16 @@ await client console.error('Error when sending: ', erro); //return object error }); + +// Send image file base64 +await client.sendImageFromBase64('000000000000@c.us', base64Image, "name file") + .then((result) => { + console.log('Result: ', result); //return object success + }) + .catch((erro) => { + console.error('Error when sending: ', erro); //return object error + }); + // Send file (venom will take care of mime types, just need the path) // you can also upload an image using a valid HTTP protocol await client @@ -486,8 +496,6 @@ await client.sendVideoAsGif( ); - - // Send seen ✔️✔️ await client.sendSeen('000000000000@c.us'); diff --git a/src/api/layers/sender.layer.ts b/src/api/layers/sender.layer.ts index 64b6706f5..6155ca018 100644 --- a/src/api/layers/sender.layer.ts +++ b/src/api/layers/sender.layer.ts @@ -179,10 +179,10 @@ export class SenderLayer extends ListenerLayer { } /** - * Sends image message + * Sends image message base64 * @param to Chat id * @param base64 File path, http link or base64Encoded - * @param filename + * @param filename * @param caption */ public async sendImageFromBase64( @@ -225,7 +225,7 @@ export class SenderLayer extends ListenerLayer { let mimeType = base64MimeType(base64); if (!mimeType) { - const obj = { + obj = { erro: true, to: to, text: 'Invalid base64!', @@ -251,13 +251,12 @@ export class SenderLayer extends ListenerLayer { { to, base64, filename, caption } ); if (result['erro'] == true) { - reject(result); + return reject(result); } else { - resolve(result); + return resolve(result); } }); } - public async sendMessageOptions( chat: any,