whatsapp-web-sj.js 1.26.0 → 1.31.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 CHANGED
@@ -7,7 +7,7 @@
7
7
  <p>
8
8
  <a href="https://www.npmjs.com/package/whatsapp-web.js"><img src="https://img.shields.io/npm/v/whatsapp-web.js.svg" alt="npm" /></a>
9
9
  <a href="https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765"><img src="https://badges.depfu.com/badges/4a65a0de96ece65fdf39e294e0c8dcba/overview.svg" alt="Depfu" /></a>
10
- <img src="https://img.shields.io/badge/WhatsApp_Web-2.3000.1016590837-brightgreen.svg" alt="WhatsApp_Web 2.2346.52" />
10
+ <img src="https://img.shields.io/badge/WhatsApp_Web-2.3000.1017054665-brightgreen.svg" alt="WhatsApp_Web 2.2346.52" />
11
11
  <a href="https://discord.gg/H7DqQs4"><img src="https://img.shields.io/discord/698610475432411196.svg?logo=discord" alt="Discord server" /></a>
12
12
  </p>
13
13
  <br />
@@ -128,9 +128,9 @@ For further details on saving and restoring sessions, explore the provided [Auth
128
128
  | Set user status message | ✅ |
129
129
  | React to messages | ✅ |
130
130
  | Create polls | ✅ |
131
+ | Channels | ✅ |
131
132
  | Vote in polls | 🔜 |
132
133
  | Communities | 🔜 |
133
- | Channels | 🔜 |
134
134
 
135
135
  Something missing? Make an issue and let us know!
136
136
 
package/example.js CHANGED
@@ -450,7 +450,7 @@ client.on('message', async msg => {
450
450
  */
451
451
  const result = await msg.pin(60); // Will pin a message for 1 minute
452
452
  console.log(result); // True if the operation completed successfully, false otherwise
453
- }else if (msg.body === '!howManyConnections'){
453
+ } else if (msg.body === '!howManyConnections') {
454
454
  /**
455
455
  * Get user device count by ID
456
456
  * Each WaWeb Connection counts as one device, and the phone (if exists) counts as one
@@ -458,6 +458,52 @@ client.on('message', async msg => {
458
458
  */
459
459
  let deviceCount = await client.getContactDeviceCount(msg.from);
460
460
  await msg.reply(`You have *${deviceCount}* devices connected`);
461
+ } else if (msg.body === '!syncHistory') {
462
+ const isSynced = await client.syncHistory(msg.from);
463
+ // Or through the Chat object:
464
+ // const chat = await client.getChatById(msg.from);
465
+ // const isSynced = await chat.syncHistory();
466
+
467
+ await msg.reply(isSynced ? 'Historical chat is syncing..' : 'There is no historical chat to sync.');
468
+ } else if (msg.body === '!statuses') {
469
+ const statuses = await client.getBroadcasts();
470
+ console.log(statuses);
471
+ const chat = await statuses[0]?.getChat(); // Get user chat of a first status
472
+ console.log(chat);
473
+ } else if (msg.body === '!sendMediaHD' && msg.hasQuotedMsg) {
474
+ const quotedMsg = await msg.getQuotedMessage();
475
+ if (quotedMsg.hasMedia) {
476
+ const media = await quotedMsg.downloadMedia();
477
+ await client.sendMessage(msg.from, media, { sendMediaAsHd: true });
478
+ }
479
+ } else if (msg.body === '!parseVCard') {
480
+ const vCard =
481
+ 'BEGIN:VCARD\n' +
482
+ 'VERSION:3.0\n' +
483
+ 'FN:John Doe\n' +
484
+ 'ORG:Microsoft;\n' +
485
+ 'EMAIL;type=INTERNET:john.doe@gmail.com\n' +
486
+ 'URL:www.johndoe.com\n' +
487
+ 'TEL;type=CELL;type=VOICE;waid=18006427676:+1 (800) 642 7676\n' +
488
+ 'END:VCARD';
489
+ const vCardExtended =
490
+ 'BEGIN:VCARD\n' +
491
+ 'VERSION:3.0\n' +
492
+ 'FN:John Doe\n' +
493
+ 'ORG:Microsoft;\n' +
494
+ 'item1.TEL:+1 (800) 642 7676\n' +
495
+ 'item1.X-ABLabel:USA Customer Service\n' +
496
+ 'item2.TEL:+55 11 4706 0900\n' +
497
+ 'item2.X-ABLabel:Brazil Customer Service\n' +
498
+ 'PHOTO;BASE64:here you can paste a binary data of a contact photo in Base64 encoding\n' +
499
+ 'END:VCARD';
500
+ const userId = 'XXXXXXXXXX@c.us';
501
+ await client.sendMessage(userId, vCard);
502
+ await client.sendMessage(userId, vCardExtended);
503
+ } else if (msg.body === '!changeSync') {
504
+ // NOTE: this action will take effect after you restart the client.
505
+ const backgroundSync = await client.setBackgroundSync(true);
506
+ console.log(backgroundSync);
461
507
  }
462
508
  });
