diff --git a/example.js b/example.js index a7dfae1..d5f0e00 100644 --- a/example.js +++ b/example.js @@ -66,10 +66,9 @@ client.on('message', async msg => { } } else if(msg.body.startsWith('!join ')) { const inviteCode = msg.body.split(' ')[1]; - try { - const chat = await client.acceptInvite(inviteCode); - msg.reply(`Joined *${chat.name}*!`); + await client.acceptInvite(inviteCode); + msg.reply('Joined the group!'); } catch(e) { msg.reply('That invite code seems to be invalid.'); } diff --git a/src/Client.js b/src/Client.js index 7eb2770..528d0e0 100644 --- a/src/Client.js +++ b/src/Client.js @@ -239,12 +239,11 @@ class Client extends EventEmitter { * @param {string} inviteCode */ async acceptInvite(inviteCode) { - const chat = await this.pupPage.evaluate(async inviteCode => { - const chatId = await window.Store.Invite.sendJoinGroupViaInvite(inviteCode); - return window.WWebJS.getChat(chatId._serialized); + const chatId = await this.pupPage.evaluate(async inviteCode => { + return await window.Store.Invite.sendJoinGroupViaInvite(inviteCode); }, inviteCode); - return ChatFactory.create(this.client, chat); + return chatId._serialized; } }