Webwhatsapp-wrapper: Send Media Messages not working

Created on 30 Jan 2020  路  14Comments  路  Source: mukulhase/WebWhatsapp-Wrapper

When running the following line during send media option

new window.Store.MediaCollection()

the following error occurs

Uncaught TypeError: Cannot read property 'chatParticipantCount' of undefined
at new t (app2.6028db482da470f704f8.js:2)
at :1:1

As a result send media does not work.
Please post a solution on this if someone has already encountered this.

Most helpful comment

When running the following line during send media option

new window.Store.MediaCollection()

the following error occurs

Uncaught TypeError: Cannot read property 'chatParticipantCount' of undefined
at new t (app2.6028db482da470f704f8.js:2)
at :1:1

As a result send media does not work.
Please post a solution on this if someone has already encountered this.

Search for all occurrences of mediaCollection and replace:
var mc = new Store.MediaCollection();
to
var mc = new Store.MediaCollection(chat);

All 14 comments

When running the following line during send media option

new window.Store.MediaCollection()

the following error occurs

Uncaught TypeError: Cannot read property 'chatParticipantCount' of undefined
at new t (app2.6028db482da470f704f8.js:2)
at :1:1

As a result send media does not work.
Please post a solution on this if someone has already encountered this.

Search for all occurrences of mediaCollection and replace:
var mc = new Store.MediaCollection();
to
var mc = new Store.MediaCollection(chat);

Perfect

solved

Thank you @nicolaubrasil

God bless you. Very thanks! @nicolaubrasil

God Bless You :))

@nicolaubrasil, i am also trying to create new group, but i get this error:

command:
WAPI.createGroup('roy1','{someNumberPhone}@c.us')

error:
app2.f48061877e9df2cd6e52.js:2 Uncaught TypeError: Cannot read property 'map' of undefined
at e (app2.f48061877e9df2cd6e52.js:2)
at Object.t.createGroup (app2.f48061877e9df2cd6e52.js:2)
at Object.window.WAPI.createGroup (:185:29)
at :1:6

@roysG to create a new group you need to pass in an array in the second argument - like this WAPI.createGroup('roy1',['[email protected]'])

@fernand0aguilar, i also tried to pass it with array, without success, same error, you can also test it in your side

code:
WAPI.createGroup("group007" ,['[email protected]'])
result:

app2.f48061877e9df2cd6e52.js:2 Uncaught TypeError: Cannot read property 'map' of undefined
at e (app2.f48061877e9df2cd6e52.js:2)
at Object.t.createGroup (app2.f48061877e9df2cd6e52.js:2)
at Object.window.WAPI.createGroup (:186:29)
at :1:6

I'm getting TypeError: window.Store.MediaCollection is not a constructor here now. Seems that MediaCollection has changed and now the autoDiscoverModules is unable to find it.

Was able to fix the issue by clearing all the data.

change this

{ id: "MediaCollection", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.processFiles !== undefined) ? module.default : null },

mc.processFiles([mediaBlob], chat, 1).then(() => {
    var media = mc.models[0];
    media.sendToChat(chat, { caption: caption });
    if (done !== undefined) done(true);
});

to this

{ id: "MediaCollection", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.processAttachments) ? module.default : null },

if (Debug.VERSION === '0.4.613') {
    mc.processAttachments([mediaBlob], chat, 1).then(() => {
        var media = mc.models[0];
        media.sendToChat(chat, {caption: caption});
        if (done !== undefined) done(true);
    });
} else {
        mc.processAttachments([{file: mediaBlob}], chat, 1).then(() => {
        var media = mc.models[0];
        media.sendToChat(chat, {caption: caption});
        if (done !== undefined) done(true);
    });
}

This works! Thanks

Thanks a ton the above

change this

{ id: "MediaCollection", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.processFiles !== undefined) ? module.default : null },

mc.processFiles([mediaBlob], chat, 1).then(() => {
    var media = mc.models[0];
    media.sendToChat(chat, { caption: caption });
    if (done !== undefined) done(true);
});

to this

{ id: "MediaCollection", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.processAttachments) ? module.default : null },

if (Debug.VERSION === '0.4.613') {
    mc.processAttachments([mediaBlob], chat, 1).then(() => {
        var media = mc.models[0];
        media.sendToChat(chat, {caption: caption});
        if (done !== undefined) done(true);
    });
} else {
        mc.processAttachments([{file: mediaBlob}], chat, 1).then(() => {
        var media = mc.models[0];
        media.sendToChat(chat, {caption: caption});
        if (done !== undefined) done(true);
    });
}

this worked.....

var mc = new Store.MediaCollection();
and
var mc = new Store.MediaCollection(chat);
both not working

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NolanWang picture NolanWang  路  5Comments

d2hf picture d2hf  路  6Comments

Zingers-ZA picture Zingers-ZA  路  6Comments

juancrescente picture juancrescente  路  4Comments

wallysonn picture wallysonn  路  3Comments