463
509
 
package/index.d.ts CHANGED
@@ -24,6 +24,15 @@ declare namespace WAWebJS {
24
24
  /**Accepts an invitation to join a group */
25
25
  acceptInvite(inviteCode: string): Promise<string>
26
26
 
27
+ /** Accepts a channel admin invitation and promotes the current user to a channel admin */
28
+ acceptChannelAdminInvite(channelId: string): Promise<boolean>
29
+
30
+ /** Revokes a channel admin invitation sent to a user by a channel owner */
31
+ revokeChannelAdminInvite(channelId: string, userId: string): Promise<boolean>
32
+
33
+ /** Demotes a channel admin to a regular subscriber (can be used also for self-demotion) */
34
+ demoteChannelAdmin(channelId: string, userId: string): Promise<boolean>
35
+
27
36
  /** Accepts a private invitation to join a group (v4 invite) */
28
37
  acceptGroupV4Invite: (inviteV4: InviteV4Data) => Promise<{status: number}>
29
38
 
@@ -42,6 +51,27 @@ declare namespace WAWebJS {
42
51
  /** Creates a new group */
43
52
  createGroup(title: string, participants?: string | Contact | Contact[] | string[], options?: CreateGroupOptions): Promise<CreateGroupResult|string>
44
53
 
54
+ /** Creates a new channel */
55
+ createChannel(title: string, options?: CreateChannelOptions): Promise<CreateChannelResult | string>
56
+
57
+ /** Deletes the channel you created */
58
+ deleteChannel(channelId: string): Promise<boolean>;
59
+
60
+ /** Subscribe to channel */
61
+ subscribeToChannel(channelId: string): Promise<boolean>
62
+
63
+ /** Unsubscribe from channel */
64
+ unsubscribeFromChannel(channelId: string, options?: UnsubscribeOptions): Promise<boolean>
65
+
66
+ /**
67
+ * Searches for channels based on search criteria, there are some notes:
68
+ * 1. The method finds only channels you are not subscribed to currently
69
+ * 2. If you have never been subscribed to a found channel
70
+ * or you have unsubscribed from it with {@link UnsubscribeOptions.deleteLocalModels} set to 'true',
71
+ * the lastMessage property of a found channel will be 'null'
72
+ */
73
+ searchChannels(searchOptions: SearchChannelsOptions): Promise<Array<Channel> | []>
74
+
45
75
  /** Closes the client */
46
76
  destroy(): Promise<void>
47
77
 
@@ -51,12 +81,18 @@ declare namespace WAWebJS {
51
81
  /** Get all blocked contacts by host account */
52
82
  getBlockedContacts(): Promise<Contact[]>
53
83
 
54
- /** Get chat instance by ID */
84
+ /** Gets chat or channel instance by ID */
55
85
  getChatById(chatId: string): Promise<Chat>
56
86
 
87
+ /** Gets a {@link Channel} instance by invite code */
88
+ getChannelByInviteCode(inviteCode: string): Promise<Channel>
89
+
57
90
  /** Get all current chat instances */
58
91
  getChats(): Promise<Chat[]>
59
92
 
93
+ /** Gets all cached {@link Channel} instances */
94
+ getChannels(): Promise<Channel[]>
95
+
60
96
  /** Get contact instance by ID */
61
97
  getContactById(contactId: string): Promise<Contact>
62
98
 
@@ -75,6 +111,9 @@ declare namespace WAWebJS {
75
111
  /** Get all current Labels */
76
112
  getLabels(): Promise<Label[]>
77
113
 
114
+ /** Get all current Broadcasts */
115
+ getBroadcasts(): Promise<Broadcast[]>
116
+
78
117
  /** Change labels in chats */
79
118
  addOrRemoveLabels(labelIds: Array<number|string>, chatIds: Array<string>): Promise<void>
80
119
 
@@ -113,7 +152,7 @@ declare namespace WAWebJS {
113
152
  * @param chatId ID of the chat that will be muted
114
153
  * @param unmuteDate Date when the chat will be unmuted, leave as is to mute forever
115
154
  */
116
- muteChat(chatId: string, unmuteDate?: Date): Promise<void>
155
+ muteChat(chatId: string, unmuteDate?: Date): Promise<{ isMuted: boolean, muteExpiration: number }>
117
156
 
118
157
  /**
119
158
  * Request authentication via pairing code instead of QR code
@@ -128,6 +167,9 @@ declare namespace WAWebJS {
128
167
 
129
168
  /** Send a message to a specific chatId */
130
169
  sendMessage(chatId: string, content: MessageContent, options?: MessageSendOptions): Promise<Message>
170
+
171
+ /** Sends a channel admin invitation to a user, allowing them to become an admin of the channel */
172
+ sendChannelAdminInvite(chatId: string, channelId: string, options?: { comment?: string }): Promise<boolean>
131
173
 
132
174
  /** Searches for messages */
133
175
  searchMessages(query: string, options?: { chatId?: string, page?: number, limit?: number }): Promise<Message[]>
@@ -177,19 +219,35 @@ declare namespace WAWebJS {
177
219
  */
178
220
  setAutoDownloadVideos(flag: boolean): Promise<void>
179
221
 
222
+ /**
223
+ * Changing the background synchronization setting.
224
+ * NOTE: this action will take effect after you restart the client.
225
+ * @param flag true/false on or off
226
+ */
227
+ setBackgroundSync(flag: boolean): Promise<void>
228
+
180
229
  /**
181
230
  * Get user device count by ID
182
231
  * Each WaWeb Connection counts as one device, and the phone (if exists) counts as one
183
232
  * So for a non-enterprise user with one WaWeb connection it should return "2"
184
233
  * @param {string} contactId
185
234
  */
186
- getContactDeviceCount(contactId: string): Promise<Number>
235
+ getContactDeviceCount(userId: string): Promise<number>
236
+
237
+ /** Sync history conversation of the Chat */
238
+ syncHistory(chatId: string): Promise<boolean>
239
+
240
+ /** Save new contact to user's addressbook or edit the existing one */
241
+ saveOrEditAddressbookContact(phoneNumber: string, firstName: string, lastName: string, syncToAddressbook?: boolean): Promise<ChatId>
242
+
243
+ /** Deletes the contact from user's addressbook */
244
+ deleteAddressbookContact(honeNumber: string): Promise<void>
187
245
 
188
246
  /** Changes and returns the archive state of the Chat */
189
247
  unarchiveChat(chatId: string): Promise<boolean>
190
248
 
191
249
  /** Unmutes the Chat */
192
- unmuteChat(chatId: string): Promise<void>
250
+ unmuteChat(chatId: string): Promise<{ isMuted: boolean, muteExpiration: number }>
193
251
 
194
252
  /** Sets the current user's profile picture */
195
253
  setProfilePicture(media: MessageMedia): Promise<boolean>
@@ -198,13 +256,19 @@ declare namespace WAWebJS {
198
256
  deleteProfilePicture(): Promise<boolean>
199
257
 
200
258
  /** Gets an array of membership requests */
201
- getGroupMembershipRequests: (groupId: string) => Promise<Array<GroupMembershipRequest>>
259
+ getGroupMembershipRequests(groupId: string): Promise<Array<GroupMembershipRequest>>
202
260
 
203
261
  /** Approves membership requests if any */
204
- approveGroupMembershipRequests: (groupId: string, options: MembershipRequestActionOptions) => Promise<Array<MembershipRequestActionResult>>;
262
+ approveGroupMembershipRequests(groupId: string, options: MembershipRequestActionOptions): Promise<Array<MembershipRequestActionResult>>;
205
263
 
206
264
  /** Rejects membership requests if any */
207
- rejectGroupMembershipRequests: (groupId: string, options: MembershipRequestActionOptions) => Promise<Array<MembershipRequestActionResult>>;
265
+ rejectGroupMembershipRequests(groupId: string, options: MembershipRequestActionOptions): Promise<Array<MembershipRequestActionResult>>;
266
+
267
+ /**
268
+ * Transfers a channel ownership to another user.
269
+ * Note: the user you are transferring the channel ownership to must be a channel admin.
270
+ */
271
+ transferChannelOwnership(channelId: string, newOwnerId: string, options?: TransferChannelOwnershipOptions): Promise<boolean>;
208
272
 
209
273
  /** Generic event */
210
274
  on(event: string, listener: (...args: any) => void): this
@@ -532,7 +596,8 @@ declare namespace WAWebJS {
532
596
  public dataPath?: string;
533
597
  constructor(options?: {
534
598
  clientId?: string,
535
- dataPath?: string
599
+ dataPath?: string,
600
+ rmMaxRetries?: number
536
601
  })
537
602
  }
538
603
 
@@ -546,7 +611,8 @@ declare namespace WAWebJS {
546
611
  store: Store,
547
612
  clientId?: string,
548
613
  dataPath?: string,
549
- backupSyncIntervalMs: number
614
+ backupSyncIntervalMs: number,
615
+ rmMaxRetries?: number
550
616
  })
551
617
  }
552
618
 
@@ -634,6 +700,46 @@ declare namespace WAWebJS {
634
700
  };
635
701
  }
636
702
 
703
+ /** An object that handles options for channel creation */
704
+ export interface CreateChannelOptions {
705
+ /** The channel description */
706
+ description?: string,
707
+ /** The channel profile picture */
708
+ picture?: MessageMedia
709
+ }
710
+
711
+ /** An object that handles the result for createGroup method */
712
+ export interface CreateChannelResult {
713
+ /** A channel title */
714
+ title: string,
715
+ /** An object that handles the newly created channel ID */
716
+ nid: ChatId,
717
+ /** The channel invite link, starts with 'https://whatsapp.com/channel/' */
718
+ inviteLink: string,
719
+ /** The timestamp the channel was created at */
720
+ createdAtTs: number
721
+ }
722
+
723
+ /** Options for unsubscribe from a channel */
724
+ export interface UnsubscribeOptions {
725
+ /**
726
+ * If true, after an unsubscription, it will completely remove a channel from the channel collection
727
+ * making it seem like the current user have never interacted with it.
728
+ * Otherwise it will only remove a channel from the list of channels the current user is subscribed to
729
+ * and will set the membership type for that channel to GUEST
730
+ */
731
+ deleteLocalModels?: boolean
732
+ }
733
+
734
+ /** Options for searching for channels */
735
+ export interface SearchChannelsOptions {
736
+ searchText?: string;
737
+ countryCodes?: string[];
738
+ skipSubscribedNewsletters?: boolean;
739
+ view?: number;
740
+ limit?: number;
741
+ }
742
+
637
743
  export interface GroupNotification {
638
744
  /** ContactId for the user that produced the GroupNotification */
639
745
  author: string,
@@ -885,15 +991,11 @@ declare namespace WAWebJS {
885
991
  /** MediaKey that represents the sticker 'ID' */
886
992
  mediaKey?: string,
887
993
  /** Indicates the mentions in the message body. */
888
- mentionedIds: ChatId[],
994
+ mentionedIds: string[],
889
995
  /** Indicates whether there are group mentions in the message body */
890
996
  groupMentions: {
891
997
  groupSubject: string;
892
- groupJid: {
893
- server: string;
894
- user: string;
895
- _serialized: string;
896
- };
998
+ groupJid: string;
897
999
  }[],
898
1000
  /** Unix timestamp for when the message was created */
899
1001
  timestamp: number,
@@ -945,7 +1047,7 @@ declare namespace WAWebJS {
945
1047
  /** Accept the Group V4 Invite in message */
946
1048
  acceptGroupV4Invite: () => Promise<{status: number}>,
947
1049
  /** Deletes the message from the chat */
948
- delete: (everyone?: boolean) => Promise<void>,
1050
+ delete: (everyone?: boolean, clearMedia?: boolean) => Promise<void>,
949
1051
  /** Downloads and returns the attached message media */
950
1052
  downloadMedia: () => Promise<MessageMedia>,
951
1053
  /** Returns the Chat this message was sent in */
@@ -1018,7 +1120,10 @@ declare namespace WAWebJS {
1018
1120
  export class Location {
1019
1121
  latitude: string;
1020
1122
  longitude: string;
1021
- options?: LocationSendOptions;
1123
+ name?: string;
1124
+ address?: string;
1125
+ url?: string;
1126
+ description?: string;
1022
1127
 
1023
1128
  constructor(latitude: number, longitude: number, options?: LocationSendOptions)
1024
1129
  }
@@ -1086,6 +1191,28 @@ declare namespace WAWebJS {
1086
1191
  getChats: () => Promise<Chat[]>
1087
1192
  }
1088
1193
 
1194
+ export interface Broadcast {
1195
+ /** Chat Object ID */
1196
+ id: {
1197
+ server: string,
1198
+ user: string,
1199
+ _serialized: string
1200
+ },
1201
+ /** Unix timestamp of last story */
1202
+ timestamp: number,
1203
+ /** Number of available statuses */
1204
+ totalCount: number,
1205
+ /** Number of not viewed */
1206
+ unreadCount: number,
1207
+ /** Unix timestamp of last story */
1208
+ msgs: Message[],
1209
+
1210
+ /** Returns the Chat of the owner of the story */
1211
+ getChat: () => Promise<Chat>,
1212
+ /** Returns the Contact of the owner of the story */
1213
+ getContact: () => Promise<Contact>,
1214
+ }
1215
+
1089
1216
  /** Options for sending a message */
1090
1217
  export interface MessageSendOptions {
1091
1218
  /** Show links preview. Has no effect on multi-device accounts. */
@@ -1098,6 +1225,8 @@ declare namespace WAWebJS {
1098
1225
  sendMediaAsSticker?: boolean
1099
1226
  /** Send media as document */
1100
1227
  sendMediaAsDocument?: boolean
1228
+ /** Send media as quality HD */
1229
+ sendMediaAsHd?: boolean
1101
1230
  /** Send photo/video as a view once message */
1102
1231
  isViewOnce?: boolean
1103
1232
  /** Automatically parse vCards and send them as contacts */
@@ -1128,7 +1257,10 @@ declare namespace WAWebJS {
1128
1257
  /** Sticker author, if sendMediaAsSticker is true */
1129
1258
  stickerAuthor?: string
1130
1259
  /** Sticker categories, if sendMediaAsSticker is true */
1131
- stickerCategories?: string[]
1260
+ stickerCategories?: string[],
1261
+ /** Should the bot send a quoted message without the quoted message if it fails to get the quote?
1262
+ * @default true (enabled) */
1263
+ ignoreQuoteErrors?: boolean
1132
1264
  }
1133
1265
 
1134
1266
  /** Options for editing a message */
@@ -1419,11 +1551,11 @@ declare namespace WAWebJS {
1419
1551
  /** Loads chat messages, sorted from earliest to latest. */
1420
1552
  fetchMessages: (searchOptions: MessageSearchOptions) => Promise<Message[]>,
1421
1553
  /** Mutes this chat forever, unless a date is specified */
1422
- mute: (unmuteDate?: Date) => Promise<void>,
1554
+ mute: (unmuteDate?: Date) => Promise<{ isMuted: boolean, muteExpiration: number }>,
1423
1555
  /** Send a message to this chat */
1424
1556
  sendMessage: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
1425
- /** Set the message as seen */
1426
- sendSeen: () => Promise<void>,
1557
+ /** Sets the chat as seen */
1558
+ sendSeen: () => Promise<boolean>,
1427
1559
  /** Simulate recording audio in chat. This will last for 25 seconds */
1428
1560
  sendStateRecording: () => Promise<void>,
1429
1561
  /** Simulate typing in chat. This will last for 25 seconds. */
@@ -1431,7 +1563,7 @@ declare namespace WAWebJS {
1431
1563
  /** un-archives this chat */
1432
1564
  unarchive: () => Promise<void>,
1433
1565
  /** Unmutes this chat */
1434
- unmute: () => Promise<void>,
1566
+ unmute: () => Promise<{ isMuted: boolean, muteExpiration: number }>,
1435
1567
  /** Returns the Contact that corresponds to this Chat. */
1436
1568
  getContact: () => Promise<Contact>,
1437
1569
  /** Marks this Chat as unread */
@@ -1440,6 +1572,101 @@ declare namespace WAWebJS {
1440
1572
  getLabels: () => Promise<Label[]>,
1441
1573
  /** Add or remove labels to this Chat */
1442
1574
  changeLabels: (labelIds: Array<string | number>) => Promise<void>
1575
+ /** Sync history conversation of the Chat */
1576
+ syncHistory: () => Promise<boolean>
1577
+ }
1578
+
1579
+ export interface Channel {
1580
+ /** ID that represents the channel */
1581
+ id: {
1582
+ server: string;
1583
+ user: string;
1584
+ _serialized: string;
1585
+ };
1586
+ /** Title of the channel */
1587
+ name: string;
1588
+ /** The channel description */
1589
+ description: string;
1590
+ /** Indicates if it is a Channel */
1591
+ isChannel: boolean;
1592
+ /** Indicates if it is a Group */
1593
+ isGroup: boolean;
1594
+ /** Indicates if the channel is readonly */
1595
+ isReadOnly: boolean;
1596
+ /** Amount of messages unread */
1597
+ unreadCount: number;
1598
+ /** Unix timestamp for when the last activity occurred */
1599
+ timestamp: number;
1600
+ /** Indicates if the channel is muted or not */
1601
+ isMuted: boolean;
1602
+ /** Unix timestamp for when the mute expires */
1603
+ muteExpiration: number;
1604
+ /** Last message in the channel */
1605
+ lastMessage: Message | undefined;
1606
+
1607
+ /** Gets the subscribers of the channel (only those who are in your contact list) */
1608
+ getSubscribers(limit?: number): Promise<{contact: Contact, role: string}[]>;
1609
+ /** Updates the channel subject */
1610
+ setSubject(newSubject: string): Promise<boolean>;
1611
+ /** Updates the channel description */
1612
+ setDescription(newDescription: string): Promise<boolean>;
1613
+ /** Updates the channel profile picture */
1614
+ setProfilePicture(newProfilePicture: MessageMedia): Promise<boolean>;
1615
+ /**
1616
+ * Updates available reactions to use in the channel
1617
+ *
1618
+ * Valid values for passing to the method are:
1619
+ * 0 for NONE reactions to be avaliable
1620
+ * 1 for BASIC reactions to be available: 👍, ❤️, 😂, 😮, 😢, 🙏
1621
+ * 2 for ALL reactions to be available
1622
+ */
1623
+ setReactionSetting(reactionCode: number): Promise<boolean>;
1624
+ /** Mutes the channel */
1625
+ mute(): Promise<boolean>;
1626
+ /** Unmutes the channel */
1627
+ unmute(): Promise<boolean>;
1628
+ /** Sends a message to this channel */
1629
+ sendMessage(content: string|MessageMedia, options?: MessageSendChannelOptions): Promise<Message>;
1630
+ /** Sets the channel as seen */
1631
+ sendSeen(): Promise<boolean>;
1632
+ /** Sends a channel admin invitation to a user, allowing them to become an admin of the channel */
1633
+ sendChannelAdminInvite(chatId: string, options?: { comment?: string }): Promise<boolean>;
1634
+ /** Accepts a channel admin invitation and promotes the current user to a channel admin */
1635
+ acceptChannelAdminInvite(): Promise<boolean>;
1636
+ /** Revokes a channel admin invitation sent to a user by a channel owner */
1637
+ revokeChannelAdminInvite(userId: string): Promise<boolean>;
1638
+ /** Demotes a channel admin to a regular subscriber (can be used also for self-demotion) */
1639
+ demoteChannelAdmin(userId: string): Promise<boolean>;
1640
+ /** Loads channel messages, sorted from earliest to latest */
1641
+ fetchMessages: (searchOptions: MessageSearchOptions) => Promise<Message[]>;
1642
+ /**
1643
+ * Transfers a channel ownership to another user.
1644
+ * Note: the user you are transferring the channel ownership to must be a channel admin.
1645
+ */
1646
+ transferChannelOwnership(newOwnerId: string, options?: TransferChannelOwnershipOptions): Promise<boolean>;
1647
+ /** Deletes the channel you created */
1648
+ deleteChannel(): Promise<boolean>;
1649
+ }
1650
+
1651
+ /** Options for transferring a channel ownership to another user */
1652
+ export interface TransferChannelOwnershipOptions {
1653
+ /**
1654
+ * If true, after the channel ownership is being transferred to another user,
1655
+ * the current user will be dismissed as a channel admin and will become to a channel subscriber.
1656
+ */
1657
+ shouldDismissSelfAsAdmin?: boolean
1658
+ }
1659
+
1660
+ /** Options for sending a message */
1661
+ export interface MessageSendChannelOptions {
1662
+ /** Image or videos caption */
1663
+ caption?: string
1664
+ /** User IDs of user that will be mentioned in the message */
1665
+ mentions?: string[]
1666
+ /** Image or video to be sent */
1667
+ media?: MessageMedia
1668
+ /** Extra options */
1669
+ extra?: any
1443
1670
  }
1444
1671
 
1445
1672
  export interface MessageSearchOptions {
package/index.js CHANGED
@@ -11,6 +11,7 @@ module.exports = {
11
11
  Chat: require('./src/structures/Chat'),
12
12
  PrivateChat: require('./src/structures/PrivateChat'),
13
13
  GroupChat: require('./src/structures/GroupChat'),
14
+ Channel: require('./src/structures/Channel'),
14
15
  Message: require('./src/structures/Message'),
15
16
  MessageMedia: require('./src/structures/MessageMedia'),
16
17
  Contact: require('./src/structures/Contact'),
@@ -22,6 +23,7 @@ module.exports = {
22
23
  ProductMetadata: require('./src/structures/ProductMetadata'),
23
24
  List: require('./src/structures/List'),
24
25
  Buttons: require('./src/structures/Buttons'),
26
+ Broadcast: require('./src/structures/Broadcast'),
25
27
 
26
28
  // Auth Strategies
27
29
  NoAuth: require('./src/authStrategies/NoAuth'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whatsapp-web-sj.js",
3
- "version": "1.26.0",
3
+ "version": "1.31.0",
4
4
  "description": "Library for interacting with the WhatsApp Web API ",
5
5
  "main": "./index.js",
6
6
  "typings": "./index.d.ts",
@@ -8,7 +8,11 @@
8
8
  "test": "mocha tests --recursive --timeout 5000",
9
9
  "test-single": "mocha",
10
10
  "shell": "node --experimental-repl-await ./shell.js",
11
- "generate-docs": "node_modules/.bin/jsdoc --configure .jsdoc.json --verbose"
11
+ "generate-docs": "npx jsdoc --configure .jsdoc.json --verbose"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/pedroslopez/whatsapp-web.js.git"
12
16
  },
13
17
  "keywords": [
14
18
  "whatsapp",
@@ -26,7 +30,7 @@
26
30
  "homepage": "https://wwebjs.dev/",
27
31
  "dependencies": {
28
32
  "@pedroslopez/moduleraid": "^5.0.2",
29
- "fluent-ffmpeg": "2.1.2",
33
+ "fluent-ffmpeg": "2.1.3",
30
34
  "mime": "^3.0.0",
31
35
  "node-fetch": "^2.6.9",
32
36
  "node-webpmux": "3.1.7",