@pney/whatsapp-web 1.34.6-3 → 1.34.7-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/.env.example +0 -1
  2. package/.gitattributes +4 -0
  3. package/.husky/commit-msg +4 -0
  4. package/.husky/pre-commit +1 -0
  5. package/.lintstagedrc.json +6 -0
  6. package/.prettierignore +8 -0
  7. package/.prettierrc.json +10 -0
  8. package/README.md +83 -80
  9. package/commitlint.config.js +29 -0
  10. package/eslint.config.mjs +67 -0
  11. package/example.js +151 -71
  12. package/index.d.ts +982 -734
  13. package/index.js +4 -4
  14. package/package.json +1 -1
  15. package/shell.js +4 -4
  16. package/src/Client.js +1860 -921
  17. package/src/authStrategies/BaseAuthStrategy.js +4 -2
  18. package/src/authStrategies/LocalAuth.js +25 -12
  19. package/src/authStrategies/NoAuth.js +3 -4
  20. package/src/authStrategies/RemoteAuth.js +92 -43
  21. package/src/factories/ChatFactory.js +1 -1
  22. package/src/factories/ContactFactory.js +2 -2
  23. package/src/structures/Base.js +5 -3
  24. package/src/structures/Broadcast.js +1 -2
  25. package/src/structures/BusinessContact.js +1 -2
  26. package/src/structures/Buttons.js +14 -10
  27. package/src/structures/Call.js +10 -6
  28. package/src/structures/Channel.js +171 -91
  29. package/src/structures/Chat.js +57 -41
  30. package/src/structures/ClientInfo.js +1 -1
  31. package/src/structures/Contact.js +37 -16
  32. package/src/structures/GroupChat.js +425 -228
  33. package/src/structures/GroupNotification.js +21 -12
  34. package/src/structures/Label.js +6 -6
  35. package/src/structures/List.js +22 -14
  36. package/src/structures/Location.js +5 -4
  37. package/src/structures/Message.js +412 -160
  38. package/src/structures/MessageMedia.js +31 -18
  39. package/src/structures/Order.js +4 -4
  40. package/src/structures/Payment.js +6 -3
  41. package/src/structures/Poll.js +2 -2
  42. package/src/structures/PollVote.js +9 -6
  43. package/src/structures/PrivateChat.js +2 -4
  44. package/src/structures/PrivateContact.js +2 -4
  45. package/src/structures/Product.js +1 -1
  46. package/src/structures/ProductMetadata.js +1 -2
  47. package/src/structures/Reaction.js +2 -4
  48. package/src/structures/ScheduledEvent.js +22 -10
  49. package/src/util/Constants.js +8 -6
  50. package/src/util/Injected/AuthStore/AuthStore.js +7 -3
  51. package/src/util/Injected/Utils.js +753 -345
  52. package/src/util/InterfaceController.js +72 -25
  53. package/src/util/Puppeteer.js +1 -1
  54. package/src/util/Util.js +28 -15
  55. package/src/webCache/LocalWebCache.js +7 -5
  56. package/src/webCache/RemoteWebCache.js +10 -4
  57. package/src/webCache/WebCache.js +8 -5
  58. package/src/webCache/WebCacheFactory.js +9 -9
  59. package/CODE_OF_CONDUCT.md +0 -133
package/index.d.ts CHANGED
@@ -1,67 +1,80 @@
1
-
2
- import { EventEmitter } from 'events'
3
- import { RequestInit } from 'node-fetch'
4
- import * as puppeteer from 'puppeteer'
5
- import InterfaceController from './src/util/InterfaceController'
1
+ import { EventEmitter } from 'events';
2
+ import { RequestInit } from 'node-fetch';
3
+ import * as puppeteer from 'puppeteer';
4
+ import InterfaceController from './src/util/InterfaceController';
6
5
 
