WhiskeySockets / Baileys

Lightweight full-featured typescript/javascript WhatsApp Web API
https://baileys.whiskeysockets.io/
MIT License
3.98k stars 1.35k forks source link

[BUG] profilePictureUrl stop working since Jul.03 #909

Closed lauriolasw closed 4 months ago

lauriolasw commented 4 months ago

Describe the bug Starting Jul 03 get the display picture of some person stop working

To Reproduce const ppUrl = await sock.profilePictureUrl("xyz@g.us") # (replace xyz)

Expected behavior Picture profile download

lauriolasw commented 4 months ago

fixed in https://github.com/WhiskeySockets/Baileys/pull/901

dimasmpp130 commented 4 months ago

Now now you don't need to update your baileys version to the latest version example $ npm install @whiskeysockets/baileys@zennn08/Baileys#profile-picture-url

You can take or access profile photos without it saying "BAD REQUEST". There is one way to retrieve or access a profile photo without it not saying "BAD REQUEST"

The first step : You go to your own bot script folder then look for the folder node_modules > @whiskeysockets > baileys > lib > Socket > chats.js

Second step: After finding the folder above that I told you about above, then you look for a function or code in the form of "profilePictureUrl" then replace the previous code with the new code below 👇👇

const profilePictureUrl = async (jid, type = 'preview', timeoutMs) => { var _a; jid = (0, WABinary_1.jidNormalizedUser)(jid); const result = await query({ tag: 'iq', attrs: { target: jid, to: WABinary_1.S_WHATSAPP_NET, type: 'get', xmlns: 'w:profile:picture' }, content: [ { tag: 'picture', attrs: { type, query: 'url' } } ] }, timeoutMs); const child = (0, WABinary_1.getBinaryNodeChild)(result, 'picture'); return (_a = child === null || child === void 0 ? void 0 : child.attrs) === null || _a === void 0 ? void 0 : _a.url; };

After you change it, just save the previous edits and try to see the results, good luck :)

Note: The code or function above can be installed on any Baileys version, whether it's 6.5.0 / 6.6.0 or also 6.4.0 and previous versions, so there's no need to update to the Baileys version like I said above, maybe this might work for you, thank you!!!