innovators-bot2 2.0.4 → 2.0.6

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.
package/example.js CHANGED
@@ -1,4 +1,4 @@
1
- const { WhatsAppClient } = require('./index')
1
+ const { WhatsAppClient, STATUS_BACKGROUNDS, STATUS_FONTS } = require('./index')
2
2
  const qrcode = require('qrcode-terminal')
3
3
  const fs = require('fs');
4
4
  const readline = require('readline');
@@ -9,6 +9,10 @@ const rl = readline.createInterface({
9
9
  output: process.stdout
10
10
  });
11
11
 
12
+ String.prototype.toTitleCase = function () {
13
+ return this.split(' ').map(w => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(' ');
14
+ };
15
+
12
16
  const question = (text) => new Promise((resolve) => rl.question(text, resolve));
13
17
 
14
18
  async function start() {
@@ -177,10 +181,22 @@ async function start() {
177
181
  return
178
182
  }
179
183
 
184
+
180
185
  console.log('Message Received');
181
- console.log('Number:', msg.from);
182
- console.log('Sender:', msg.raw.pushName);
186
+
187
+
188
+ isGroupMsg = msg.isGroup
189
+ if (isGroupMsg) {
190
+ msgFrom = msg.from
191
+ } else {
192
+ msgFrom = msg.sender
193
+ }
194
+
195
+ console.log('Msg From:', msg.from);
196
+ console.log('Msg Sender:', msg.sender);
197
+ console.log('Sender Name:', msg.raw.pushName);
183
198
  console.log('Message:', msg.body);
199
+ console.log('Is Group:', msg.isGroup);
184
200
  // Mark the message as read
185
201
  await client.readMessage(msg.raw.key)
186
202
 
@@ -189,32 +205,40 @@ async function start() {
189
205
 
190
206
  switch (command) {
191
207
  case '!ping':
192
- await client.sendMessage(msg.from, 'pong')
208
+ await client.sendMessage(msgFrom, 'Hello Pong! šŸŽŠ')
193
209
  break
194
-
195
210
  case '!echo':
196
211
  if (args) {
197
- await client.sendMessage(msg.from, args)
212
+ await client.sendMessage(msgFrom, args)
198
213
  } else {
199
- await client.sendMessage(msg.from, 'Please provide text to echo')
214
+ await client.sendMessage(msgFrom, 'Please provide text to echo')
200
215
  }
201
216
  break
202
-
203
217
  case '!mention':
204
- const number = msg.from.split('@')[0]
205
- await client.sendMessage(msg.from, {
218
+ const number = msg.sender.split('@')[0]
219
+ await client.sendMessage(msgFrom, {
206
220
  type: 'text',
207
221
  text: `Hey @${number}! How are you?`,
208
- mentions: [msg.from]
222
+ mentions: [number]
223
+ })
224
+ break
225
+ case '!mentionall':
226
+ if (!isGroupMsg) {
227
+ await client.sendMessage(msgFrom, 'This command is only for groups')
228
+ return
229
+ }
230
+ await client.sendMessage(msgFrom, {
231
+ type: 'text',
232
+ text: `Hey @all! How are you?`,
233
+ mentions: ['@all']
209
234
  })
210
235
  break
211
-
212
236
  case '!reply':
213
237
  await msg.reply('This is a reply message')
214
238
  break
215
239
 
216
240
  case '!location':
217
- await client.sendMessage(msg.from, {
241
+ await client.sendMessage(msgFrom, {
218
242
  type: 'location',
219
243
  latitude: 24.121231,
220
244
  longitude: 55.1121221
@@ -222,7 +246,7 @@ async function start() {
222
246
  break
223
247
 
224
248
  case '!contact':
225
- await client.sendMessage(msg.from, {
249
+ await client.sendMessage(msgFrom, {
226
250
  type: 'contact',
227
251
  fullName: 'John Doe',
228
252
  organization: 'Example Corp',
@@ -232,7 +256,7 @@ async function start() {
232
256
 
233
257
  case '!react':
234
258
  await client.sendMessage(
235
- msg.from,
259
+ msgFrom,
236
260
  {
237
261
  type: 'reaction',
238
262
  emoji: 'šŸ’–',
@@ -242,24 +266,24 @@ async function start() {
242
266
  break
243
267
  case '!media':
244
268
  if (fs.existsSync('./example.jpg')) {
245
- await client.sendMedia(msg.from, './example.jpg', {
269
+ await client.sendMedia(msgFrom, './example.jpg', {
246
270
  caption: 'Check out this image!'
247
271
  })
248
272
  } else {
249
- await client.sendMessage(msg.from, 'Example image not found')
273
+ await client.sendMessage(msgFrom, 'Example image not found')
250
274
  }
251
275
  break
252
276
 
253
277
  case '!doc':
254
278
  if (fs.existsSync('./example.pdf')) {
255
- await client.sendDocument(msg.from, './example.pdf', 'Check out this document!')
279
+ await client.sendDocument(msgFrom, './example.pdf', 'Check out this document!')
256
280
  } else {
257
- await client.sendMessage(msg.from, 'Example document not found')
281
+ await client.sendMessage(msgFrom, 'Example document not found')
258
282
  }
259
283
  break
260
284
 
261
285
  case '!list':
262
- await client.SendList(msg.from, {
286
+ await client.SendList(msgFrom, {
263
287
  text: 'Please select an option from the list below:',
264
288
  title: 'Comprehensive Menu',
265
289
  buttonText: 'View All Options',
@@ -294,7 +318,7 @@ async function start() {
294
318
  break
295
319
  case '!buttons':
296
320
  // Example: Send a text interactive message (modern Baileys format)
297
- await client.sendButtons(msg.from, {
321
+ await client.sendButtons(msgFrom, {
298
322
  text: 'Do you like this bot?',
299
323
  title: 'Feedback',
300
324
  subtitle: 'Let us know!',
@@ -319,7 +343,7 @@ async function start() {
319
343
 
320
344
  // Example: Send an image interactive message (modern Baileys format)
321
345
 
322
- await client.sendButtons(msg.from, {
346
+ await client.sendButtons(msgFrom, {
323
347
  imagePath: './example.jpg',
324
348
  caption: 'here is captions of image\nwith linebreaks', // Keep it short and concise
325
349
  title: 'Image Title', // Max 24 chars
@@ -367,17 +391,154 @@ async function start() {
367
391
  });
368
392
  break
369
393
 
394
+ case '!quickreplyv2':
395
+ await client.sendQuickReplyV2(msgFrom, 'Please select an option below:', [
396
+ { id: 'btn-1', displayText: 'āœ… Accept' },
397
+ { id: 'btn-2', displayText: 'āŒ Reject' },
398
+ { id: 'btn-3', displayText: 'šŸ“ž Contact Support' }
399
+ ], { footer: 'Powered by Innovators Soft' });
400
+ break
401
+
402
+ case '!urlbuttonv2':
403
+ await client.sendUrlButtonV2(msgFrom, 'Visit our website for more info', [
404
+ { displayText: '🌐 Open Website', url: 'https://example.com' }
405
+ ], { title: 'Product Info', footer: 'Click to open' });
406
+ break
407
+
408
+ case '!copycodev2':
409
+ await client.sendCopyCodeV2(msgFrom, 'Your OTP Code is:', '123456', 'šŸ“‹ Copy Code');
410
+ break
411
+
412
+ case '!combinedv2':
413
+ await client.sendCombinedButtonsV2(msgFrom, 'Choose an action:', [
414
+ { type: 'reply', displayText: 'šŸ›’ Order Now', id: 'order' },
415
+ { type: 'url', displayText: '🌐 Website', url: 'https://example.com' },
416
+ { type: 'call', displayText: 'šŸ“ž Phone', phoneNumber: '+923224559543' },
417
+ { type: 'copy', displayText: 'šŸ“‹ Copy Promo', copyCode: 'PROMO2024' }
418
+ ], { title: 'Main Menu', footer: 'Innovators Soft' });
419
+ break
420
+
421
+ case '!listv2':
422
+ await client.sendListV2(msgFrom, {
423
+ title: 'šŸ“‹ Product Menu',
424
+ buttonText: 'View Menu',
425
+ description: 'Please select a product',
426
+ footer: 'Powered by Innovators Soft',
427
+ sections: [
428
+ {
429
+ title: 'Food',
430
+ rows: [
431
+ { rowId: 'nasi-goreng', title: 'Fried Rice', description: '$2.50' },
432
+ { rowId: 'mie-goreng', title: 'Fried Noodles', description: '$2.00' }
433
+ ]
434
+ },
435
+ {
436
+ title: 'Beverages',
437
+ rows: [
438
+ { rowId: 'es-teh', title: 'Ice Tea', description: '$0.50' },
439
+ { rowId: 'kopi', title: 'Coffee', description: '$1.00' }
440
+ ]
441
+ }
442
+ ]
443
+ });
444
+ break
445
+
446
+ case '!cards':
447
+ if (fs.existsSync('./example.jpg')) {
448
+ const imageBuffer = fs.readFileSync('./example.jpg');
449
+ const videoBuffer = fs.readFileSync('./example.mp4');
450
+
451
+ await client.sendcards(msgFrom, {
452
+ text: 'Body Message',
453
+ title: 'Title Message',
454
+ subtile: 'Subtitle Message',
455
+ footer: 'Footer Message',
456
+ cards: [
457
+ {
458
+ image: imageBuffer, // use local buffer
459
+ title: 'Title Cards 1',
460
+ body: 'Body Cards 1',
461
+ footer: 'Footer Cards 1',
462
+ buttons: [
463
+ {
464
+ name: 'quick_reply',
465
+ buttonParamsJson: JSON.stringify({
466
+ display_text: 'Display Button',
467
+ id: 'ID'
468
+ })
469
+ },
470
+ {
471
+ name: 'cta_url',
472
+ buttonParamsJson: JSON.stringify({
473
+ display_text: 'Display Button',
474
+ url: 'https://www.example.com'
475
+ })
476
+ }
477
+ ]
478
+ },
479
+ {
480
+ video: { url: 'https://files.inqscribe.com/samples/IS_Intro.mp4' },//videoBuffer, // use same local buffer for second card
481
+ title: 'Title Cards 2',
482
+ body: 'Body Cards 2',
483
+ footer: 'Video URL',
484
+ buttons: [
485
+ {
486
+ name: 'quick_reply',
487
+ buttonParamsJson: JSON.stringify({
488
+ display_text: 'Display Button',
489
+ id: 'ID2'
490
+ })
491
+ },
492
+ {
493
+ name: 'cta_url',
494
+ buttonParamsJson: JSON.stringify({
495
+ display_text: 'Display Button',
496
+ url: 'https://www.example.com'
497
+ })
498
+ }
499
+ ]
500
+ },
501
+ {
502
+ video: videoBuffer, // use same local buffer for second card
503
+ title: 'Title Cards 3',
504
+ body: 'Body Cards 3',
505
+ footer: 'Video Buffer',
506
+ buttons: [
507
+ {
508
+ name: 'quick_reply',
509
+ buttonParamsJson: JSON.stringify({
510
+ display_text: 'Display Button',
511
+ id: 'ID3'
512
+ })
513
+ },
514
+ {
515
+ name: 'cta_url',
516
+ buttonParamsJson: JSON.stringify({
517
+ display_text: 'Display Button',
518
+ url: 'https://www.example.com'
519
+ })
520
+ }
521
+ ]
522
+ }
523
+ ]
524
+ });
525
+ } else {
526
+ await client.sendMessage(msgFrom, 'Example image (example.jpg) not found for cards demonstration.');
527
+ }
528
+ break
529
+
530
+
370
531
  case '!call':
371
532
  try {
372
533
  if (autoCancelCallTimer) {
373
534
  clearTimeout(autoCancelCallTimer);
374
535
  autoCancelCallTimer = null;
375
536
  }
376
- const result = await client.initiateCall(msg.from);
537
+ const result = await client.initiateCall(msgFrom);
377
538
  lastOutgoingCallId = result?.callId || null;
378
- lastOutgoingCallJid = msg.from;
379
-
380
- await client.sendMessage(msg.from, `Calling... CallId: ${lastOutgoingCallId || 'unknown'}`);
539
+ lastOutgoingCallJid = msgFrom;
540
+
541
+ await client.sendMessage(msgFrom, `Calling... CallId: ${lastOutgoingCallId || 'unknown'}`);
381
542
 
382
543
  if (lastOutgoingCallId) {
383
544
  autoCancelCallTimer = setTimeout(async () => {
@@ -394,7 +555,7 @@ async function start() {
394
555
  }
395
556
  } catch (error) {
396
557
  console.error('Error initiating voice call:', error);
397
- await client.sendMessage(msg.from, 'Failed to initiate call');
558
+ await client.sendMessage(msgFrom, 'Failed to initiate call');
398
559
  }
399
560
  break
400
561
 
@@ -404,10 +565,10 @@ async function start() {
404
565
  clearTimeout(autoCancelCallTimer);
405
566
  autoCancelCallTimer = null;
406
567
  }
407
- const result = await client.initiateCall(msg.from, { isVideo: true });
568
+ const result = await client.initiateCall(msgFrom, { isVideo: true });
408
569
  lastOutgoingCallId = result?.callId || null;
409
- lastOutgoingCallJid = msg.from;
410
- await client.sendMessage(msg.from, `Video calling... CallId: ${lastOutgoingCallId || 'unknown'}`);
570
+ lastOutgoingCallJid = msgFrom;
571
+ await client.sendMessage(msgFrom, `Video calling... CallId: ${lastOutgoingCallId || 'unknown'}`);
411
572
 
412
573
  if (lastOutgoingCallId) {
413
574
  autoCancelCallTimer = setTimeout(async () => {
@@ -424,7 +585,7 @@ async function start() {
424
585
  }
425
586
  } catch (error) {
426
587
  console.error('Error initiating video call:', error);
427
- await client.sendMessage(msg.from, 'Failed to initiate video call');
588
+ await client.sendMessage(msgFrom, 'Failed to initiate video call');
428
589
  }
429
590
  break
430
591
 
@@ -435,16 +596,16 @@ async function start() {
435
596
  autoCancelCallTimer = null;
436
597
  }
437
598
  if (!lastOutgoingCallId) {
438
- await client.sendMessage(msg.from, 'No outgoing call to cancel');
599
+ await client.sendMessage(msgFrom, 'No outgoing call to cancel');
439
600
  break;
440
601
  }
441
- await client.cancelCall(lastOutgoingCallId, msg.from);
442
- await client.sendMessage(msg.from, `Canceled call: ${lastOutgoingCallId}`);
602
+ await client.cancelCall(lastOutgoingCallId, msgFrom);
603
+ await client.sendMessage(msgFrom, `Canceled call: ${lastOutgoingCallId}`);
443
604
  lastOutgoingCallId = null;
444
605
  lastOutgoingCallJid = null;
445
606
  } catch (error) {
446
607
  console.error('Error canceling call:', error);
447
- await client.sendMessage(msg.from, 'Failed to cancel call');
608
+ await client.sendMessage(msgFrom, 'Failed to cancel call');
448
609
  }
449
610
  break
450
611
 
@@ -501,11 +662,26 @@ async function start() {
501
662
  `• !statusprivacy <value> - Update status privacy\n` +
502
663
  `• !readreceiptprivacy <value> - Update read receipts\n` +
503
664
  `• !groupaddprivacy <value> - Who can add to groups\n` +
504
- `• !disappearing <seconds> - Default disappearing mode\n\n` +
665
+ `• !disappearing <seconds> - Default disappearing mode\n` +
666
+ `• !updatestatus <text> - Update profile status\n` +
667
+ `• !updatename <text> - Update profile name\n\n` +
505
668
 
506
669
  `*šŸŽ›ļø Templates & Buttons*\n` +
507
670
  `• !buttons - Button template\n` +
508
671
  `• !list - Scrollable list\n\n` +
672
+ `• !quickreplyv2 - Quick reply buttons V2\n` +
673
+ `• !urlbuttonv2 - URL button V2\n` +
674
+ `• !copycodev2 - Copy code button V2\n` +
675
+ `• !combinedv2 - Mixed buttons V2\n` +
676
+ `• !listv2 - Interactive list V2\n` +
677
+ `• !cards - Interactive cards message\n\n` +
678
+
679
+ `*🟢 Status*\n` +
680
+ `• !statustext - Post a text status\n` +
681
+ `• !statusimage - Post an image status\n` +
682
+ `• !statusvideo - Post a video status\n` +
683
+ `• !statusvoice - Post a voice note status\n` +
684
+ `• !groupstatus - Post a status directly inside a group (@g.us)\n\n` +
509
685
 
510
686
  `*šŸ“ž Calls*\n` +
511
687
  `• !call - Initiate a voice call\n` +
@@ -532,10 +708,14 @@ async function start() {
532
708
  `• !typing - Show typing indicator\n` +
533
709
  `• !recording - Show recording indicator\n` +
534
710
  `• !paused - Clear typing or recording indicator\n` +
711
+ `• !typing_simulate - Simulate typing for 5s then send msg\n` +
712
+ `• !typing_start - Start typing with auto-pause\n` +
713
+ `• !typing_stop - Stop typing indicator\n` +
714
+ `• !recording_start - Start recording indicator\n` +
535
715
  `• !logout - End session\n\n` +
536
716
 
537
717
  `*šŸ“ Note*:\nReplace <number> with phone number\n(without + or spaces)`
538
- await client.sendMessage(msg.from, help)
718
+ await client.sendMessage(msgFrom, help)
539
719
  break
540
720
 
541
721
  case '!groups':
@@ -551,13 +731,13 @@ async function start() {
551
731
  if (group.desc) groupList += ` Description: ${group.desc}\n`
552
732
  groupList += '\n'
553
733
  })
554
- await client.sendMessage(msg.from, groupList)
734
+ await client.sendMessage(msgFrom, groupList)
555
735
  } else {
556
- await client.sendMessage(msg.from, 'You are not in any groups')
736
+ await client.sendMessage(msgFrom, 'You are not in any groups')
557
737
  }
558
738
  } catch (error) {
559
739
  console.error('Error fetching groups:', error)
560
- await client.sendMessage(msg.from, 'Failed to fetch groups')
740
+ await client.sendMessage(msgFrom, 'Failed to fetch groups')
561
741
  }
562
742
  break
563
743
 
@@ -566,7 +746,7 @@ async function start() {
566
746
  // Use provided group JID or current group
567
747
  const groupJid = args.trim() || msg.raw.key.remoteJid
568
748
  if (!groupJid || !groupJid.endsWith('@g.us')) {
569
- await client.sendMessage(msg.from, 'āŒ Please provide a group JID or use this command in a group.\nUsage: !groupinfo <groupJid>')
749
+ await client.sendMessage(msgFrom, 'āŒ Please provide a group JID or use this command in a group.\nUsage: !groupinfo <groupJid>')
570
750
  break
571
751
  }
572
752
  const groupInfo = await client.getGroupMetadata(groupJid)
@@ -591,18 +771,18 @@ async function start() {
591
771
  groupList += '\n'
592
772
  })
593
773
 
594
- await client.sendMessage(msg.from, groupList)
774
+ await client.sendMessage(msgFrom, groupList)
595
775
  } else {
596
- await client.sendMessage(msg.from, 'Group not found')
776
+ await client.sendMessage(msgFrom, 'Group not found')
597
777
  }
598
778
  } catch (error) {
599
779
  console.error('Error fetching group info:', error)
600
- await client.sendMessage(msg.from, 'Failed to fetch group info')
780
+ await client.sendMessage(msgFrom, 'Failed to fetch group info')
601
781
  }
602
782
  break
603
783
  case '!logout':
604
784
  // Ask for confirmation before logging out
605
- await client.sendButtons(msg.from, {
785
+ await client.sendButtons(msgFrom, {
606
786
  text: 'Are you sure you want to logout?',
607
787
  title: 'Logout Confirmation',
608
788
  footer: 'Choose Yes to logout or No to cancel',
@@ -629,26 +809,26 @@ async function start() {
629
809
  case 'yes':
630
810
  case 'logout_yes':
631
811
 
632
- await client.sendMessage(msg.from, 'You have been logged out.');
812
+ await client.sendMessage(msgFrom, 'You have been logged out.');
633
813
  await client.logout();
634
814
  break;
635
815
  case 'No':
636
816
  case 'no':
637
817
  case 'logout_no':
638
- await client.sendMessage(msg.from, 'Logout cancelled.');
818
+ await client.sendMessage(msgFrom, 'Logout cancelled.');
639
819
  break;
640
820
  case '!lid':
641
821
  // Get LID for the user's phone number
642
822
  try {
643
- const lid = await client.getLIDForPN(msg.from);
823
+ const lid = await client.getLIDForPN(msgFrom);
644
824
  if (lid) {
645
- await client.sendMessage(msg.from, `Your LID: ${lid}\nYour PN: ${msg.from}`);
825
+ await client.sendMessage(msgFrom, `Your LID: ${lid}\nYour PN: ${msgFrom}`);
646
826
  } else {
647
- await client.sendMessage(msg.from, `No LID found for ${msg.from}. You might be using a PN-only session.`);
827
+ await client.sendMessage(msgFrom, `No LID found for ${msgFrom}. You might be using a PN-only session.`);
648
828
  }
649
829
  } catch (error) {
650
830
  console.error('Error getting LID:', error);
651
- await client.sendMessage(msg.from, 'Failed to get LID.');
831
+ await client.sendMessage(msgFrom, 'Failed to get LID.');
652
832
  }
653
833
  break;
654
834
 
@@ -657,23 +837,23 @@ async function start() {
657
837
  try {
658
838
  const lidToCheck = args.trim();
659
839
  if (!lidToCheck) {
660
- await client.sendMessage(msg.from, 'Please provide a LID. Example: !pn 123456@lid');
840
+ await client.sendMessage(msgFrom, 'Please provide a LID. Example: !pn 123456@lid');
661
841
  break;
662
842
  }
663
843
  const pn = await client.getPNForLID(lidToCheck);
664
844
  if (pn) {
665
- await client.sendMessage(msg.from, `Phone Number for ${lidToCheck}: ${pn}`);
845
+ await client.sendMessage(msgFrom, `Phone Number for ${lidToCheck}: ${pn}`);
666
846
  } else {
667
- await client.sendMessage(msg.from, `No phone number found for LID: ${lidToCheck}`);
847
+ await client.sendMessage(msgFrom, `No phone number found for LID: ${lidToCheck}`);
668
848
  }
669
849
  } catch (error) {
670
850
  console.error('Error getting PN from LID:', error);
671
- await client.sendMessage(msg.from, 'Failed to get phone number.');
851
+ await client.sendMessage(msgFrom, 'Failed to get phone number.');
672
852
  }
673
853
  break;
674
854
  case '!ad':
675
855
  await client.sendAdReply(
676
- msg.from,
856
+ msgFrom,
677
857
  'Ad Message',
678
858
  './example.jpg',
679
859
  'Ad Title',
@@ -686,48 +866,82 @@ async function start() {
686
866
  if (fs.existsSync('./example.jpg')) {
687
867
  const path = './example.jpg';
688
868
  const imageBuffer = fs.readFileSync(path);
689
- await client.sendSticker(msg.from, imageBuffer, { packName: 'Innovators', author: 'Innovators Soft' });
869
+ await client.sendSticker(msgFrom, imageBuffer, { packName: 'Innovators', author: 'Innovators Soft' });
690
870
  } else {
691
- await client.sendMessage(msg.from, 'Example image (jpg) not found')
871
+ await client.sendMessage(msgFrom, 'Example image (jpg) not found')
692
872
  }
693
873
  break;
694
874
 
695
875
  case '!parse':
696
876
  if (args) {
697
877
  const info = client.parseJid(args);
698
- await client.sendMessage(msg.from, `*JID Info:*\n\nUser: ${info.user}\nServer: ${info.server}\nIs LID: ${info.isLid}`);
878
+ await client.sendMessage(msgFrom, `*JID Info:*\n\nUser: ${info.user}\nServer: ${info.server}\nIs LID: ${info.isLid}`);
699
879
  } else {
700
- await client.sendMessage(msg.from, 'Please provide a JID to parse');
880
+ await client.sendMessage(msgFrom, 'Please provide a JID to parse');
701
881
  }
702
882
  break;
703
883
 
704
884
  case '!normalize':
705
885
  if (args) {
706
886
  const jid = client.normalizePhoneToJid(args);
707
- await client.sendMessage(msg.from, `*Normalized JID:* ${jid}`);
887
+ await client.sendMessage(msgFrom, `*Normalized JID:* ${jid}`);
708
888
  } else {
709
- await client.sendMessage(msg.from, 'Please provide a phone number');
889
+ await client.sendMessage(msgFrom, 'Please provide a phone number');
710
890
  }
711
891
  break;
712
892
 
713
893
  case '!typing':
714
- await client.sendStateTyping(msg.from);
715
- await client.sendMessage(msg.from, 'Typing indicator sent!');
894
+ await client.sendStateTyping(msgFrom);
895
+ await client.sendMessage(msgFrom, 'Typing indicator sent!');
716
896
  break;
717
897
 
718
898
  case '!recording':
719
- await client.sendStateRecording(msg.from);
720
- await client.sendMessage(msg.from, 'Recording indicator sent!');
899
+ await client.sendStateRecording(msgFrom);
900
+ await client.sendMessage(msgFrom, 'Recording indicator sent!');
721
901
  break;
722
902
 
723
903
  case '!paused':
724
- await client.clearState(msg.from);
725
- await client.sendMessage(msg.from, 'Stopped typing/recording indicator sent!');
904
+ await client.clearState(msgFrom);
905
+ await client.sendMessage(msgFrom, 'Stopped typing/recording indicator sent!');
906
+ break;
907
+
908
+ case '!typing_simulate':
909
+ // Show "typing..." for 5 seconds, then send the message — all in one call
910
+ await client.sendMessage(msgFrom, 'Simulating typing for 5 seconds...');
911
+ const typing = client.createPresenceController();
912
+ await typing.simulateTyping(msgFrom, 5000, async () => {
913
+ await client.sendMessage(msgFrom, 'This message was sent after 5 seconds of typing! āœ…');
914
+ });
915
+ break;
916
+
917
+ case '!typing_start':
918
+ // Manual start (auto-pauses after 5 s by default if not specified)
919
+ const typingStart = client.createPresenceController();
920
+ await typingStart.startTyping(msgFrom, { duration: 10000 }); // Show for 10s
921
+ await client.sendMessage(msgFrom, 'Typing indicator started for 10 seconds.');
922
+ break;
923
+
924
+ case '!typing_stop':
925
+ const typingStop = client.createPresenceController();
926
+ await typingStop.stopTyping(msgFrom);
927
+ await client.sendMessage(msgFrom, 'Typing indicator stopped.');
928
+ break;
929
+
930
+ case '!recording_start':
931
+ const recordingIndicator = client.createPresenceController();
932
+ await recordingIndicator.startRecording(msgFrom, { duration: 5000 });
933
+ await client.sendMessage(msgFrom, 'Recording indicator started for 5 seconds.');
934
+ break;
935
+
936
+ case '!typing_stop_all':
937
+ const typingStopAll = client.createPresenceController();
938
+ await typingStopAll.stopAll();
939
+ await client.sendMessage(msgFrom, 'All active indicators for this controller stopped.');
726
940
  break;
727
941
 
728
942
  case '!read':
729
943
  await client.readMessage(msg.raw.key);
730
- await client.sendMessage(msg.from, 'Message marked as read!');
944
+ await client.sendMessage(msgFrom, 'Message marked as read!');
731
945
  break;
732
946
 
733
947
  case '!add':
@@ -736,7 +950,7 @@ async function start() {
736
950
  case '!demote':
737
951
  try {
738
952
  if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
739
- await client.sendMessage(msg.from, 'This command can only be used in groups')
953
+ await client.sendMessage(msgFrom, 'This command can only be used in groups')
740
954
  break
741
955
  }
742
956
 
@@ -744,7 +958,7 @@ async function start() {
744
958
 
745
959
  // Validate phone number format
746
960
  if (!rawNumber || rawNumber.length < 10) {
747
- await client.sendMessage(msg.from,
961
+ await client.sendMessage(msgFrom,
748
962
  `āŒ Invalid phone number format.\n\n` +
749
963
  `āœ… Correct format: !${command.slice(1)} 923001234567\n` +
750
964
  `(Include country code without + or spaces)`
@@ -754,7 +968,7 @@ async function start() {
754
968
 
755
969
  // Ensure country code is present (check if starts with common codes)
756
970
  if (rawNumber.startsWith('0')) {
757
- await client.sendMessage(msg.from,
971
+ await client.sendMessage(msgFrom,
758
972
  `āŒ Phone number must include country code.\n\n` +
759
973
  `Example:\n` +
760
974
  `• Pakistan: 923001234567 (not 03001234567)\n` +
@@ -783,18 +997,18 @@ async function start() {
783
997
  }
784
998
 
785
999
  if (result[0].status == 200) {
786
- await client.sendMessage(msg.from, `Successfully ${actionMap[action]} the group`)
1000
+ await client.sendMessage(msgFrom, `Successfully ${actionMap[action]} the group`)
787
1001
  } else if (result[0].status == 403 && result[0].invitationSent) {
788
- await client.sendMessage(msg.from, `āš ļø Could not add directly due to privacy settings.\nāœ… Group invitation link has been sent to the user instead!`)
1002
+ await client.sendMessage(msgFrom, `āš ļø Could not add directly due to privacy settings.\nāœ… Group invitation link has been sent to the user instead!`)
789
1003
  } else {
790
- await client.sendMessage(msg.from, `Failed to ${action} participant: ${result[0].message || result[0].content || result[0].error || 'Unknown error'}`)
1004
+ await client.sendMessage(msgFrom, `Failed to ${action} participant: ${result[0].message || result[0].content || result[0].error || 'Unknown error'}`)
791
1005
  }
792
1006
  } catch (error) {
793
1007
  console.error(`Error ${command} participant:`, error)
794
1008
  if (error.output?.statusCode === 408) {
795
- await client.sendMessage(msg.from, `ā±ļø Request timed out. The number might be invalid or not on WhatsApp.`)
1009
+ await client.sendMessage(msgFrom, `ā±ļø Request timed out. The number might be invalid or not on WhatsApp.`)
796
1010
  } else {
797
- await client.sendMessage(msg.from, `Failed to ${command.slice(1)} participant: ${error.message || 'Unknown error'}`)
1011
+ await client.sendMessage(msgFrom, `Failed to ${command.slice(1)} participant: ${error.message || 'Unknown error'}`)
798
1012
  }
799
1013
  }
800
1014
  break
@@ -803,7 +1017,7 @@ async function start() {
803
1017
  case '!invite':
804
1018
  try {
805
1019
  if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
806
- await client.sendMessage(msg.from, 'This command can only be used in groups')
1020
+ await client.sendMessage(msgFrom, 'This command can only be used in groups')
807
1021
  break
808
1022
  }
809
1023
 
@@ -811,7 +1025,7 @@ async function start() {
811
1025
 
812
1026
  // Validate phone number format
813
1027
  if (!rawInviteNumber || rawInviteNumber.length < 10) {
814
- await client.sendMessage(msg.from,
1028
+ await client.sendMessage(msgFrom,
815
1029
  `āŒ Invalid phone number format.\n\n` +
816
1030
  `āœ… Correct format: !invite 923001234567\n` +
817
1031
  `(Include country code without + or spaces)`
@@ -821,7 +1035,7 @@ async function start() {
821
1035
 
822
1036
  // Ensure country code is present
823
1037
  if (rawInviteNumber.startsWith('0')) {
824
- await client.sendMessage(msg.from,
1038
+ await client.sendMessage(msgFrom,
825
1039
  `āŒ Phone number must include country code.\n\n` +
826
1040
  `Example:\n` +
827
1041
  `• Pakistan: 923001234567 (not 03001234567)\n` +
@@ -834,13 +1048,13 @@ async function start() {
834
1048
  const inviteNumber = rawInviteNumber + '@s.whatsapp.net'
835
1049
 
836
1050
  await client.sendGroupInvitation(msg.raw.key.remoteJid, inviteNumber)
837
- await client.sendMessage(msg.from, `āœ… Group invitation sent to ${rawInviteNumber}`)
1051
+ await client.sendMessage(msgFrom, `āœ… Group invitation sent to ${rawInviteNumber}`)
838
1052
  } catch (error) {
839
1053
  console.error('Error sending invitation:', error)
840
1054
  if (error.output?.statusCode === 408) {
841
- await client.sendMessage(msg.from, `ā±ļø Request timed out. The number might be invalid or not on WhatsApp.`)
1055
+ await client.sendMessage(msgFrom, `ā±ļø Request timed out. The number might be invalid or not on WhatsApp.`)
842
1056
  } else {
843
- await client.sendMessage(msg.from, `Failed to send group invitation: ${error.message || 'Unknown error'}`)
1057
+ await client.sendMessage(msgFrom, `Failed to send group invitation: ${error.message || 'Unknown error'}`)
844
1058
  }
845
1059
  }
846
1060
  break
@@ -852,61 +1066,61 @@ async function start() {
852
1066
  case '!creategroup':
853
1067
  try {
854
1068
  if (!args) {
855
- await client.sendMessage(msg.from, 'āŒ Please provide a group name.\nUsage: !creategroup My New Group');
1069
+ await client.sendMessage(msgFrom, 'āŒ Please provide a group name.\nUsage: !creategroup My New Group');
856
1070
  break;
857
1071
  }
858
- const newGroup = await client.createGroup(args, [msg.sender]);
859
- await client.sendMessage(msg.from, `āœ… Group created!\n\nName: *${args}*\nID: ${newGroup.id || newGroup.gid}`);
1072
+ const newGroup = await client.createGroup(args, [msgFrom]);
1073
+ await client.sendMessage(msgFrom, `āœ… Group created!\n\nName: *${args}*\nID: ${newGroup.id || newGroup.gid}`);
860
1074
  } catch (error) {
861
1075
  console.error('Error creating group:', error);
862
- await client.sendMessage(msg.from, `āŒ Failed to create group: ${error.message}`);
1076
+ await client.sendMessage(msgFrom, `āŒ Failed to create group: ${error.message}`);
863
1077
  }
864
1078
  break;
865
1079
 
866
1080
  case '!groupsubject':
867
1081
  try {
868
1082
  if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
869
- await client.sendMessage(msg.from, 'āŒ This command can only be used in groups');
1083
+ await client.sendMessage(msgFrom, 'āŒ This command can only be used in groups');
870
1084
  break;
871
1085
  }
872
1086
  if (!args) {
873
- await client.sendMessage(msg.from, 'āŒ Please provide a new group name.\nUsage: !groupsubject New Name');
1087
+ await client.sendMessage(msgFrom, 'āŒ Please provide a new group name.\nUsage: !groupsubject New Name');
874
1088
  break;
875
1089
  }
876
1090
  await client.changeGroupSubject(msg.raw.key.remoteJid, args);
877
- await client.sendMessage(msg.from, `āœ… Group name changed to: *${args}*`);
1091
+ await client.sendMessage(msgFrom, `āœ… Group name changed to: *${args}*`);
878
1092
  } catch (error) {
879
1093
  console.error('Error changing group subject:', error);
880
- await client.sendMessage(msg.from, `āŒ Failed to change group name: ${error.message}`);
1094
+ await client.sendMessage(msgFrom, `āŒ Failed to change group name: ${error.message}`);
881
1095
  }
882
1096
  break;
883
1097
 
884
1098
  case '!groupdesc':
885
1099
  try {
886
1100
  if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
887
- await client.sendMessage(msg.from, 'āŒ This command can only be used in groups');
1101
+ await client.sendMessage(msgFrom, 'āŒ This command can only be used in groups');
888
1102
  break;
889
1103
  }
890
1104
  if (!args) {
891
- await client.sendMessage(msg.from, 'āŒ Please provide a new description.\nUsage: !groupdesc New description here');
1105
+ await client.sendMessage(msgFrom, 'āŒ Please provide a new description.\nUsage: !groupdesc New description here');
892
1106
  break;
893
1107
  }
894
1108
  await client.changeGroupDescription(msg.raw.key.remoteJid, args);
895
- await client.sendMessage(msg.from, `āœ… Group description updated!`);
1109
+ await client.sendMessage(msgFrom, `āœ… Group description updated!`);
896
1110
  } catch (error) {
897
1111
  console.error('Error changing group description:', error);
898
- await client.sendMessage(msg.from, `āŒ Failed to change description: ${error.message}`);
1112
+ await client.sendMessage(msgFrom, `āŒ Failed to change description: ${error.message}`);
899
1113
  }
900
1114
  break;
901
1115
 
902
1116
  case '!groupsetting':
903
1117
  try {
904
1118
  if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
905
- await client.sendMessage(msg.from, 'āŒ This command can only be used in groups');
1119
+ await client.sendMessage(msgFrom, 'āŒ This command can only be used in groups');
906
1120
  break;
907
1121
  }
908
1122
  if (!args || !['announcement', 'not_announcement', 'locked', 'unlocked'].includes(args.trim())) {
909
- await client.sendMessage(msg.from,
1123
+ await client.sendMessage(msgFrom,
910
1124
  `āŒ Invalid setting.\n\n` +
911
1125
  `Usage: !groupsetting <setting>\n\n` +
912
1126
  `Available settings:\n` +
@@ -918,66 +1132,66 @@ async function start() {
918
1132
  break;
919
1133
  }
920
1134
  await client.changeGroupSettings(msg.raw.key.remoteJid, args.trim());
921
- await client.sendMessage(msg.from, `āœ… Group setting changed to: *${args.trim()}*`);
1135
+ await client.sendMessage(msgFrom, `āœ… Group setting changed to: *${args.trim()}*`);
922
1136
  } catch (error) {
923
1137
  console.error('Error changing group settings:', error);
924
- await client.sendMessage(msg.from, `āŒ Failed to change setting: ${error.message}`);
1138
+ await client.sendMessage(msgFrom, `āŒ Failed to change setting: ${error.message}`);
925
1139
  }
926
1140
  break;
927
1141
 
928
1142
  case '!invitecode':
929
1143
  try {
930
1144
  if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
931
- await client.sendMessage(msg.from, 'āŒ This command can only be used in groups');
1145
+ await client.sendMessage(msgFrom, 'āŒ This command can only be used in groups');
932
1146
  break;
933
1147
  }
934
1148
  const inviteCode = await client.getGroupInviteCode(msg.raw.key.remoteJid);
935
- await client.sendMessage(msg.from, `āœ… Group Invite Link:\nhttps://chat.whatsapp.com/${inviteCode}`);
1149
+ await client.sendMessage(msgFrom, `āœ… Group Invite Link:\nhttps://chat.whatsapp.com/${inviteCode}`);
936
1150
  } catch (error) {
937
1151
  console.error('Error getting invite code:', error);
938
- await client.sendMessage(msg.from, `āŒ Failed to get invite code: ${error.message}`);
1152
+ await client.sendMessage(msgFrom, `āŒ Failed to get invite code: ${error.message}`);
939
1153
  }
940
1154
  break;
941
1155
 
942
1156
  case '!revokeinvite':
943
1157
  try {
944
1158
  if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
945
- await client.sendMessage(msg.from, 'āŒ This command can only be used in groups');
1159
+ await client.sendMessage(msgFrom, 'āŒ This command can only be used in groups');
946
1160
  break;
947
1161
  }
948
1162
  const newInviteCode = await client.revokeGroupInviteCode(msg.raw.key.remoteJid);
949
- await client.sendMessage(msg.from, `āœ… Invite code revoked!\nNew invite link:\nhttps://chat.whatsapp.com/${newInviteCode}`);
1163
+ await client.sendMessage(msgFrom, `āœ… Invite code revoked!\nNew invite link:\nhttps://chat.whatsapp.com/${newInviteCode}`);
950
1164
  } catch (error) {
951
1165
  console.error('Error revoking invite code:', error);
952
- await client.sendMessage(msg.from, `āŒ Failed to revoke invite code: ${error.message}`);
1166
+ await client.sendMessage(msgFrom, `āŒ Failed to revoke invite code: ${error.message}`);
953
1167
  }
954
1168
  break;
955
1169
 
956
1170
  case '!leavegroup':
957
1171
  try {
958
1172
  if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
959
- await client.sendMessage(msg.from, 'āŒ This command can only be used in groups');
1173
+ await client.sendMessage(msgFrom, 'āŒ This command can only be used in groups');
960
1174
  break;
961
1175
  }
962
- await client.sendMessage(msg.from, 'šŸ‘‹ Leaving group...');
1176
+ await client.sendMessage(msgFrom, 'šŸ‘‹ Leaving group...');
963
1177
  await client.leaveGroup(msg.raw.key.remoteJid);
964
1178
  } catch (error) {
965
1179
  console.error('Error leaving group:', error);
966
- await client.sendMessage(msg.from, `āŒ Failed to leave group: ${error.message}`);
1180
+ await client.sendMessage(msgFrom, `āŒ Failed to leave group: ${error.message}`);
967
1181
  }
968
1182
  break;
969
1183
 
970
1184
  case '!joingroup':
971
1185
  try {
972
1186
  if (!args) {
973
- await client.sendMessage(msg.from, 'āŒ Please provide an invite code.\nUsage: !joingroup AbCdEfGhIjK\n(or full link: !joingroup https://chat.whatsapp.com/AbCdEfGhIjK)');
1187
+ await client.sendMessage(msgFrom, 'āŒ Please provide an invite code.\nUsage: !joingroup AbCdEfGhIjK\n(or full link: !joingroup https://chat.whatsapp.com/AbCdEfGhIjK)');
974
1188
  break;
975
1189
  }
976
1190
  const joinedGroupId = await client.joinGroupByInviteCode(args.trim());
977
- await client.sendMessage(msg.from, `āœ… Successfully joined group!\nGroup ID: ${joinedGroupId}`);
1191
+ await client.sendMessage(msgFrom, `āœ… Successfully joined group!\nGroup ID: ${joinedGroupId}`);
978
1192
  } catch (error) {
979
1193
  console.error('Error joining group:', error);
980
- await client.sendMessage(msg.from, `āŒ Failed to join group: ${error.message}`);
1194
+ await client.sendMessage(msgFrom, `āŒ Failed to join group: ${error.message}`);
981
1195
  }
982
1196
  break;
983
1197
 
@@ -989,7 +1203,7 @@ async function start() {
989
1203
  if (!input) {
990
1204
  // No args: use current group
991
1205
  if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
992
- await client.sendMessage(msg.from, 'āŒ Use this command in a group, or provide a group JID / invite code.\nUsage:\n• !groupinfo (in a group)\n• !groupinfo 120363xxxxx@g.us\n• !groupinfo AbCdEfGhIjK')
1206
+ await client.sendMessage(msgFrom, 'āŒ Use this command in a group, or provide a group JID / invite code.\nUsage:\n• !groupinfo (in a group)\n• !groupinfo 120363xxxxx@g.us\n• !groupinfo AbCdEfGhIjK')
993
1207
  break
994
1208
  }
995
1209
  groupInfoResult = await client.getGroupMetadata(msg.raw.key.remoteJid)
@@ -1002,7 +1216,7 @@ async function start() {
1002
1216
  }
1003
1217
 
1004
1218
  if (!groupInfoResult) {
1005
- await client.sendMessage(msg.from, 'āŒ Group not found.')
1219
+ await client.sendMessage(msgFrom, 'āŒ Group not found.')
1006
1220
  break
1007
1221
  }
1008
1222
 
@@ -1038,17 +1252,17 @@ async function start() {
1038
1252
  })
1039
1253
  }
1040
1254
 
1041
- await client.sendMessage(msg.from, infoText)
1255
+ await client.sendMessage(msgFrom, infoText)
1042
1256
  } catch (error) {
1043
1257
  console.error('Error getting group info:', error)
1044
- await client.sendMessage(msg.from, `āŒ Failed to get group info: ${error.message}`)
1258
+ await client.sendMessage(msgFrom, `āŒ Failed to get group info: ${error.message}`)
1045
1259
  }
1046
1260
  break;
1047
1261
 
1048
1262
  case '!joinrequests':
1049
1263
  try {
1050
1264
  if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
1051
- await client.sendMessage(msg.from, 'āŒ This command can only be used in groups');
1265
+ await client.sendMessage(msgFrom, 'āŒ This command can only be used in groups');
1052
1266
  break;
1053
1267
  }
1054
1268
  const requests = await client.getGroupJoinRequests(msg.raw.key.remoteJid);
@@ -1059,63 +1273,63 @@ async function start() {
1059
1273
  if (req.request_time) requestList += ` Requested: ${new Date(req.request_time * 1000).toLocaleString()}\n`;
1060
1274
  });
1061
1275
  requestList += `\nUse !approvejoin or !rejectjoin <number> to respond`;
1062
- await client.sendMessage(msg.from, requestList);
1276
+ await client.sendMessage(msgFrom, requestList);
1063
1277
  } else {
1064
- await client.sendMessage(msg.from, 'āœ… No pending join requests.');
1278
+ await client.sendMessage(msgFrom, 'āœ… No pending join requests.');
1065
1279
  }
1066
1280
  } catch (error) {
1067
1281
  console.error('Error getting join requests:', error);
1068
- await client.sendMessage(msg.from, `āŒ Failed to get join requests: ${error.message}`);
1282
+ await client.sendMessage(msgFrom, `āŒ Failed to get join requests: ${error.message}`);
1069
1283
  }
1070
1284
  break;
1071
1285
 
1072
1286
  case '!approvejoin':
1073
1287
  try {
1074
1288
  if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
1075
- await client.sendMessage(msg.from, 'āŒ This command can only be used in groups');
1289
+ await client.sendMessage(msgFrom, 'āŒ This command can only be used in groups');
1076
1290
  break;
1077
1291
  }
1078
1292
  const approveNum = args?.replace(/[^0-9]/g, '');
1079
1293
  if (!approveNum || approveNum.length < 10) {
1080
- await client.sendMessage(msg.from, 'āŒ Please provide a valid phone number.\nUsage: !approvejoin 923001234567');
1294
+ await client.sendMessage(msgFrom, 'āŒ Please provide a valid phone number.\nUsage: !approvejoin 923001234567');
1081
1295
  break;
1082
1296
  }
1083
1297
  const approveResult = await client.handleGroupJoinRequest(msg.raw.key.remoteJid, [approveNum + '@s.whatsapp.net'], 'approve');
1084
- await client.sendMessage(msg.from, `āœ… Join request approved for ${approveNum}`);
1298
+ await client.sendMessage(msgFrom, `āœ… Join request approved for ${approveNum}`);
1085
1299
  } catch (error) {
1086
1300
  console.error('Error approving join request:', error);
1087
- await client.sendMessage(msg.from, `āŒ Failed to approve: ${error.message}`);
1301
+ await client.sendMessage(msgFrom, `āŒ Failed to approve: ${error.message}`);
1088
1302
  }
1089
1303
  break;
1090
1304
 
1091
1305
  case '!rejectjoin':
1092
1306
  try {
1093
1307
  if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
1094
- await client.sendMessage(msg.from, 'āŒ This command can only be used in groups');
1308
+ await client.sendMessage(msgFrom, 'āŒ This command can only be used in groups');
1095
1309
  break;
1096
1310
  }
1097
1311
  const rejectNum = args?.replace(/[^0-9]/g, '');
1098
1312
  if (!rejectNum || rejectNum.length < 10) {
1099
- await client.sendMessage(msg.from, 'āŒ Please provide a valid phone number.\nUsage: !rejectjoin 923001234567');
1313
+ await client.sendMessage(msgFrom, 'āŒ Please provide a valid phone number.\nUsage: !rejectjoin 923001234567');
1100
1314
  break;
1101
1315
  }
1102
1316
  const rejectResult = await client.handleGroupJoinRequest(msg.raw.key.remoteJid, [rejectNum + '@s.whatsapp.net'], 'reject');
1103
- await client.sendMessage(msg.from, `āœ… Join request rejected for ${rejectNum}`);
1317
+ await client.sendMessage(msgFrom, `āœ… Join request rejected for ${rejectNum}`);
1104
1318
  } catch (error) {
1105
1319
  console.error('Error rejecting join request:', error);
1106
- await client.sendMessage(msg.from, `āŒ Failed to reject: ${error.message}`);
1320
+ await client.sendMessage(msgFrom, `āŒ Failed to reject: ${error.message}`);
1107
1321
  }
1108
1322
  break;
1109
1323
 
1110
1324
  case '!ephemeral':
1111
1325
  try {
1112
1326
  if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
1113
- await client.sendMessage(msg.from, 'āŒ This command can only be used in groups');
1327
+ await client.sendMessage(msgFrom, 'āŒ This command can only be used in groups');
1114
1328
  break;
1115
1329
  }
1116
1330
  const ephemeralSeconds = parseInt(args);
1117
1331
  if (isNaN(ephemeralSeconds)) {
1118
- await client.sendMessage(msg.from,
1332
+ await client.sendMessage(msgFrom,
1119
1333
  `āŒ Please provide duration in seconds.\n\n` +
1120
1334
  `Usage: !ephemeral <seconds>\n\n` +
1121
1335
  `Options:\n` +
@@ -1128,21 +1342,21 @@ async function start() {
1128
1342
  }
1129
1343
  await client.toggleGroupEphemeral(msg.raw.key.remoteJid, ephemeralSeconds);
1130
1344
  const durationText = ephemeralSeconds === 0 ? 'OFF' : `${ephemeralSeconds} seconds`;
1131
- await client.sendMessage(msg.from, `āœ… Disappearing messages set to: *${durationText}*`);
1345
+ await client.sendMessage(msgFrom, `āœ… Disappearing messages set to: *${durationText}*`);
1132
1346
  } catch (error) {
1133
1347
  console.error('Error toggling ephemeral:', error);
1134
- await client.sendMessage(msg.from, `āŒ Failed to toggle disappearing messages: ${error.message}`);
1348
+ await client.sendMessage(msgFrom, `āŒ Failed to toggle disappearing messages: ${error.message}`);
1135
1349
  }
1136
1350
  break;
1137
1351
 
1138
1352
  case '!addmode':
1139
1353
  try {
1140
1354
  if (!msg.raw.key.remoteJid.endsWith('@g.us')) {
1141
- await client.sendMessage(msg.from, 'āŒ This command can only be used in groups');
1355
+ await client.sendMessage(msgFrom, 'āŒ This command can only be used in groups');
1142
1356
  break;
1143
1357
  }
1144
1358
  if (!args || !['all_member_add', 'admin_add'].includes(args.trim())) {
1145
- await client.sendMessage(msg.from,
1359
+ await client.sendMessage(msgFrom,
1146
1360
  `āŒ Invalid mode.\n\n` +
1147
1361
  `Usage: !addmode <mode>\n\n` +
1148
1362
  `Options:\n` +
@@ -1152,10 +1366,10 @@ async function start() {
1152
1366
  break;
1153
1367
  }
1154
1368
  await client.changeGroupAddMode(msg.raw.key.remoteJid, args.trim());
1155
- await client.sendMessage(msg.from, `āœ… Group add mode changed to: *${args.trim()}*`);
1369
+ await client.sendMessage(msgFrom, `āœ… Group add mode changed to: *${args.trim()}*`);
1156
1370
  } catch (error) {
1157
1371
  console.error('Error changing add mode:', error);
1158
- await client.sendMessage(msg.from, `āŒ Failed to change add mode: ${error.message}`);
1372
+ await client.sendMessage(msgFrom, `āŒ Failed to change add mode: ${error.message}`);
1159
1373
  }
1160
1374
  break;
1161
1375
 
@@ -1167,14 +1381,14 @@ async function start() {
1167
1381
  try {
1168
1382
  const blockNum = args?.replace(/[^0-9]/g, '');
1169
1383
  if (!blockNum || blockNum.length < 10) {
1170
- await client.sendMessage(msg.from, 'āŒ Please provide a valid phone number.\nUsage: !block 923001234567');
1384
+ await client.sendMessage(msgFrom, 'āŒ Please provide a valid phone number.\nUsage: !block 923001234567');
1171
1385
  break;
1172
1386
  }
1173
1387
  await client.blockUser(blockNum + '@s.whatsapp.net');
1174
- await client.sendMessage(msg.from, `āœ… User ${blockNum} has been blocked.`);
1388
+ await client.sendMessage(msgFrom, `āœ… User ${blockNum} has been blocked.`);
1175
1389
  } catch (error) {
1176
1390
  console.error('Error blocking user:', error);
1177
- await client.sendMessage(msg.from, `āŒ Failed to block user: ${error.message}`);
1391
+ await client.sendMessage(msgFrom, `āŒ Failed to block user: ${error.message}`);
1178
1392
  }
1179
1393
  break;
1180
1394
 
@@ -1182,14 +1396,14 @@ async function start() {
1182
1396
  try {
1183
1397
  const unblockNum = args?.replace(/[^0-9]/g, '');
1184
1398
  if (!unblockNum || unblockNum.length < 10) {
1185
- await client.sendMessage(msg.from, 'āŒ Please provide a valid phone number.\nUsage: !unblock 923001234567');
1399
+ await client.sendMessage(msgFrom, 'āŒ Please provide a valid phone number.\nUsage: !unblock 923001234567');
1186
1400
  break;
1187
1401
  }
1188
1402
  await client.unblockUser(unblockNum + '@s.whatsapp.net');
1189
- await client.sendMessage(msg.from, `āœ… User ${unblockNum} has been unblocked.`);
1403
+ await client.sendMessage(msgFrom, `āœ… User ${unblockNum} has been unblocked.`);
1190
1404
  } catch (error) {
1191
1405
  console.error('Error unblocking user:', error);
1192
- await client.sendMessage(msg.from, `āŒ Failed to unblock user: ${error.message}`);
1406
+ await client.sendMessage(msgFrom, `āŒ Failed to unblock user: ${error.message}`);
1193
1407
  }
1194
1408
  break;
1195
1409
 
@@ -1200,10 +1414,10 @@ async function start() {
1200
1414
  for (const [key, value] of Object.entries(privacySettings)) {
1201
1415
  privacyText += `• ${key}: *${value}*\n`;
1202
1416
  }
1203
- await client.sendMessage(msg.from, privacyText);
1417
+ await client.sendMessage(msgFrom, privacyText);
1204
1418
  } catch (error) {
1205
1419
  console.error('Error fetching privacy settings:', error);
1206
- await client.sendMessage(msg.from, `āŒ Failed to get privacy settings: ${error.message}`);
1420
+ await client.sendMessage(msgFrom, `āŒ Failed to get privacy settings: ${error.message}`);
1207
1421
  }
1208
1422
  break;
1209
1423
 
@@ -1215,13 +1429,13 @@ async function start() {
1215
1429
  blockedList.forEach((jid, i) => {
1216
1430
  blockText += `${i + 1}. ${jid}\n`;
1217
1431
  });
1218
- await client.sendMessage(msg.from, blockText);
1432
+ await client.sendMessage(msgFrom, blockText);
1219
1433
  } else {
1220
- await client.sendMessage(msg.from, 'āœ… No blocked contacts.');
1434
+ await client.sendMessage(msgFrom, 'āœ… No blocked contacts.');
1221
1435
  }
1222
1436
  } catch (error) {
1223
1437
  console.error('Error fetching block list:', error);
1224
- await client.sendMessage(msg.from, `āŒ Failed to get block list: ${error.message}`);
1438
+ await client.sendMessage(msgFrom, `āŒ Failed to get block list: ${error.message}`);
1225
1439
  }
1226
1440
  break;
1227
1441
 
@@ -1229,16 +1443,16 @@ async function start() {
1229
1443
  try {
1230
1444
  const lsValues = ['all', 'contacts', 'contact_blacklist', 'none'];
1231
1445
  if (!args || !lsValues.includes(args.trim())) {
1232
- await client.sendMessage(msg.from,
1446
+ await client.sendMessage(msgFrom,
1233
1447
  `āŒ Invalid value.\n\nUsage: !lastseenprivacy <value>\n\nOptions: ${lsValues.join(', ')}`
1234
1448
  );
1235
1449
  break;
1236
1450
  }
1237
1451
  await client.updateLastSeenPrivacy(args.trim());
1238
- await client.sendMessage(msg.from, `āœ… Last seen privacy updated to: *${args.trim()}*`);
1452
+ await client.sendMessage(msgFrom, `āœ… Last seen privacy updated to: *${args.trim()}*`);
1239
1453
  } catch (error) {
1240
1454
  console.error('Error updating last seen privacy:', error);
1241
- await client.sendMessage(msg.from, `āŒ Failed to update: ${error.message}`);
1455
+ await client.sendMessage(msgFrom, `āŒ Failed to update: ${error.message}`);
1242
1456
  }
1243
1457
  break;
1244
1458
 
@@ -1246,16 +1460,16 @@ async function start() {
1246
1460
  try {
1247
1461
  const onValues = ['all', 'match_last_seen'];
1248
1462
  if (!args || !onValues.includes(args.trim())) {
1249
- await client.sendMessage(msg.from,
1463
+ await client.sendMessage(msgFrom,
1250
1464
  `āŒ Invalid value.\n\nUsage: !onlineprivacy <value>\n\nOptions: ${onValues.join(', ')}`
1251
1465
  );
1252
1466
  break;
1253
1467
  }
1254
1468
  await client.updateOnlinePrivacy(args.trim());
1255
- await client.sendMessage(msg.from, `āœ… Online privacy updated to: *${args.trim()}*`);
1469
+ await client.sendMessage(msgFrom, `āœ… Online privacy updated to: *${args.trim()}*`);
1256
1470
  } catch (error) {
1257
1471
  console.error('Error updating online privacy:', error);
1258
- await client.sendMessage(msg.from, `āŒ Failed to update: ${error.message}`);
1472
+ await client.sendMessage(msgFrom, `āŒ Failed to update: ${error.message}`);
1259
1473
  }
1260
1474
  break;
1261
1475
 
@@ -1263,16 +1477,16 @@ async function start() {
1263
1477
  try {
1264
1478
  const pfpValues = ['all', 'contacts', 'contact_blacklist', 'none'];
1265
1479
  if (!args || !pfpValues.includes(args.trim())) {
1266
- await client.sendMessage(msg.from,
1480
+ await client.sendMessage(msgFrom,
1267
1481
  `āŒ Invalid value.\n\nUsage: !pfpprivacy <value>\n\nOptions: ${pfpValues.join(', ')}`
1268
1482
  );
1269
1483
  break;
1270
1484
  }
1271
1485
  await client.updateProfilePicturePrivacy(args.trim());
1272
- await client.sendMessage(msg.from, `āœ… Profile picture privacy updated to: *${args.trim()}*`);
1486
+ await client.sendMessage(msgFrom, `āœ… Profile picture privacy updated to: *${args.trim()}*`);
1273
1487
  } catch (error) {
1274
1488
  console.error('Error updating profile picture privacy:', error);
1275
- await client.sendMessage(msg.from, `āŒ Failed to update: ${error.message}`);
1489
+ await client.sendMessage(msgFrom, `āŒ Failed to update: ${error.message}`);
1276
1490
  }
1277
1491
  break;
1278
1492
 
@@ -1280,16 +1494,16 @@ async function start() {
1280
1494
  try {
1281
1495
  const stValues = ['all', 'contacts', 'contact_blacklist', 'none'];
1282
1496
  if (!args || !stValues.includes(args.trim())) {
1283
- await client.sendMessage(msg.from,
1497
+ await client.sendMessage(msgFrom,
1284
1498
  `āŒ Invalid value.\n\nUsage: !statusprivacy <value>\n\nOptions: ${stValues.join(', ')}`
1285
1499
  );
1286
1500
  break;
1287
1501
  }
1288
1502
  await client.updateStatusPrivacy(args.trim());
1289
- await client.sendMessage(msg.from, `āœ… Status privacy updated to: *${args.trim()}*`);
1503
+ await client.sendMessage(msgFrom, `āœ… Status privacy updated to: *${args.trim()}*`);
1290
1504
  } catch (error) {
1291
1505
  console.error('Error updating status privacy:', error);
1292
- await client.sendMessage(msg.from, `āŒ Failed to update: ${error.message}`);
1506
+ await client.sendMessage(msgFrom, `āŒ Failed to update: ${error.message}`);
1293
1507
  }
1294
1508
  break;
1295
1509
 
@@ -1297,16 +1511,16 @@ async function start() {
1297
1511
  try {
1298
1512
  const rrValues = ['all', 'none'];
1299
1513
  if (!args || !rrValues.includes(args.trim())) {
1300
- await client.sendMessage(msg.from,
1514
+ await client.sendMessage(msgFrom,
1301
1515
  `āŒ Invalid value.\n\nUsage: !readreceiptprivacy <value>\n\nOptions: ${rrValues.join(', ')}`
1302
1516
  );
1303
1517
  break;
1304
1518
  }
1305
1519
  await client.updateReadReceiptsPrivacy(args.trim());
1306
- await client.sendMessage(msg.from, `āœ… Read receipts privacy updated to: *${args.trim()}*`);
1520
+ await client.sendMessage(msgFrom, `āœ… Read receipts privacy updated to: *${args.trim()}*`);
1307
1521
  } catch (error) {
1308
1522
  console.error('Error updating read receipts privacy:', error);
1309
- await client.sendMessage(msg.from, `āŒ Failed to update: ${error.message}`);
1523
+ await client.sendMessage(msgFrom, `āŒ Failed to update: ${error.message}`);
1310
1524
  }
1311
1525
  break;
1312
1526
 
@@ -1314,16 +1528,16 @@ async function start() {
1314
1528
  try {
1315
1529
  const gaValues = ['all', 'contacts', 'contact_blacklist'];
1316
1530
  if (!args || !gaValues.includes(args.trim())) {
1317
- await client.sendMessage(msg.from,
1531
+ await client.sendMessage(msgFrom,
1318
1532
  `āŒ Invalid value.\n\nUsage: !groupaddprivacy <value>\n\nOptions: ${gaValues.join(', ')}`
1319
1533
  );
1320
1534
  break;
1321
1535
  }
1322
1536
  await client.updateGroupsAddPrivacy(args.trim());
1323
- await client.sendMessage(msg.from, `āœ… Groups add privacy updated to: *${args.trim()}*`);
1537
+ await client.sendMessage(msgFrom, `āœ… Groups add privacy updated to: *${args.trim()}*`);
1324
1538
  } catch (error) {
1325
1539
  console.error('Error updating groups add privacy:', error);
1326
- await client.sendMessage(msg.from, `āŒ Failed to update: ${error.message}`);
1540
+ await client.sendMessage(msgFrom, `āŒ Failed to update: ${error.message}`);
1327
1541
  }
1328
1542
  break;
1329
1543
 
@@ -1331,7 +1545,7 @@ async function start() {
1331
1545
  try {
1332
1546
  const disappearingSeconds = parseInt(args);
1333
1547
  if (isNaN(disappearingSeconds)) {
1334
- await client.sendMessage(msg.from,
1548
+ await client.sendMessage(msgFrom,
1335
1549
  `āŒ Please provide duration in seconds.\n\n` +
1336
1550
  `Usage: !disappearing <seconds>\n\n` +
1337
1551
  `Options:\n` +
@@ -1344,73 +1558,193 @@ async function start() {
1344
1558
  }
1345
1559
  await client.updateDefaultDisappearingMode(disappearingSeconds);
1346
1560
  const disappearText = disappearingSeconds === 0 ? 'OFF' : `${disappearingSeconds} seconds`;
1347
- await client.sendMessage(msg.from, `āœ… Default disappearing mode set to: *${disappearText}*`);
1561
+ await client.sendMessage(msgFrom, `āœ… Default disappearing mode set to: *${disappearText}*`);
1348
1562
  } catch (error) {
1349
1563
  console.error('Error updating default disappearing mode:', error);
1350
- await client.sendMessage(msg.from, `āŒ Failed to update: ${error.message}`);
1564
+ await client.sendMessage(msgFrom, `āŒ Failed to update: ${error.message}`);
1565
+ }
1566
+ break;
1567
+
1568
+ case '!updatestatus':
1569
+ try {
1570
+ if (!args) {
1571
+ await client.sendMessage(msgFrom, 'āŒ Please provide a new status.\nUsage: !updatestatus <text>');
1572
+ break;
1573
+ }
1574
+ await client.updateProfileStatus(args.trim());
1575
+ await client.sendMessage(msgFrom, `āœ… Profile status updated successfully!`);
1576
+ } catch (error) {
1577
+ console.error('Error updating profile status:', error);
1578
+ await client.sendMessage(msgFrom, `āŒ Failed to update profile status: ${error.message}`);
1579
+ }
1580
+ break;
1581
+
1582
+ case '!updatename':
1583
+ try {
1584
+ if (!args) {
1585
+ await client.sendMessage(msgFrom, 'āŒ Please provide a new name.\nUsage: !updatename <text>');
1586
+ break;
1587
+ }
1588
+ const newName = args.trim().toTitleCase();
1589
+ await client.updateProfileName(newName);
1590
+ await client.sendMessage(msgFrom, `āœ… *${newName}* \nProfile name updated successfully!`);
1591
+ } catch (error) {
1592
+ console.error('Error updating profile name:', error);
1593
+ await client.sendMessage(msgFrom, `āŒ Failed to update profile name: ${error.message}`);
1594
+ }
1595
+ break;
1596
+
1597
+ case '!statustext':
1598
+ try {
1599
+ await client.sendStatus({
1600
+ text: 'This is a test status!',
1601
+ backgroundColor: STATUS_BACKGROUNDS.solid.orange,
1602
+ font: STATUS_FONTS.SANS_SERIF
1603
+ }, [msgFrom]);
1604
+ await client.sendMessage(msgFrom, 'āœ… Status posted successfully!');
1605
+ } catch (error) {
1606
+ console.error('Error sending text status:', error);
1607
+ await client.sendMessage(msgFrom, `āŒ Failed to post text status: ${error.message}`);
1608
+ }
1609
+ break;
1610
+
1611
+ case '!statusimage':
1612
+ try {
1613
+ if (fs.existsSync('./example.jpg')) {
1614
+ await client.sendStatus({
1615
+ imagePath: './example.jpg',
1616
+ caption: args || 'Beautiful day from Innovators Soft! ā˜€ļø'
1617
+ }, [msgFrom]);
1618
+ await client.sendMessage(msgFrom, 'āœ… Image status posted successfully!');
1619
+ } else {
1620
+ await client.sendMessage(msgFrom, 'āŒ example.jpg not found for status demonstration.');
1621
+ }
1622
+ } catch (error) {
1623
+ console.error('Error sending image status:', error);
1624
+ await client.sendMessage(msgFrom, `āŒ Failed to post image status: ${error.message}`);
1625
+ }
1626
+ break;
1627
+
1628
+ case '!statusvideo':
1629
+ try {
1630
+ if (fs.existsSync('./example.mp4')) {
1631
+ await client.sendStatus({
1632
+ videoPath: './example.mp4',
1633
+ caption: args || 'Check this out! šŸŽ¬',
1634
+ isGif: false
1635
+ }, [msgFrom]);
1636
+ await client.sendMessage(msgFrom, 'āœ… Video status posted successfully!');
1637
+ } else {
1638
+ await client.sendMessage(msgFrom, 'āŒ example.mp4 not found for status demonstration.');
1639
+ }
1640
+ } catch (error) {
1641
+ console.error('Error sending video status:', error);
1642
+ await client.sendMessage(msgFrom, `āŒ Failed to post video status: ${error.message}`);
1643
+ }
1644
+ break;
1645
+
1646
+ case '!statusvoice':
1647
+ try {
1648
+ if (fs.existsSync('./example.ogg')) {
1649
+ await client.sendStatus({
1650
+ audioPath: './example.ogg'
1651
+ }, [msgFrom]);
1652
+ await client.sendMessage(msgFrom, 'āœ… Voice note status posted successfully!');
1653
+ } else {
1654
+ await client.sendMessage(msgFrom, 'āŒ example.ogg not found for status demonstration. Try finding a small audio file.');
1655
+ }
1656
+ } catch (error) {
1657
+ console.error('Error sending voice note status:', error);
1658
+ await client.sendMessage(msgFrom, `āŒ Failed to post voice note status: ${error.message}`);
1659
+ }
1660
+ break;
1661
+
1662
+ case '!groupstatus':
1663
+ try {
1664
+ if (!msgFrom.endsWith('@g.us')) {
1665
+ await client.sendMessage(msgFrom, 'āŒ This command only works inside a group chat (@g.us).');
1666
+ break;
1667
+ }
1668
+
1669
+ await client.sendGroupStatus(msgFrom, {
1670
+ text: 'this is group status'
1671
+ });
1672
+
1673
+ if (fs.existsSync('./example.jpg')) {
1674
+ await client.sendGroupStatus(msgFrom, {
1675
+ image: { url: './example.jpg' },
1676
+ caption: args || 'Hello Group!'
1677
+ });
1678
+ await client.sendMessage(msgFrom, 'āœ… Group status posted successfully!');
1679
+ } else {
1680
+ await client.sendMessage(msgFrom, 'āŒ example.jpg not found for group status demonstration.');
1681
+ }
1682
+ } catch (error) {
1683
+ console.error('Error sending group status:', error);
1684
+ await client.sendMessage(msgFrom, `āŒ Failed to post group status: ${error.message}`);
1351
1685
  }
1352
1686
  break;
1353
1687
 
1354
1688
  case '!messages':
1355
- const history = client.getStoredMessages(msg.from);
1689
+ const history = client.getStoredMessages(msgFrom);
1356
1690
  let historyText = `*šŸ’¾ Stored Messages for this chat (${history.length}):*\n\n`;
1357
1691
  history.slice(-10).forEach((m, i) => {
1358
1692
  const content = m.message.conversation || m.message.extendedTextMessage?.text || "[Media/Other]";
1359
1693
  historyText += `${i + 1}. ID: ${m.key.id}\n Text: ${content.substring(0, 50)}${content.length > 50 ? '...' : ''}\n\n`;
1360
1694
  });
1361
- await client.sendMessage(msg.from, historyText);
1695
+ await client.sendMessage(msgFrom, historyText);
1362
1696
  break;
1363
1697
 
1364
1698
  case '!message':
1365
1699
  if (!args) {
1366
- await client.sendMessage(msg.from, "āŒ Please provide a message ID.");
1700
+ await client.sendMessage(msgFrom, "āŒ Please provide a message ID.");
1367
1701
  break;
1368
1702
  }
1369
- const storedMsg = client.getStoredMessage({ remoteJid: msg.from, id: args.trim(), fromMe: false });
1703
+ const storedMsg = client.getStoredMessage({ remoteJid: msgFrom, id: args.trim(), fromMe: false });
1370
1704
  if (storedMsg) {
1371
- await client.sendMessage(msg.from, `āœ… Found message!\n\nContent: ${JSON.stringify(storedMsg.message, null, 2).substring(0, 1000)}`);
1705
+ await client.sendMessage(msgFrom, `āœ… Found message!\n\nContent: ${JSON.stringify(storedMsg.message, null, 2).substring(0, 1000)}`);
1372
1706
  } else {
1373
- await client.sendMessage(msg.from, "āŒ Message not found in store.");
1707
+ await client.sendMessage(msgFrom, "āŒ Message not found in store.");
1374
1708
  }
1375
1709
  break;
1376
1710
 
1377
1711
  case '!stats':
1378
1712
  const stats = client.getStoreStats();
1379
- await client.sendMessage(msg.from, `*šŸ“Š Message Store Statistics*\n\n• Total Chats: ${stats.totalChats}\n• Total Messages: ${stats.totalMessages}\n• Total Deleted: ${stats.totalDeleted}`);
1713
+ await client.sendMessage(msgFrom, `*šŸ“Š Message Store Statistics*\n\n• Total Chats: ${stats.totalChats}\n• Total Messages: ${stats.totalMessages}\n• Total Deleted: ${stats.totalDeleted}`);
1380
1714
  break;
1381
1715
 
1382
1716
  case '!allmessages':
1383
1717
  const allMsgs = client.getAllStoredMessages();
1384
1718
  const activeChats = client.getStoredChatIds();
1385
- await client.sendMessage(msg.from, `*🌐 Global Message Store*\n\n• Total Messages Held: ${allMsgs.length}\n• Total Active Chats: ${activeChats.length}\n\n*Active JIDs:* \n${activeChats.join('\n')}`);
1719
+ await client.sendMessage(msgFrom, `*🌐 Global Message Store*\n\n• Total Messages Held: ${allMsgs.length}\n• Total Active Chats: ${activeChats.length}\n\n*Active JIDs:* \n${activeChats.join('\n')}`);
1386
1720
  break;
1387
1721
 
1388
1722
  case '!savestore':
1389
- await client.sendMessage(msg.from, 'šŸ’¾ Saving message store to file...');
1723
+ await client.sendMessage(msgFrom, 'šŸ’¾ Saving message store to file...');
1390
1724
  const saveResult = await client.saveMessageStore();
1391
1725
  if (saveResult.success) {
1392
- await client.sendMessage(msg.from,
1726
+ await client.sendMessage(msgFrom,
1393
1727
  `āœ… *Store Saved Successfully*\n\n` +
1394
1728
  `• Messages: ${saveResult.messageCount}\n` +
1395
1729
  `• Path: ${saveResult.path}\n` +
1396
1730
  `• Saved at: ${saveResult.savedAt.toLocaleString()}`
1397
1731
  );
1398
1732
  } else {
1399
- await client.sendMessage(msg.from, `āŒ Failed to save store: ${saveResult.error}`);
1733
+ await client.sendMessage(msgFrom, `āŒ Failed to save store: ${saveResult.error}`);
1400
1734
  }
1401
1735
  break;
1402
1736
 
1403
1737
  case '!loadstore':
1404
- await client.sendMessage(msg.from, 'šŸ“‚ Loading message store from file...');
1738
+ await client.sendMessage(msgFrom, 'šŸ“‚ Loading message store from file...');
1405
1739
  const loadResult = await client.loadMessageStore();
1406
1740
  if (loadResult.success) {
1407
- await client.sendMessage(msg.from,
1741
+ await client.sendMessage(msgFrom,
1408
1742
  `āœ… *Store Loaded Successfully*\n\n` +
1409
1743
  `• Messages: ${loadResult.messageCount}\n` +
1410
1744
  `• Loaded from: ${loadResult.loadedFrom}`
1411
1745
  );
1412
1746
  } else {
1413
- await client.sendMessage(msg.from,
1747
+ await client.sendMessage(msgFrom,
1414
1748
  `āš ļø Could not load store\n` +
1415
1749
  `Reason: ${loadResult.reason || loadResult.error}`
1416
1750
  );