7
6
  declare namespace WAWebJS {
8
-
9
7
  export class Client extends EventEmitter {
10
- constructor(options: ClientOptions)
8
+ constructor(options: ClientOptions);
11
9
 
12
10
  /** Current connection information */
13
- public info: ClientInfo
11
+ public info: ClientInfo;
14
12
 
15
13
  /** Puppeteer page running WhatsApp Web */
16
- pupPage?: puppeteer.Page
14
+ pupPage?: puppeteer.Page;
17
15
 
18
16
  /** Puppeteer browser running WhatsApp Web */
19
- pupBrowser?: puppeteer.Browser
17
+ pupBrowser?: puppeteer.Browser;
20
18
 
21
19
  /** Client interactivity interface */
22
- interface?: InterfaceController
20
+ interface?: InterfaceController;
23
21
 
24
22
  /**Accepts an invitation to join a group */
25
- acceptInvite(inviteCode: string): Promise<string>
23
+ acceptInvite(inviteCode: string): Promise<string>;
26
24
 
27
25
  /** Accepts a channel admin invitation and promotes the current user to a channel admin */
28
- acceptChannelAdminInvite(channelId: string): Promise<boolean>
26
+ acceptChannelAdminInvite(channelId: string): Promise<boolean>;
29
27
 
30
28
  /** Revokes a channel admin invitation sent to a user by a channel owner */
31
- revokeChannelAdminInvite(channelId: string, userId: string): Promise<boolean>
29
+ revokeChannelAdminInvite(
30
+ channelId: string,
31
+ userId: string,
32
+ ): Promise<boolean>;
32
33
 
33
34
  /** Demotes a channel admin to a regular subscriber (can be used also for self-demotion) */
34
- demoteChannelAdmin(channelId: string, userId: string): Promise<boolean>
35
+ demoteChannelAdmin(channelId: string, userId: string): Promise<boolean>;
35
36
 
36
37
  /** Accepts a private invitation to join a group (v4 invite) */
37
- acceptGroupV4Invite: (inviteV4: InviteV4Data) => Promise<{status: number}>
38
+ acceptGroupV4Invite: (
39
+ inviteV4: InviteV4Data,
40
+ ) => Promise<{ status: number }>;
38
41
 
39
42
  /**Returns an object with information about the invite code's group */
40
- getInviteInfo(inviteCode: string): Promise<object>
43
+ getInviteInfo(inviteCode: string): Promise<object>;
41
44
 
42
45
  /** Enables and returns the archive state of the Chat */
43
- archiveChat(chatId: string): Promise<boolean>
46
+ archiveChat(chatId: string): Promise<boolean>;
44
47
 
45
48
  /** Pins the Chat and returns its new Pin state */
46
- pinChat(chatId: string): Promise<boolean>
49
+ pinChat(chatId: string): Promise<boolean>;
47
50
 
48
51
  /** Unpins the Chat and returns its new Pin state */
49
- unpinChat(chatId: string): Promise<boolean>
52
+ unpinChat(chatId: string): Promise<boolean>;
50
53
 
51
54
  /** Creates a new group */
52
- createGroup(title: string, participants?: string | Contact | Contact[] | string[], options?: CreateGroupOptions): Promise<CreateGroupResult|string>
55
+ createGroup(
56
+ title: string,
57
+ participants?: string | Contact | Contact[] | string[],
58
+ options?: CreateGroupOptions,
59
+ ): Promise<CreateGroupResult | string>;
53
60
 
54
61
  /** Creates a new channel */
55
- createChannel(title: string, options?: CreateChannelOptions): Promise<CreateChannelResult | string>
62
+ createChannel(
63
+ title: string,
64
+ options?: CreateChannelOptions,
65
+ ): Promise<CreateChannelResult | string>;
56
66
 
57
67
  /** Deletes the channel you created */
58
68
  deleteChannel(channelId: string): Promise<boolean>;
59
69
 
60
70
  /** Subscribe to channel */
61
- subscribeToChannel(channelId: string): Promise<boolean>
71
+ subscribeToChannel(channelId: string): Promise<boolean>;
62
72
 
63
73
  /** Unsubscribe from channel */
64
- unsubscribeFromChannel(channelId: string, options?: UnsubscribeOptions): Promise<boolean>
74
+ unsubscribeFromChannel(
75
+ channelId: string,
76
+ options?: UnsubscribeOptions,
77
+ ): Promise<boolean>;
65
78
 
66
79
  /**
67
80
  * Searches for channels based on search criteria, there are some notes:
@@ -70,98 +83,106 @@ declare namespace WAWebJS {
70
83
  * or you have unsubscribed from it with {@link UnsubscribeOptions.deleteLocalModels} set to 'true',
71
84
  * the lastMessage property of a found channel will be 'null'
72
85
  */
73
- searchChannels(searchOptions: SearchChannelsOptions): Promise<Array<Channel> | []>
86
+ searchChannels(
87
+ searchOptions: SearchChannelsOptions,
88
+ ): Promise<Array<Channel> | []>;
74
89
 
75
90
  /** Closes the client */
76
- destroy(): Promise<void>
91
+ destroy(): Promise<void>;
77
92
 
78
93
  /** Logs out the client, closing the current session */
79
- logout(): Promise<void>
94
+ logout(): Promise<void>;
80
95
 
81
96
  /** Get all blocked contacts by host account */
82
- getBlockedContacts(): Promise<Contact[]>
97
+ getBlockedContacts(): Promise<Contact[]>;
83
98
 
84
99
  /** Gets chat or channel instance by ID */
85
- getChatById(chatId: string): Promise<Chat>
100
+ getChatById(chatId: string): Promise<Chat>;
86
101
 
87
102
  /** Gets a {@link Channel} instance by invite code */
88
- getChannelByInviteCode(inviteCode: string): Promise<Channel>
103
+ getChannelByInviteCode(inviteCode: string): Promise<Channel>;
89
104
 
90
105
  /** Get all current chat instances */
91
- getChats(): Promise<Chat[]>
106
+ getChats(): Promise<Chat[]>;
92
107
 
93
108
  /** Gets all cached {@link Channel} instances */
94
- getChannels(): Promise<Channel[]>
109
+ getChannels(): Promise<Channel[]>;
95
110
 
96
111
  /** Get contact instance by ID */
97
- getContactById(contactId: string): Promise<Contact>
112
+ getContactById(contactId: string): Promise<Contact>;
98
113
 
99
114
  /** Get message by ID */
100
- getMessageById(messageId: string): Promise<Message>
115
+ getMessageById(messageId: string): Promise<Message>;
101
116
 
102
117
  /** Gets instances of all pinned messages in a chat */
103
- getPinnedMessages(chatId: string): Promise<[Message]|[]>
118
+ getPinnedMessages(chatId: string): Promise<[Message] | []>;
104
119
 
105
120
  /** Get all current contact instances */
106
- getContacts(): Promise<Contact[]>
107
-
121
+ getContacts(): Promise<Contact[]>;
122
+
108
123
  /** Get the country code of a WhatsApp ID. (154185968@c.us) => (1) */
109
- getCountryCode(number: string): Promise<string>
124
+ getCountryCode(number: string): Promise<string>;
110
125
 
111
126
  /** Get the formatted number of a WhatsApp ID. (12345678901@c.us) => (+1 (234) 5678-901) */
112
- getFormattedNumber(number: string): Promise<string>
127
+ getFormattedNumber(number: string): Promise<string>;
113
128
 
114
129
  /** Get all current Labels */
115
- getLabels(): Promise<Label[]>
130
+ getLabels(): Promise<Label[]>;
116
131
 
117
132
  /** Get all current Broadcasts */
118
- getBroadcasts(): Promise<Broadcast[]>
133
+ getBroadcasts(): Promise<Broadcast[]>;
119
134
 
120
135
  /** Get broadcast instance by current user ID */
121
- getBroadcastById(contactId: string): Promise<Broadcast>
136
+ getBroadcastById(contactId: string): Promise<Broadcast>;
122
137
 
123
138
  /** Revoke current own status messages */
124
- revokeStatusMessage(messageId: string): Promise<void>
125
-
139
+ revokeStatusMessage(messageId: string): Promise<void>;
140
+
126
141
  /** Change labels in chats */
127
- addOrRemoveLabels(labelIds: Array<number|string>, chatIds: Array<string>): Promise<void>
142
+ addOrRemoveLabels(
143
+ labelIds: Array<number | string>,
144
+ chatIds: Array<string>,
145
+ ): Promise<void>;
128
146
 
129
147
  /** Get Label instance by ID */
130
- getLabelById(labelId: string): Promise<Label>
148
+ getLabelById(labelId: string): Promise<Label>;
131
149
 
132
150
  /** Get all Labels assigned to a Chat */
133
- getChatLabels(chatId: string): Promise<Label[]>
151
+ getChatLabels(chatId: string): Promise<Label[]>;
134
152
 
135
153
  /** Get all Chats for a specific Label */
136
- getChatsByLabelId(labelId: string): Promise<Chat[]>
154
+ getChatsByLabelId(labelId: string): Promise<Chat[]>;
137
155
 
138
156
  /** Returns the contact ID's profile picture URL, if privacy settings allow it */
139
- getProfilePicUrl(contactId: string): Promise<string>
157
+ getProfilePicUrl(contactId: string): Promise<string>;
140
158
 
141
159
  /** Gets the Contact's common groups with you. Returns empty array if you don't have any common group. */
142
- getCommonGroups(contactId: string): Promise<ChatId[]>
160
+ getCommonGroups(contactId: string): Promise<ChatId[]>;
143
161
 
144
162
  /** Gets the current connection state for the client */
145
- getState(): Promise<WAState>
163
+ getState(): Promise<WAState>;
146
164
 
147
165
  /** Returns the version of WhatsApp Web currently being run */
148
- getWWebVersion(): Promise<string>
166
+ getWWebVersion(): Promise<string>;
149
167
 
150
168
  /** Sets up events and requirements, kicks off authentication request */
151
- initialize(): Promise<void>
169
+ initialize(): Promise<void>;
152
170
 
153
171
  /** Check if a given ID is registered in whatsapp */
154
- isRegisteredUser(contactId: string): Promise<boolean>
172
+ isRegisteredUser(contactId: string): Promise<boolean>;
155
173
 
156
174
  /** Get the registered WhatsApp ID for a number. Returns null if the number is not registered on WhatsApp. */
157
- getNumberId(number: string): Promise<ContactId | null>
175
+ getNumberId(number: string): Promise<ContactId | null>;
158
176
 
159
177
  /**
160
178
  * Mutes this chat forever, unless a date is specified
161
179
  * @param chatId ID of the chat that will be muted
162
180
  * @param unmuteDate Date when the chat will be unmuted, leave as is to mute forever
163
181
  */
164
- muteChat(chatId: string, unmuteDate?: Date): Promise<{ isMuted: boolean, muteExpiration: number }>
182
+ muteChat(
183
+ chatId: string,
184
+ unmuteDate?: Date,
185
+ ): Promise<{ isMuted: boolean; muteExpiration: number }>;
165
186
 
166
187
  /**
167
188
  * Request authentication via pairing code instead of QR code
@@ -170,71 +191,95 @@ declare namespace WAWebJS {
170
191
  * @param intervalMs - The interval in milliseconds on how frequent to generate pairing code (WhatsApp default to 3 minutes). Defaults to `180000`
171
192
  * @returns {Promise<string>} - Returns a pairing code in format "ABCDEFGH"
172
193
  */
173
- requestPairingCode(phoneNumber: string, showNotification?: boolean, intervalMs?: number): Promise<string>
194
+ requestPairingCode(
195
+ phoneNumber: string,
196
+ showNotification?: boolean,
197
+ intervalMs?: number,
198
+ ): Promise<string>;
199
+
200
+ /** Cancels an active pairing code session and returns to QR code mode */
201
+ cancelPairingCode(): Promise<void>
174
202
 
175
203
  /** Force reset of connection state for the client */
176
- resetState(): Promise<void>
204
+ resetState(): Promise<void>;
177
205
 
178
206
  /** Send a message to a specific chatId */
179
- sendMessage(chatId: string, content: MessageContent, options?: MessageSendOptions): Promise<Message>
207
+ sendMessage(
208
+ chatId: string,
209
+ content: MessageContent,
210
+ options?: MessageSendOptions,
211
+ ): Promise<Message>;
212
+
213
+ /** Send a reaction to a specific messageId */
214
+ sendReaction(
215
+ messageId: string,
216
+ reaction: string,
217
+ ): Promise<void>;
180
218
 
181
219
  /** Sends a channel admin invitation to a user, allowing them to become an admin of the channel */
182
- sendChannelAdminInvite(chatId: string, channelId: string, options?: { comment?: string }): Promise<boolean>
183
-
220
+ sendChannelAdminInvite(
221
+ chatId: string,
222
+ channelId: string,
223
+ options?: { comment?: string },
224
+ ): Promise<boolean>;
225
+
184
226
  /** Searches for messages */
185
- searchMessages(query: string, options?: { chatId?: string, page?: number, limit?: number }): Promise<Message[]>
227
+ searchMessages(
228
+ query: string,
229
+ options?: { chatId?: string; page?: number; limit?: number },
230
+ ): Promise<Message[]>;
186
231
 
187
232
  /** Marks the client as online */
188
- sendPresenceAvailable(): Promise<void>
233
+ sendPresenceAvailable(): Promise<void>;
189
234
 
190
235
  /** Marks the client as offline */
191
- sendPresenceUnavailable(): Promise<void>
236
+ sendPresenceUnavailable(): Promise<void>;
192
237
 
193
238
  /** Mark as seen for the Chat */
194
- sendSeen(chatId: string): Promise<boolean>
239
+ sendSeen(chatId: string): Promise<boolean>;
195
240
 
196
241
  /** Mark the Chat as unread */
197
- markChatUnread(chatId: string): Promise<void>
242
+ markChatUnread(chatId: string): Promise<void>;
198
243
 
199
- /**
244
+ /**
200
245
  * Sets the current user's status message
201
246
  * @param status New status message
202
247
  */
203
- setStatus(status: string): Promise<void>
248
+ setStatus(status: string): Promise<void>;
204
249
 
205
- /**
250
+ /**
206
251
  * Sets the current user's display name
207
252
  * @param displayName New display name
208
253
  */
209
- setDisplayName(displayName: string): Promise<boolean>
210
-
254
+ setDisplayName(displayName: string): Promise<boolean>;
255
+
211
256
  /**
212
257
  * Changes the autoload Audio
213
258
  * @param flag true/false on or off
214
259
  */
215
- setAutoDownloadAudio(flag: boolean): Promise<void>
260
+ setAutoDownloadAudio(flag: boolean): Promise<void>;
216
261
  /**
217
262
  * Changes the autoload Documents
218
263
  * @param flag true/false on or off
219
264
  */
220
- setAutoDownloadDocuments(flag: boolean): Promise<void>
265
+ setAutoDownloadDocuments(flag: boolean): Promise<void>;
221
266
  /**
222
267
  * Changes the autoload Photos
223
268
  * @param flag true/false on or off
224
269
  */
225
- setAutoDownloadPhotos(flag: boolean): Promise<void>
270
+ setAutoDownloadPhotos(flag: boolean): Promise<void>;
226
271
  /**
227
272
  * Changes the autoload Videos
228
273
  * @param flag true/false on or off
229
274
  */
230
- setAutoDownloadVideos(flag: boolean): Promise<void>
275
+ setAutoDownloadVideos(flag: boolean): Promise<void>;
231
276
 
232
277
  /**
233
278
  * Changing the background synchronization setting.
234
279
  * NOTE: this action will take effect after you restart the client.
235
280
  * @param flag true/false on or off
236
281
  */
237
- setBackgroundSync(flag: boolean): Promise<void>
282
+ setBackgroundSync(flag: boolean): Promise<void>;
238
283
 
239
284
  /**
240
285
  * Get user device count by ID
@@ -242,19 +287,24 @@ declare namespace WAWebJS {
242
287
  * So for a non-enterprise user with one WaWeb connection it should return "2"
243
288
  * @param {string} contactId
244
289
  */
245
- getContactDeviceCount(userId: string): Promise<number>
246
-
290
+ getContactDeviceCount(userId: string): Promise<number>;
291
+
247
292
  /** Sync history conversation of the Chat */
248
- syncHistory(chatId: string): Promise<boolean>
293
+ syncHistory(chatId: string): Promise<boolean>;
249
294
 
250
295
  /** Save new contact to user's addressbook or edit the existing one */
251
- saveOrEditAddressbookContact(phoneNumber: string, firstName: string, lastName: string, syncToAddressbook?: boolean): Promise<void>
296
+ saveOrEditAddressbookContact(
297
+ phoneNumber: string,
298
+ firstName: string,
299
+ lastName: string,
300
+ syncToAddressbook?: boolean,
301
+ ): Promise<void>;
252
302
 
253
303
  /**
254
304
  * Add or edit a customer note
255
305
  * @see https://faq.whatsapp.com/1433099287594476
256
306
  */
257
- addOrEditCustomerNote(userId: string, note: string): Promise<void>
307
+ addOrEditCustomerNote(userId: string, note: string): Promise<void>;
258
308
 
259
309
  /**
260
310
  * Get a customer note
@@ -267,362 +317,473 @@ declare namespace WAWebJS {
267
317
  id: string;
268
318
  modifiedAt: number;
269
319
  type: string;
270
- }>
320
+ }>;
271
321
 
272
322
  /** Deletes the contact from user's addressbook */
273
- deleteAddressbookContact(honeNumber: string): Promise<void>
323
+ deleteAddressbookContact(honeNumber: string): Promise<void>;
274
324
 
275
325
  /** Get Contact lid and phone */
276
- getContactLidAndPhone(userIds: string[]): Promise<{ lid: string; pn: string }[]>
277
-
326
+ getContactLidAndPhone(
327
+ userIds: string[],
328
+ ): Promise<{ lid: string; pn: string }[]>;
329
+
278
330
  /** Changes and returns the archive state of the Chat */
279
- unarchiveChat(chatId: string): Promise<boolean>
331
+ unarchiveChat(chatId: string): Promise<boolean>;
280
332
 
281
333
  /** Unmutes the Chat */
282
- unmuteChat(chatId: string): Promise<{ isMuted: boolean, muteExpiration: number }>
334
+ unmuteChat(
335
+ chatId: string,
336
+ ): Promise<{ isMuted: boolean; muteExpiration: number }>;
283
337
 
284
338
  /** Sets the current user's profile picture */
285
- setProfilePicture(media: MessageMedia): Promise<boolean>
339
+ setProfilePicture(media: MessageMedia): Promise<boolean>;
286
340
 
287
341
  /** Deletes the current user's profile picture */
288
- deleteProfilePicture(): Promise<boolean>
342
+ deleteProfilePicture(): Promise<boolean>;
289
343
 
290
344
  /** Generates a WhatsApp call link (video call or voice call) */
291
- createCallLink(startTime: Date, callType: string): Promise<string>
345
+ createCallLink(startTime: Date, callType: string): Promise<string>;
292
346
 
293
347
  /**
294
348
  * Sends a response to the scheduled event message, indicating whether a user is going to attend the event or not
295
349
  * @param response The response code to the event message. Valid values are: `0` for NONE response (removes a previous response) | `1` for GOING | `2` for NOT GOING | `3` for MAYBE going
296
350
  * @param eventMessageId The event message ID
297
351
  */
298
- sendResponseToScheduledEvent(response: number, eventMessageId: string): Promise<boolean>
352
+ sendResponseToScheduledEvent(
353
+ response: number,
354
+ eventMessageId: string,
355
+ ): Promise<boolean>;
299
356
 
300
357
  /** Gets an array of membership requests */
301
- getGroupMembershipRequests(groupId: string): Promise<Array<GroupMembershipRequest>>
358
+ getGroupMembershipRequests(
359
+ groupId: string,
360
+ ): Promise<Array<GroupMembershipRequest>>;
302
361
 
303
362
  /** Approves membership requests if any */
304
- approveGroupMembershipRequests(groupId: string, options: MembershipRequestActionOptions): Promise<Array<MembershipRequestActionResult>>;
363
+ approveGroupMembershipRequests(
364
+ groupId: string,
365
+ options: MembershipRequestActionOptions,
366
+ ): Promise<Array<MembershipRequestActionResult>>;
305
367
 
306
368
  /** Rejects membership requests if any */
307
- rejectGroupMembershipRequests(groupId: string, options: MembershipRequestActionOptions): Promise<Array<MembershipRequestActionResult>>;
308
-
369
+ rejectGroupMembershipRequests(
370
+ groupId: string,
371
+ options: MembershipRequestActionOptions,
372
+ ): Promise<Array<MembershipRequestActionResult>>;
373
+
309
374
  /**
310
375
  * Transfers a channel ownership to another user.
311
376
  * Note: the user you are transferring the channel ownership to must be a channel admin.
312
377
  */
313
- transferChannelOwnership(channelId: string, newOwnerId: string, options?: TransferChannelOwnershipOptions): Promise<boolean>;
378
+ transferChannelOwnership(
379
+ channelId: string,
380
+ newOwnerId: string,
381
+ options?: TransferChannelOwnershipOptions,
382
+ ): Promise<boolean>;
314
383
 
315
384
  /** Get Poll Votes */
316
- getPollVotes(messageId: string): Promise<PollVote[]>
385
+ getPollVotes(messageId: string): Promise<PollVote[]>;
317
386
 
318
387
  /** Generic event */
319
- on(event: string, listener: (...args: any) => void): this
388
+ on(event: string, listener: (...args: any) => void): this;
320
389
 
321
390
  /** Emitted when there has been an error while trying to restore an existing session */
322
- on(event: 'auth_failure', listener: (message: string) => void): this
391
+ on(event: 'auth_failure', listener: (message: string) => void): this;
323
392
 
324
393
  /** Emitted when authentication is successful */
325
- on(event: 'authenticated', listener: () => void): this
394
+ on(event: 'authenticated', listener: () => void): this;
326
395
 
327
- /**
396
+ /**
328
397
  * Emitted when the battery percentage for the attached device changes
329
- * @deprecated
398
+ * @deprecated
330
399
  */
331
- on(event: 'change_battery', listener: (batteryInfo: BatteryInfo) => void): this
400
+ on(
401
+ event: 'change_battery',
402
+ listener: (batteryInfo: BatteryInfo) => void,
403
+ ): this;
332
404
 
333
405
  /** Emitted when the connection state changes */
334
- on(event: 'change_state', listener: (
335
- /** the new connection state */
336
- state: WAState
337
- ) => void): this
406
+ on(
407
+ event: 'change_state',
408
+ listener: (
409
+ /** the new connection state */
410
+ state: WAState,
411
+ ) => void,
412
+ ): this;
338
413
 
339
414
  /** Emitted when the client has been disconnected */
340
- on(event: 'disconnected', listener: (
341
- /** reason that caused the disconnect */
342
- reason: WAState | "LOGOUT"
343
- ) => void): this
415
+ on(
416
+ event: 'disconnected',
417
+ listener: (
418
+ /** reason that caused the disconnect */
419
+ reason: WAState | 'LOGOUT',
420
+ ) => void,
421
+ ): this;
344
422
 
345
423
  /** Emitted when a user joins the chat via invite link or is added by an admin */
346
- on(event: 'group_join', listener: (
347
- /** GroupNotification with more information about the action */
348
- notification: GroupNotification
349
- ) => void): this
424
+ on(
425
+ event: 'group_join',
426
+ listener: (
427
+ /** GroupNotification with more information about the action */
428
+ notification: GroupNotification,
429
+ ) => void,
430
+ ): this;
350
431
 
351
432
  /** Emitted when a user leaves the chat or is removed by an admin */
352
- on(event: 'group_leave', listener: (
353
- /** GroupNotification with more information about the action */
354
- notification: GroupNotification
355
- ) => void): this
433
+ on(
434
+ event: 'group_leave',
435
+ listener: (
436
+ /** GroupNotification with more information about the action */
437
+ notification: GroupNotification,
438
+ ) => void,
439
+ ): this;
356
440
 
357
441
  /** Emitted when a current user is promoted to an admin or demoted to a regular user */
358
- on(event: 'group_admin_changed', listener: (
359
- /** GroupNotification with more information about the action */
360
- notification: GroupNotification
361
- ) => void): this
442
+ on(
443
+ event: 'group_admin_changed',
444
+ listener: (
445
+ /** GroupNotification with more information about the action */
446
+ notification: GroupNotification,
447
+ ) => void,
448
+ ): this;
362
449
 
363
450
  /**
364
451
  * Emitted when some user requested to join the group
365
452
  * that has the membership approval mode turned on
366
453
  */
367
- on(event: 'group_membership_request', listener: (
368
- /** GroupNotification with more information about the action */
369
- notification: GroupNotification
370
- ) => void): this
454
+ on(
455
+ event: 'group_membership_request',
456
+ listener: (
457
+ /** GroupNotification with more information about the action */
458
+ notification: GroupNotification,
459
+ ) => void,
460
+ ): this;
371
461
 
372
462
  /** Emitted when group settings are updated, such as subject, description or picture */
373
- on(event: 'group_update', listener: (
374
- /** GroupNotification with more information about the action */
375
- notification: GroupNotification
376
- ) => void): this
463
+ on(
464
+ event: 'group_update',
465
+ listener: (
466
+ /** GroupNotification with more information about the action */
467
+ notification: GroupNotification,
468
+ ) => void,
469
+ ): this;
377
470
 
378
471
  /** Emitted when a contact or a group participant changed their phone number. */
379
- on(event: 'contact_changed', listener: (
380
- /** Message with more information about the event. */
381
- message: Message,
382
- /** Old user's id. */
383
- oldId : String,
384
- /** New user's id. */
385
- newId : String,
386
- /** Indicates if a contact or a group participant changed their phone number. */
387
- isContact : Boolean
388
- ) => void): this
472
+ on(
473
+ event: 'contact_changed',
474
+ listener: (
475
+ /** Message with more information about the event. */
476
+ message: Message,
477
+ /** Old user's id. */
478
+ oldId: String,
479
+ /** New user's id. */
480
+ newId: String,
481
+ /** Indicates if a contact or a group participant changed their phone number. */
482
+ isContact: Boolean,
483
+ ) => void,
484
+ ): this;
389
485
 
390
486
  /** Emitted when media has been uploaded for a message sent by the client */
391
- on(event: 'media_uploaded', listener: (
392
- /** The message with media that was uploaded */
393
- message: Message
394
- ) => void): this
487
+ on(
488
+ event: 'media_uploaded',
489
+ listener: (
490
+ /** The message with media that was uploaded */
491
+ message: Message,
492
+ ) => void,
493
+ ): this;
395
494
 
396
495
  /** Emitted when a new message is received */
397
- on(event: 'message', listener: (
398
- /** The message that was received */
399
- message: Message
400
- ) => void): this
496
+ on(
497
+ event: 'message',
498
+ listener: (
499
+ /** The message that was received */
500
+ message: Message,
501
+ ) => void,
502
+ ): this;
401
503
 
402
504
  /** Emitted when an ack event occurrs on message type */
403
- on(event: 'message_ack', listener: (
404
- /** The message that was affected */
405
- message: Message,
406
- /** The new ACK value */
407
- ack: MessageAck
408
- ) => void): this
409
-
505
+ on(
506
+ event: 'message_ack',
507
+ listener: (
508
+ /** The message that was affected */
509
+ message: Message,
510
+ /** The new ACK value */
511
+ ack: MessageAck,
512
+ ) => void,
513
+ ): this;
514
+
410
515
  /** Emitted when an edit event occurrs on message type */
411
- on(event: 'message_edit', listener: (
412
- /** The message that was affected */
413
- message: Message,
414
- /** New text message */
415
- newBody: String,
416
- /** Prev text message */
417
- prevBody: String
418
- ) => void): this
419
-
516
+ on(
517
+ event: 'message_edit',
518
+ listener: (
519
+ /** The message that was affected */
520
+ message: Message,
521
+ /** New text message */
522
+ newBody: String,
523
+ /** Prev text message */
524
+ prevBody: String,
525
+ ) => void,
526
+ ): this;
527
+
420
528
  /** Emitted when a chat unread count changes */
421
- on(event: 'unread_count', listener: (
422
- /** The chat that was affected */
423
- chat: Chat
424
- ) => void): this
529
+ on(
530
+ event: 'unread_count',
531
+ listener: (
532
+ /** The chat that was affected */
533
+ chat: Chat,
534
+ ) => void,
535
+ ): this;
425
536
 
426
537
  /** Emitted when a new message is created, which may include the current user's own messages */
427
- on(event: 'message_create', listener: (
428
- /** The message that was created */
429
- message: Message
430
- ) => void): this
431
-
538
+ on(
539
+ event: 'message_create',
540
+ listener: (
541
+ /** The message that was created */
542
+ message: Message,
543
+ ) => void,
544
+ ): this;
545
+
432
546
  /** Emitted when a new message ciphertext is received */
433
- on(event: 'message_ciphertext', listener: (
434
- /** The message that was ciphertext */
435
- message: Message
436
- ) => void): this
547
+ on(
548
+ event: 'message_ciphertext',
549
+ listener: (
550
+ /** The message that was ciphertext */
551
+ message: Message,
552
+ ) => void,
553
+ ): this;
554
+
555
+ /** Emitted when a ciphertext message failed to decrypt after recovery attempt */
556
+ on(
557
+ event: 'message_ciphertext_failed',
558
+ listener: (
559
+ /** The message that failed to decrypt */
560
+ message: Message,
561
+ ) => void,
562
+ ): this;
437
563
 
438
564
  /** Emitted when a message is deleted for everyone in the chat */
439
- on(event: 'message_revoke_everyone', listener: (
440
- /** The message that was revoked, in its current state. It will not contain the original message's data */
441
- message: Message,
442
- /**The message that was revoked, before it was revoked.
443
- * It will contain the message's original data.
444
- * Note that due to the way this data is captured,
445
- * it may be possible that this param will be undefined. */
446
- revoked_msg?: Message | null
447
- ) => void): this
565
+ on(
566
+ event: 'message_revoke_everyone',
567
+ listener: (
568
+ /** The message that was revoked, in its current state. It will not contain the original message's data */
569
+ message: Message,
570
+ /**The message that was revoked, before it was revoked.
571
+ * It will contain the message's original data.
572
+ * Note that due to the way this data is captured,
573
+ * it may be possible that this param will be undefined. */
574
+ revoked_msg?: Message | null,
575
+ ) => void,
576
+ ): this;
448
577
 
449
578
  /** Emitted when a message is deleted by the current user */
450
- on(event: 'message_revoke_me', listener: (
451
- /** The message that was revoked */
452
- message: Message
453
- ) => void): this
579
+ on(
580
+ event: 'message_revoke_me',
581
+ listener: (
582
+ /** The message that was revoked */
583
+ message: Message,
584
+ ) => void,
585
+ ): this;
454
586
 
455
587
  /** Emitted when a reaction is sent, received, updated or removed */
456
- on(event: 'message_reaction', listener: (
457
- /** The reaction object */
458
- reaction: Reaction
459
- ) => void): this
588
+ on(
589
+ event: 'message_reaction',
590
+ listener: (
591
+ /** The reaction object */
592
+ reaction: Reaction,
593
+ ) => void,
594
+ ): this;
460
595
 
461
596
  /** Emitted when a chat is removed */
462
- on(event: 'chat_removed', listener: (
463
- /** The chat that was removed */
464
- chat: Chat
465
- ) => void): this
597
+ on(
598
+ event: 'chat_removed',
599
+ listener: (
600
+ /** The chat that was removed */
601
+ chat: Chat,
602
+ ) => void,
603
+ ): this;
466
604
 
467
605
  /** Emitted when a chat is archived/unarchived */
468
- on(event: 'chat_archived', listener: (
469
- /** The chat that was archived/unarchived */
470
- chat: Chat,
471
- /** State the chat is currently in */
472
- currState: boolean,
473
- /** State the chat was previously in */
474
- prevState: boolean
475
- ) => void): this
606
+ on(
607
+ event: 'chat_archived',
608
+ listener: (
609
+ /** The chat that was archived/unarchived */
610
+ chat: Chat,
611
+ /** State the chat is currently in */
612
+ currState: boolean,
613
+ /** State the chat was previously in */
614
+ prevState: boolean,
615
+ ) => void,
616
+ ): this;
476
617
 
477
618
  /** Emitted when loading screen is appearing */
478
- on(event: 'loading_screen', listener: (percent: string, message: string) => void): this
619
+ on(
620
+ event: 'loading_screen',
621
+ listener: (percent: string, message: string) => void,
622
+ ): this;
479
623
 
480
624
  /** Emitted when the QR code is received */
481
- on(event: 'qr', listener: (
482
- /** qr code string
483
- * @example ```1@9Q8tWf6bnezr8uVGwVCluyRuBOJ3tIglimzI5dHB0vQW2m4DQ0GMlCGf,f1/vGcW4Z3vBa1eDNl3tOjWqLL5DpYTI84DMVkYnQE8=,ZL7YnK2qdPN8vKo2ESxhOQ==``` */
484
- qr: string
485
- ) => void): this
625
+ on(
626
+ event: 'qr',
627
+ listener: (
628
+ /** qr code string
629
+ * @example ```1@9Q8tWf6bnezr8uVGwVCluyRuBOJ3tIglimzI5dHB0vQW2m4DQ0GMlCGf,f1/vGcW4Z3vBa1eDNl3tOjWqLL5DpYTI84DMVkYnQE8=,ZL7YnK2qdPN8vKo2ESxhOQ==``` */
630
+ qr: string,
631
+ ) => void,
632
+ ): this;
486
633
 
487
634
  /** Emitted when the phone number pairing code is received */
488
- on(event: 'code', listener: (
489
- /** pairing code string
490
- * @example `8W2WZ3TS` */
491
- code: string
492
- ) => void): this
635
+ on(
636
+ event: 'code',
637
+ listener: (
638
+ /** pairing code string
639
+ * @example `8W2WZ3TS` */
640
+ code: string,
641
+ ) => void,
642
+ ): this;
493
643
 
494
644
  /** Emitted when a call is received */
495
- on(event: 'call', listener: (
496
- /** The call that started */
497
- call: Call
498
- ) => void): this
645
+ on(
646
+ event: 'call',
647
+ listener: (
648
+ /** The call that started */
649
+ call: Call,
650
+ ) => void,
651
+ ): this;
499
652
 
500
653
  /** Emitted when the client has initialized and is ready to receive messages */
501
- on(event: 'ready', listener: () => void): this
654
+ on(event: 'ready', listener: () => void): this;
502
655
 
503
656
  /** Emitted when the RemoteAuth session is saved successfully on the external Database */
504
- on(event: 'remote_session_saved', listener: () => void): this
657
+ on(event: 'remote_session_saved', listener: () => void): this;
505
658
 
506
659
  /**
507
660
  * Emitted when some poll option is selected or deselected,
508
661
  * shows a user's current selected option(s) on the poll
509
662
  */
510
- on(event: 'vote_update', listener: (
511
- vote: PollVote
512
- ) => void): this
663
+ on(event: 'vote_update', listener: (vote: PollVote) => void): this;
513
664
  }
514
665
 
515
666
  /** Current connection information */
516
667
  export interface ClientInfo {
517
- /**
518
- * Current user ID
519
- * @deprecated Use .wid instead
668
+ /**
669
+ * Current user ID
670
+ * @deprecated Use .wid instead
520
671
  */
521
- me: ContactId
672
+ me: ContactId;
522
673
  /** Current user ID */
523
- wid: ContactId
524
- /**
525
- * Information about the phone this client is connected to. Not available in multi-device.
526
- * @deprecated
674
+ wid: ContactId;
675
+ /**
676
+ * Information about the phone this client is connected to. Not available in multi-device.
677
+ * @deprecated
527
678
  */
528
- phone: ClientInfoPhone
679
+ phone: ClientInfoPhone;
529
680
  /** Platform the phone is running on */
530
- platform: string
681
+ platform: string;
531
682
  /** Name configured to be shown in push notifications */
532
- pushname: string
683
+ pushname: string;
533
684
 
534
685
  /** Get current battery percentage and charging status for the attached device */
535
- getBatteryStatus: () => Promise<BatteryInfo>
686
+ getBatteryStatus: () => Promise<BatteryInfo>;
536
687
  }
537
688
 
538
- /**
539
- * Information about the phone this client is connected to
689
+ /**
690
+ * Information about the phone this client is connected to
540
691
  * @deprecated
541
692
  */
542
693
  export interface ClientInfoPhone {
543
694
  /** WhatsApp Version running on the phone */
544
- wa_version: string
695
+ wa_version: string;
545
696
  /** OS Version running on the phone (iOS or Android version) */
546
- os_version: string
697
+ os_version: string;
547
698
  /** Device manufacturer */
548
- device_manufacturer: string
699
+ device_manufacturer: string;
549
700
  /** Device model */
550
- device_model: string
701
+ device_model: string;
551
702
  /** OS build number */
552
- os_build_number: string
703
+ os_build_number: string;
553
704
  }
554
705
 
555
706
  /** Options for initializing the whatsapp client */
556
707
  export interface ClientOptions {
557
708
  /** Timeout for authentication selector in puppeteer
558
709
  * @default 0 */
559
- authTimeoutMs?: number,
710
+ authTimeoutMs?: number;
560
711
  /** function to be evaluated On New Document
561
712
  * @default undefined */
562
- evalOnNewDoc?: Function,
713
+ evalOnNewDoc?: Function;
563
714
  /** Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/ */
564
- puppeteer?: puppeteer.PuppeteerNodeLaunchOptions & puppeteer.ConnectOptions
565
- /** Determines how to save and restore sessions. Will use LegacySessionAuth if options.session is set. Otherwise, NoAuth will be used. */
566
- authStrategy?: AuthStrategy,
715
+ puppeteer?: puppeteer.PuppeteerNodeLaunchOptions &
716
+ puppeteer.ConnectOptions;
717
+ /** Determines how to save and restore sessions. Will use LegacySessionAuth if options.session is set. Otherwise, NoAuth will be used. */
718
+ authStrategy?: AuthStrategy;
567
719
  /** The version of WhatsApp Web to use. Use options.webVersionCache to configure how the version is retrieved. */
568
- webVersion?: string,
720
+ webVersion?: string;
569
721
  /** Determines how to retrieve the WhatsApp Web version specified in options.webVersion. */
570
- webVersionCache?: WebCacheOptions,
722
+ webVersionCache?: WebCacheOptions;
571
723
  /** How many times should the qrcode be refreshed before giving up
572
- * @default 0 (disabled) */
573
- qrMaxRetries?: number
724
+ * @default 0 (disabled) */
725
+ qrMaxRetries?: number;
574
726
  /** If another whatsapp web session is detected (another browser), take over the session in the current browser
575
727
  * @default false */
576
- takeoverOnConflict?: boolean,
728
+ takeoverOnConflict?: boolean;
577
729
  /** How much time to wait before taking over the session
578
730
  * @default 0 */
579
- takeoverTimeoutMs?: number,
731
+ takeoverTimeoutMs?: number;
580
732
  /** User agent to use in puppeteer.
581
733
  * @default 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36' */
582
- userAgent?: string
583
- /** Ffmpeg path to use when formatting videos to webp while sending stickers
734
+ userAgent?: string;
735
+ /** Ffmpeg path to use when formatting videos to webp while sending stickers
584
736
  * @default 'ffmpeg' */
585
- ffmpegPath?: string,
586
- /** Sets bypassing of page's Content-Security-Policy
737
+ ffmpegPath?: string;
738
+ /** Sets bypassing of page's Content-Security-Policy
587
739
  * @default false */
588
- bypassCSP?: boolean,
740
+ bypassCSP?: boolean;
589
741
  /** Sets the device name of a current linked device., i.e.: 'TEST' */
590
- deviceName?: string,
742
+ deviceName?: string;
591
743
  /**
592
744
  * Sets the browser name of a current linked device, i.e.: 'Firefox'.
593
745
  * Valid value are: 'Chrome' | 'Firefox' | 'IE' | 'Opera' | 'Safari' | 'Edge'
594
746
  */
595
- browserName?: string,
747
+ browserName?: string;
596
748
  /** Object with proxy autentication requirements @default: undefined */
597
- proxyAuthentication?: {username: string, password: string} | undefined
598
- /** Phone number pairing configuration. Refer the requestPairingCode function of Client.
749
+ proxyAuthentication?:
750
+ | { username: string; password: string }
751
+ | undefined;
752
+ /** Phone number pairing configuration. Refer the requestPairingCode function of Client.
599
753
  * @default
600
754
  * {
601
755
  * phoneNumber: "",
602
756
  * showNotification: true,
603
757
  * intervalMs: 180000,
604
758
  * }
605
- */
606
- pairWithPhoneNumber?: {phoneNumber: string, showNotification?: boolean, intervalMs?: number}
759
+ */
760
+ pairWithPhoneNumber?: {
761
+ phoneNumber: string;
762
+ showNotification?: boolean;
763
+ intervalMs?: number;
764
+ };
607
765
  }
608
766
 
609
767
  export interface LocalWebCacheOptions {
610
- type: 'local',
611
- path?: string,
612
- strict?: boolean
768
+ type: 'local';
769
+ path?: string;
770
+ strict?: boolean;
613
771
  }
614
772
 
615
773
  export interface RemoteWebCacheOptions {
616
- type: 'remote',
617
- remotePath: string,
618
- strict?: boolean
774
+ type: 'remote';
775
+ remotePath: string;
776
+ strict?: boolean;
619
777
  }
620
778
 
621
779
  export interface NoWebCacheOptions {
622
- type: 'none'
780
+ type: 'none';
623
781
  }
624
782
 
625
- export type WebCacheOptions = NoWebCacheOptions | LocalWebCacheOptions | RemoteWebCacheOptions;
783
+ export type WebCacheOptions =
784
+ | NoWebCacheOptions
785
+ | LocalWebCacheOptions
786
+ | RemoteWebCacheOptions;
626
787
 
627
788
  /**
628
789
  * Base class which all authentication strategies extend
@@ -632,9 +793,9 @@ declare namespace WAWebJS {
632
793
  beforeBrowserInitialized: () => Promise<void>;
633
794
  afterBrowserInitialized: () => Promise<void>;
634
795
  onAuthenticationNeeded: () => Promise<{
635
- failed?: boolean;
636
- restart?: boolean;
637
- failureEventPayload?: any
796
+ failed?: boolean;
797
+ restart?: boolean;
798
+ failureEventPayload?: any;
638
799
  }>;
639
800
  getAuthEventPayload: () => Promise<any>;
640
801
  afterAuthReady: () => Promise<void>;
@@ -656,45 +817,50 @@ declare namespace WAWebJS {
656
817
  public clientId?: string;
657
818
  public dataPath?: string;
658
819
  constructor(options?: {
659
- clientId?: string,
660
- dataPath?: string,
661
- rmMaxRetries?: number
662
- })
820
+ clientId?: string;
821
+ dataPath?: string;
822
+ rmMaxRetries?: number;
823
+ });
663
824
  }
664
-
825
+
665
826
  /**
666
827
  * Remote-based authentication
667
828
  */
668
- export class RemoteAuth extends AuthStrategy {
829
+ export class RemoteAuth extends AuthStrategy {
669
830
  public clientId?: string;
670
831
  public dataPath?: string;
671
832
  constructor(options?: {
672
- store: Store,
673
- clientId?: string,
674
- dataPath?: string,
675
- backupSyncIntervalMs: number,
676
- rmMaxRetries?: number
677
- })
833
+ store: Store;
834
+ clientId?: string;
835
+ dataPath?: string;
836
+ backupSyncIntervalMs: number;
837
+ rmMaxRetries?: number;
838
+ });
678
839
  }
