zaileys 1.1.40 โ†’ 2.0.0

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/README.MD ADDED
@@ -0,0 +1,990 @@
1
+ <div align="center">
2
+ <img alt="Zaileys - Simplified WhatsApp Node.js TypeScript/JavaScript API" src="https://socialify.git.ci/zeative/zaileys/image?custom_description=Simplified+WhatsApp+Node.js+TypeScript%2FJavaScript+API&custom_language=TypeScript&description=1&font=Inter&language=1&owner=1&pattern=Charlie+Brown&theme=Auto">
3
+
4
+ <h1 align="center">Zaileys - Simplified WhatsApp Node.js TypeScript/JavaScript API</h1>
5
+
6
+ <a href="https://www.npmjs.com/package/zaileys"><img src="https://img.shields.io/npm/v/zaileys.svg" alt="NPM Version"></a>
7
+ <a href="https://www.npmjs.com/package/zaileys"><img src="https://img.shields.io/npm/dw/zaileys?label=npm&color=%23CB3837" alt="NPM Downloads"></a>
8
+ <a href="https://github.com/zeative/zaileys/releases"><img src="https://img.shields.io/npm/dt/zaileys" alt="NPM Downloads"></a>
9
+ <a href="https://github.com/zeative/zaileys"><img src="https://img.shields.io/github/languages/code-size/zeative/zaileys" alt="GitHub Code Size"></a>
10
+ <a href="https://github.com/zeative/zaileys"><img src="https://img.shields.io/badge/TypeScript-5.0%2B-blue?style=flat-square&logo=typescript" alt="TypeScript"></a>
11
+ <a href="https://github.com/zeative/zaileys"><img src="https://img.shields.io/github/license/zeative/zaileys" alt="GitHub License"></a>
12
+ <a href="https://github.com/zeative/zaileys"><img src="https://img.shields.io/github/stars/zeative/zaileys" alt="GitHub Stars"></a>
13
+ <a href="https://github.com/zeative/zaileys"><img src="https://img.shields.io/github/forks/zeative/zaileys" alt="GitHub Forks"></a>
14
+
15
+ </div>
16
+
17
+ <div align="center">
18
+ <p>
19
+ <b>Zaileys</b> is a powerful, type-safe wrapper around <a href="https://github.com/WhiskeySockets/Baileys">Baileys</a>, designed to simplify the development of WhatsApp bots. It provides a robust architecture with built-in state management, middleware support, and easy-to-use event handlers, making it perfect for building scalable and maintainable WhatsApp applications.
20
+ </p>
21
+ </div>
22
+
23
+ <br>
24
+
25
+ <div align="center">
26
+
27
+ [๐Ÿš€ Overview](#-overview) &nbsp;&nbsp;โ€ข&nbsp;&nbsp;
28
+ [๐Ÿชถ Features](#-features) &nbsp;&nbsp;โ€ข&nbsp;&nbsp;
29
+ [๐Ÿ“ฆ Installation](#-installation) &nbsp;&nbsp;โ€ข&nbsp;&nbsp;
30
+ [โšก Quick Start](#-quick-start) &nbsp;&nbsp;โ€ข&nbsp;&nbsp;
31
+ [๐Ÿงฉ Plugins](#-plugins) &nbsp;&nbsp;โ€ข&nbsp;&nbsp;
32
+ [๐Ÿ“จ Sending Messages](#-sending-messages) &nbsp;&nbsp;โ€ข&nbsp;&nbsp;
33
+ [๐Ÿ‘ฅ Group Management](#-group-management) &nbsp;&nbsp;โ€ข&nbsp;&nbsp;
34
+ [๐Ÿ“ฐ Newsletter Management](#-newsletter-channel) &nbsp;&nbsp;โ€ข&nbsp;&nbsp;
35
+ [๐ŸŒ Community Management](#-community-management) &nbsp;&nbsp;โ€ข&nbsp;&nbsp;
36
+ [๐Ÿ”’ Privacy](#-privacy-settings) &nbsp;&nbsp;โ€ข&nbsp;&nbsp;
37
+ [๐Ÿค Contributing](#-contributing)
38
+
39
+ </div>
40
+
41
+ <br>
42
+
43
+ ---
44
+
45
+ ## ๐Ÿš€ Overview
46
+
47
+ > Zaileys solves the complexity of managing raw WhatsApp socket connections by providing a high-level, opinionated API. It is built for developers who need to create bots, customer support agents, or automated notification systems without getting bogged down in protocol details.
48
+
49
+ Targeting **Node.js** and **TypeScript** developers, Zaileys integrates essential features like rate limiting, session management, and input validation out of the box.
50
+
51
+ ## ๐Ÿชถ Features
52
+
53
+ - ๐Ÿ›ก๏ธ **Type-Safe** - Full TypeScript + Zod validation with autocomplete
54
+ - ๐Ÿ“ **Middleware** - Intercept and process events globally
55
+ - ๐Ÿงฉ **Plugin System** - Drop-in file-based plugins
56
+ - ๐Ÿ’พ **State Management** - Built-in `lowdb` for data persistence
57
+ - ๐Ÿ”” **Event-Driven** - Clean listeners for `connection`, `messages`, `calls`
58
+ - ๐Ÿ“ข **Rate Limiting** - Anti-spam protection out of the box
59
+ - ๐Ÿค– **Auto-Everything** - Auto-read, auto-reject calls, auto-mentions
60
+ - ๐Ÿ“ฒ **Multi-Device** - QR code or Pairing Code authentication
61
+ - ๐ŸŽฌ **Built-in FFmpeg** - No external dependencies for media processing
62
+ - ๐Ÿ”˜ **Interactive Buttons** - Simple buttons, URL, copy code, call buttons, and lists
63
+
64
+ ## ๐ŸŽจ Concepts & Architecture
65
+
66
+ **Client** - Your bot's brain. Manages connections, events, and the entire lifecycle.
67
+
68
+ **Context** - Rich event objects with all the data and helpers you need.
69
+
70
+ **Middleware** - Pre-process events for logging, auth, spam filtering, or custom logic.
71
+
72
+ **Plugins** - Drop files in `plugins/` directory. Auto-loaded, zero config.
73
+
74
+ **Store** - JSON database (`lowdb`) that auto-syncs chats, contacts, and messages.
75
+
76
+ ## ๐Ÿ“ฆ Installation
77
+
78
+ Install `zaileys` using your preferred package manager:
79
+
80
+ ```bash
81
+ npm install zaileys
82
+ # or
83
+ pnpm add zaileys
84
+ # or
85
+ yarn add zaileys
86
+ ```
87
+
88
+ > **Note**: Requires Node.js v20+ and TypeScript for best experience.
89
+
90
+ > **FFmpeg**: No need to install FFmpeg separately! It's already bundled with Zaileys for seamless media processing (audio, video, stickers).
91
+
92
+ ## โšก Quick Start
93
+
94
+ Here is a minimal example to get your bot running with QR code authentication:
95
+
96
+ ```typescript
97
+ import { Client } from 'zaileys';
98
+ // or
99
+ const { Client } = require('zaileys');
100
+
101
+ const wa = new Client({
102
+ authType: 'qr',
103
+ });
104
+
105
+ wa.on('messages', async (ctx) => {
106
+ if (ctx.text == 'ping') {
107
+ await wa.send(ctx.roomId, 'Pong! ๐Ÿ“');
108
+ }
109
+ });
110
+ ```
111
+
112
+ ## ๐Ÿ› ๏ธ Configuration
113
+
114
+ The `Client` constructor accepts a configuration object. Below are the valid options based on the library's type definitions.
115
+
116
+ ### General Options
117
+
118
+ These options apply to both authentication methods:
119
+
120
+ | Option | Type | Default | Description |
121
+ | :---------------- | :-------- | :---------- | :-------------------------------------- |
122
+ | `session` | `string` | `'zaileys'` | Name of the session folder. |
123
+ | `prefix` | `string` | `undefined` | Command prefix (e.g., `'/'`). |
124
+ | `showLogs` | `boolean` | `true` | Enable internal logging. |
125
+ | `ignoreMe` | `boolean` | `true` | Ignore messages sent by the bot itself. |
126
+ | `syncFullHistory` | `boolean` | `true` | Sync full chat history on startup. |
127
+
128
+ ### Automation Options
129
+
130
+ | Option | Type | Default | Description |
131
+ | :--------------- | :-------- | :------ | :--------------------------------------------------------- |
132
+ | `autoRead` | `boolean` | `true` | Automatically mark messages as read. |
133
+ | `autoOnline` | `boolean` | `true` | Automatically set presence to online. |
134
+ | `autoPresence` | `boolean` | `true` | Automatically send presence updates (composing/recording). |
135
+ | `autoMentions` | `boolean` | `true` | Automatically handle mentions. |
136
+ | `autoRejectCall` | `boolean` | `true` | Automatically reject incoming calls. |
137
+
138
+ ### Advanced Configuration
139
+
140
+ | Option | Type | Description |
141
+ | :---------- | :------- | :------------------------------------------------------------------------------ |
142
+ | `limiter` | `object` | Rate limiting configuration. Default: `maxMessages: 20, durationMs: 10_000`. |
143
+ | `fakeReply` | `object` | Configuration for fake reply provider. |
144
+ | `sticker` | `object` | Default metadata for sticker creation (`packageName`, `authorName`, `quality`). |
145
+ | `citation` | `object` | Custom citation sources. |
146
+
147
+ ## ๐Ÿ’ก Advanced Usage
148
+
149
+ ### Middleware & Spam Protection
150
+
151
+ You can use middleware to filter messages or add custom logic before your handlers run.
152
+
153
+ ```typescript
154
+ wa.use(async (ctx, next) => {
155
+ if (ctx.messages.isSpam) {
156
+ console.warn(`Spam detected from ${ctx.messages.senderName}`);
157
+ return;
158
+ }
159
+
160
+ await next();
161
+ });
162
+ ```
163
+
164
+ ### ๐Ÿงฉ Plugins
165
+
166
+ Zaileys features a built-in file-based plugin system. By default, it looks for plugins in the `plugins` directory of your project root.
167
+
168
+ **1. Create a plugin file** (e.g., `plugins/hello.ts`):
169
+
170
+ ```typescript
171
+ import { definePlugins } from 'zaileys';
172
+
173
+ export default definePlugins(
174
+ async (wa, ctx) => {
175
+ await wa.send(ctx.roomId, 'Hello from plugin!');
176
+ },
177
+ {
178
+ matcher: ['/hello', '!hello'], // Trigger commands
179
+ metadata: {
180
+ description: 'A simple hello world plugin',
181
+ },
182
+ },
183
+ );
184
+ ```
185
+
186
+ **2. That's it!** The client automatically loads and executes plugins that match the incoming message.
187
+
188
+ **3. Extract plugin information** (optional):
189
+
190
+ ```typescript
191
+ const pluginsInfo = wa.plugins.getPluginsInfo();
192
+
193
+ /* Example output
194
+ [
195
+ {
196
+ matcher: ['/hello', '!hello'],
197
+ metadata: {
198
+ description: 'A simple hello world plugin',
199
+ },
200
+ }
201
+ ]
202
+ */
203
+ ```
204
+
205
+ This returns an array of all loaded plugins with their `matcher` and `metadata`, useful for generating help menus or listing available commands.
206
+
207
+ ### ๐Ÿ” Citation (Custom Authorization)
208
+
209
+ Citation allows you to define custom authorization logic by creating named checkers that verify if a user is in a specific list (e.g., premium users, banned users).
210
+
211
+ **1. Configure citation sources** in the client options:
212
+
213
+ ```typescript
214
+ const wa = new Client({
215
+ authType: 'qr',
216
+ citation: {
217
+ premium: async () => {
218
+ // const numbers = await fetch...
219
+ return [6280000000, 12388888888];
220
+ },
221
+ banned: async () => {
222
+ return [6285555555555];
223
+ },
224
+ },
225
+ });
226
+ ```
227
+
228
+ **2. Use citation in your message handlers**:
229
+
230
+ ```typescript
231
+ wa.on('messages', async (ctx) => {
232
+ const isBanned = await ctx.citation.banned();
233
+ const isPremium = await ctx.citation.premium();
234
+
235
+ if (isBanned) return;
236
+
237
+ if (isPremium) {
238
+ await wa.send(ctx.roomId, 'Premium feature unlocked!');
239
+ }
240
+ });
241
+ ```
242
+
243
+ Each citation function returns `true` if the sender matches any ID in the returned list, `false` otherwise.
244
+
245
+ **How it works:**
246
+
247
+ Citation functions return an array of phone numbers, group id and lid Internally, Zaileys compares the sender's ID against this list by checking:
248
+
249
+ - `roomId` - The chat/group ID
250
+ - `senderId` - The sender's WhatsApp ID
251
+ - `senderLid` - The sender's LID
252
+
253
+ If any of these match a number in your returned array, the citation check returns `true`. This makes it flexible for both individual chats and group scenarios.
254
+
255
+ ## ๐Ÿ“ซ Sending Messages
256
+
257
+ > **Quick Jump:** [Text](#send-text) ยท [Reply](#reply-to-message) ยท [Forward](#forward-message) ยท [Media](#send-media) ยท [Banner](#send-with-banner) ยท [Location](#send-location) ยท [Contact](#send-contact) ยท [Poll](#send-poll) ยท [Reaction](#send-reaction) ยท [Presence](#update-presence) ยท [Mentions](#mentions) ยท [Edit & Delete](#edit--delete-messages) ยท [Buttons](#interactive-buttons)
258
+
259
+ ### Send Text
260
+
261
+ Send a simple text message to any chat.
262
+
263
+ ```typescript
264
+ await wa.send(ctx.roomId, 'Hello World!');
265
+
266
+ await wa.send(ctx.roomId, {
267
+ text: 'Hello with options!',
268
+ });
269
+ ```
270
+
271
+ ### Reply to Message
272
+
273
+ Reply to a specific message using the `replied` option.
274
+
275
+ ```typescript
276
+ await wa.send(ctx.roomId, {
277
+ text: 'This is a reply!',
278
+ replied: ctx.message(),
279
+ });
280
+ ```
281
+
282
+ ### Forward Message
283
+
284
+ Forward message to any chat.
285
+
286
+ ```typescript
287
+ await wa.forward(ctx.roomId, {
288
+ text: 'Forwarded message',
289
+ isForwardedMany: true,
290
+ });
291
+ ```
292
+
293
+ ### Send Media
294
+
295
+ Send images, videos, audio, stickers, or documents. Media can be a URL, Buffer, or base64 string.
296
+
297
+ **Image:**
298
+
299
+ ```typescript
300
+ await wa.send(ctx.roomId, {
301
+ image: 'https://example.com/image.jpg',
302
+ caption: 'Check this out!',
303
+ });
304
+
305
+ await wa.send(ctx.roomId, {
306
+ image: fs.readFileSync('./image.jpg'),
307
+ caption: 'Image from buffer',
308
+ isViewOnce: true,
309
+ });
310
+ ```
311
+
312
+ **Video:**
313
+
314
+ ```typescript
315
+ await wa.send(ctx.roomId, {
316
+ video: 'https://example.com/video.mp4',
317
+ caption: 'Cool video!',
318
+ ptv: true,
319
+ });
320
+ ```
321
+
322
+ **Audio:**
323
+
324
+ ```typescript
325
+ await wa.send(ctx.roomId, {
326
+ audio: 'https://example.com/audio.mp3',
327
+ ptt: true,
328
+ });
329
+ ```
330
+
331
+ **Sticker:**
332
+
333
+ ```typescript
334
+ // support gif and video
335
+ await wa.send(ctx.roomId, {
336
+ sticker: 'https://example.com/sticker.mp4',
337
+ });
338
+ ```
339
+
340
+ **Document:**
341
+
342
+ ```typescript
343
+ await wa.send(ctx.roomId, {
344
+ document: 'https://example.com/file.pdf',
345
+ fileName: 'document.pdf',
346
+ caption: 'Here is the file',
347
+ });
348
+ ```
349
+
350
+ ### Send with Banner
351
+
352
+ Send messages with an external ad reply banner (link preview).
353
+
354
+ ```typescript
355
+ await wa.send(ctx.roomId, {
356
+ text: 'Banner message!',
357
+ banner: {
358
+ thumbnailUrl: 'https://github.com/zeative.png',
359
+ sourceUrl: 'https://jaa.web.id',
360
+ title: 'Test Banner',
361
+ body: 'Hello World!',
362
+ },
363
+ });
364
+ ```
365
+
366
+ ### Send Location
367
+
368
+ Send location with coordinates.
369
+
370
+ ```typescript
371
+ await wa.send(ctx.roomId, {
372
+ location: {
373
+ latitude: -6.2,
374
+ longitude: 106.816666,
375
+ title: 'Jakarta',
376
+ footer: 'Capital of Indonesia',
377
+ url: 'https://maps.google.com/?q=-6.200000,106.816666',
378
+ },
379
+ });
380
+ ```
381
+
382
+ ### Send Contact
383
+
384
+ Send one or multiple contacts.
385
+
386
+ ```typescript
387
+ await wa.send(ctx.roomId, {
388
+ title: 'My Contacts',
389
+ contacts: [
390
+ {
391
+ fullname: 'John Doe',
392
+ phoneNumber: 6281234567890,
393
+ organization: 'Company Inc.',
394
+ },
395
+ {
396
+ fullname: 'Jane Smith',
397
+ phoneNumber: 6289876543210,
398
+ },
399
+ ],
400
+ });
401
+ ```
402
+
403
+ ### Send Poll
404
+
405
+ Create a poll with multiple options.
406
+
407
+ ```typescript
408
+ await wa.send(ctx.roomId, {
409
+ poll: {
410
+ name: 'What is your favorite color?',
411
+ answers: ['Red', 'Blue', 'Green', 'Yellow'],
412
+ isMultiple: false,
413
+ },
414
+ });
415
+ ```
416
+
417
+ ### Send Reaction
418
+
419
+ React to a message with an emoji.
420
+
421
+ ```typescript
422
+ await wa.reaction(ctx.message(), '๐Ÿ‘');
423
+
424
+ await wa.reaction(ctx.message(), 'โค๏ธ');
425
+ ```
426
+
427
+ ### Update Presence
428
+
429
+ Update your presence status in a chat.
430
+
431
+ ```typescript
432
+ await wa.presence(ctx.roomId, 'typing');
433
+
434
+ await wa.presence(ctx.roomId, 'recording');
435
+ ```
436
+
437
+ ### Mentions
438
+
439
+ Mentions are automatically detected when `autoMentions` is enabled (default: `true`).
440
+
441
+ ```typescript
442
+ // support lid
443
+ await wa.send(ctx.roomId, 'Hello @6281234567890!');
444
+ ```
445
+
446
+ ### Edit & Delete Messages
447
+
448
+ **Edit message:**
449
+
450
+ ```typescript
451
+ const sent = await wa.send(ctx.roomId, 'Original text');
452
+
453
+ setTimeout(async () => {
454
+ await wa.edit(sent, 'Edited text');
455
+ }, 2000);
456
+ ```
457
+
458
+ **Delete message:**
459
+
460
+ ```typescript
461
+ const sent = await wa.send(ctx.roomId, 'This will be deleted');
462
+
463
+ setTimeout(async () => {
464
+ await wa.delete(sent);
465
+ }, 2000);
466
+
467
+ // or multiple messages
468
+ await wa.delete([sent1, sent2]);
469
+ ```
470
+
471
+ ### Interactive Buttons
472
+
473
+ Send messages with interactive buttons.
474
+
475
+ **Simple Buttons:**
476
+
477
+ > โœ… Simple button has support Android/iPhone/Desktop
478
+
479
+ ```typescript
480
+ await wa.button(ctx.roomId, {
481
+ text: 'Choose an option:',
482
+ buttons: {
483
+ type: 'simple',
484
+ footer: 'Footer text',
485
+ data: [
486
+ { id: 'btn1', text: 'Option 1' },
487
+ { id: 'btn2', text: 'Option 2' },
488
+ { id: 'btn3', text: 'Option 3' },
489
+ ],
490
+ },
491
+ });
492
+ ```
493
+
494
+ **Interactive Buttons:**
495
+
496
+ > โš ๏ธ Experimental, only support Android/iPhone
497
+
498
+ ```typescript
499
+ await wa.button(ctx.roomId, {
500
+ text: 'Interactive menu:',
501
+ buttons: {
502
+ type: 'interactive',
503
+ footer: 'Footer text',
504
+ data: [
505
+ { type: 'quick_reply', id: 'reply1', text: 'Quick Reply' },
506
+ { type: 'cta_url', text: 'Visit Website', url: 'https://example.com' },
507
+ { type: 'cta_copy', id: 'copy1', text: 'Copy Code', copy: 'PROMO123' },
508
+ { type: 'cta_call', text: 'Call Us', phoneNumber: '+6281234567890' },
509
+ ],
510
+ },
511
+ });
512
+ ```
513
+
514
+ **Lists Buttons:**
515
+
516
+ > โš ๏ธ Experimental, not supported on some devices. Don't use in production!
517
+
518
+ ```typescript
519
+ await wa.button(ctx.roomId, {
520
+ text: 'Choose an option:',
521
+ buttons: {
522
+ type: 'interactive',
523
+ footer: 'Footer text',
524
+ data: [
525
+ {
526
+ type: 'single_select',
527
+ text: 'Choose an option:',
528
+ section: [
529
+ {
530
+ title: 'Section 1',
531
+ rows: [
532
+ { id: 'btn1', title: 'Option 1' },
533
+ { id: 'btn2', title: 'Option 2' },
534
+ { id: 'btn3', title: 'Option 3' },
535
+ ],
536
+ },
537
+ ],
538
+ },
539
+ ],
540
+ },
541
+ });
542
+ ```
543
+
544
+ ## ๐Ÿ‘ฅ Group Management
545
+
546
+ > **Quick Jump:** [Create](#create-group) ยท [Participants](#manage-participants) ยท [Profile](#group-profile) ยท [Settings](#group-settings) ยท [Invite Code](#invite-code) ยท [Metadata](#group-metadata) ยท [Join Requests](#join-requests) ยท [Fetch All](#fetch-all-groups) ยท [Ephemeral](#ephemeral-messages) ยท [Leave](#leave-group)
547
+
548
+ Manage groups, participants, and settings easily.
549
+
550
+ ### Create Group
551
+
552
+ Create a new group with initial participants.
553
+
554
+ ```typescript
555
+ // Create group with name and participants
556
+ const group = await wa.group.create('My Group', ['senderId']);
557
+ console.log('Group created:', group);
558
+ ```
559
+
560
+ ### Manage Participants
561
+
562
+ Add, remove, promote, or demote participants.
563
+
564
+ ```typescript
565
+ const groupId = '1234567890@g.us';
566
+
567
+ // Add participants
568
+ await wa.group.participant(groupId, ['senderId'], 'add');
569
+
570
+ // Remove participants
571
+ await wa.group.participant(groupId, [...], 'remove');
572
+
573
+ // Promote to admin
574
+ await wa.group.participant(groupId, [...], 'promote');
575
+
576
+ // Demote to member
577
+ await wa.group.participant(groupId, [...], 'demote');
578
+ ```
579
+
580
+ ### Group Profile
581
+
582
+ Update group subject, description, or icon.
583
+
584
+ ```typescript
585
+ // Update subject
586
+ await wa.group.profile(groupId, 'New Group Name', 'subject');
587
+
588
+ // Update description
589
+ await wa.group.profile(groupId, 'This is the new description', 'description');
590
+
591
+ // Update group avatar (from URL or Buffer)
592
+ await wa.group.profile(groupId, 'https://example.com/icon.jpg', 'avatar');
593
+ ```
594
+
595
+ ### Group Settings
596
+
597
+ Configure group permissions.
598
+
599
+ ```typescript
600
+ // All members can send messages
601
+ await wa.group.setting(groupId, 'open');
602
+
603
+ // Only admins can send messages
604
+ await wa.group.setting(groupId, 'close');
605
+
606
+ // Only admins can edit group info
607
+ await wa.group.setting(groupId, 'locked');
608
+
609
+ // All members can edit group info
610
+ await wa.group.setting(groupId, 'unlocked');
611
+
612
+ // Only admins can add members
613
+ await wa.group.setting(groupId, 'admin_add');
614
+
615
+ // All members can add members
616
+ await wa.group.setting(groupId, 'all_member_add');
617
+ ```
618
+
619
+ ### Invite Code
620
+
621
+ Manage group invite links.
622
+
623
+ ```typescript
624
+ // Get current invite code
625
+ const code = await wa.group.inviteCode(groupId, 'code');
626
+ console.log('Invite link:', `https://chat.whatsapp.com/${code}`);
627
+
628
+ // Revoke invite code
629
+ await wa.group.inviteCode(groupId, 'revoke');
630
+
631
+ // Get invite info
632
+ const info = await wa.group.inviteCode('INVITE_CODE', 'info');
633
+
634
+ // Join group via invite code
635
+ await wa.group.inviteCode('INVITE_CODE', 'accept');
636
+ ```
637
+
638
+ ### Group Metadata
639
+
640
+ Get full group metadata.
641
+
642
+ ```typescript
643
+ const metadata = await wa.group.metadata(groupId);
644
+ console.log(metadata);
645
+ ```
646
+
647
+ ### Join Requests
648
+
649
+ Manage pending join requests.
650
+
651
+ ```typescript
652
+ // Get list of pending requests
653
+ const requests = await wa.group.requestJoinList(groupId);
654
+
655
+ // Approve requests
656
+ await wa.group.requestJoin(groupId, ['senderId'], 'approve');
657
+
658
+ // Reject requests
659
+ await wa.group.requestJoin(groupId, [...], 'reject');
660
+ ```
661
+
662
+ ### Fetch All Groups
663
+
664
+ Get all groups the bot is part of.
665
+
666
+ ```typescript
667
+ const groups = await wa.group.fetchAllGroups();
668
+ console.log('Joined groups:', Object.keys(groups).length);
669
+ ```
670
+
671
+ ### Ephemeral Messages
672
+
673
+ Set disappearing messages in groups.
674
+
675
+ ```typescript
676
+ // Turn off disappearing messages
677
+ await wa.group.ephemeral(groupId, 'off');
678
+
679
+ // Set to 24 hours
680
+ await wa.group.ephemeral(groupId, '24h');
681
+
682
+ // Set to 7 days
683
+ await wa.group.ephemeral(groupId, '7d');
684
+
685
+ // Set to 90 days
686
+ await wa.group.ephemeral(groupId, '90d');
687
+ ```
688
+
689
+ ### Leave Group
690
+
691
+ Leave group.
692
+
693
+ ```typescript
694
+ await wa.group.leave(groupId);
695
+ ```
696
+
697
+ ## ๐Ÿ“ฐ Newsletter (Channel)
698
+
699
+ Create and manage WhatsApp Channels (Newsletters).
700
+
701
+ > **Quick Jump:** [Create](#create-channel) ยท [Actions](#channel-actions) ยท [Update](#update-channel) ยท [Info](#channel-info) ยท [Messages](#manage-messages) ยท [Admin](#admin-actions)
702
+
703
+ ### Create Channel
704
+
705
+ ```typescript
706
+ const channel = await wa.newsletter.create('My Channel', 'Description here');
707
+ console.log('Channel created:', channel);
708
+ ```
709
+
710
+ ### Channel Actions
711
+
712
+ Follow, unfollow, mute, or unmute a channel.
713
+
714
+ ```typescript
715
+ const channelId = '1234567890@newsletter';
716
+
717
+ // Follow
718
+ await wa.newsletter.action(channelId, 'follow');
719
+
720
+ // Unfollow
721
+ await wa.newsletter.action(channelId, 'unfollow');
722
+
723
+ // Mute
724
+ await wa.newsletter.action(channelId, 'mute');
725
+
726
+ // Unmute
727
+ await wa.newsletter.action(channelId, 'unmute');
728
+ ```
729
+
730
+ ### Update Channel
731
+
732
+ Update channel info.
733
+
734
+ ```typescript
735
+ // Update name
736
+ await wa.newsletter.update(channelId, 'New Name', 'name');
737
+
738
+ // Update description
739
+ await wa.newsletter.update(channelId, 'New Description', 'description');
740
+
741
+ // Update picture (URL/Buffer)
742
+ await wa.newsletter.update(channelId, 'https://example.com/image.jpg', 'picture');
743
+
744
+ // Remove picture
745
+ await wa.newsletter.removePicture(channelId);
746
+ ```
747
+
748
+ ### Channel Info
749
+
750
+ Get channel details.
751
+
752
+ ```typescript
753
+ // Get metadata by ChannelId
754
+ const meta = await wa.newsletter.metadata(channelId, 'jid');
755
+
756
+ // Get metadata by Invite Code
757
+ const metaInvite = await wa.newsletter.metadata('INVITE_CODE', 'invite');
758
+
759
+ // Get subscribers
760
+ const subs = await wa.newsletter.subscribers(channelId);
761
+
762
+ // Get admin count
763
+ const adminCount = await wa.newsletter.adminCount(channelId);
764
+ ```
765
+
766
+ ### Manage Messages
767
+
768
+ Fetch messages or react to them.
769
+
770
+ ```typescript
771
+ // Fetch messages
772
+ const since = new Date() - 1000 * 60 * 60 * 24; // 1 day
773
+ const after = new Date();
774
+
775
+ const count = 10;
776
+
777
+ const messages = await wa.newsletter.fetchMessages(channelId, count, since, after);
778
+
779
+ // React to message
780
+ await wa.newsletter.reaction(channelId, 'chatId', '๐Ÿ‘');
781
+ ```
782
+
783
+ ### Admin Actions
784
+
785
+ Manage channel ownership and admins.
786
+
787
+ ```typescript
788
+ // Change owner
789
+ await wa.newsletter.changeOwner(channelId, 'senderId');
790
+
791
+ // Demote admin
792
+ await wa.newsletter.demote(channelId, 'senderId');
793
+
794
+ // Delete channel
795
+ await wa.newsletter.delete(channelId);
796
+ ```
797
+
798
+ ## ๐ŸŒ Community Management
799
+
800
+ Create and manage WhatsApp Communities.
801
+
802
+ > **Quick Jump:** [Create](#create-community) ยท [Create Group](#create-group-in-community) ยท [Groups](#manage-groups) ยท [Info](#community-info) ยท [Participants](#manage-participants-1) ยท [Invite](#invite-code-1) ยท [Settings](#community-settings) ยท [Leave](#leave-community)
803
+
804
+ ### Create Community
805
+
806
+ ```typescript
807
+ const community = await wa.community.create('My Community', 'Description here');
808
+ console.log('Community created:', community);
809
+ ```
810
+
811
+ ### Create Group in Community
812
+
813
+ Create a new group linked to a community.
814
+
815
+ ```typescript
816
+ const communityId = '1234567890@g.us';
817
+ const group = await wa.community.createGroup('New Group', ['senderId'], communityId);
818
+ ```
819
+
820
+ ### Manage Groups
821
+
822
+ Link or unlink groups from a community.
823
+
824
+ ```typescript
825
+ const groupId = '0987654321@g.us';
826
+
827
+ // Link group
828
+ await wa.community.group(communityId, 'link', groupId);
829
+
830
+ // Unlink group
831
+ await wa.community.group(communityId, 'unlink', groupId);
832
+
833
+ // Get linked groups
834
+ const linkedGroups = await wa.community.group(communityId, 'linked');
835
+ ```
836
+
837
+ ### Community Info
838
+
839
+ Get metadata or update info.
840
+
841
+ ```typescript
842
+ // Get metadata
843
+ const meta = await wa.community.metadata(communityId);
844
+
845
+ // Update subject
846
+ await wa.community.update(communityId, 'subject', 'New Name');
847
+
848
+ // Update description
849
+ await wa.community.update(communityId, 'description', 'New Description');
850
+ ```
851
+
852
+ ### Manage Participants
853
+
854
+ Manage community participants.
855
+
856
+ ```typescript
857
+ // List participants
858
+ const participants = await wa.community.participants(communityId, 'list');
859
+
860
+ // Add participant
861
+ await wa.community.participants(communityId, 'update', 'add', ['senderId']);
862
+
863
+ // Remove participant
864
+ await wa.community.participants(communityId, 'update', 'remove', ['senderId']);
865
+
866
+ // Promote to admin
867
+ await wa.community.participants(communityId, 'update', 'promote', ['senderId']);
868
+
869
+ // Demote to member
870
+ await wa.community.participants(communityId, 'update', 'demote', ['senderId']);
871
+ ```
872
+
873
+ ### Invite Code
874
+
875
+ Manage community invite links.
876
+
877
+ ```typescript
878
+ // Get invite code
879
+ const code = await wa.community.invite(communityId, 'code');
880
+
881
+ // Revoke invite code
882
+ await wa.community.invite(communityId, 'revoke');
883
+
884
+ // Get invite info
885
+ const info = await wa.community.invite('INVITE_CODE', 'info');
886
+
887
+ // Join via invite code
888
+ await wa.community.invite('INVITE_CODE', 'accept');
889
+ ```
890
+
891
+ ### Community Settings
892
+
893
+ Configure community settings.
894
+
895
+ ```typescript
896
+ // Toggle ephemeral messages
897
+ await wa.community.settings(communityId, 'ephemeral', 86400); // 24 hours
898
+
899
+ // Who can add members? 'all_member_add' or 'admin_add'
900
+ await wa.community.settings(communityId, 'memberAdd', 'admin_add');
901
+
902
+ // Join approval mode? 'on' or 'off'
903
+ await wa.community.settings(communityId, 'approval', 'on');
904
+ ```
905
+
906
+ ### Leave Community
907
+
908
+ Leave a community.
909
+
910
+ ```typescript
911
+ await wa.community.leave(communityId);
912
+ ```
913
+
914
+ ## ๐Ÿ”’ Privacy Settings
915
+
916
+ Manage your privacy settings and block list.
917
+
918
+ > **Quick Jump:** [Block/Unblock](#blockunblock) ยท [Configuration](#privacy-configuration) ยท [Get Settings](#get-settings)
919
+
920
+ ### Block/Unblock
921
+
922
+ ```typescript
923
+ // Block user
924
+ await wa.privacy.block('senderId');
925
+
926
+ // Unblock user
927
+ await wa.privacy.unblock('senderId');
928
+
929
+ // Get blocklist
930
+ const blocklist = await wa.privacy.blocklist();
931
+ ```
932
+
933
+ ### Privacy Configuration
934
+
935
+ Update privacy settings.
936
+
937
+ ```typescript
938
+ // Last Seen: 'all', 'contacts', 'contact_blacklist', 'none'
939
+ await wa.privacy.lastSeen('contacts');
940
+
941
+ // Online: 'all', 'match_last_seen'
942
+ await wa.privacy.online('match_last_seen');
943
+
944
+ // Profile Picture: 'all', 'contacts', 'contact_blacklist', 'none'
945
+ await wa.privacy.picture('all');
946
+
947
+ // Status: 'all', 'contacts', 'contact_blacklist', 'none'
948
+ await wa.privacy.status('contacts');
949
+
950
+ // Read Receipts: 'all', 'none'
951
+ await wa.privacy.readReceipt('all');
952
+
953
+ // Group Add: 'all', 'contacts', 'contact_blacklist', 'none'
954
+ await wa.privacy.groupsAdd('contacts');
955
+
956
+ // Default Disappearing Mode: 'off', '24h', '7d', '90d'
957
+ await wa.privacy.ephemeral('90d');
958
+ ```
959
+
960
+ ### Get Settings
961
+
962
+ Fetch current privacy settings.
963
+
964
+ ```typescript
965
+ const settings = await wa.privacy.getSettings();
966
+ console.log(settings);
967
+ ```
968
+
969
+ ## ๐Ÿค Contributing
970
+
971
+ Contributions are welcome! Please follow these steps:
972
+
973
+ 1. Fork the repository.
974
+ 2. Create new branch: `git checkout -b feature/my-feature`.
975
+ 3. Commit your changes: `git commit -m 'Add some feature'`.
976
+ 4. Push to the branch: `git push origin feature/my-feature`.
977
+ 5. Open Pull Request.
978
+
979
+ ### ๐ŸŽฏ Issues & Feedback
980
+
981
+ **If you encounter any problems or have feature requests, please open an [issue](https://github.com/zeative/zaileys/issues)**
982
+
983
+ - [Buy me coffee โ˜•](https://saweria.co/zaadevofc)
984
+ - [Ko-Fi](https://ko-fi.com/zaadevofc)
985
+ - [Trakteer](https://trakteer.id/zaadevofc)
986
+ - โญ Star the repo on GitHub
987
+
988
+ ### ๐Ÿ“œ License
989
+
990
+ Distributed under the **MIT License**. See [`LICENSE`](https://github.com/zeative/zaileys/blob/main/LICENSE) for details.