@innovatorssoft/innovators-bot2 1.2.8 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +135 -7
  2. package/example.js +492 -2
  3. package/index.js +516 -0
  4. package/package.json +5 -6
package/README.md CHANGED
@@ -145,6 +145,45 @@ client.on('message-deleted', async (data) => {
145
145
  // Get all groups
146
146
  const groups = await client.getAllGroups()
147
147
 
148
+ // Get group metadata (participants, name, description...)
149
+ const metadata = await client.getGroupMetadata(groupId)
150
+ console.log(metadata.id, metadata.subject, metadata.desc)
151
+
152
+ // Create a new group
153
+ const newGroup = await client.createGroup('Group Name', ['1234567890@s.whatsapp.net'])
154
+ console.log('Created group:', newGroup.id)
155
+
156
+ // Change group subject (name)
157
+ await client.changeGroupSubject(groupId, 'New Group Name')
158
+
159
+ // Change group description
160
+ await client.changeGroupDescription(groupId, 'New description for the group')
161
+
162
+ // Change group settings
163
+ // Options: 'announcement' (only admins send), 'not_announcement' (everyone sends),
164
+ // 'locked' (only admins edit info), 'unlocked' (everyone edits info)
165
+ await client.changeGroupSettings(groupId, 'announcement')
166
+
167
+ // Get group invite code
168
+ const code = await client.getGroupInviteCode(groupId)
169
+ console.log('Invite link: https://chat.whatsapp.com/' + code)
170
+
171
+ // Revoke invite code (generates a new one)
172
+ const newCode = await client.revokeGroupInviteCode(groupId)
173
+ console.log('New invite link: https://chat.whatsapp.com/' + newCode)
174
+
175
+ // Join group by invite code
176
+ const joinedGroupId = await client.joinGroupByInviteCode('AbCdEfGhIjK')
177
+ // Also accepts full URL - it strips the prefix automatically
178
+ await client.joinGroupByInviteCode('https://chat.whatsapp.com/AbCdEfGhIjK')
179
+
180
+ // Get group info by invite code (without joining)
181
+ const groupInfo = await client.getGroupInfoByInviteCode('AbCdEfGhIjK')
182
+ console.log('Group name:', groupInfo.subject)
183
+
184
+ // Leave a group
185
+ await client.leaveGroup(groupId)
186
+
148
187
  // Add participant to group
149
188
  // Note: If adding fails due to user's privacy settings (403),
150
189
  // an invitation link is automatically sent to the user instead.
@@ -165,9 +204,71 @@ await client.changeGroupParticipants(groupId, ['1234567890@s.whatsapp.net'], 'pr
165
204
 
166
205
  // Demote admin
167
206
  await client.changeGroupParticipants(groupId, ['1234567890@s.whatsapp.net'], 'demote')
207
+
208
+ // Get pending join requests
209
+ const requests = await client.getGroupJoinRequests(groupId)
210
+ console.log('Pending requests:', requests)
211
+
212
+ // Approve/Reject join requests
213
+ await client.handleGroupJoinRequest(groupId, ['1234567890@s.whatsapp.net'], 'approve')
214
+ await client.handleGroupJoinRequest(groupId, ['1234567890@s.whatsapp.net'], 'reject')
215
+
216
+ // Toggle ephemeral (disappearing) messages
217
+ // Options: 0 (off), 86400 (24h), 604800 (7d), 7776000 (90d)
218
+ await client.toggleGroupEphemeral(groupId, 86400)
219
+
220
+ // Change who can add members
221
+ // Options: 'all_member_add' or 'admin_add'
222
+ await client.changeGroupAddMode(groupId, 'admin_add')
168
223
  ```
169
224
 
170
- ### 4. Interactive Messages
225
+ ### 6. Privacy Management
226
+
227
+ ```javascript
228
+ // Block a user
229
+ await client.blockUser('1234567890@s.whatsapp.net')
230
+
231
+ // Unblock a user
232
+ await client.unblockUser('1234567890@s.whatsapp.net')
233
+
234
+ // Get all privacy settings
235
+ const settings = await client.getPrivacySettings()
236
+ console.log('Privacy settings:', settings)
237
+
238
+ // Get blocked contacts list
239
+ const blocklist = await client.getBlockList()
240
+ console.log('Blocked users:', blocklist)
241
+
242
+ // Update last seen privacy
243
+ // Options: 'all' | 'contacts' | 'contact_blacklist' | 'none'
244
+ await client.updateLastSeenPrivacy('contacts')
245
+
246
+ // Update online status privacy
247
+ // Options: 'all' | 'match_last_seen'
248
+ await client.updateOnlinePrivacy('match_last_seen')
249
+
250
+ // Update profile picture privacy
251
+ // Options: 'all' | 'contacts' | 'contact_blacklist' | 'none'
252
+ await client.updateProfilePicturePrivacy('contacts')
253
+
254
+ // Update status privacy
255
+ // Options: 'all' | 'contacts' | 'contact_blacklist' | 'none'
256
+ await client.updateStatusPrivacy('contacts')
257
+
258
+ // Update read receipts privacy
259
+ // Options: 'all' | 'none'
260
+ await client.updateReadReceiptsPrivacy('all')
261
+
262
+ // Update who can add you to groups
263
+ // Options: 'all' | 'contacts' | 'contact_blacklist'
264
+ await client.updateGroupsAddPrivacy('contacts')
265
+
266
+ // Update default disappearing mode for new chats
267
+ // Options: 0 (off), 86400 (24h), 604800 (7d), 7776000 (90d)
268
+ await client.updateDefaultDisappearingMode(604800)
269
+ ```
270
+
271
+ ### 7. Interactive Messages
171
272
 
172
273
  #### Buttons
173
274
  ```javascript
@@ -223,7 +324,7 @@ await client.SendList('1234567890@s.whatsapp.net', {
223
324
  });
224
325
  ```
225
326
 
226
- ### 4. Message History
327
+ ### 8. Message History
227
328
 
228
329
  ```javascript
229
330
  // Get chat history
@@ -260,13 +361,16 @@ The library includes example bot commands that you can use:
260
361
  - `!react` - React to your message with ❤️
261
362
  - `!read` - Mark messages as read
262
363
  - `!typing` - Show typing indicator
263
- - `!presence` - Set online presence
364
+ - `!recording` - Show recording indicator
365
+ - `!paused` - Clear typing or recording indicator
264
366
 
265
367
  ### Media & Content
266
368
  - `!media` - Send an example image
267
369
  - `!doc` - Send an example document
268
370
  - `!location` - Send a location
269
371
  - `!contact` - Send a contact card
372
+ - `!sticker` - Create a sticker from an image
373
+ - `!ad` - Send an ad reply message
270
374
 
271
375
  ### Group Management
272
376
  - `!groups` - List all your groups
@@ -274,7 +378,34 @@ The library includes example bot commands that you can use:
274
378
  - `!remove <number>` - Remove participant from group
275
379
  - `!promote <number>` - Promote participant to admin
276
380
  - `!demote <number>` - Demote admin to participant
277
- - `!list` - Show interactive list message
381
+ - `!invite <number>` - Send group invite link to user
382
+ - `!creategroup <name>` - Create a new group
383
+ - `!groupsubject <name>` - Change group name
384
+ - `!groupdesc <text>` - Change group description
385
+ - `!groupsetting <setting>` - Change group settings (announcement/not_announcement/locked/unlocked)
386
+ - `!invitecode` - Get group invite code/link
387
+ - `!revokeinvite` - Revoke current invite code and generate new one
388
+ - `!leavegroup` - Leave the current group
389
+ - `!joingroup <code>` - Join a group by invite code
390
+ - `!groupinfo <code>` - Get group info by invite code without joining
391
+ - `!joinrequests` - List pending join requests
392
+ - `!approvejoin <number>` - Approve a join request
393
+ - `!rejectjoin <number>` - Reject a join request
394
+ - `!ephemeral <seconds>` - Toggle disappearing messages (0/86400/604800/7776000)
395
+ - `!addmode <mode>` - Change who can add members (all_member_add/admin_add)
396
+
397
+ ### 🔒 Privacy
398
+ - `!block <number>` - Block a user
399
+ - `!unblock <number>` - Unblock a user
400
+ - `!privacy` - View all privacy settings
401
+ - `!blocklist` - List all blocked contacts
402
+ - `!lastseenprivacy <value>` - Update last seen privacy (all/contacts/contact_blacklist/none)
403
+ - `!onlineprivacy <value>` - Update online privacy (all/match_last_seen)
404
+ - `!pfpprivacy <value>` - Update profile picture privacy (all/contacts/contact_blacklist/none)
405
+ - `!statusprivacy <value>` - Update status privacy (all/contacts/contact_blacklist/none)
406
+ - `!readreceiptprivacy <value>` - Update read receipts privacy (all/none)
407
+ - `!groupaddprivacy <value>` - Update who can add you to groups (all/contacts/contact_blacklist)
408
+ - `!disappearing <seconds>` - Update default disappearing mode (0/86400/604800/7776000)
278
409
 
279
410
  ### Interactive Messages
280
411
  - `!buttons` - Show interactive buttons
@@ -290,9 +421,6 @@ The library includes example bot commands that you can use:
290
421
  - `!parse <jid>` - Parse detailed JID information
291
422
  - `!normalize <number>` - Normalize a number to JID format
292
423
 
293
- ### 🎨 Sticker Commands
294
- - `!sticker` - Create a sticker from an image
295
-
296
424
  ### Connection Events
297
425
  ```javascript
298
426
  // When QR code is generated
package/example.js CHANGED
@@ -91,7 +91,7 @@ async function start() {
91
91
  console.log('Is Removed:', reaction.isRemoved)
92
92
  console.log('Message ID:', reaction.messageKey.id)
93
93
  })
94
-
94
+
95
95
  client.on('call', (call) => {
96
96
  const callData = call[0]; // Get the first call object from the array
97
97
  if (callData.status !== 'offer') return;
@@ -406,7 +406,34 @@ async function start() {
406
406
  `• !invite <number> - Send group invite link\n` +
407
407
  `• !remove <number> - Remove participant\n` +
408
408
  `• !promote <number> - Make admin\n` +
409
- `• !demote <number> - Remove admin\n\n` +
409
+ `• !demote <number> - Remove admin\n` +
410
+ `• !creategroup <name> - Create a new group\n` +
411
+ `• !groupsubject <name> - Change group name\n` +
412
+ `• !groupdesc <text> - Change group description\n` +
413
+ `• !groupsetting <setting> - Change group settings\n` +
414
+ `• !invitecode - Get group invite code\n` +
415
+ `• !revokeinvite - Revoke group invite code\n` +
416
+ `• !leavegroup - Leave the group\n` +
417
+ `• !joingroup <code> - Join group by invite code\n` +
418
+ `• !groupinfo <code> - Get group info by invite code\n` +
419
+ `• !joinrequests - List pending join requests\n` +
420
+ `• !approvejoin <number> - Approve join request\n` +
421
+ `• !rejectjoin <number> - Reject join request\n` +
422
+ `• !ephemeral <seconds> - Toggle disappearing msgs\n` +
423
+ `• !addmode <mode> - Change who can add members\n\n` +
424
+
425
+ `*🔒 Privacy*\n` +
426
+ `• !block <number> - Block a user\n` +
427
+ `• !unblock <number> - Unblock a user\n` +
428
+ `• !privacy - Get privacy settings\n` +
429
+ `• !blocklist - Get blocked contacts\n` +
430
+ `• !lastseenprivacy <value> - Update last seen\n` +
431
+ `• !onlineprivacy <value> - Update online status\n` +
432
+ `• !pfpprivacy <value> - Update profile pic privacy\n` +
433
+ `• !statusprivacy <value> - Update status privacy\n` +
434
+ `• !readreceiptprivacy <value> - Update read receipts\n` +
435
+ `• !groupaddprivacy <value> - Who can add to groups\n` +
436
+ `• !disappearing <seconds> - Default disappearing mode\n\n` +
410
437
 
411
438
  `*🎛️ Templates & Buttons*\n` +
412
439
  `• !buttons - Button template\n` +
@@ -698,6 +725,469 @@ async function start() {
698
725
  }
699
726
  }
700
727
  break
728
+
729
+ // ═══════════════════════════════════════════════════
730
+ // 📁 GROUP MANAGEMENT COMMANDS
731
+ // ═══════════════════════════════════════════════════
732
+
733
+ case '!creategroup':
734
+ try {
735
+ if (!args) {
736
+ await client.sendMessage(msg.from, '❌ Please provide a group name.\nUsage: !creategroup My New Group');
737
+ break;
738
+ }
739
+ const newGroup = await client.createGroup(args, [msg.sender]);
740
+ await client.sendMessage(msg.from, `✅ Group created!\n\nName: *${args}*\nID: ${newGroup.id || newGroup.gid}`);
741
+ } catch (error) {
742
+ console.error('Error creating group:', error);
743
+ await client.sendMessage(msg.from, `❌ Failed to create group: ${error.message}`);
744
+ }
745
+ break;
746
+
747
+ case '!groupsubject':
748
+ try {
749
+ if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
750
+ await client.sendMessage(msg.from, '❌ This command can only be used in groups');
751
+ break;
752
+ }
753
+ if (!args) {
754
+ await client.sendMessage(msg.from, '❌ Please provide a new group name.\nUsage: !groupsubject New Name');
755
+ break;
756
+ }
757
+ await client.changeGroupSubject(msg.raw.key.remoteJid, args);
758
+ await client.sendMessage(msg.from, `✅ Group name changed to: *${args}*`);
759
+ } catch (error) {
760
+ console.error('Error changing group subject:', error);
761
+ await client.sendMessage(msg.from, `❌ Failed to change group name: ${error.message}`);
762
+ }
763
+ break;
764
+
765
+ case '!groupdesc':
766
+ try {
767
+ if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
768
+ await client.sendMessage(msg.from, '❌ This command can only be used in groups');
769
+ break;
770
+ }
771
+ if (!args) {
772
+ await client.sendMessage(msg.from, '❌ Please provide a new description.\nUsage: !groupdesc New description here');
773
+ break;
774
+ }
775
+ await client.changeGroupDescription(msg.raw.key.remoteJid, args);
776
+ await client.sendMessage(msg.from, `✅ Group description updated!`);
777
+ } catch (error) {
778
+ console.error('Error changing group description:', error);
779
+ await client.sendMessage(msg.from, `❌ Failed to change description: ${error.message}`);
780
+ }
781
+ break;
782
+
783
+ case '!groupsetting':
784
+ try {
785
+ if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
786
+ await client.sendMessage(msg.from, '❌ This command can only be used in groups');
787
+ break;
788
+ }
789
+ if (!args || !['announcement', 'not_announcement', 'locked', 'unlocked'].includes(args.trim())) {
790
+ await client.sendMessage(msg.from,
791
+ `❌ Invalid setting.\n\n` +
792
+ `Usage: !groupsetting <setting>\n\n` +
793
+ `Available settings:\n` +
794
+ `• announcement - Only admins can send messages\n` +
795
+ `• not_announcement - Everyone can send messages\n` +
796
+ `• locked - Only admins can edit group info\n` +
797
+ `• unlocked - Everyone can edit group info`
798
+ );
799
+ break;
800
+ }
801
+ await client.changeGroupSettings(msg.raw.key.remoteJid, args.trim());
802
+ await client.sendMessage(msg.from, `✅ Group setting changed to: *${args.trim()}*`);
803
+ } catch (error) {
804
+ console.error('Error changing group settings:', error);
805
+ await client.sendMessage(msg.from, `❌ Failed to change setting: ${error.message}`);
806
+ }
807
+ break;
808
+
809
+ case '!invitecode':
810
+ try {
811
+ if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
812
+ await client.sendMessage(msg.from, '❌ This command can only be used in groups');
813
+ break;
814
+ }
815
+ const inviteCode = await client.getGroupInviteCode(msg.raw.key.remoteJid);
816
+ await client.sendMessage(msg.from, `✅ Group Invite Link:\nhttps://chat.whatsapp.com/${inviteCode}`);
817
+ } catch (error) {
818
+ console.error('Error getting invite code:', error);
819
+ await client.sendMessage(msg.from, `❌ Failed to get invite code: ${error.message}`);
820
+ }
821
+ break;
822
+
823
+ case '!revokeinvite':
824
+ try {
825
+ if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
826
+ await client.sendMessage(msg.from, '❌ This command can only be used in groups');
827
+ break;
828
+ }
829
+ const newInviteCode = await client.revokeGroupInviteCode(msg.raw.key.remoteJid);
830
+ await client.sendMessage(msg.from, `✅ Invite code revoked!\nNew invite link:\nhttps://chat.whatsapp.com/${newInviteCode}`);
831
+ } catch (error) {
832
+ console.error('Error revoking invite code:', error);
833
+ await client.sendMessage(msg.from, `❌ Failed to revoke invite code: ${error.message}`);
834
+ }
835
+ break;
836
+
837
+ case '!leavegroup':
838
+ try {
839
+ if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
840
+ await client.sendMessage(msg.from, '❌ This command can only be used in groups');
841
+ break;
842
+ }
843
+ await client.sendMessage(msg.from, '👋 Leaving group...');
844
+ await client.leaveGroup(msg.raw.key.remoteJid);
845
+ } catch (error) {
846
+ console.error('Error leaving group:', error);
847
+ await client.sendMessage(msg.from, `❌ Failed to leave group: ${error.message}`);
848
+ }
849
+ break;
850
+
851
+ case '!joingroup':
852
+ try {
853
+ if (!args) {
854
+ await client.sendMessage(msg.from, '❌ Please provide an invite code.\nUsage: !joingroup AbCdEfGhIjK\n(or full link: !joingroup https://chat.whatsapp.com/AbCdEfGhIjK)');
855
+ break;
856
+ }
857
+ const joinedGroupId = await client.joinGroupByInviteCode(args.trim());
858
+ await client.sendMessage(msg.from, `✅ Successfully joined group!\nGroup ID: ${joinedGroupId}`);
859
+ } catch (error) {
860
+ console.error('Error joining group:', error);
861
+ await client.sendMessage(msg.from, `❌ Failed to join group: ${error.message}`);
862
+ }
863
+ break;
864
+
865
+ case '!groupinfo':
866
+ try {
867
+ if (!args) {
868
+ await client.sendMessage(msg.from, '❌ Please provide an invite code.\nUsage: !groupinfo AbCdEfGhIjK');
869
+ break;
870
+ }
871
+ const groupInfoResult = await client.getGroupInfoByInviteCode(args.trim());
872
+ let infoText = `*📋 Group Info*\n\n`;
873
+ infoText += `Name: *${groupInfoResult.subject || 'N/A'}*\n`;
874
+ infoText += `ID: ${groupInfoResult.id || 'N/A'}\n`;
875
+ infoText += `Creator: ${groupInfoResult.owner || 'N/A'}\n`;
876
+ infoText += `Description: ${groupInfoResult.desc || 'No description'}\n`;
877
+ infoText += `Members: ${groupInfoResult.size || groupInfoResult.participants?.length || 'N/A'}\n`;
878
+ infoText += `Created: ${groupInfoResult.creation ? new Date(groupInfoResult.creation * 1000).toLocaleString() : 'N/A'}`;
879
+ await client.sendMessage(msg.from, infoText);
880
+ } catch (error) {
881
+ console.error('Error getting group info:', error);
882
+ await client.sendMessage(msg.from, `❌ Failed to get group info: ${error.message}`);
883
+ }
884
+ break;
885
+
886
+ case '!joinrequests':
887
+ try {
888
+ if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
889
+ await client.sendMessage(msg.from, '❌ This command can only be used in groups');
890
+ break;
891
+ }
892
+ const requests = await client.getGroupJoinRequests(msg.raw.key.remoteJid);
893
+ if (requests && requests.length > 0) {
894
+ let requestList = `*📋 Pending Join Requests (${requests.length}):*\n\n`;
895
+ requests.forEach((req, i) => {
896
+ requestList += `${i + 1}. ${req.jid}\n`;
897
+ if (req.request_time) requestList += ` Requested: ${new Date(req.request_time * 1000).toLocaleString()}\n`;
898
+ });
899
+ requestList += `\nUse !approvejoin or !rejectjoin <number> to respond`;
900
+ await client.sendMessage(msg.from, requestList);
901
+ } else {
902
+ await client.sendMessage(msg.from, '✅ No pending join requests.');
903
+ }
904
+ } catch (error) {
905
+ console.error('Error getting join requests:', error);
906
+ await client.sendMessage(msg.from, `❌ Failed to get join requests: ${error.message}`);
907
+ }
908
+ break;
909
+
910
+ case '!approvejoin':
911
+ try {
912
+ if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
913
+ await client.sendMessage(msg.from, '❌ This command can only be used in groups');
914
+ break;
915
+ }
916
+ const approveNum = args?.replace(/[^0-9]/g, '');
917
+ if (!approveNum || approveNum.length < 10) {
918
+ await client.sendMessage(msg.from, '❌ Please provide a valid phone number.\nUsage: !approvejoin 923001234567');
919
+ break;
920
+ }
921
+ const approveResult = await client.handleGroupJoinRequest(msg.raw.key.remoteJid, [approveNum + '@s.whatsapp.net'], 'approve');
922
+ await client.sendMessage(msg.from, `✅ Join request approved for ${approveNum}`);
923
+ } catch (error) {
924
+ console.error('Error approving join request:', error);
925
+ await client.sendMessage(msg.from, `❌ Failed to approve: ${error.message}`);
926
+ }
927
+ break;
928
+
929
+ case '!rejectjoin':
930
+ try {
931
+ if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
932
+ await client.sendMessage(msg.from, '❌ This command can only be used in groups');
933
+ break;
934
+ }
935
+ const rejectNum = args?.replace(/[^0-9]/g, '');
936
+ if (!rejectNum || rejectNum.length < 10) {
937
+ await client.sendMessage(msg.from, '❌ Please provide a valid phone number.\nUsage: !rejectjoin 923001234567');
938
+ break;
939
+ }
940
+ const rejectResult = await client.handleGroupJoinRequest(msg.raw.key.remoteJid, [rejectNum + '@s.whatsapp.net'], 'reject');
941
+ await client.sendMessage(msg.from, `✅ Join request rejected for ${rejectNum}`);
942
+ } catch (error) {
943
+ console.error('Error rejecting join request:', error);
944
+ await client.sendMessage(msg.from, `❌ Failed to reject: ${error.message}`);
945
+ }
946
+ break;
947
+
948
+ case '!ephemeral':
949
+ try {
950
+ if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
951
+ await client.sendMessage(msg.from, '❌ This command can only be used in groups');
952
+ break;
953
+ }
954
+ const ephemeralSeconds = parseInt(args);
955
+ if (isNaN(ephemeralSeconds)) {
956
+ await client.sendMessage(msg.from,
957
+ `❌ Please provide duration in seconds.\n\n` +
958
+ `Usage: !ephemeral <seconds>\n\n` +
959
+ `Options:\n` +
960
+ `• 0 - Turn off\n` +
961
+ `• 86400 - 24 hours\n` +
962
+ `• 604800 - 7 days\n` +
963
+ `• 7776000 - 90 days`
964
+ );
965
+ break;
966
+ }
967
+ await client.toggleGroupEphemeral(msg.raw.key.remoteJid, ephemeralSeconds);
968
+ const durationText = ephemeralSeconds === 0 ? 'OFF' : `${ephemeralSeconds} seconds`;
969
+ await client.sendMessage(msg.from, `✅ Disappearing messages set to: *${durationText}*`);
970
+ } catch (error) {
971
+ console.error('Error toggling ephemeral:', error);
972
+ await client.sendMessage(msg.from, `❌ Failed to toggle disappearing messages: ${error.message}`);
973
+ }
974
+ break;
975
+
976
+ case '!addmode':
977
+ try {
978
+ if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
979
+ await client.sendMessage(msg.from, '❌ This command can only be used in groups');
980
+ break;
981
+ }
982
+ if (!args || !['all_member_add', 'admin_add'].includes(args.trim())) {
983
+ await client.sendMessage(msg.from,
984
+ `❌ Invalid mode.\n\n` +
985
+ `Usage: !addmode <mode>\n\n` +
986
+ `Options:\n` +
987
+ `• all_member_add - All members can add\n` +
988
+ `• admin_add - Only admins can add`
989
+ );
990
+ break;
991
+ }
992
+ await client.changeGroupAddMode(msg.raw.key.remoteJid, args.trim());
993
+ await client.sendMessage(msg.from, `✅ Group add mode changed to: *${args.trim()}*`);
994
+ } catch (error) {
995
+ console.error('Error changing add mode:', error);
996
+ await client.sendMessage(msg.from, `❌ Failed to change add mode: ${error.message}`);
997
+ }
998
+ break;
999
+
1000
+ // ═══════════════════════════════════════════════════
1001
+ // 🔒 PRIVACY COMMANDS
1002
+ // ═══════════════════════════════════════════════════
1003
+
1004
+ case '!block':
1005
+ try {
1006
+ const blockNum = args?.replace(/[^0-9]/g, '');
1007
+ if (!blockNum || blockNum.length < 10) {
1008
+ await client.sendMessage(msg.from, '❌ Please provide a valid phone number.\nUsage: !block 923001234567');
1009
+ break;
1010
+ }
1011
+ await client.blockUser(blockNum + '@s.whatsapp.net');
1012
+ await client.sendMessage(msg.from, `✅ User ${blockNum} has been blocked.`);
1013
+ } catch (error) {
1014
+ console.error('Error blocking user:', error);
1015
+ await client.sendMessage(msg.from, `❌ Failed to block user: ${error.message}`);
1016
+ }
1017
+ break;
1018
+
1019
+ case '!unblock':
1020
+ try {
1021
+ const unblockNum = args?.replace(/[^0-9]/g, '');
1022
+ if (!unblockNum || unblockNum.length < 10) {
1023
+ await client.sendMessage(msg.from, '❌ Please provide a valid phone number.\nUsage: !unblock 923001234567');
1024
+ break;
1025
+ }
1026
+ await client.unblockUser(unblockNum + '@s.whatsapp.net');
1027
+ await client.sendMessage(msg.from, `✅ User ${unblockNum} has been unblocked.`);
1028
+ } catch (error) {
1029
+ console.error('Error unblocking user:', error);
1030
+ await client.sendMessage(msg.from, `❌ Failed to unblock user: ${error.message}`);
1031
+ }
1032
+ break;
1033
+
1034
+ case '!privacy':
1035
+ try {
1036
+ const privacySettings = await client.getPrivacySettings();
1037
+ let privacyText = `*🔒 Privacy Settings*\n\n`;
1038
+ for (const [key, value] of Object.entries(privacySettings)) {
1039
+ privacyText += `• ${key}: *${value}*\n`;
1040
+ }
1041
+ await client.sendMessage(msg.from, privacyText);
1042
+ } catch (error) {
1043
+ console.error('Error fetching privacy settings:', error);
1044
+ await client.sendMessage(msg.from, `❌ Failed to get privacy settings: ${error.message}`);
1045
+ }
1046
+ break;
1047
+
1048
+ case '!blocklist':
1049
+ try {
1050
+ const blockedList = await client.getBlockList();
1051
+ if (blockedList && blockedList.length > 0) {
1052
+ let blockText = `*🚫 Blocked Contacts (${blockedList.length}):*\n\n`;
1053
+ blockedList.forEach((jid, i) => {
1054
+ blockText += `${i + 1}. ${jid}\n`;
1055
+ });
1056
+ await client.sendMessage(msg.from, blockText);
1057
+ } else {
1058
+ await client.sendMessage(msg.from, '✅ No blocked contacts.');
1059
+ }
1060
+ } catch (error) {
1061
+ console.error('Error fetching block list:', error);
1062
+ await client.sendMessage(msg.from, `❌ Failed to get block list: ${error.message}`);
1063
+ }
1064
+ break;
1065
+
1066
+ case '!lastseenprivacy':
1067
+ try {
1068
+ const lsValues = ['all', 'contacts', 'contact_blacklist', 'none'];
1069
+ if (!args || !lsValues.includes(args.trim())) {
1070
+ await client.sendMessage(msg.from,
1071
+ `❌ Invalid value.\n\nUsage: !lastseenprivacy <value>\n\nOptions: ${lsValues.join(', ')}`
1072
+ );
1073
+ break;
1074
+ }
1075
+ await client.updateLastSeenPrivacy(args.trim());
1076
+ await client.sendMessage(msg.from, `✅ Last seen privacy updated to: *${args.trim()}*`);
1077
+ } catch (error) {
1078
+ console.error('Error updating last seen privacy:', error);
1079
+ await client.sendMessage(msg.from, `❌ Failed to update: ${error.message}`);
1080
+ }
1081
+ break;
1082
+
1083
+ case '!onlineprivacy':
1084
+ try {
1085
+ const onValues = ['all', 'match_last_seen'];
1086
+ if (!args || !onValues.includes(args.trim())) {
1087
+ await client.sendMessage(msg.from,
1088
+ `❌ Invalid value.\n\nUsage: !onlineprivacy <value>\n\nOptions: ${onValues.join(', ')}`
1089
+ );
1090
+ break;
1091
+ }
1092
+ await client.updateOnlinePrivacy(args.trim());
1093
+ await client.sendMessage(msg.from, `✅ Online privacy updated to: *${args.trim()}*`);
1094
+ } catch (error) {
1095
+ console.error('Error updating online privacy:', error);
1096
+ await client.sendMessage(msg.from, `❌ Failed to update: ${error.message}`);
1097
+ }
1098
+ break;
1099
+
1100
+ case '!pfpprivacy':
1101
+ try {
1102
+ const pfpValues = ['all', 'contacts', 'contact_blacklist', 'none'];
1103
+ if (!args || !pfpValues.includes(args.trim())) {
1104
+ await client.sendMessage(msg.from,
1105
+ `❌ Invalid value.\n\nUsage: !pfpprivacy <value>\n\nOptions: ${pfpValues.join(', ')}`
1106
+ );
1107
+ break;
1108
+ }
1109
+ await client.updateProfilePicturePrivacy(args.trim());
1110
+ await client.sendMessage(msg.from, `✅ Profile picture privacy updated to: *${args.trim()}*`);
1111
+ } catch (error) {
1112
+ console.error('Error updating profile picture privacy:', error);
1113
+ await client.sendMessage(msg.from, `❌ Failed to update: ${error.message}`);
1114
+ }
1115
+ break;
1116
+
1117
+ case '!statusprivacy':
1118
+ try {
1119
+ const stValues = ['all', 'contacts', 'contact_blacklist', 'none'];
1120
+ if (!args || !stValues.includes(args.trim())) {
1121
+ await client.sendMessage(msg.from,
1122
+ `❌ Invalid value.\n\nUsage: !statusprivacy <value>\n\nOptions: ${stValues.join(', ')}`
1123
+ );
1124
+ break;
1125
+ }
1126
+ await client.updateStatusPrivacy(args.trim());
1127
+ await client.sendMessage(msg.from, `✅ Status privacy updated to: *${args.trim()}*`);
1128
+ } catch (error) {
1129
+ console.error('Error updating status privacy:', error);
1130
+ await client.sendMessage(msg.from, `❌ Failed to update: ${error.message}`);
1131
+ }
1132
+ break;
1133
+
1134
+ case '!readreceiptprivacy':
1135
+ try {
1136
+ const rrValues = ['all', 'none'];
1137
+ if (!args || !rrValues.includes(args.trim())) {
1138
+ await client.sendMessage(msg.from,
1139
+ `❌ Invalid value.\n\nUsage: !readreceiptprivacy <value>\n\nOptions: ${rrValues.join(', ')}`
1140
+ );
1141
+ break;
1142
+ }
1143
+ await client.updateReadReceiptsPrivacy(args.trim());
1144
+ await client.sendMessage(msg.from, `✅ Read receipts privacy updated to: *${args.trim()}*`);
1145
+ } catch (error) {
1146
+ console.error('Error updating read receipts privacy:', error);
1147
+ await client.sendMessage(msg.from, `❌ Failed to update: ${error.message}`);
1148
+ }
1149
+ break;
1150
+
1151
+ case '!groupaddprivacy':
1152
+ try {
1153
+ const gaValues = ['all', 'contacts', 'contact_blacklist'];
1154
+ if (!args || !gaValues.includes(args.trim())) {
1155
+ await client.sendMessage(msg.from,
1156
+ `❌ Invalid value.\n\nUsage: !groupaddprivacy <value>\n\nOptions: ${gaValues.join(', ')}`
1157
+ );
1158
+ break;
1159
+ }
1160
+ await client.updateGroupsAddPrivacy(args.trim());
1161
+ await client.sendMessage(msg.from, `✅ Groups add privacy updated to: *${args.trim()}*`);
1162
+ } catch (error) {
1163
+ console.error('Error updating groups add privacy:', error);
1164
+ await client.sendMessage(msg.from, `❌ Failed to update: ${error.message}`);
1165
+ }
1166
+ break;
1167
+
1168
+ case '!disappearing':
1169
+ try {
1170
+ const disappearingSeconds = parseInt(args);
1171
+ if (isNaN(disappearingSeconds)) {
1172
+ await client.sendMessage(msg.from,
1173
+ `❌ Please provide duration in seconds.\n\n` +
1174
+ `Usage: !disappearing <seconds>\n\n` +
1175
+ `Options:\n` +
1176
+ `• 0 - Turn off\n` +
1177
+ `• 86400 - 24 hours\n` +
1178
+ `• 604800 - 7 days\n` +
1179
+ `• 7776000 - 90 days`
1180
+ );
1181
+ break;
1182
+ }
1183
+ await client.updateDefaultDisappearingMode(disappearingSeconds);
1184
+ const disappearText = disappearingSeconds === 0 ? 'OFF' : `${disappearingSeconds} seconds`;
1185
+ await client.sendMessage(msg.from, `✅ Default disappearing mode set to: *${disappearText}*`);
1186
+ } catch (error) {
1187
+ console.error('Error updating default disappearing mode:', error);
1188
+ await client.sendMessage(msg.from, `❌ Failed to update: ${error.message}`);
1189
+ }
1190
+ break;
701
1191
  }