679
840
 
680
- /**
841
+ /**
681
842
  * Remote store interface
682
843
  */
683
844
  export interface Store {
684
- sessionExists: (options: { session: string }) => Promise<boolean> | boolean,
685
- delete: (options: { session: string }) => Promise<any> | any,
686
- save: (options: { session: string }) => Promise<any> | any,
687
- extract: (options: { session: string, path: string }) => Promise<any> | any,
845
+ sessionExists: (options: {
846
+ session: string;
847
+ }) => Promise<boolean> | boolean;
848
+ delete: (options: { session: string }) => Promise<any> | any;
849
+ save: (options: { session: string }) => Promise<any> | any;
850
+ extract: (options: {
851
+ session: string;
852
+ path: string;
853
+ }) => Promise<any> | any;
688
854
  }
689
855
 
690
- /**
856
+ /**
691
857
  * @deprecated
692
858
  */
693
859
  export interface BatteryInfo {
694
860
  /** The current battery percentage */
695
- battery: number,
861
+ battery: number;
696
862
  /** Indicates if the phone is plugged in (true) or not (false) */
697
- plugged: boolean,
863
+ plugged: boolean;
698
864
  }
699
865
 
700
866
  /** An object that handles options for group creation */
@@ -704,39 +870,39 @@ declare namespace WAWebJS {
704
870
  * won't take an effect if the group is been creating with myself only
705
871
  * @default 0
706
872
  */
707
- messageTimer?: number
873
+ messageTimer?: number;
708
874
  /**
709
875
  * The ID of a parent community group to link the newly created group with,
710
876
  * won't take an effect if the group is been creating with myself only
711
877
  */
712
- parentGroupId?: string
878
+ parentGroupId?: string;
713
879
  /** If true, the inviteV4 will be sent to those participants
714
880
  * who have restricted others from being automatically added to groups,
715
881
  * otherwise the inviteV4 won't be sent
716
882
  * @default true
717
883
  */
718
- autoSendInviteV4?: boolean,
884
+ autoSendInviteV4?: boolean;
719
885
  /**
720
886
  * The comment to be added to an inviteV4 (empty string by default)
721
887
  * @default ''
722
888
  */
723
- comment?: string
889
+ comment?: string;
724
890
  /** If true, only admins can add members to the group (false by default)
725
891
  * @default false
726
892
  */
727
- memberAddMode?: boolean,
893
+ memberAddMode?: boolean;
728
894
  /** If true, group admins will be required to approve anyone who wishes to join the group (false by default)
729
895
  * @default false
730
896
  */
731
- membershipApprovalMode?: boolean,
897
+ membershipApprovalMode?: boolean;
732
898
  /** If true, only admins can change group group info (true by default)
733
899
  * @default true
734
900
  */
735
- isRestrict?: boolean,
901
+ isRestrict?: boolean;
736
902
  /** If true, only admins can send messages (false by default)
737
903
  * @default false
738
904
  */
739
- isAnnounce?: boolean,
905
+ isAnnounce?: boolean;
740
906
  }
