From 05f651b5210c191967896ef2f727fa2e9c0d978a Mon Sep 17 00:00:00 2001 From: BenyFilho <168232825+BenyFilho@users.noreply.github.com> Date: Thu, 6 Nov 2025 16:34:53 -0300 Subject: [PATCH] Fix Group setAddMembersAdminsOnly setMessagesAdminsOnly setInfoAdminsOnly (#3933) * Add module to setGroupProperty * Update methods setAddMembersAdminsOnly setMessagesAdmin setInfoAdminsOnlysOnly --------- Co-authored-by: Rajeh Taher --- src/structures/GroupChat.js | 18 +++++++++--------- src/util/Injected/Store.js | 3 ++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/structures/GroupChat.js b/src/structures/GroupChat.js index fd4e16a..95a58c3 100644 --- a/src/structures/GroupChat.js +++ b/src/structures/GroupChat.js @@ -297,12 +297,12 @@ class GroupChat extends Chat { */ async setAddMembersAdminsOnly(adminsOnly=true) { const success = await this.client.pupPage.evaluate(async (groupId, adminsOnly) => { - const chatWid = window.Store.WidFactory.createWid(groupId); + const chat = await window.WWebJS.getChat(groupId, { getAsModel: false }); try { - const response = await window.Store.GroupUtils.setGroupMemberAddMode(chatWid, 'member_add_mode', adminsOnly ? 0 : 1); - return response.name === 'SetMemberAddModeResponseSuccess'; + await window.Store.GroupUtils.setGroupProperty(chat, 'member_add_mode', adminsOnly ? 0 : 1); + return true; } catch (err) { - if(err.name === 'SmaxParsingFailure') return false; + if(err.name === 'ServerStatusCodeError') return false; throw err; } }, this.id._serialized, adminsOnly); @@ -318,9 +318,9 @@ class GroupChat extends Chat { */ async setMessagesAdminsOnly(adminsOnly=true) { const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => { - const chatWid = window.Store.WidFactory.createWid(chatId); + const chat = await window.WWebJS.getChat(chatId, { getAsModel: false }); try { - await window.Store.GroupUtils.setGroupProperty(chatWid, 'announcement', adminsOnly ? 1 : 0); + await window.Store.GroupUtils.setGroupProperty(chat, 'announcement', adminsOnly ? 1 : 0); return true; } catch (err) { if(err.name === 'ServerStatusCodeError') return false; @@ -341,9 +341,9 @@ class GroupChat extends Chat { */ async setInfoAdminsOnly(adminsOnly=true) { const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => { - const chatWid = window.Store.WidFactory.createWid(chatId); + const chat = await window.WWebJS.getChat(chatId, { getAsModel: false }); try { - await window.Store.GroupUtils.setGroupProperty(chatWid, 'restrict', adminsOnly ? 1 : 0); + await window.Store.GroupUtils.setGroupProperty(chat, 'restrict', adminsOnly ? 1 : 0); return true; } catch (err) { if(err.name === 'ServerStatusCodeError') return false; @@ -356,7 +356,7 @@ class GroupChat extends Chat { this.groupMetadata.restrict = adminsOnly; return true; } - + /** * Deletes the group's picture. * @returns {Promise} Returns true if the picture was properly deleted. This can return false if the user does not have the necessary permissions. diff --git a/src/util/Injected/Store.js b/src/util/Injected/Store.js index 6d1a0c8..efeebfb 100644 --- a/src/util/Injected/Store.js +++ b/src/util/Injected/Store.js @@ -139,7 +139,8 @@ exports.ExposeStore = () => { ...window.require('WAWebGroupCreateJob'), ...window.require('WAWebGroupModifyInfoJob'), ...window.require('WAWebExitGroupAction'), - ...window.require('WAWebContactProfilePicThumbBridge') + ...window.require('WAWebContactProfilePicThumbBridge'), + ...window.require('WAWebSetPropertyGroupAction') }; window.Store.GroupParticipants = { ...window.require('WAWebModifyParticipantsGroupAction'),