702
1192
  })
703
1193
 
package/index.js CHANGED
@@ -1461,6 +1461,522 @@ class WhatsAppClient extends EventEmitter {
1461
1461
  }
1462
1462
  }
1463
1463
 
1464
+ // ═══════════════════════════════════════════════════════════
1465
+ // 📁 GROUP MANAGEMENT METHODS
1466
+ // ═══════════════════════════════════════════════════════════
1467
+
1468
+ /**
1469
+ * Create a new WhatsApp group
1470
+ * @param {string} name - The name/subject of the group
1471
+ * @param {Array<string>} participants - Array of participant JIDs (e.g., ['1234@s.whatsapp.net'])
1472
+ * @returns {Promise<object>} The created group info (includes gid/id)
1473
+ * @throws {Error} If client is not connected or group creation fails
1474
+ */
1475
+ async createGroup(name, participants = []) {
1476
+ if (!this.isConnected) {
1477
+ throw new Error('Client is not connected');
1478
+ }
1479
+
1480
+ try {
1481
+ const group = await this.sock.groupCreate(name, participants);
1482
+ return group;
1483
+ } catch (error) {
1484
+ console.error('Error creating group:', error);
1485
+ throw error;
1486
+ }
1487
+ }
1488
+
1489
+ /**
1490
+ * Change the subject (name) of a group
1491
+ * @param {string} groupId - The group JID
1492
+ * @param {string} newSubject - The new subject/name for the group
1493
+ * @returns {Promise<void>}
1494
+ * @throws {Error} If client is not connected or update fails
1495
+ */
1496
+ async changeGroupSubject(groupId, newSubject) {
1497
+ if (!this.isConnected) {
1498
+ throw new Error('Client is not connected');
1499
+ }
1500
+
1501
+ try {
1502
+ await this.sock.groupUpdateSubject(groupId, newSubject);
1503
+ // Update the cache with the new subject
1504
+ const cached = this.groupMetadataCache.get(groupId);
1505
+ if (cached) {
1506
+ cached.subject = newSubject;
1507
+ this.updateGroupMetadataCache(groupId, cached);
1508
+ }
1509
+ } catch (error) {
1510
+ console.error('Error changing group subject:', error);
1511
+ throw error;
1512
+ }
1513
+ }
1514
+
1515
+ /**
1516
+ * Change the description of a group
1517
+ * @param {string} groupId - The group JID
1518
+ * @param {string} newDescription - The new description for the group
1519
+ * @returns {Promise<void>}
1520
+ * @throws {Error} If client is not connected or update fails
1521
+ */
1522
+ async changeGroupDescription(groupId, newDescription) {
1523
+ if (!this.isConnected) {
1524
+ throw new Error('Client is not connected');
1525
+ }
1526
+
1527
+ try {
1528
+ await this.sock.groupUpdateDescription(groupId, newDescription);
1529
+ // Update the cache with the new description
1530
+ const cached = this.groupMetadataCache.get(groupId);
1531
+ if (cached) {
1532
+ cached.desc = newDescription;
1533
+ this.updateGroupMetadataCache(groupId, cached);
1534
+ }
1535
+ } catch (error) {
1536
+ console.error('Error changing group description:', error);
1537
+ throw error;
1538
+ }
1539
+ }
1540
+
1541
+ /**
1542
+ * Change group settings (announcement mode, locked/unlocked)
1543
+ * @param {string} groupId - The group JID
1544
+ * @param {string} setting - The setting to apply: 'announcement' (only admins send), 'not_announcement' (everyone sends), 'locked' (only admins edit info), 'unlocked' (everyone edits info)
1545
+ * @returns {Promise<void>}
1546
+ * @throws {Error} If client is not connected or update fails
1547
+ */
1548
+ async changeGroupSettings(groupId, setting) {
1549
+ if (!this.isConnected) {
1550
+ throw new Error('Client is not connected');
1551
+ }
1552
+
1553
+ const validSettings = ['announcement', 'not_announcement', 'locked', 'unlocked'];
1554
+ if (!validSettings.includes(setting)) {
1555
+ throw new Error(`Invalid setting: ${setting}. Must be one of: ${validSettings.join(', ')}`);
1556
+ }
1557
+
1558
+ try {
1559
+ await this.sock.groupSettingUpdate(groupId, setting);
1560
+ } catch (error) {
1561
+ console.error('Error changing group settings:', error);
1562
+ throw error;
1563
+ }
1564
+ }
1565
+
1566
+ /**
1567
+ * Get the invite code for a group
1568
+ * @param {string} groupId - The group JID
1569
+ * @returns {Promise<string>} The invite code (use with https://chat.whatsapp.com/{code})
1570
+ * @throws {Error} If client is not connected or fetch fails
1571
+ */
1572
+ async getGroupInviteCode(groupId) {
1573
+ if (!this.isConnected) {
1574
+ throw new Error('Client is not connected');
1575
+ }
1576
+
1577
+ try {
1578
+ const code = await this.sock.groupInviteCode(groupId);
1579
+ return code;
1580
+ } catch (error) {
1581
+ console.error('Error getting group invite code:', error);
1582
+ throw error;
1583
+ }
1584
+ }
1585
+
1586
+ /**
1587
+ * Revoke the current invite code for a group (generates a new one)
1588
+ * @param {string} groupId - The group JID
1589
+ * @returns {Promise<string>} The new invite code
1590
+ * @throws {Error} If client is not connected or revoke fails
1591
+ */
1592
+ async revokeGroupInviteCode(groupId) {
1593
+ if (!this.isConnected) {
1594
+ throw new Error('Client is not connected');
1595
+ }
1596
+
1597
+ try {
1598
+ const newCode = await this.sock.groupRevokeInvite(groupId);
1599
+ return newCode;
1600
+ } catch (error) {
1601
+ console.error('Error revoking group invite code:', error);
1602
+ throw error;
1603
+ }
1604
+ }
1605
+
1606
+ /**
1607
+ * Leave a group
1608
+ * @param {string} groupId - The group JID
1609
+ * @returns {Promise<void>}
1610
+ * @throws {Error} If client is not connected or leave fails
1611
+ */
1612
+ async leaveGroup(groupId) {
1613
+ if (!this.isConnected) {
1614
+ throw new Error('Client is not connected');
1615
+ }
1616
+
1617
+ try {
1618
+ await this.sock.groupLeave(groupId);
1619
+ // Clean up the cache for this group
1620
+ this.clearGroupMetadataCache(groupId);
1621
+ } catch (error) {
1622
+ console.error('Error leaving group:', error);
1623
+ throw error;
1624
+ }
1625
+ }
1626
+
1627
+ /**
1628
+ * Join a group using an invitation code
1629
+ * @param {string} inviteCode - The invite code (without https://chat.whatsapp.com/)
1630
+ * @returns {Promise<string>} The group JID that was joined
1631
+ * @throws {Error} If client is not connected or join fails
1632
+ */
1633
+ async joinGroupByInviteCode(inviteCode) {
1634
+ if (!this.isConnected) {
1635
+ throw new Error('Client is not connected');
1636
+ }
1637
+
1638
+ try {
1639
+ // Strip URL prefix if accidentally included
1640
+ const code = inviteCode.replace('https://chat.whatsapp.com/', '');
1641
+ const response = await this.sock.groupAcceptInvite(code);
1642
+ return response;
1643
+ } catch (error) {
1644
+ console.error('Error joining group by invite code:', error);
1645
+ throw error;
1646
+ }
1647
+ }
1648
+
1649
+ /**
1650
+ * Get group info by invite code (without joining)
1651
+ * @param {string} inviteCode - The invite code (without https://chat.whatsapp.com/)
1652
+ * @returns {Promise<object>} The group information
1653
+ * @throws {Error} If client is not connected or fetch fails
1654
+ */
1655
+
1656
+ async getGroupInfoByInviteCode(inviteCode) {
1657
+ if (!this.isConnected) {
1658
+ throw new Error('Client is not connected');
1659
+ }
1660
+
1661
+ try {
1662
+ // Strip URL prefix if accidentally included
1663
+ const code = inviteCode.replace('https://chat.whatsapp.com/', '');
1664
+ const response = await this.sock.groupGetInviteInfo(code);
1665
+ return response;
1666
+ } catch (error) {
1667
+ console.error('Error getting group info by invite code:', error);
1668
+ throw error;
1669
+ }
1670
+ }
1671
+
1672
+ /**
1673
+ * Get the list of pending join requests for a group
1674
+ * @param {string} groupId - The group JID
1675
+ * @returns {Promise<Array>} Array of pending join requests
1676
+ * @throws {Error} If client is not connected or fetch fails
1677
+ */
1678
+
1679
+ async getGroupJoinRequests(groupId) {
1680
+ if (!this.isConnected) {
1681
+ throw new Error('Client is not connected');
1682
+ }
1683
+
1684
+ try {
1685
+ const response = await this.sock.groupRequestParticipantsList(groupId);
1686
+ return response;
1687
+ } catch (error) {
1688
+ console.error('Error getting group join requests:', error);
1689
+ throw error;
1690
+ }
1691
+ }
1692
+
1693
+ /**
1694
+ * Approve or reject group join requests
1695
+ * @param {string} groupId - The group JID
1696
+ * @param {Array<string>} participantIds - Array of participant JIDs to approve/reject
1697
+ * @param {string} action - 'approve' or 'reject'
1698
+ * @returns {Promise<object>} The response from the action
1699
+ * @throws {Error} If client is not connected or action fails
1700
+ */
1701
+ async handleGroupJoinRequest(groupId, participantIds, action) {
1702
+ if (!this.isConnected) {
1703
+ throw new Error('Client is not connected');
1704
+ }
1705
+
1706
+ const validActions = ['approve', 'reject'];
1707
+ if (!validActions.includes(action)) {
1708
+ throw new Error(`Invalid action: ${action}. Must be one of: ${validActions.join(', ')}`);
1709
+ }
1710
+
1711
+ try {
1712
+ const response = await this.sock.groupRequestParticipantsUpdate(groupId, participantIds, action);
1713
+ return response;
1714
+ } catch (error) {
1715
+ console.error(`Error ${action}ing group join request:`, error);
1716
+ throw error;
1717
+ }
1718
+ }
1719
+
1720
+ /**
1721
+ * Toggle ephemeral (disappearing) messages in a group
1722
+ * @param {string} groupId - The group JID
1723
+ * @param {number} ephemeralExpiration - Duration in seconds (0 = off, 86400 = 24h, 604800 = 7d, 7776000 = 90d)
1724
+ * @returns {Promise<void>}
1725
+ * @throws {Error} If client is not connected or toggle fails
1726
+ */
1727
+ async toggleGroupEphemeral(groupId, ephemeralExpiration) {
1728
+ if (!this.isConnected) {
1729
+ throw new Error('Client is not connected');
1730
+ }
1731
+
1732
+ try {
1733
+ await this.sock.groupToggleEphemeral(groupId, ephemeralExpiration);
1734
+ } catch (error) {
1735
+ console.error('Error toggling group ephemeral:', error);
1736
+ throw error;
1737
+ }
1738
+ }
1739
+
1740
+ /**
1741
+ * Change who can add members to a group
1742
+ * @param {string} groupId - The group JID
1743
+ * @param {string} mode - 'all_member_add' (all members can add) or 'admin_add' (only admins can add)
1744
+ * @returns {Promise<void>}
1745
+ * @throws {Error} If client is not connected or update fails
1746
+ */
1747
+ async changeGroupAddMode(groupId, mode) {
1748
+ if (!this.isConnected) {
1749
+ throw new Error('Client is not connected');
1750
+ }
1751
+
1752
+ const validModes = ['all_member_add', 'admin_add'];
1753
+ if (!validModes.includes(mode)) {
1754
+ throw new Error(`Invalid mode: ${mode}. Must be one of: ${validModes.join(', ')}`);
1755
+ }
1756
+
1757
+ try {
1758
+ await this.sock.groupMemberAddMode(groupId, mode);
1759
+ } catch (error) {
1760
+ console.error('Error changing group add mode:', error);
1761
+ throw error;
1762
+ }
1763
+ }
1764
+
1765
+ // ═══════════════════════════════════════════════════════════
1766
+ // 🔒 PRIVACY METHODS
1767
+ // ═══════════════════════════════════════════════════════════
1768
+
1769
+ /**
1770
+ * Block a user
1771
+ * @param {string} jid - The JID of the user to block
1772
+ * @returns {Promise<void>}
1773
+ * @throws {Error} If client is not connected or block fails
1774
+ */
1775
+ async blockUser(jid) {
1776
+ if (!this.isConnected) {
1777
+ throw new Error('Client is not connected');
1778
+ }
1779
+
1780
+ try {
1781
+ await this.sock.updateBlockStatus(jid, 'block');
1782
+ } catch (error) {
1783
+ console.error('Error blocking user:', error);
1784
+ throw error;
1785
+ }
1786
+ }
1787
+
1788
+ /**
1789
+ * Unblock a user
1790
+ * @param {string} jid - The JID of the user to unblock
1791
+ * @returns {Promise<void>}
1792
+ * @throws {Error} If client is not connected or unblock fails
1793
+ */
1794
+ async unblockUser(jid) {
1795
+ if (!this.isConnected) {
1796
+ throw new Error('Client is not connected');
1797
+ }
1798
+
1799
+ try {
1800
+ await this.sock.updateBlockStatus(jid, 'unblock');
1801
+ } catch (error) {
1802
+ console.error('Error unblocking user:', error);
1803
+ throw error;
1804
+ }
1805
+ }
1806
+
1807
+ /**
1808
+ * Get current privacy settings
1809
+ * @param {boolean} [forceGet=true] - Whether to force-fetch the latest settings
1810
+ * @returns {Promise<object>} The privacy settings object
1811
+ * @throws {Error} If client is not connected or fetch fails
1812
+ */
1813
+ async getPrivacySettings(forceGet = true) {
1814
+ if (!this.isConnected) {
1815
+ throw new Error('Client is not connected');
1816
+ }
1817
+
1818
+ try {
1819
+ const settings = await this.sock.fetchPrivacySettings(forceGet);
1820
+ return settings;
1821
+ } catch (error) {
1822
+ console.error('Error fetching privacy settings:', error);
1823
+ throw error;
1824
+ }
1825
+ }
1826
+
1827
+ /**
1828
+ * Get the list of blocked contacts
1829
+ * @returns {Promise<Array<string>>} Array of blocked JIDs
1830
+ * @throws {Error} If client is not connected or fetch fails
1831
+ */
1832
+ async getBlockList() {
1833
+ if (!this.isConnected) {
1834
+ throw new Error('Client is not connected');
1835
+ }
1836
+
1837
+ try {
1838
+ const blocklist = await this.sock.fetchBlocklist();
1839
+ return blocklist;
1840
+ } catch (error) {
1841
+ console.error('Error fetching block list:', error);
1842
+ throw error;
1843
+ }
1844
+ }
1845
+
1846
+ /**
1847
+ * Update last seen privacy setting
1848
+ * @param {string} value - 'all' | 'contacts' | 'contact_blacklist' | 'none'
1849
+ * @returns {Promise<void>}
1850
+ * @throws {Error} If client is not connected or update fails
1851
+ */
1852
+ async updateLastSeenPrivacy(value) {
1853
+ if (!this.isConnected) {
1854
+ throw new Error('Client is not connected');
1855
+ }
1856
+
1857
+ try {
1858
+ await this.sock.updateLastSeenPrivacy(value);
1859
+ } catch (error) {
1860
+ console.error('Error updating last seen privacy:', error);
1861
+ throw error;
1862
+ }
1863
+ }
1864
+
1865
+ /**
1866
+ * Update online status privacy setting
1867
+ * @param {string} value - 'all' | 'match_last_seen'
1868
+ * @returns {Promise<void>}
1869
+ * @throws {Error} If client is not connected or update fails
1870
+ */
1871
+ async updateOnlinePrivacy(value) {
1872
+ if (!this.isConnected) {
1873
+ throw new Error('Client is not connected');
1874
+ }
1875
+
1876
+ try {
1877
+ await this.sock.updateOnlinePrivacy(value);
1878
+ } catch (error) {
1879
+ console.error('Error updating online privacy:', error);
1880
+ throw error;
1881
+ }
1882
+ }
1883
+
1884
+ /**
1885
+ * Update profile picture privacy setting
1886
+ * @param {string} value - 'all' | 'contacts' | 'contact_blacklist' | 'none'
1887
+ * @returns {Promise<void>}
1888
+ * @throws {Error} If client is not connected or update fails
1889
+ */
1890
+ async updateProfilePicturePrivacy(value) {
1891
+ if (!this.isConnected) {
1892
+ throw new Error('Client is not connected');
1893
+ }
1894
+
1895
+ try {
1896
+ await this.sock.updateProfilePicturePrivacy(value);
1897
+ } catch (error) {
1898
+ console.error('Error updating profile picture privacy:', error);
1899
+ throw error;
1900
+ }
1901
+ }
1902
+
1903
+ /**
1904
+ * Update status privacy setting
1905
+ * @param {string} value - 'all' | 'contacts' | 'contact_blacklist' | 'none'
1906
+ * @returns {Promise<void>}
1907
+ * @throws {Error} If client is not connected or update fails
1908
+ */
1909
+ async updateStatusPrivacy(value) {
1910
+ if (!this.isConnected) {
1911
+ throw new Error('Client is not connected');
1912
+ }
1913
+
1914
+ try {
1915
+ await this.sock.updateStatusPrivacy(value);
1916
+ } catch (error) {
1917
+ console.error('Error updating status privacy:', error);
1918
+ throw error;
1919
+ }
1920
+ }
1921
+
1922
+ /**
1923
+ * Update read receipts privacy setting
1924
+ * @param {string} value - 'all' | 'none'
1925
+ * @returns {Promise<void>}
1926
+ * @throws {Error} If client is not connected or update fails
1927
+ */
1928
+
1929
+ async updateReadReceiptsPrivacy(value) {
1930
+ if (!this.isConnected) {
1931
+ throw new Error('Client is not connected');
1932
+ }
1933
+
1934
+ try {
1935
+ await this.sock.updateReadReceiptsPrivacy(value);
1936
+ } catch (error) {
1937
+ console.error('Error updating read receipts privacy:', error);
1938
+ throw error;
1939
+ }
1940
+ }
1941
+
1942
+ /**
1943
+ * Update groups add privacy setting (who can add you to groups)
1944
+ * @param {string} value - 'all' | 'contacts' | 'contact_blacklist'
1945
+ * @returns {Promise<void>}
1946
+ * @throws {Error} If client is not connected or update fails
1947
+ */
1948
+
1949
+ async updateGroupsAddPrivacy(value) {
1950
+ if (!this.isConnected) {
1951
+ throw new Error('Client is not connected');
1952
+ }
1953
+ try {
1954
+ await this.sock.updateGroupsAddPrivacy(value);
1955
+ } catch (error) {
1956
+ console.error('Error updating groups add privacy:', error);
1957
+ throw error;
1958
+ }
1959
+ }
1960
+
1961
+ /**
1962
+ * Update default disappearing mode for new chats
1963
+ * @param {number} duration - Duration in seconds (0 = off, 86400 = 24h, 604800 = 7d, 7776000 = 90d)
1964
+ * @returns {Promise<void>}
1965
+ * @throws {Error} If client is not connected or update fails
1966
+ */
1967
+
1968
+ async updateDefaultDisappearingMode(duration) {
1969
+ if (!this.isConnected) {
1970
+ throw new Error('Client is not connected');
1971
+ }
1972
+ try {
1973
+ await this.sock.updateDefaultDisappearingMode(duration);
1974
+ } catch (error) {
1975
+ console.error('Error updating default disappearing mode:', error);
1976
+ throw error;
1977
+ }
1978
+ }
1979
+
1464
1980
  /**
1465
1981
  * Add EXIF metadata to an existing WebP buffer
1466
1982
  * @param {Buffer} buffer - WebP buffer
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@innovatorssoft/innovators-bot2",
3
- "version": "1.2.8",
4
- "description": "",
3
+ "version": "2.0.1",
4
+ "description": "WhatsApp API",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "start": "node example.js",
8
- "publish-dual": "node publish-dual.js"
8
+ "publish:all": "node publish-dual.js"
9
9
  },
10
10
  "keywords": [
11
11
  "whatsapp",
@@ -22,16 +22,15 @@
22
22
  "client"
23
23
  ],
24
24
  "author": "Javed Arshad Bhatti",
25
- "license": "ISC",
25
+ "license": "MIT",
26
26
  "repository": {
27
27
  "type": "git",
28
28
  "url": "git+https://github.com/innovatorssoft/WhatsAppAPI.git"
29
29
  },
30
30
  "homepage": "https://github.com/innovatorssoft/WhatsAppAPI?tab=readme-ov-file#whatsapp-api",
31
31
  "dependencies": {
32
- "@innovatorssoft/baileys": "^7.3.5",
32
+ "@innovatorssoft/baileys": "^7.4.0",
33
33
  "figlet": "^1.8.0",
34
- "link-preview-js": "^3.0.13",
35
34
  "mime": "^3.0.0",
36
35
  "mime-types": "^2.1.35",
37
36
  "node-cache": "^5.1.2",