741
907
 
742
908
  /** An object that handles the result for createGroup method */
@@ -748,10 +914,10 @@ declare namespace WAWebJS {
748
914
  /** An object that handles the result value for each added to the group participant */
749
915
  participants: {
750
916
  [participantId: string]: {
751
- statusCode: number,
752
- message: string,
753
- isGroupCreator: boolean,
754
- isInviteV4Sent: boolean
917
+ statusCode: number;
918
+ message: string;
919
+ isGroupCreator: boolean;
920
+ isInviteV4Sent: boolean;
755
921
  };
756
922
  };
757
923
  }
@@ -759,21 +925,21 @@ declare namespace WAWebJS {
759
925
  /** An object that handles options for channel creation */
760
926
  export interface CreateChannelOptions {
761
927
  /** The channel description */
762
- description?: string,
928
+ description?: string;
763
929
  /** The channel profile picture */
764
- picture?: MessageMedia
930
+ picture?: MessageMedia;
765
931
  }
766
932
 
767
933
  /** An object that handles the result for createGroup method */
768
934
  export interface CreateChannelResult {
769
935
  /** A channel title */
770
- title: string,
936
+ title: string;
771
937
  /** An object that handles the newly created channel ID */
772
- nid: ChatId,
938
+ nid: ChatId;
773
939
  /** The channel invite link, starts with 'https://whatsapp.com/channel/' */
774
- inviteLink: string,
940
+ inviteLink: string;
775
941
  /** The timestamp the channel was created at */
776
- createdAtTs: number
942
+ createdAtTs: number;
777
943
  }
778
944
 
779
945
  /** Options for unsubscribe from a channel */
@@ -784,7 +950,7 @@ declare namespace WAWebJS {
784
950
  * Otherwise it will only remove a channel from the list of channels the current user is subscribed to
785
951
  * and will set the membership type for that channel to GUEST
786
952
  */
787
- deleteLocalModels?: boolean
953
+ deleteLocalModels?: boolean;
788
954
  }
789
955
 
790
956
  /** Options for searching for channels */
@@ -798,37 +964,39 @@ declare namespace WAWebJS {
798
964
 
799
965
  export interface GroupNotification {
800
966
  /** ContactId for the user that produced the GroupNotification */
801
- author: string,
967
+ author: string;
802
968
  /** Extra content */
803
- body: string,
969
+ body: string;
804
970
  /** ID for the Chat that this groupNotification was sent for */
805
- chatId: string,
806
- /** ID that represents the groupNotification
971
+ chatId: string;
972
+ /** ID that represents the groupNotification
807
973
  * @todo create a more specific type for the id object */
808
- id: object,
974
+ id: object;
809
975
  /** Contact IDs for the users that were affected by this GroupNotification */
810
- recipientIds: string[],
976
+ recipientIds: string[];
811
977
  /** Unix timestamp for when the groupNotification was created */
812
- timestamp: number,
978
+ timestamp: number;
813
979
  /** GroupNotification type */
814
- type: GroupNotificationTypes,
980
+ type: GroupNotificationTypes;
815
981
 
816
982
  /** Returns the Chat this GroupNotification was sent in */
817
- getChat: () => Promise<Chat>,
983
+ getChat: () => Promise<Chat>;
818
984
  /** Returns the Contact this GroupNotification was produced by */
819
- getContact: () => Promise<Contact>,
985
+ getContact: () => Promise<Contact>;
820
986
  /** Returns the Contacts affected by this GroupNotification */
821
- getRecipients: () => Promise<Contact[]>,
987
+ getRecipients: () => Promise<Contact[]>;
822
988
  /** Sends a message to the same chat this GroupNotification was produced in */
823
- reply: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
824
-
989
+ reply: (
990
+ content: MessageContent,
991
+ options?: MessageSendOptions,
992
+ ) => Promise<Message>;
825
993
  }
826
-
994
+
827
995
  /** whatsapp web url */
828
- export const WhatsWebURL: string
996
+ export const WhatsWebURL: string;
829
997
 
830
998
  /** default client options */
831
- export const DefaultOptions: ClientOptions
999
+ export const DefaultOptions: ClientOptions;
832
1000
 
833
1001
  /** Chat types */
834
1002
  export enum ChatTypes {
@@ -846,6 +1014,7 @@ declare namespace WAWebJS {
846
1014
  CHAT_ARCHIVED = 'chat_archived',
847
1015
  MESSAGE_RECEIVED = 'message',
848
1016
  MESSAGE_CIPHERTEXT = 'message_ciphertext',
1017
+ MESSAGE_CIPHERTEXT_FAILED = 'message_ciphertext_failed',
849
1018
  MESSAGE_CREATE = 'message_create',
850
1019
  MESSAGE_REVOKED_EVERYONE = 'message_revoke_everyone',
851
1020
  MESSAGE_REVOKED_ME = 'message_revoke_me',
@@ -963,26 +1132,26 @@ declare namespace WAWebJS {
963
1132
  }
964
1133
 
965
1134
  export type MessageInfo = {
966
- delivery: Array<{id: ContactId, t: number}>,
967
- deliveryRemaining: number,
968
- played: Array<{id: ContactId, t: number}>,
969
- playedRemaining: number,
970
- read: Array<{id: ContactId, t: number}>,
971
- readRemaining: number
972
- }
1135
+ delivery: Array<{ id: ContactId; t: number }>;
1136
+ deliveryRemaining: number;
1137
+ played: Array<{ id: ContactId; t: number }>;
1138
+ playedRemaining: number;
1139
+ read: Array<{ id: ContactId; t: number }>;
1140
+ readRemaining: number;
1141
+ };
973
1142
 
974
1143
  export type InviteV4Data = {
975
- inviteCode: string,
976
- inviteCodeExp: number,
977
- groupId: string,
978
- groupName?: string,
979
- fromId: string,
980
- toId: string
981
- }
1144
+ inviteCode: string;
1145
+ inviteCodeExp: number;
1146
+ groupId: string;
1147
+ groupName?: string;
1148
+ fromId: string;
1149
+ toId: string;
1150
+ };
982
1151
 
983
1152
  /**
984
1153
  * Represents a Message on WhatsApp
985
- *
1154
+ *
986
1155
  * @example
987
1156
  * {
988
1157
  * mediaKey: undefined,
@@ -1011,202 +1180,211 @@ declare namespace WAWebJS {
1011
1180
  */
1012
1181
  export interface Message {
1013
1182
  /** ACK status for the message */
1014
- ack: MessageAck,
1183
+ ack: MessageAck;
1015
1184
  /** If the message was sent to a group, this field will contain the user that sent the message. */
1016
- author?: string,
1185
+ author?: string;
1017
1186
  /** String that represents from which device type the message was sent */
1018
- deviceType: string,
1187
+ deviceType: string;
1019
1188
  /** Message content */
1020
- body: string,
1189
+ body: string;
1021
1190
  /** Indicates if the message was a broadcast */
1022
- broadcast: boolean,
1191
+ broadcast: boolean;
1023
1192
  /** Indicates if the message was a status update */
1024
- isStatus: boolean,
1193
+ isStatus: boolean;
1025
1194
  /** Indicates if the message is a Gif */
1026
- isGif: boolean,
1195
+ isGif: boolean;
1027
1196
  /** Indicates if the message will disappear after it expires */
1028
- isEphemeral: boolean,
1197
+ isEphemeral: boolean;
1029
1198
  /** ID for the Chat that this message was sent to, except if the message was sent by the current user */
1030
- from: string,
1199
+ from: string;
1031
1200
  /** Indicates if the message was sent by the current user */
1032
- fromMe: boolean,
1201
+ fromMe: boolean;
1033
1202
  /** Indicates if the message has media available for download */
1034
- hasMedia: boolean,
1203
+ hasMedia: boolean;
1035
1204
  /** Indicates if the message was sent as a reply to another message */
1036
- hasQuotedMsg: boolean,
1205
+ hasQuotedMsg: boolean;
1037
1206
  /** Indicates whether there are reactions to the message */
1038
- hasReaction: boolean,
1207
+ hasReaction: boolean;
1039
1208
  /** Indicates the duration of the message in seconds */
1040
- duration: string,
1209
+ duration: string;
1041
1210
  /** ID that represents the message */
1042
- id: MessageId,
1211
+ id: MessageId;
1043
1212
  /** Indicates if the message was forwarded */
1044
- isForwarded: boolean,
1213
+ isForwarded: boolean;
1045
1214
  /**
1046
1215
  * Indicates how many times the message was forwarded.
1047
1216
  * The maximum value is 127.
1048
1217
  */
1049
- forwardingScore: number,
1218
+ forwardingScore: number;
1050
1219
  /** Indicates if the message was starred */
1051
- isStarred: boolean,
1220
+ isStarred: boolean;
1052
1221
  /** Location information contained in the message, if the message is type "location" */
1053
- location: Location,
1222
+ location: Location;
1054
1223
  /** List of vCards contained in the message */
1055
- vCards: string[],
1224
+ vCards: string[];
1056
1225
  /** Invite v4 info */
1057
- inviteV4?: InviteV4Data,
1226
+ inviteV4?: InviteV4Data;
1058
1227
  /** MediaKey that represents the sticker 'ID' */
1059
- mediaKey?: string,
1228
+ mediaKey?: string;
1060
1229
  /** Indicates the mentions in the message body. */
1061
- mentionedIds: string[],
1230
+ mentionedIds: string[];
1062
1231
  /** Indicates whether there are group mentions in the message body */
1063
1232
  groupMentions: {
1064
1233
  groupSubject: string;
1065
1234
  groupJid: string;
1066
- }[],
1235
+ }[];
1067
1236
  /** Unix timestamp for when the message was created */
1068
- timestamp: number,
1237
+ timestamp: number;
1069
1238
  /**
1070
1239
  * ID for who this message is for.
1071
1240
  * If the message is sent by the current user, it will be the Chat to which the message is being sent.
1072
1241
  * If the message is sent by another user, it will be the ID for the current user.
1073
1242
  */
1074
- to: string,
1243
+ to: string;
1075
1244
  /** Message type */
1076
- type: MessageTypes,
1245
+ type: MessageTypes;
1077
1246
  /** Links included in the message. */
1078
1247
  links: Array<{
1079
- link: string,
1080
- isSuspicious: boolean
1081
- }>,
1248
+ link: string;
1249
+ isSuspicious: boolean;
1250
+ }>;
1082
1251
  /** Order ID */
1083
- orderId: string,
1252
+ orderId: string;
1084
1253
  /** title */
1085
- title?: string,
1254
+ title?: string;
1086
1255
  /** description*/
1087
- description?: string,
1256
+ description?: string;
1088
1257
  /** Business Owner JID */
1089
- businessOwnerJid?: string,
1258
+ businessOwnerJid?: string;
1090
1259
  /** Product JID */
1091
- productId?: string,
1260
+ productId?: string;
1092
1261
  /** Last edit time */
1093
- latestEditSenderTimestampMs?: number,
1262
+ latestEditSenderTimestampMs?: number;
1094
1263
  /** Last edit message author */
1095
- latestEditMsgKey?: MessageId,
1264
+ latestEditMsgKey?: MessageId;
1096
1265
  /**
1097
1266
  * Protocol message key.
1098
1267
  * Can be used to retrieve the ID of an original message that was revoked.
1099
1268
  */
1100
- protocolMessageKey?: MessageId,
1269
+ protocolMessageKey?: MessageId;
1101
1270
  /** Message buttons */
1102
- dynamicReplyButtons?: object,
1271
+ dynamicReplyButtons?: object;
1103
1272
  /** Selected button ID */
1104
- selectedButtonId?: string,
1273
+ selectedButtonId?: string;
1105
1274
  /** Selected list row ID */
1106
- selectedRowId?: string,
1275
+ selectedRowId?: string;
1107
1276
  /** Returns message in a raw format */
1108
- rawData: object,
1109
- pollName: string,
1277
+ rawData: object;
1278
+ pollName: string;
1110
1279
  /** Avaiaible poll voting options */
1111
- pollOptions: string[],
1280
+ pollOptions: string[];
1112
1281
  /** False for a single choice poll, true for a multiple choice poll */
1113
- allowMultipleAnswers: boolean,
1282
+ allowMultipleAnswers: boolean;
1114
1283
  /** The start time of the event in timestamp (10 digits) */
1115
- eventStartTime: number,
1284
+ eventStartTime: number;
1116
1285
  /** The end time of the event in timestamp (10 digits) */
1117
- eventEndTime?: number,
1286
+ eventEndTime?: number;
1118
1287
  /** The event description */
1119
- eventDescription?: string,
1288
+ eventDescription?: string;
1120
1289
  /** The location of the event */
1121
1290
  eventLocation?: {
1122
1291
  degreesLatitude: number;
1123
1292
  degreesLongitude: number;
1124
1293
  name: string;
1125
- },
1294
+ };
1126
1295
  /** WhatsApp call link (video call or voice call) */
1127
- eventJoinLink?: string,
1296
+ eventJoinLink?: string;
1128
1297
  /** Indicates if an event should be sent as an already canceled */
1129
- isEventCaneled: boolean,
1298
+ isEventCaneled: boolean;
1130
1299
  /** The custom message secret, can be used as an event ID */
1131
- messageSecret?: Array<number>,
1132
- /*
1133
- * Reloads this Message object's data in-place with the latest values from WhatsApp Web.
1134
- * Note that the Message must still be in the web app cache for this to work, otherwise will return null.
1135
- */
1136
- reload: () => Promise<Message>,
1300
+ messageSecret?: Array<number>;
1301
+ /*
1302
+ * Reloads this Message object's data in-place with the latest values from WhatsApp Web.
1303
+ * Note that the Message must still be in the web app cache for this to work, otherwise will return null.
1304
+ */
1305
+ reload: () => Promise<Message>;
1137
1306
  /** Accept the Group V4 Invite in message */
1138
- acceptGroupV4Invite: () => Promise<{status: number}>,
1307
+ acceptGroupV4Invite: () => Promise<{ status: number }>;
1139
1308
  /** Deletes the message from the chat */
1140
- delete: (everyone?: boolean, clearMedia?: boolean) => Promise<void>,
1309
+ delete: (everyone?: boolean, clearMedia?: boolean) => Promise<void>;
1141
1310
  /** Downloads and returns the attached message media */
1142
- downloadMedia: () => Promise<MessageMedia>,
1311
+ downloadMedia: () => Promise<MessageMedia>;
1143
1312
  /** Returns the Chat this message was sent in */
1144
- getChat: () => Promise<Chat>,
1313
+ getChat: () => Promise<Chat>;
1145
1314
  /** Returns the Contact this message was sent from */
1146
- getContact: () => Promise<Contact>,
1315
+ getContact: () => Promise<Contact>;
1147
1316
  /** Returns the Contacts mentioned in this message */
1148
- getMentions: () => Promise<Contact[]>,
1317
+ getMentions: () => Promise<Contact[]>;
1149
1318
  /** Returns groups mentioned in this message */
1150
- getGroupMentions: () => Promise<GroupChat[]|[]>,
1319
+ getGroupMentions: () => Promise<GroupChat[] | []>;
1151
1320
  /** Returns the quoted message, if any */
1152
- getQuotedMessage: () => Promise<Message>,
1153
- /**
1154
- * Sends a message as a reply to this message.
1321
+ getQuotedMessage: () => Promise<Message>;
1322
+ /**
1323
+ * Sends a message as a reply to this message.
1155
1324
  * If chatId is specified, it will be sent through the specified Chat.
1156
- * If not, it will send the message in the same Chat as the original message was sent.
1325
+ * If not, it will send the message in the same Chat as the original message was sent.
1157
1326
  */
1158
- reply: (content: MessageContent, chatId?: string, options?: MessageSendOptions) => Promise<Message>,
1327
+ reply: (
1328
+ content: MessageContent,
1329
+ chatId?: string,
1330
+ options?: MessageSendOptions,
1331
+ ) => Promise<Message>;
1159
1332
  /** React to this message with an emoji*/
1160
- react: (reaction: string) => Promise<void>,
1161
- /**
1333
+ react: (reaction: string) => Promise<void>;
1334
+ /**
1162
1335
  * Forwards this message to another chat (that you chatted before, otherwise it will fail)
1163
1336
  */
1164
- forward: (chat: Chat | string) => Promise<void>,
1337
+ forward: (chat: Chat | string) => Promise<void>;
1165
1338
  /** Star this message */
1166
- star: () => Promise<void>,
1339
+ star: () => Promise<void>;
1167
1340
  /** Unstar this message */
1168
- unstar: () => Promise<void>,
1341
+ unstar: () => Promise<void>;
1169
1342
  /** Pins the message (group admins can pin messages of all group members) */
1170
- pin: (duration: number) => Promise<boolean>,
1343
+ pin: (duration: number) => Promise<boolean>;
1171
1344
  /** Unpins the message (group admins can unpin messages of all group members) */
1172
- unpin: () => Promise<boolean>,
1345
+ unpin: () => Promise<boolean>;
1173
1346
  /** Get information about message delivery status */
1174
- getInfo: () => Promise<MessageInfo | null>,
1347
+ getInfo: () => Promise<MessageInfo | null>;
1175
1348
  /**
1176
1349
  * Gets the order associated with a given message
1177
1350
  */
1178
- getOrder: () => Promise<Order>,
1351
+ getOrder: () => Promise<Order>;
1179
1352
  /**
1180
1353
  * Gets the payment details associated with a given message
1181
1354
  */
1182
- getPayment: () => Promise<Payment>,
1355
+ getPayment: () => Promise<Payment>;
1183
1356
  /**
1184
1357
  * Get Poll Votes associated with the given message
1185
1358
  */
1186
- getPollVotes: () => Promise<PollVote[]>,
1359
+ getPollVotes: () => Promise<PollVote[]>;
1187
1360
  /**
1188
1361
  * Gets the reactions associated with the given message
1189
1362
  */
1190
- getReactions: () => Promise<ReactionList[]>,
1363
+ getReactions: () => Promise<ReactionList[]>;
1191
1364
  /** Edits the current message */
1192
- edit: (content: MessageContent, options?: MessageEditOptions) => Promise<Message | null>,
1365
+ edit: (
1366
+ content: MessageContent,
1367
+ options?: MessageEditOptions,
1368
+ ) => Promise<Message | null>;
1193
1369
  /**
1194
1370
  * Edits the current ScheduledEvent message.
1195
1371
  * Once the event is canceled, it can not be edited.
1196
1372
  */
1197
- editScheduledEvent: (editedEventObject: Event) => Promise<Message | null>,
1373
+ editScheduledEvent: (
1374
+ editedEventObject: Event,
1375
+ ) => Promise<Message | null>;
1198
1376
  /**
1199
1377
  * Send votes to the poll message
1200
1378
  */
1201
- vote: (selectedOptions: Array<string>) => Promise<void>,
1379
+ vote: (selectedOptions: Array<string>) => Promise<void>;
1202
1380
  }
1203
1381
 
1204
1382
  /** ID that represents a message */
1205
1383
  export interface MessageId {
1206
- fromMe: boolean,
1207
- remote: string,
1208
- id: string,
1209
- _serialized: string,
1384
+ fromMe: boolean;
1385
+ remote: string;
1386
+ id: string;
1387
+ _serialized: string;
1210
1388
  }
1211
1389
 
1212
1390
  /** Options for sending a location */
@@ -1227,59 +1405,67 @@ declare namespace WAWebJS {
1227
1405
  address?: string;
1228
1406
  url?: string;
1229
1407
  description?: string;
1230
-
1231
- constructor(latitude: number, longitude: number, options?: LocationSendOptions)
1408
+
1409
+ constructor(
1410
+ latitude: number,
1411
+ longitude: number,
1412
+ options?: LocationSendOptions,
1413
+ );
1232
1414
  }
1233
1415
 
1234
1416
  /** Poll send options */
1235
1417
  export interface PollSendOptions {
1236
1418
  /** False for a single choice poll, true for a multiple choice poll (false by default) */
1237
- allowMultipleAnswers?: boolean,
1419
+ allowMultipleAnswers?: boolean;
1238
1420
  /**
1239
1421
  * The custom message secret, can be used as a poll ID
1240
1422
  * @note It has to be a unique vector with a length of 32
1241
1423
  */
1242
- messageSecret: Array<number>|undefined
1424
+ messageSecret: Array<number> | undefined;
1243
1425
  }
1244
1426
 
1245
1427
  /** Represents a Poll on WhatsApp */
1246
1428
  export class Poll {
1247
- pollName: string
1429
+ pollName: string;
1248
1430
  pollOptions: Array<{
1249
- name: string,
1250
- localId: number
1251
- }>
1252
- options: PollSendOptions
1431
+ name: string;
1432
+ localId: number;
1433
+ }>;
1434
+ options: PollSendOptions;
1253
1435
 
1254
- constructor(pollName: string, pollOptions: Array<string>, options?: PollSendOptions)
1436
+ constructor(
1437
+ pollName: string,
1438
+ pollOptions: Array<string>,
1439
+ options?: PollSendOptions,
1440
+ );
1255
1441
  }
1256
1442
 
1257
1443
  /** ScheduledEvent send options */
1258
1444
  export interface ScheduledEventSendOptions {
1259
1445
  /** The scheduled event description */
1260
- description?: string,
1446
+ description?: string;
1261
1447
  /** The end time of the event */
1262
- endTime?: Date,
1448
+ endTime?: Date;
1263
1449
  /** The location of the event */
1264
- location?: string,
1450
+ location?: string;
1265
1451
  /** The type of a WhatsApp call link to generate, valid values are: `video` | `voice` | `none` */
1266
- callType?: string,
1452
+ callType?: string;
1267
1453
  /**
1268
1454
  * Indicates if a scheduled event should be sent as an already canceled
1269
1455
  * @default false
1270
1456
  */
1271
- isEventCanceled?: boolean
1457
+ isEventCanceled?: boolean;
1272
1458
  /**
1273
1459
  * The custom message secret, can be used as an event ID
1274
1460
  * @note It has to be a unique vector with a length of 32
1275
1461
  */
1276
- messageSecret: Array<number>|undefined
1462
+ messageSecret: Array<number> | undefined;
1277
1463
  }
1278
1464
 
1279
1465
  /** Represents a ScheduledEvent on WhatsApp */
1280
1466
  export class ScheduledEvent {
1281
- name: string
1282
- startTimeTs: number
1467
+ name: string;
1468
+ startTimeTs: number;
1283
1469
  eventSendOptions: {
1284
1470
  description?: string;
1285
1471
  endTimeTs?: number;
@@ -1289,7 +1475,11 @@ declare namespace WAWebJS {
1289
1475
  messageSecret?: string;
1290
1476
  };
1291
1477
 
1292
- constructor(name: string, startTime: Date, options?: ScheduledEventSendOptions)
1478
+ constructor(
1479
+ name: string,
1480
+ startTime: Date,
1481
+ options?: ScheduledEventSendOptions,
1482
+ );
1293
1483
  }
1294
1484
 
1295
1485
  /** Represents a Poll Vote on WhatsApp */
@@ -1322,120 +1512,120 @@ declare namespace WAWebJS {
1322
1512
 
1323
1513
  export interface Label {
1324
1514
  /** Label name */
1325
- name: string,
1515
+ name: string;
1326
1516
  /** Label ID */
1327
- id: string,
1517
+ id: string;
1328
1518
  /** Color assigned to the label */
1329
- hexColor: string,
1519
+ hexColor: string;
1330
1520
 
1331
1521
  /** Get all chats that have been assigned this Label */
1332
- getChats: () => Promise<Chat[]>
1522
+ getChats: () => Promise<Chat[]>;
1333
1523
  }
1334
1524
 
1335
1525
  export interface Broadcast {
1336
1526
  /** Chat Object ID */
1337
1527
  id: {
1338
- server: string,
1339
- user: string,
1340
- _serialized: string
1341
- },
1528
+ server: string;
1529
+ user: string;
1530
+ _serialized: string;
1531
+ };
1342
1532
  /** Unix timestamp of last story */
1343
- timestamp: number,
1533
+ timestamp: number;
1344
1534
  /** Number of available statuses */
1345
- totalCount: number,
1535
+ totalCount: number;
1346
1536
  /** Number of not viewed */
1347
- unreadCount: number,
1537
+ unreadCount: number;
1348
1538
  /** Unix timestamp of last story */
1349
- msgs: Message[],
1539
+ msgs: Message[];
1350
1540
 
1351
1541
  /** Returns the Chat of the owner of the story */
1352
- getChat: () => Promise<Chat>,
1542
+ getChat: () => Promise<Chat>;
1353
1543
  /** Returns the Contact of the owner of the story */
1354
- getContact: () => Promise<Contact>,
1544
+ getContact: () => Promise<Contact>;
1355
1545
  }
1356
1546
 
1357
1547
  /** Options for sending a message */
1358
1548
  export interface MessageSendOptions {
1359
1549
  /** Show links preview. Has no effect on multi-device accounts. */
1360
- linkPreview?: boolean
1550
+ linkPreview?: boolean;
1361
1551
  /** Send audio as voice message with a generated waveform */
1362
- sendAudioAsVoice?: boolean
1552
+ sendAudioAsVoice?: boolean;
1363
1553
  /** Send video as gif */
1364
- sendVideoAsGif?: boolean
1554
+ sendVideoAsGif?: boolean;
1365
1555
  /** Send media as sticker */
1366
- sendMediaAsSticker?: boolean
1556
+ sendMediaAsSticker?: boolean;
1367
1557
  /** Send media as document */
1368
- sendMediaAsDocument?: boolean
1558
+ sendMediaAsDocument?: boolean;
1369
1559
  /** Send media as quality HD */
1370
- sendMediaAsHd?: boolean
1560
+ sendMediaAsHd?: boolean;
1371
1561
  /** Send photo/video as a view once message */
1372
- isViewOnce?: boolean
1562
+ isViewOnce?: boolean;
1373
1563
  /** Automatically parse vCards and send them as contacts */
1374
- parseVCards?: boolean
1564
+ parseVCards?: boolean;
1375
1565
  /** Image or videos caption */
1376
- caption?: string
1566
+ caption?: string;
1377
1567
  /** Id of the message that is being quoted (or replied to) */
1378
- quotedMessageId?: string
1568
+ quotedMessageId?: string;
1379
1569
  /** User IDs to mention in the message */
1380
- mentions?: string[]
1570
+ mentions?: string[];
1381
1571
  /** An array of object that handle group mentions */
1382
1572
  groupMentions?: {
1383
1573
  /** The name of a group to mention (can be custom) */
1384
- subject: string,
1574
+ subject: string;
1385
1575
  /** The group ID, e.g.: 'XXXXXXXXXX@g.us' */
1386
- id: string
1387
- }[]
1576
+ id: string;
1577
+ }[];
1388
1578
  /** Send 'seen' status */
1389
- sendSeen?: boolean
1579
+ sendSeen?: boolean;
1390
1580
  /** Bot Wid when doing a bot mention like @Meta AI */
1391
- invokedBotWid?: string
1581
+ invokedBotWid?: string;
1392
1582
  /** Media to be sent */
1393
- media?: MessageMedia
1583
+ media?: MessageMedia;
1394
1584
  /** Extra options */
1395
- extra?: any
1585
+ extra?: any;
1396
1586
  /** Sticker name, if sendMediaAsSticker is true */
1397
- stickerName?: string
1587
+ stickerName?: string;
1398
1588
  /** Sticker author, if sendMediaAsSticker is true */
1399
- stickerAuthor?: string
1589
+ stickerAuthor?: string;
1400
1590
  /** Sticker categories, if sendMediaAsSticker is true */
1401
- stickerCategories?: string[],
1591
+ stickerCategories?: string[];
1402
1592
  /** Should the bot send a quoted message without the quoted message if it fails to get the quote?
1403
1593
  * @default true (enabled) */
1404
- ignoreQuoteErrors?: boolean
1594
+ ignoreQuoteErrors?: boolean;
1405
1595
  /**
1406
1596
  * Should the bot wait for the message send result?
1407
1597
  * @default false
1408
1598
  */
1409
- waitUntilMsgSent?: boolean
1599
+ waitUntilMsgSent?: boolean;
1410
1600
  }
1411
1601
 
1412
1602
  /** Options for editing a message */
1413
1603
  export interface MessageEditOptions {
1414
1604
  /** Show links preview. Has no effect on multi-device accounts. */
1415
- linkPreview?: boolean
1605
+ linkPreview?: boolean;
1416
1606
  /** User IDs of users that being mentioned in the message */
1417
- mentions?: string[]
1607
+ mentions?: string[];
1418
1608
  /** Extra options */
1419
- extra?: any
1609
+ extra?: any;
1420
1610
  }
1421
1611
 
1422
1612
  export interface MediaFromURLOptions {
1423
- client?: Client
1424
- filename?: string
1425
- unsafeMime?: boolean
1426
- reqOptions?: RequestInit
1613
+ client?: Client;
1614
+ filename?: string;
1615
+ unsafeMime?: boolean;
1616
+ reqOptions?: RequestInit;
1427
1617
  }
1428
1618
 
1429
1619
  /** Media attached to a message */
1430
1620
  export class MessageMedia {
1431
1621
  /** MIME type of the attachment */
1432
- mimetype: string
1622
+ mimetype: string;
1433
1623
  /** Base64-encoded data of the file */
1434
- data: string
1624
+ data: string;
1435
1625
  /** Document file name. Value can be null */
1436
- filename?: string | null
1626
+ filename?: string | null;
1437
1627
  /** Document file size in bytes. Value can be null. */
1438
- filesize?: number | null
1628
+ filesize?: number | null;
1439
1629
 
1440
1630
  /**
1441
1631
  * @param {string} mimetype MIME type of the attachment
@@ -1443,21 +1633,38 @@ declare namespace WAWebJS {
1443
1633
  * @param {?string} filename Document file name. Value can be null
1444
1634
  * @param {?number} filesize Document file size in bytes. Value can be null.
1445
1635
  */
1446
- constructor(mimetype: string, data: string, filename?: string | null, filesize?: number | null)
1636
+ constructor(
1637
+ mimetype: string,
1638
+ data: string,
1639
+ filename?: string | null,
1640
+ filesize?: number | null,
1641
+ );
1447
1642
 
1448
1643
  /** Creates a MessageMedia instance from a local file path */
1449
- static fromFilePath: (filePath: string) => MessageMedia
1644
+ static fromFilePath: (filePath: string) => MessageMedia;
1450
1645
 
1451
1646
  /** Creates a MessageMedia instance from a URL */
1452
- static fromUrl: (url: string, options?: MediaFromURLOptions) => Promise<MessageMedia>
1453
- }
1454
-
1455
- export type MessageContent = string | MessageMedia | Location | Poll | Contact | Contact[] | List | Buttons | ScheduledEvent
1647
+ static fromUrl: (
1648
+ url: string,
1649
+ options?: MediaFromURLOptions,
1650
+ ) => Promise<MessageMedia>;
1651
+ }
1652
+
1653
+ export type MessageContent =
1654
+ | string
1655
+ | MessageMedia
1656
+ | Location
1657
+ | Poll
1658
+ | Contact
1659
+ | Contact[]
1660
+ | List
1661
+ | Buttons
1662
+ | ScheduledEvent;
1456
1663
 
1457
1664
  /**
1458
1665
  * Represents a Contact on WhatsApp
1459
1666
  *
1460
- * @example
1667
+ * @example
1461
1668
  * {
1462
1669
  * id: {
1463
1670
  * server: 'c.us',
@@ -1485,162 +1692,158 @@ declare namespace WAWebJS {
1485
1692
  */
1486
1693
  export interface Contact {
1487
1694
  /** Contact's phone number */
1488
- number: string,
1695
+ number: string;
1489
1696
  /** Indicates if the contact is a business contact */
1490
- isBusiness: boolean,
1697
+ isBusiness: boolean;
1491
1698
  /** ID that represents the contact */
1492
- id: ContactId,
1699
+ id: ContactId;
1493
1700
  /** Indicates if the contact is an enterprise contact */
1494
- isEnterprise: boolean,
1701
+ isEnterprise: boolean;
1495
1702
  /** Indicates if the contact is a group contact */
1496
- isGroup: boolean,
1703
+ isGroup: boolean;
1497
1704
  /** Indicates if the contact is the current user's contact */
1498
- isMe: boolean,
1705
+ isMe: boolean;
1499
1706
  /** Indicates if the number is saved in the current phone's contacts */
1500
- isMyContact: boolean
1707
+ isMyContact: boolean;
1501
1708
  /** Indicates if the contact is a user contact */
1502
- isUser: boolean,
1709
+ isUser: boolean;
1503
1710
  /** Indicates if the number is registered on WhatsApp */
1504
- isWAContact: boolean,
1711
+ isWAContact: boolean;
1505
1712
  /** Indicates if you have blocked this contact */
1506
- isBlocked: boolean,
1713
+ isBlocked: boolean;
1507
1714
  /** @todo verify labels type. didn't have any documentation */
1508
- labels?: string[],
1715
+ labels?: string[];
1509
1716
  /** The contact's name, as saved by the current user */
1510
- name?: string,
1717
+ name?: string;
1511
1718
  /** The name that the contact has configured to be shown publically */
1512
- pushname: string,
1719
+ pushname: string;
1513
1720
  /** @todo missing documentation */
1514
- sectionHeader: string,
1721
+ sectionHeader: string;
1515
1722
  /** A shortened version of name */
1516
- shortName?: string,
1723
+ shortName?: string;
1517
1724
  /** Indicates if the status from the contact is muted */
1518
- statusMute: boolean,
1725
+ statusMute: boolean;
1519
1726
  /** @todo missing documentation */
1520
- type: string,
1727
+ type: string;
1521
1728
  /** @todo missing documentation */
1522
- verifiedLevel?: undefined,
1729
+ verifiedLevel?: undefined;
1523
1730
  /** @todo missing documentation */
1524
- verifiedName?: undefined,
1731
+ verifiedName?: undefined;
1525
1732
 
1526
1733
  /** Returns the contact's profile picture URL, if privacy settings allow it */
1527
- getProfilePicUrl: () => Promise<string>,
1734
+ getProfilePicUrl: () => Promise<string>;
1528
1735
 
1529
- /** Returns the Chat that corresponds to this Contact.
1736
+ /** Returns the Chat that corresponds to this Contact.
1530
1737
  * Will return null when getting chat for currently logged in user.
1531
1738
  */
1532
- getChat: () => Promise<Chat>,
1533
-
1739
+ getChat: () => Promise<Chat>;
1740
+
1534
1741
  /** Returns the contact's countrycode, (1541859685@c.us) => (1) */
1535
- getCountryCode(): Promise<string>,
1536
-
1742
+ getCountryCode(): Promise<string>;
1743
+
1537
1744
  /** Returns the contact's formatted phone number, (12345678901@c.us) => (+1 (234) 5678-901) */
1538
- getFormattedNumber(): Promise<string>,
1539
-
1745
+ getFormattedNumber(): Promise<string>;
1746
+
1540
1747
  /** Blocks this contact from WhatsApp */
1541
- block: () => Promise<boolean>,
1748
+ block: () => Promise<boolean>;
1542
1749
 
1543
1750
  /** Unlocks this contact from WhatsApp */
1544
- unblock: () => Promise<boolean>,
1751
+ unblock: () => Promise<boolean>;
1545
1752
 
1546
1753
  /** Gets the Contact's current "about" info. Returns null if you don't have permission to read their status. */
1547
- getAbout: () => Promise<string | null>,
1548
-
1754
+ getAbout: () => Promise<string | null>;
1755
+
1549
1756
  /** Gets the Contact's common groups with you. Returns empty array if you don't have any common group. */
1550
- getCommonGroups: () => Promise<ChatId[]>
1757
+ getCommonGroups: () => Promise<ChatId[]>;
1551
1758
 
1552
1759
  /** Gets the Contact's current status broadcast. */
1553
- getBroadcast: () => Promise<Broadcast>
1760
+ getBroadcast: () => Promise<Broadcast>;
1554
1761
  }
1555
1762
 
1556
1763
  export interface ContactId {
1557
- server: string,
1558
- user: string,
1559
- _serialized: string,
1764
+ server: string;
1765
+ user: string;
1766
+ _serialized: string;
1560
1767
  }
1561
-
1768
+
1562
1769
  export interface BusinessCategory {
1563
- id: string,
1564
- localized_display_name: string,
1770
+ id: string;
1771
+ localized_display_name: string;
1565
1772
  }
1566
1773
 
1567
1774
  export interface BusinessHoursOfDay {
1568
- mode: string,
1569
- hours: number[]
1775
+ mode: string;
1776
+ hours: number[];
1570
1777
  }
1571
-
1778
+
1572
1779
  export interface BusinessHours {
1573
1780
  config: {
1574
- sun: BusinessHoursOfDay,
1575
- mon: BusinessHoursOfDay,
1576
- tue: BusinessHoursOfDay,
1577
- wed: BusinessHoursOfDay,
1578
- thu: BusinessHoursOfDay,
1579
- fri: BusinessHoursOfDay,
1580
- }
1581
- timezone: string,
1582
- }
1583
-
1584
-
1781
+ sun: BusinessHoursOfDay;
1782
+ mon: BusinessHoursOfDay;
1783
+ tue: BusinessHoursOfDay;
1784
+ wed: BusinessHoursOfDay;
1785
+ thu: BusinessHoursOfDay;
1786
+ fri: BusinessHoursOfDay;
1787
+ };
1788
+ timezone: string;
1789
+ }
1585
1790
 
1586
1791
  export interface BusinessContact extends Contact {
1587
- /**
1792
+ /**
1588
1793
  * The contact's business profile
1589
1794
  */
1590
1795
  businessProfile: {
1591
1796
  /** The contact's business profile id */
1592
- id: ContactId,
1797
+ id: ContactId;
1593
1798
 
1594
1799
  /** The contact's business profile tag */
1595
- tag: string,
1800
+ tag: string;
1596
1801
 
1597
1802
  /** The contact's business profile description */
1598
- description: string,
1803
+ description: string;
1599
1804
 
1600
1805
  /** The contact's business profile categories */
1601
- categories: BusinessCategory[],
1806
+ categories: BusinessCategory[];
1602
1807
 
1603
1808
  /** The contact's business profile options */
1604
1809
  profileOptions: {
1605
1810
  /** The contact's business profile commerce experience*/
1606
- commerceExperience: string,
1607
-
1811
+ commerceExperience: string;
1812
+
1608
1813
  /** The contact's business profile cart options */
1609
- cartEnabled: boolean,
1610
- }
1814
+ cartEnabled: boolean;
1815
+ };
1611
1816
 
1612
1817
  /** The contact's business profile email */
1613
- email: string,
1818
+ email: string;
1614
1819
 
1615
1820
  /** The contact's business profile websites */
1616
- website: string[],
1821
+ website: string[];
1617
1822
 
1618
1823
  /** The contact's business profile latitude */
1619
- latitude: number,
1620
-
1824
+ latitude: number;
1825
+
1621
1826
  /** The contact's business profile longitude */
1622
- longitude: number,
1623
-
1827
+ longitude: number;
1828
+
1624
1829
  /** The contact's business profile work hours*/
1625
- businessHours: BusinessHours
1626
-
1830
+ businessHours: BusinessHours;
1831
+
1627
1832
  /** The contact's business profile address */
1628
- address: string,
1629
-
1833
+ address: string;
1834
+
1630
1835
  /** The contact's business profile facebook page */
1631
- fbPage: object,
1632
-
1836
+ fbPage: object;
1837
+
1633
1838
  /** Indicate if the contact's business profile linked */
1634
- ifProfileLinked: boolean
1635
-
1839
+ ifProfileLinked: boolean;
1840
+
1636
1841
  /** The contact's business profile coverPhoto */
1637
- coverPhoto: null | any,
1638
- }
1842
+ coverPhoto: null | any;
1843
+ };
1639
1844
  }
1640
1845
 
1641
- export interface PrivateContact extends Contact {
1642
-
1643
- }
1846
+ export interface PrivateContact extends Contact {}
1644
1847
 
1645
1848
  /**
1646
1849
  * Represents a Chat on WhatsApp
@@ -1662,72 +1865,79 @@ declare namespace WAWebJS {
1662
1865
  */
1663
1866
  export interface Chat {
1664
1867
  /** Indicates if the Chat is archived */
1665
- archived: boolean,
1868
+ archived: boolean;
1666
1869
  /** ID that represents the chat */
1667
- id: ChatId,
1870
+ id: ChatId;
1668
1871
  /** Indicates if the Chat is a Group Chat */
1669
- isGroup: boolean,
1872
+ isGroup: boolean;
1670
1873
  /** Indicates if the Chat is readonly */
1671
- isReadOnly: boolean,
1874
+ isReadOnly: boolean;
1672
1875
  /** Indicates if the Chat is muted */
1673
- isMuted: boolean,
1876
+ isMuted: boolean;
1674
1877
  /** Unix timestamp for when the mute expires */
1675
- muteExpiration: number,
1878
+ muteExpiration: number;
1676
1879
  /** Title of the chat */
1677
- name: string,
1880
+ name: string;
1678
1881
  /** Unix timestamp for when the last activity occurred */
1679
- timestamp: number,
1882
+ timestamp: number;
1680
1883
  /** Amount of messages unread */
1681
- unreadCount: number,
1884
+ unreadCount: number;
1682
1885
  /** Last message of chat */
1683
- lastMessage: Message,
1886
+ lastMessage: Message;
1684
1887
  /** Indicates if the Chat is pinned */
1685
- pinned: boolean,
1888
+ pinned: boolean;
1686
1889
  /** Indicates if the Chat is locked */
1687
- isLocked: boolean,
1890
+ isLocked: boolean;
1688
1891
 
1689
1892
  /** Archives this chat */
1690
- archive: () => Promise<void>,
1893
+ archive: () => Promise<void>;
1691
1894
  /** Pins this chat and returns its new Pin state */
1692
- pin: () => Promise<boolean>,
1895
+ pin: () => Promise<boolean>;
1693
1896
  /** Unpins this chat and returns its new Pin state */
1694
- unpin: () => Promise<boolean>,
1897
+ unpin: () => Promise<boolean>;
1695
1898
  /** Clears all messages from the chat */
1696
- clearMessages: () => Promise<boolean>,
1899
+ clearMessages: () => Promise<boolean>;
1697
1900
  /** Stops typing or recording in chat immediately. */
1698
- clearState: () => Promise<boolean>,
1901
+ clearState: () => Promise<boolean>;
1699
1902
  /** Deletes the chat */
1700
- delete: () => Promise<boolean>,
1903
+ delete: () => Promise<boolean>;
1701
1904
  /** Loads chat messages, sorted from earliest to latest. */
1702
- fetchMessages: (searchOptions: MessageSearchOptions) => Promise<Message[]>,
1905
+ fetchMessages: (
1906
+ searchOptions: MessageSearchOptions,
1907
+ ) => Promise<Message[]>;
1703
1908
  /** Mutes this chat forever, unless a date is specified */
1704
- mute: (unmuteDate?: Date) => Promise<{ isMuted: boolean, muteExpiration: number }>,
1909
+ mute: (
1910
+ unmuteDate?: Date,
1911
+ ) => Promise<{ isMuted: boolean; muteExpiration: number }>;
1705
1912
  /** Send a message to this chat */
1706
- sendMessage: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
1913
+ sendMessage: (
1914
+ content: MessageContent,
1915
+ options?: MessageSendOptions,
1916
+ ) => Promise<Message>;
1707
1917
  /** Sets the chat as seen */
1708
- sendSeen: () => Promise<boolean>,
1918
+ sendSeen: () => Promise<boolean>;
1709
1919
  /** Simulate recording audio in chat. This will last for 25 seconds */
1710
- sendStateRecording: () => Promise<void>,
1920
+ sendStateRecording: () => Promise<void>;
1711
1921
  /** Simulate typing in chat. This will last for 25 seconds. */
1712
- sendStateTyping: () => Promise<void>,
1922
+ sendStateTyping: () => Promise<void>;
1713
1923
  /** un-archives this chat */
1714
- unarchive: () => Promise<void>,
1924
+ unarchive: () => Promise<void>;
1715
1925
  /** Unmutes this chat */
1716
- unmute: () => Promise<{ isMuted: boolean, muteExpiration: number }>,
1926
+ unmute: () => Promise<{ isMuted: boolean; muteExpiration: number }>;
1717
1927
  /** Returns the Contact that corresponds to this Chat. */
1718
- getContact: () => Promise<Contact>,
1928
+ getContact: () => Promise<Contact>;
1719
1929
  /** Marks this Chat as unread */
1720
- markUnread: () => Promise<void>,
1930
+ markUnread: () => Promise<void>;
1721
1931
  /** Returns array of all Labels assigned to this Chat */
1722
- getLabels: () => Promise<Label[]>,
1932
+ getLabels: () => Promise<Label[]>;
1723
1933
  /** Add or remove labels to this Chat */
1724
- changeLabels: (labelIds: Array<string | number>) => Promise<void>
1934
+ changeLabels: (labelIds: Array<string | number>) => Promise<void>;
1725
1935
  /** Gets instances of all pinned messages in a chat */
1726
- getPinnedMessages: () => Promise<[Message]|[]>
1936
+ getPinnedMessages: () => Promise<[Message] | []>;
1727
1937
  /** Sync history conversation of the Chat */
1728
- syncHistory: () => Promise<boolean>
1938
+ syncHistory: () => Promise<boolean>;
1729
1939
  /** Add or edit a customer note */
1730
- addOrEditCustomerNote: (note: string) => Promise<void>
1940
+ addOrEditCustomerNote: (note: string) => Promise<void>;
1731
1941
  /** Get a customer note */
1732
1942
  getCustomerNote: () => Promise<{
1733
1943
  chatId: string;
@@ -1736,7 +1946,7 @@ declare namespace WAWebJS {
1736
1946
  id: string;
1737
1947
  modifiedAt: number;
1738
1948
  type: string;
1739
- }>
1949
+ }>;
1740
1950
  }
1741
1951
 
1742
1952
  export interface Channel {
@@ -1768,7 +1978,9 @@ declare namespace WAWebJS {
1768
1978
  lastMessage: Message | undefined;
1769
1979
 
1770
1980
  /** Gets the subscribers of the channel (only those who are in your contact list) */
1771
- getSubscribers(limit?: number): Promise<{contact: Contact, role: string}[]>;
1981
+ getSubscribers(
1982
+ limit?: number,
1983
+ ): Promise<{ contact: Contact; role: string }[]>;
1772
1984
  /** Updates the channel subject */
1773
1985
  setSubject(newSubject: string): Promise<boolean>;
1774
1986
  /** Updates the channel description */
@@ -1777,7 +1989,7 @@ declare namespace WAWebJS {
1777
1989
  setProfilePicture(newProfilePicture: MessageMedia): Promise<boolean>;
1778
1990
  /**
1779
1991
  * Updates available reactions to use in the channel
1780
- *
1992
+ *
1781
1993
  * Valid values for passing to the method are:
1782
1994
  * 0 for NONE reactions to be avaliable
1783
1995
  * 1 for BASIC reactions to be available: 👍, ❤️, 😂, 😮, 😢, 🙏
@@ -1789,11 +2001,17 @@ declare namespace WAWebJS {
1789
2001
  /** Unmutes the channel */
1790
2002
  unmute(): Promise<boolean>;
1791
2003
  /** Sends a message to this channel */
1792
- sendMessage(content: string|MessageMedia, options?: MessageSendChannelOptions): Promise<Message>;
2004
+ sendMessage(
2005
+ content: string | MessageMedia,
2006
+ options?: MessageSendChannelOptions,
2007
+ ): Promise<Message>;
1793
2008
  /** Sets the channel as seen */
1794
2009
  sendSeen(): Promise<boolean>;
1795
2010
  /** Sends a channel admin invitation to a user, allowing them to become an admin of the channel */
1796
- sendChannelAdminInvite(chatId: string, options?: { comment?: string }): Promise<boolean>;
2011
+ sendChannelAdminInvite(
2012
+ chatId: string,
2013
+ options?: { comment?: string },
2014
+ ): Promise<boolean>;
1797
2015
  /** Accepts a channel admin invitation and promotes the current user to a channel admin */
1798
2016
  acceptChannelAdminInvite(): Promise<boolean>;
1799
2017
  /** Revokes a channel admin invitation sent to a user by a channel owner */
@@ -1801,12 +2019,17 @@ declare namespace WAWebJS {
1801
2019
  /** Demotes a channel admin to a regular subscriber (can be used also for self-demotion) */
1802
2020
  demoteChannelAdmin(userId: string): Promise<boolean>;
1803
2021
  /** Loads channel messages, sorted from earliest to latest */
1804
- fetchMessages: (searchOptions: MessageSearchOptions) => Promise<Message[]>;
2022
+ fetchMessages: (
2023
+ searchOptions: MessageSearchOptions,
2024
+ ) => Promise<Message[]>;
1805
2025
  /**
1806
2026
  * Transfers a channel ownership to another user.
1807
2027
  * Note: the user you are transferring the channel ownership to must be a channel admin.
1808
2028
  */
1809
- transferChannelOwnership(newOwnerId: string, options?: TransferChannelOwnershipOptions): Promise<boolean>;
2029
+ transferChannelOwnership(
2030
+ newOwnerId: string,
2031
+ options?: TransferChannelOwnershipOptions,
2032
+ ): Promise<boolean>;
1810
2033
  /** Deletes the channel you created */
1811
2034
  deleteChannel(): Promise<boolean>;
1812
2035
  }
@@ -1817,37 +2040,37 @@ declare namespace WAWebJS {
1817
2040
  * If true, after the channel ownership is being transferred to another user,
1818
2041
  * the current user will be dismissed as a channel admin and will become to a channel subscriber.
1819
2042
  */
1820
- shouldDismissSelfAsAdmin?: boolean
2043
+ shouldDismissSelfAsAdmin?: boolean;
1821
2044
  }
1822
2045
 
1823
2046
  /** Options for sending a message */
1824
2047
  export interface MessageSendChannelOptions {
1825
2048
  /** Image or videos caption */
1826
- caption?: string
2049
+ caption?: string;
1827
2050
  /** User IDs of user that will be mentioned in the message */
1828
- mentions?: string[]
2051
+ mentions?: string[];
1829
2052
  /** Image or video to be sent */
1830
- media?: MessageMedia
2053
+ media?: MessageMedia;
1831
2054
  /** Extra options */
1832
- extra?: any
2055
+ extra?: any;
1833
2056
  }
1834
2057
 
1835
2058
  export interface MessageSearchOptions {
1836
2059
  /**
1837
2060
  * The amount of messages to return. If no limit is specified, the available messages will be returned.
1838
- * Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation.
2061
+ * Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation.
1839
2062
  * Set this to Infinity to load all messages.
1840
2063
  */
1841
- limit?: number
2064
+ limit?: number;
1842
2065
  /**
1843
- * Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.
1844
- */
1845
- fromMe?: boolean
2066
+ * Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.
2067
+ */
2068
+ fromMe?: boolean;
1846
2069
  }
1847
2070
 
1848
2071
  /**
1849
2072
  * Id that represents the chat
1850
- *
2073
+ *
1851
2074
  * @example
1852
2075
  * id: {
1853
2076
  * server: 'c.us',
@@ -1860,40 +2083,39 @@ declare namespace WAWebJS {
1860
2083
  * Whatsapp server domain
1861
2084
  * @example `c.us`
1862
2085
  */
1863
- server: string,
2086
+ server: string;
1864
2087
  /**
1865
2088
  * User whatsapp number
1866
2089
  * @example `554199999999`
1867
2090
  */
1868
- user: string,
2091
+ user: string;
1869
2092
  /**
1870
2093
  * Serialized id
1871
2094
  * @example `554199999999@c.us`
1872
2095
  */
1873
- _serialized: string,
2096
+ _serialized: string;
1874
2097
  }
1875
2098
 
1876
- export interface PrivateChat extends Chat {
1877
-
1878
- }
2099
+ export interface PrivateChat extends Chat {}
1879
2100
 
1880
2101
  export type GroupParticipant = {
1881
- id: ContactId,
1882
- isAdmin: boolean
1883
- isSuperAdmin: boolean
1884
- }
2102
+ id: ContactId;
2103
+ isAdmin: boolean;
2104
+ isSuperAdmin: boolean;
2105
+ };
1885
2106
 
1886
2107
  /** Promotes or demotes participants by IDs to regular users or admins */
1887
- export type ChangeParticipantsPermissions =
1888
- (participantIds: Array<string>) => Promise<{ status: number }>
2108
+ export type ChangeParticipantsPermissions = (
2109
+ participantIds: Array<string>,
2110
+ ) => Promise<{ status: number }>;
1889
2111
 
1890
2112
  /** An object that handles the result for addParticipants method */
1891
2113
  export interface AddParticipantsResult {
1892
2114
  [participantId: string]: {
1893
2115
  code: number;
1894
2116
  message: string;
1895
- isInviteV4Sent: boolean,
1896
- }
2117
+ isInviteV4Sent: boolean;
2118
+ };
1897
2119
  }
1898
2120
 
1899
2121
  /** An object that handles options for adding participants */
@@ -1905,19 +2127,19 @@ declare namespace WAWebJS {
1905
2127
  * will be added). If sleep is a number, a sleep time equal to its value will be added
1906
2128
  * @default [250,500]
1907
2129
  */
1908
- sleep?: Array<number>|number,
2130
+ sleep?: Array<number> | number;
1909
2131
  /**
1910
2132
  * If true, the inviteV4 will be sent to those participants
1911
2133
  * who have restricted others from being automatically added to groups,
1912
2134
  * otherwise the inviteV4 won't be sent
1913
2135
  * @default true
1914
2136
  */
1915
- autoSendInviteV4?: boolean,
2137
+ autoSendInviteV4?: boolean;
1916
2138
  /**
1917
2139
  * The comment to be added to an inviteV4 (empty string by default)
1918
2140
  * @default ''
1919
2141
  */
1920
- comment?: string
2142
+ comment?: string;
1921
2143
  }
1922
2144
 
1923
2145
  /** An object that handles the information about the group membership request */
@@ -1929,9 +2151,9 @@ declare namespace WAWebJS {
1929
2151
  /** The wid of a community parent group to which the current group is linked */
1930
2152
  parentGroupId: Object | null;
1931
2153
  /** The method used to create the request: NonAdminAdd/InviteLink/LinkedGroupJoin */
1932
- requestMethod: string,
2154
+ requestMethod: string;
1933
2155
  /** The timestamp the request was created at */
1934
- t: number
2156
+ t: number;
1935
2157
  }
1936
2158
 
1937
2159
  /** An object that handles the result for membership request action */
@@ -1962,9 +2184,14 @@ declare namespace WAWebJS {
1962
2184
  /** Group participants */
1963
2185
  participants: Array<GroupParticipant>;
1964
2186
  /** Adds a list of participants by ID to the group */
1965
- addParticipants: (participantIds: string | string[], options?: AddParticipantsOptions) => Promise<{ [key: string]: AddParticipantsResult } | string>;
2187
+ addParticipants: (
2188
+ participantIds: string | string[],
2189
+ options?: AddParticipantsOptions,
2190
+ ) => Promise<{ [key: string]: AddParticipantsResult } | string>;
1966
2191
  /** Removes a list of participants by ID to the group */
1967
- removeParticipants: (participantIds: string[]) => Promise<{ status: number }>;
2192
+ removeParticipants: (
2193
+ participantIds: string[],
2194
+ ) => Promise<{ status: number }>;
1968
2195
  /** Promotes participants by IDs to admins */
1969
2196
  promoteParticipants: ChangeParticipantsPermissions;
1970
2197
  /** Demotes participants by IDs to regular users */
@@ -1975,7 +2202,7 @@ declare namespace WAWebJS {
1975
2202
  setDescription: (description: string) => Promise<boolean>;
1976
2203
  /**
1977
2204
  * Updates the group setting to allow only admins to add members to the group.
1978
- * @param {boolean} [adminsOnly=true] Enable or disable this option
2205
+ * @param {boolean} [adminsOnly=true] Enable or disable this option
1979
2206
  * @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
1980
2207
  */
1981
2208
  setAddMembersAdminsOnly: (adminsOnly?: boolean) => Promise<boolean>;
@@ -1994,19 +2221,25 @@ declare namespace WAWebJS {
1994
2221
  * Gets an array of membership requests
1995
2222
  * @returns {Promise<Array<GroupMembershipRequest>>} An array of membership requests
1996
2223
  */
1997
- getGroupMembershipRequests: () => Promise<Array<GroupMembershipRequest>>;
2224
+ getGroupMembershipRequests: () => Promise<
2225
+ Array<GroupMembershipRequest>
2226
+ >;
1998
2227
  /**
1999
2228
  * Approves membership requests if any
2000
2229
  * @param {MembershipRequestActionOptions} options Options for performing a membership request action
2001
2230
  * @returns {Promise<Array<MembershipRequestActionResult>>} Returns an array of requester IDs whose membership requests were approved and an error for each requester, if any occurred during the operation. If there are no requests, an empty array will be returned
2002
2231
  */
2003
- approveGroupMembershipRequests: (options: MembershipRequestActionOptions) => Promise<Array<MembershipRequestActionResult>>;
2232
+ approveGroupMembershipRequests: (
2233
+ options: MembershipRequestActionOptions,
2234
+ ) => Promise<Array<MembershipRequestActionResult>>;
2004
2235
  /**
2005
2236
  * Rejects membership requests if any
2006
2237
  * @param {MembershipRequestActionOptions} options Options for performing a membership request action
2007
2238
  * @returns {Promise<Array<MembershipRequestActionResult>>} Returns an array of requester IDs whose membership requests were rejected and an error for each requester, if any occurred during the operation. If there are no requests, an empty array will be returned
2008
2239
  */
2009
- rejectGroupMembershipRequests: (options: MembershipRequestActionOptions) => Promise<Array<MembershipRequestActionResult>>;
2240
+ rejectGroupMembershipRequests: (
2241
+ options: MembershipRequestActionOptions,
2242
+ ) => Promise<Array<MembershipRequestActionResult>>;
2010
2243
  /** Gets the invite code for a specific group */
2011
2244
  getInviteCode: () => Promise<string>;
2012
2245
  /** Invalidates the current group invite code and generates a new one */
@@ -2025,13 +2258,13 @@ declare namespace WAWebJS {
2025
2258
  */
2026
2259
  export interface ProductMetadata {
2027
2260
  /** Product Id */
2028
- id: string,
2261
+ id: string;
2029
2262
  /** Product Name */
2030
- name: string,
2263
+ name: string;
2031
2264
  /** Product Description */
2032
- description: string,
2265
+ description: string;
2033
2266
  /** Retailer ID */
2034
- retailer_id?: string
2267
+ retailer_id?: string;
2035
2268
  }
2036
2269
 
2037
2270
  /**
@@ -2049,19 +2282,19 @@ declare namespace WAWebJS {
2049
2282
  */
2050
2283
  export interface Product {
2051
2284
  /** Product Id */
2052
- id: string,
2285
+ id: string;
2053
2286
  /** Price */
2054
- price?: string,
2287
+ price?: string;
2055
2288
  /** Product Thumbnail*/
2056
- thumbnailUrl: string,
2289
+ thumbnailUrl: string;
2057
2290
  /** Currency */
2058
- currency: string,
2291
+ currency: string;
2059
2292
  /** Product Name */
2060
- name: string,
2293
+ name: string;
2061
2294
  /** Product Quantity*/
2062
- quantity: number,
2295
+ quantity: number;
2063
2296
  /** Gets the Product metadata */
2064
- getData: () => Promise<ProductMetadata>
2297
+ getData: () => Promise<ProductMetadata>;
2065
2298
  }
2066
2299
 
2067
2300
  /**
@@ -2089,13 +2322,13 @@ declare namespace WAWebJS {
2089
2322
  */
2090
2323
  export interface Order {
2091
2324
  /** List of products*/
2092
- products: Array<Product>,
2325
+ products: Array<Product>;
2093
2326
  /** Order Subtotal */
2094
- subtotal: string,
2327
+ subtotal: string;
2095
2328
  /** Order Total */
2096
- total: string,
2329
+ total: string;
2097
2330
  /** Order Currency */
2098
- currency: string,
2331
+ currency: string;
2099
2332
  /** Order Created At*/
2100
2333
  createdAt: number;
2101
2334
  }
@@ -2130,23 +2363,23 @@ declare namespace WAWebJS {
2130
2363
  */
2131
2364
  export interface Payment {
2132
2365
  /** Payment Id*/
2133
- id: object,
2366
+ id: object;
2134
2367
  /** Payment currency */
2135
- paymentCurrency: string,
2368
+ paymentCurrency: string;
2136
2369
  /** Payment ammount */
2137
- paymentAmount1000 : number,
2370
+ paymentAmount1000: number;
2138
2371
  /** Payment receiver */
2139
- paymentMessageReceiverJid : object,
2372
+ paymentMessageReceiverJid: object;
2140
2373
  /** Payment transaction timestamp */
2141
- paymentTransactionTimestamp : number,
2374
+ paymentTransactionTimestamp: number;
2142
2375
  /** Payment paymentStatus */
2143
- paymentStatus : number,
2376
+ paymentStatus: number;
2144
2377
  /** Integer that represents the payment Text */
2145
- paymentTxnStatus : number,
2378
+ paymentTxnStatus: number;
2146
2379
  /** The note sent with the payment */
2147
- paymentNote : string;
2380
+ paymentNote: string;
2148
2381
  }
2149
-
2382
+
2150
2383
  /**
2151
2384
  * Represents a Call on WhatsApp
2152
2385
  *
@@ -2165,68 +2398,83 @@ declare namespace WAWebJS {
2165
2398
  */
2166
2399
  export interface Call {
2167
2400
  /** Call Id */
2168
- id: string,
2401
+ id: string;
2169
2402
  /** from */
2170
- from?: string,
2403
+ from?: string;
2171
2404
  /** Unix timestamp for when the call was created*/
2172
- timestamp: number,
2405
+ timestamp: number;
2173
2406
  /** Is video */
2174
- isVideo: boolean,
2407
+ isVideo: boolean;
2175
2408
  /** Is Group */
2176
- isGroup: boolean,
2409
+ isGroup: boolean;
2177
2410
  /** Indicates if the call was sent by the current user */
2178
- fromMe: boolean,
2411
+ fromMe: boolean;
2179
2412
  /** indicates if the call can be handled in waweb */
2180
- canHandleLocally: boolean,
2413
+ canHandleLocally: boolean;
2181
2414
  /** indicates if the call should be handled in waweb */
2182
- webClientShouldHandle: boolean,
2415
+ webClientShouldHandle: boolean;
2183
2416
  /** Object with participants */
2184
- participants: object
2417
+ participants: object;
2185
2418
 
2186
2419
  /** Reject the call */
2187
- reject: () => Promise<void>
2420
+ reject: () => Promise<void>;
2188
2421
  }
2189
2422
 
2190
2423
  /** Message type List */
2191
2424
  export class List {
2192
- body: string
2193
- buttonText: string
2194
- sections: Array<any>
2195
- title?: string | null
2196
- footer?: string | null
2197
-
2198
- constructor(body: string, buttonText: string, sections: Array<any>, title?: string | null, footer?: string | null)
2199
- }
2200
-
2425
+ body: string;
2426
+ buttonText: string;
2427
+ sections: Array<any>;
2428
+ title?: string | null;
2429
+ footer?: string | null;
2430
+
2431
+ constructor(
2432
+ body: string,
2433
+ buttonText: string,
2434
+ sections: Array<any>,
2435
+ title?: string | null,
2436
+ footer?: string | null,
2437
+ );
2438
+ }
2439
+
2201
2440
  /** Message type Buttons */
2202
2441
  export class Buttons {
2203
- body: string | MessageMedia
2204
- buttons: Array<{ buttonId: string; buttonText: {displayText: string}; type: number }>
2205
- title?: string | null
2206
- footer?: string | null
2207
-
2208
- constructor(body: string, buttons: Array<{ id?: string; body: string }>, title?: string | null, footer?: string | null)
2442
+ body: string | MessageMedia;
2443
+ buttons: Array<{
2444
+ buttonId: string;
2445
+ buttonText: { displayText: string };
2446
+ type: number;
2447
+ }>;
2448
+ title?: string | null;
2449
+ footer?: string | null;
2450
+
2451
+ constructor(
2452
+ body: string,
2453
+ buttons: Array<{ id?: string; body: string }>,
2454
+ title?: string | null,
2455
+ footer?: string | null,
2456
+ );
2209
2457
  }
2210
2458
 
2211
2459
  /** Message type Reaction */
2212
2460
  export class Reaction {
2213
- id: MessageId
2214
- orphan: number
2215
- orphanReason?: string
2216
- timestamp: number
2217
- reaction: string
2218
- read: boolean
2219
- msgId: MessageId
2220
- senderId: string
2221
- ack?: number
2222
- }
2223
-
2224
- export type ReactionList = {
2225
- id: string,
2226
- aggregateEmoji: string,
2227
- hasReactionByMe: boolean,
2228
- senders: Array<Reaction>
2461
+ id: MessageId;
2462
+ orphan: number;
2463
+ orphanReason?: string;
2464
+ timestamp: number;
2465
+ reaction: string;
2466
+ read: boolean;
2467
+ msgId: MessageId;
2468
+ senderId: string;
2469
+ ack?: number;
2229
2470
  }
2471
+
2472
+ export type ReactionList = {
2473
+ id: string;
2474
+ aggregateEmoji: string;
2475
+ hasReactionByMe: boolean;
2476
+ senders: Array<Reaction>;
2477
+ };
2230
2478
  }
2231
2479
 
2232
- export = WAWebJS
2480
+ export = WAWebJS;