chore(): generate docs

This commit is contained in:
WWebJS Bot 2025-05-31 18:37:38 +00:00
commit 2128f97729
75 changed files with 10148 additions and 4112 deletions

View file

@ -4,7 +4,7 @@
<head>
<meta name="generator" content="JSDoc 3.6.11">
<meta charset="utf-8">
<title>whatsapp-web.js 1.28.1-alpha.0 &raquo; Source: Client.js</title>
<title>whatsapp-web.js 1.29.0 &raquo; Source: Client.js</title>
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
@ -15,7 +15,7 @@
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
<div id="jsdoc-navbar-container">
<div id="jsdoc-navbar-content">
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>28.<wbr>1-alpha.<wbr>0</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>29.<wbr>0</a>
</div>
</div>
</nav>
@ -46,7 +46,7 @@ const { LoadUtils } &#x3D; require(&#x27;./util/Injected/Utils&#x27;);
const ChatFactory &#x3D; require(&#x27;./factories/ChatFactory&#x27;);
const ContactFactory &#x3D; require(&#x27;./factories/ContactFactory&#x27;);
const WebCacheFactory &#x3D; require(&#x27;./webCache/WebCacheFactory&#x27;);
const { ClientInfo, Message, MessageMedia, Contact, Location, Poll, PollVote, GroupNotification, Label, Call, Buttons, List, Reaction, Broadcast} &#x3D; require(&#x27;./structures&#x27;);
const { Broadcast, Buttons, Call, ClientInfo, Contact, GroupNotification, Label, List, Location, Message, MessageMedia, Poll, PollVote, Reaction } &#x3D; require(&#x27;./structures&#x27;);
const NoAuth &#x3D; require(&#x27;./authStrategies/NoAuth&#x27;);
const {exposeFunctionIfAbsent} &#x3D; require(&#x27;./util/Puppeteer&#x27;);
@ -851,11 +851,9 @@ class Client extends EventEmitter {
*
*/
async sendSeen(chatId) {
const result &#x3D; await this.pupPage.evaluate(async (chatId) &#x3D;&gt; {
return await this.pupPage.evaluate(async (chatId) &#x3D;&gt; {
return window.WWebJS.sendSeen(chatId);
}, chatId);
return result;
}
/**
@ -885,6 +883,7 @@ class Client extends EventEmitter {
* @property {string} [stickerName&#x3D;undefined] - Sets the name of the sticker, (if sendMediaAsSticker is true).
* @property {string[]} [stickerCategories&#x3D;undefined] - Sets the categories of the sticker, (if sendMediaAsSticker is true). Provide emoji char array, can be null.
* @property {MessageMedia} [media] - Media to be sent
* @property {any} [extra] - Extra options
*/
/**
@ -896,6 +895,19 @@ class Client extends EventEmitter {
* @returns {Promise&amp;lt;Message&gt;} Message that was just sent
*/
async sendMessage(chatId, content, options &#x3D; {}) {
const isChannel &#x3D; /@\w*newsletter\b/.test(chatId);
if (isChannel &amp;amp;&amp;amp; [
options.sendMediaAsDocument, options.quotedMessageId,
options.parseVCards, options.isViewOnce,
content instanceof Location, content instanceof Contact,
content instanceof Buttons, content instanceof List,
Array.isArray(content) &amp;amp;&amp;amp; content.length &gt; 0 &amp;amp;&amp;amp; content[0] instanceof Contact
].includes(true)) {
console.warn(&#x27;The message type is currently not supported for sending in channels,\nthe supported message types are: text, image, sticker, gif, video, voice and poll.&#x27;);
return null;
}
if (options.mentions) {
!Array.isArray(options.mentions) &amp;amp;&amp;amp; (options.mentions &#x3D; [options.mentions]);
if (options.mentions.some((possiblyContact) &#x3D;&gt; possiblyContact instanceof Contact)) {
@ -905,7 +917,7 @@ class Client extends EventEmitter {
}
options.groupMentions &amp;amp;&amp;amp; !Array.isArray(options.groupMentions) &amp;amp;&amp;amp; (options.groupMentions &#x3D; [options.groupMentions]);
let internalOptions &#x3D; {
linkPreview: options.linkPreview &#x3D;&#x3D;&#x3D; false ? undefined : true,
sendAudioAsVoice: options.sendAudioAsVoice,
@ -921,14 +933,14 @@ class Client extends EventEmitter {
extraOptions: options.extra
};
const sendSeen &#x3D; typeof options.sendSeen &#x3D;&#x3D;&#x3D; &#x27;undefined&#x27; ? true : options.sendSeen;
const sendSeen &#x3D; options.sendSeen !&#x3D;&#x3D; false;
if (content instanceof MessageMedia) {
internalOptions.attachment &#x3D; content;
internalOptions.media &#x3D; content;
internalOptions.isViewOnce &#x3D; options.isViewOnce,
content &#x3D; &#x27;&#x27;;
} else if (options.media instanceof MessageMedia) {
internalOptions.attachment &#x3D; options.media;
internalOptions.media &#x3D; options.media;
internalOptions.caption &#x3D; content;
internalOptions.isViewOnce &#x3D; options.isViewOnce,
content &#x3D; &#x27;&#x27;;
@ -945,17 +957,19 @@ class Client extends EventEmitter {
internalOptions.contactCardList &#x3D; content.map(contact &#x3D;&gt; contact.id._serialized);
content &#x3D; &#x27;&#x27;;
} else if (content instanceof Buttons) {
console.warn(&#x27;Buttons are now deprecated. See more at https://www.youtube.com/watch?v&#x3D;hv1R1rLeVVE.&#x27;);
if (content.type !&#x3D;&#x3D; &#x27;chat&#x27;) { internalOptions.attachment &#x3D; content.body; }
internalOptions.buttons &#x3D; content;
content &#x3D; &#x27;&#x27;;
} else if (content instanceof List) {
console.warn(&#x27;Lists are now deprecated. See more at https://www.youtube.com/watch?v&#x3D;hv1R1rLeVVE.&#x27;);
internalOptions.list &#x3D; content;
content &#x3D; &#x27;&#x27;;
}
if (internalOptions.sendMediaAsSticker &amp;amp;&amp;amp; internalOptions.attachment) {
internalOptions.attachment &#x3D; await Util.formatToWebpSticker(
internalOptions.attachment, {
if (internalOptions.sendMediaAsSticker &amp;amp;&amp;amp; internalOptions.media) {
internalOptions.media &#x3D; await Util.formatToWebpSticker(
internalOptions.media, {
name: options.stickerName,
author: options.stickerAuthor,
categories: options.stickerCategories
@ -963,20 +977,60 @@ class Client extends EventEmitter {
);
}
const newMessage &#x3D; await this.pupPage.evaluate(async (chatId, message, options, sendSeen) &#x3D;&gt; {
const chatWid &#x3D; window.Store.WidFactory.createWid(chatId);
const chat &#x3D; await window.Store.Chat.find(chatWid);
const sentMsg &#x3D; await this.pupPage.evaluate(async (chatId, content, options, sendSeen) &#x3D;&gt; {
const chat &#x3D; await window.WWebJS.getChat(chatId, { getAsModel: false });
if (!chat) return null;
if (sendSeen) {
await window.WWebJS.sendSeen(chatId);
}
const msg &#x3D; await window.WWebJS.sendMessage(chat, message, options, sendSeen);
return window.WWebJS.getMessageModel(msg);
const msg &#x3D; await window.WWebJS.sendMessage(chat, content, options);
return msg
? window.WWebJS.getMessageModel(msg)
: undefined;
}, chatId, content, internalOptions, sendSeen);
return new Message(this, newMessage);
return sentMsg
? new Message(this, sentMsg)
: undefined;
}
/**
* @typedef {Object} SendChannelAdminInviteOptions
* @property {?string} comment The comment to be added to an invitation
*/
/**
* Sends a channel admin invitation to a user, allowing them to become an admin of the channel
* @param {string} chatId The ID of a user to send the channel admin invitation to
* @param {string} channelId The ID of a channel for which the invitation is being sent
* @param {SendChannelAdminInviteOptions} options
* @returns {Promise&amp;lt;boolean&gt;} Returns true if an invitation was sent successfully, false otherwise
*/
async sendChannelAdminInvite(chatId, channelId, options &#x3D; {}) {
const response &#x3D; await this.pupPage.evaluate(async (chatId, channelId, options) &#x3D;&gt; {
const channelWid &#x3D; window.Store.WidFactory.createWid(channelId);
const chatWid &#x3D; window.Store.WidFactory.createWid(chatId);
const chat &#x3D; window.Store.Chat.get(chatWid) || (await window.Store.Chat.find(chatWid));
if (!chatWid.isUser()) {
return false;
}
return await window.Store.SendChannelMessage.sendNewsletterAdminInviteMessage(
chat,
{
newsletterWid: channelWid,
invitee: chatWid,
inviteMessage: options.comment,
base64Thumb: await window.WWebJS.getProfilePicThumbToBase64(channelWid)
}
);
}, chatId, channelId, options);
return response.messageSendResult &#x3D;&#x3D;&#x3D; &#x27;OK&#x27;;
}
/**
@ -1002,7 +1056,7 @@ class Client extends EventEmitter {
* @returns {Promise&amp;lt;Array&amp;lt;Chat&gt;&gt;}
*/
async getChats() {
let chats &#x3D; await this.pupPage.evaluate(async () &#x3D;&gt; {
const chats &#x3D; await this.pupPage.evaluate(async () &#x3D;&gt; {
return await window.WWebJS.getChats();
});
@ -1010,16 +1064,51 @@ class Client extends EventEmitter {
}
/**
* Get chat instance by ID
* Gets all cached {@link Channel} instance
* @returns {Promise&amp;lt;Array&amp;lt;Channel&gt;&gt;}
*/
async getChannels() {
const channels &#x3D; await this.pupPage.evaluate(async () &#x3D;&gt; {
return await window.WWebJS.getChannels();
});
return channels.map((channel) &#x3D;&gt; ChatFactory.create(this, channel));
}
/**
* Gets chat or channel instance by ID
* @param {string} chatId
* @returns {Promise&amp;lt;Chat&gt;}
* @returns {Promise&amp;lt;Chat|Channel&gt;}
*/
async getChatById(chatId) {
let chat &#x3D; await this.pupPage.evaluate(async chatId &#x3D;&gt; {
const chat &#x3D; await this.pupPage.evaluate(async chatId &#x3D;&gt; {
return await window.WWebJS.getChat(chatId);
}, chatId);
return chat
? ChatFactory.create(this, chat)
: undefined;
}
return ChatFactory.create(this, chat);
/**
* Gets a {@link Channel} instance by invite code
* @param {string} inviteCode The code that comes after the &#x27;https://whatsapp.com/channel/&#x27;
* @returns {Promise&amp;lt;Channel&gt;}
*/
async getChannelByInviteCode(inviteCode) {
const channel &#x3D; await this.pupPage.evaluate(async (inviteCode) &#x3D;&gt; {
let channelMetadata;
try {
channelMetadata &#x3D; await window.WWebJS.getChannelMetadata(inviteCode);
} catch (err) {
if (err.name &#x3D;&#x3D;&#x3D; &#x27;ServerStatusCodeError&#x27;) return null;
throw err;
}
return await window.WWebJS.getChat(channelMetadata.id);
}, inviteCode);
return channel
? ChatFactory.create(this, channel)
: undefined;
}
/**
@ -1089,6 +1178,61 @@ class Client extends EventEmitter {
return res.gid._serialized;
}
/**
* Accepts a channel admin invitation and promotes the current user to a channel admin
* @param {string} channelId The channel ID to accept the admin invitation from
* @returns {Promise&amp;lt;boolean&gt;} Returns true if the operation completed successfully, false otherwise
*/
async acceptChannelAdminInvite(channelId) {
return await this.pupPage.evaluate(async (channelId) &#x3D;&gt; {
try {
await window.Store.ChannelUtils.acceptNewsletterAdminInvite(channelId);
return true;
} catch (err) {
if (err.name &#x3D;&#x3D;&#x3D; &#x27;ServerStatusCodeError&#x27;) return false;
throw err;
}
}, channelId);
}
/**
* Revokes a channel admin invitation sent to a user by a channel owner
* @param {string} channelId The channel ID an invitation belongs to
* @param {string} userId The user ID the invitation was sent to
* @returns {Promise&amp;lt;boolean&gt;} Returns true if the operation completed successfully, false otherwise
*/
async revokeChannelAdminInvite(channelId, userId) {
return await this.pupPage.evaluate(async (channelId, userId) &#x3D;&gt; {
try {
const userWid &#x3D; window.Store.WidFactory.createWid(userId);
await window.Store.ChannelUtils.revokeNewsletterAdminInvite(channelId, userWid);
return true;
} catch (err) {
if (err.name &#x3D;&#x3D;&#x3D; &#x27;ServerStatusCodeError&#x27;) return false;
throw err;
}
}, channelId, userId);
}
/**
* Demotes a channel admin to a regular subscriber (can be used also for self-demotion)
* @param {string} channelId The channel ID to demote an admin in
* @param {string} userId The user ID to demote
* @returns {Promise&amp;lt;boolean&gt;} Returns true if the operation completed successfully, false otherwise
*/
async demoteChannelAdmin(channelId, userId) {
return await this.pupPage.evaluate(async (channelId, userId) &#x3D;&gt; {
try {
const userWid &#x3D; window.Store.WidFactory.createWid(userId);
await window.Store.ChannelUtils.demoteNewsletterAdmin(channelId, userWid);
return true;
} catch (err) {
if (err.name &#x3D;&#x3D;&#x3D; &#x27;ServerStatusCodeError&#x27;) return false;
throw err;
}
}, channelId, userId);
}
/**
* Accepts a private invitation to join a group
* @param {object} inviteInfo Invite V4 Info
@ -1165,7 +1309,7 @@ class Client extends EventEmitter {
*/
async archiveChat(chatId) {
return await this.pupPage.evaluate(async chatId &#x3D;&gt; {
let chat &#x3D; await window.Store.Chat.get(chatId);
let chat &#x3D; await window.WWebJS.getChat(chatId, { getAsModel: false });
await window.Store.Cmd.archiveChat(chat, true);
return true;
}, chatId);
@ -1177,7 +1321,7 @@ class Client extends EventEmitter {
*/
async unarchiveChat(chatId) {
return await this.pupPage.evaluate(async chatId &#x3D;&gt; {
let chat &#x3D; await window.Store.Chat.get(chatId);
let chat &#x3D; await window.WWebJS.getChat(chatId, { getAsModel: false });
await window.Store.Cmd.archiveChat(chat, false);
return false;
}, chatId);
@ -1189,7 +1333,7 @@ class Client extends EventEmitter {
*/
async pinChat(chatId) {
return this.pupPage.evaluate(async chatId &#x3D;&gt; {
let chat &#x3D; window.Store.Chat.get(chatId);
let chat &#x3D; await window.WWebJS.getChat(chatId, { getAsModel: false });
if (chat.pin) {
return true;
}
@ -1212,7 +1356,7 @@ class Client extends EventEmitter {
*/
async unpinChat(chatId) {
return this.pupPage.evaluate(async chatId &#x3D;&gt; {
let chat &#x3D; window.Store.Chat.get(chatId);
let chat &#x3D; await window.WWebJS.getChat(chatId, { getAsModel: false });
if (!chat.pin) {
return false;
}
@ -1264,7 +1408,7 @@ class Client extends EventEmitter {
*/
async markChatUnread(chatId) {
await this.pupPage.evaluate(async chatId &#x3D;&gt; {
let chat &#x3D; await window.Store.Chat.get(chatId);
let chat &#x3D; await window.WWebJS.getChat(chatId, { getAsModel: false });
await window.Store.Cmd.markChatUnread(chat, true);
}, chatId);
}
@ -1466,7 +1610,7 @@ class Client extends EventEmitter {
for (const participant of createGroupResult.participants) {
let isInviteV4Sent &#x3D; false;
const participantId &#x3D; participant.wid._serialized;
const statusCode &#x3D; participant.error ?? 200;
const statusCode &#x3D; participant.error || 200;
if (autoSendInviteV4 &amp;amp;&amp;amp; statusCode &#x3D;&#x3D;&#x3D; 403) {
window.Store.Contact.gadd(participant.wid, { silent: true });
@ -1505,6 +1649,219 @@ class Client extends EventEmitter {
}, title, participants, options);
}
/**
* An object that handles the result for {@link createChannel} method
* @typedef {Object} CreateChannelResult
* @property {string} title A channel title
* @property {ChatId} nid An object that handels the newly created channel ID
* @property {string} nid.server &#x27;newsletter&#x27;
* @property {string} nid.user &#x27;XXXXXXXXXX&#x27;
* @property {string} nid._serialized &#x27;XXXXXXXXXX@newsletter&#x27;
* @property {string} inviteLink The channel invite link, starts with &#x27;https://whatsapp.com/channel/&#x27;
* @property {number} createdAtTs The timestamp the channel was created at
*/
/**
* Options for the channel creation
* @typedef {Object} CreateChannelOptions
* @property {?string} description The channel description
* @property {?MessageMedia} picture The channel profile picture
*/
/**
* Creates a new channel
* @param {string} title The channel name
* @param {CreateChannelOptions} options
* @returns {Promise&amp;lt;CreateChannelResult|string&gt;} Returns an object that handles the result for the channel creation or an error message as a string
*/
async createChannel(title, options &#x3D; {}) {
return await this.pupPage.evaluate(async (title, options) &#x3D;&gt; {
let response, { description &#x3D; null, picture &#x3D; null } &#x3D; options;
if (!window.Store.ChannelUtils.isNewsletterCreationEnabled()) {
return &#x27;CreateChannelError: A channel creation is not enabled&#x27;;
}
if (picture) {
picture &#x3D; await window.WWebJS.cropAndResizeImage(picture, {
asDataUrl: true,
mimetype: &#x27;image/jpeg&#x27;,
size: 640,
quality: 1
});
}
try {
response &#x3D; await window.Store.ChannelUtils.createNewsletterQuery({
name: title,
description: description,
picture: picture,
});
} catch (err) {
if (err.name &#x3D;&#x3D;&#x3D; &#x27;ServerStatusCodeError&#x27;) {
return &#x27;CreateChannelError: An error occupied while creating a channel&#x27;;
}
throw err;
}
return {
title: title,
nid: window.Store.JidToWid.newsletterJidToWid(response.idJid),
inviteLink: &#x60;https://whatsapp.com/channel/${response.newsletterInviteLinkMetadataMixin.inviteCode}&#x60;,
createdAtTs: response.newsletterCreationTimeMetadataMixin.creationTimeValue
};
}, title, options);
}
/**
* Subscribe to channel
* @param {string} channelId The channel ID
* @returns {Promise&amp;lt;boolean&gt;} Returns true if the operation completed successfully, false otherwise
*/
async subscribeToChannel(channelId) {
return await this.pupPage.evaluate(async (channelId) &#x3D;&gt; {
return await window.WWebJS.subscribeToUnsubscribeFromChannel(channelId, &#x27;Subscribe&#x27;);
}, channelId);
}
/**
* Options for unsubscribe from a channel
* @typedef {Object} UnsubscribeOptions
* @property {boolean} [deleteLocalModels &#x3D; false] If true, after an unsubscription, it will completely remove a channel from the channel collection making it seem like the current user have never interacted with it. Otherwise it will only remove a channel from the list of channels the current user is subscribed to and will set the membership type for that channel to GUEST
*/
/**
* Unsubscribe from channel
* @param {string} channelId The channel ID
* @param {UnsubscribeOptions} options
* @returns {Promise&amp;lt;boolean&gt;} Returns true if the operation completed successfully, false otherwise
*/
async unsubscribeFromChannel(channelId, options) {
return await this.pupPage.evaluate(async (channelId, options) &#x3D;&gt; {
return await window.WWebJS.subscribeToUnsubscribeFromChannel(channelId, &#x27;Unsubscribe&#x27;, options);
}, channelId, options);
}
/**
* Options for transferring a channel ownership to another user
* @typedef {Object} TransferChannelOwnershipOptions
* @property {boolean} [shouldDismissSelfAsAdmin &#x3D; false] If true, after the channel ownership is being transferred to another user, the current user will be dismissed as a channel admin and will become to a channel subscriber.
*/
/**
* Transfers a channel ownership to another user.
* Note: the user you are transferring the channel ownership to must be a channel admin.
* @param {string} channelId
* @param {string} newOwnerId
* @param {TransferChannelOwnershipOptions} options
* @returns {Promise&amp;lt;boolean&gt;} Returns true if the operation completed successfully, false otherwise
*/
async transferChannelOwnership(channelId, newOwnerId, options &#x3D; {}) {
return await this.pupPage.evaluate(async (channelId, newOwnerId, options) &#x3D;&gt; {
const channel &#x3D; await window.WWebJS.getChat(channelId, { getAsModel: false });
const newOwner &#x3D; window.Store.Contact.get(newOwnerId) || (await window.Store.Contact.find(newOwnerId));
if (!channel.newsletterMetadata) {
await window.Store.NewsletterMetadataCollection.update(channel.id);
}
try {
await window.Store.ChannelUtils.changeNewsletterOwnerAction(channel, newOwner);
if (options.shouldDismissSelfAsAdmin) {
const meContact &#x3D; window.Store.ContactCollection.getMeContact();
meContact &amp;amp;&amp;amp; (await window.Store.ChannelUtils.demoteNewsletterAdminAction(channel, meContact));
}
} catch (error) {
return false;
}
return true;
}, channelId, newOwnerId, options);
}
/**
* Searches for channels based on search criteria, there are some notes:
* 1. The method finds only channels you are not subscribed to currently
* 2. If you have never been subscribed to a found channel
* or you have unsubscribed from it with {@link UnsubscribeOptions.deleteLocalModels} set to &#x27;true&#x27;,
* the lastMessage property of a found channel will be &#x27;null&#x27;
*
* @param {Object} searchOptions Search options
* @param {string} [searchOptions.searchText &#x3D; &#x27;&#x27;] Text to search
* @param {Array&amp;lt;string&gt;} [searchOptions.countryCodes &#x3D; [your local region]] Array of country codes in &#x27;ISO 3166-1 alpha-2&#x27; standart (@see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) to search for channels created in these countries
* @param {boolean} [searchOptions.skipSubscribedNewsletters &#x3D; false] If true, channels that user is subscribed to won&#x27;t appear in found channels
* @param {number} [searchOptions.view &#x3D; 0] View type, makes sense only when the searchText is empty. Valid values to provide are:
* 0 for RECOMMENDED channels
* 1 for TRENDING channels
* 2 for POPULAR channels
* 3 for NEW channels
* @param {number} [searchOptions.limit &#x3D; 50] The limit of found channels to be appear in the returnig result
* @returns {Promise&amp;lt;Array&amp;lt;Channel&gt;|[]&gt;} Returns an array of Channel objects or an empty array if no channels were found
*/
async searchChannels(searchOptions &#x3D; {}) {
return await this.pupPage.evaluate(async ({
searchText &#x3D; &#x27;&#x27;,
countryCodes &#x3D; [window.Store.ChannelUtils.currentRegion],
skipSubscribedNewsletters &#x3D; false,
view &#x3D; 0,
limit &#x3D; 50
}) &#x3D;&gt; {
searchText &#x3D; searchText.trim();
const currentRegion &#x3D; window.Store.ChannelUtils.currentRegion;
if (![0, 1, 2, 3].includes(view)) view &#x3D; 0;
countryCodes &#x3D; countryCodes.length &#x3D;&#x3D;&#x3D; 1 &amp;amp;&amp;amp; countryCodes[0] &#x3D;&#x3D;&#x3D; currentRegion
? countryCodes
: countryCodes.filter((code) &#x3D;&gt; Object.keys(window.Store.ChannelUtils.countryCodesIso).includes(code));
const viewTypeMapping &#x3D; {
0: &#x27;RECOMMENDED&#x27;,
1: &#x27;TRENDING&#x27;,
2: &#x27;POPULAR&#x27;,
3: &#x27;NEW&#x27;
};
searchOptions &#x3D; {
searchText: searchText,
countryCodes: countryCodes,
skipSubscribedNewsletters: skipSubscribedNewsletters,
view: viewTypeMapping[view],
categories: [],
cursorToken: &#x27;&#x27;
};
const originalFunction &#x3D; window.Store.ChannelUtils.getNewsletterDirectoryPageSize;
limit !&#x3D;&#x3D; 50 &amp;amp;&amp;amp; (window.Store.ChannelUtils.getNewsletterDirectoryPageSize &#x3D; () &#x3D;&gt; limit);
const channels &#x3D; (await window.Store.ChannelUtils.fetchNewsletterDirectories(searchOptions)).newsletters;
limit !&#x3D;&#x3D; 50 &amp;amp;&amp;amp; (window.Store.ChannelUtils.getNewsletterDirectoryPageSize &#x3D; originalFunction);
return channels
? await Promise.all(channels.map((channel) &#x3D;&gt; window.WWebJS.getChatModel(channel, { isChannel: true })))
: [];
}, searchOptions);
}
/**
* Deletes the channel you created
* @param {string} channelId The ID of a channel to delete
* @returns {Promise&amp;lt;boolean&gt;} Returns true if the operation completed successfully, false otherwise
*/
async deleteChannel(channelId) {
return await this.client.pupPage.evaluate(async (channelId) &#x3D;&gt; {
const channel &#x3D; await window.WWebJS.getChat(channelId, { getAsModel: false });
if (!channel) return false;
try {
await window.Store.ChannelUtils.deleteNewsletterAction(channel);
return true;
} catch (err) {
if (err.name &#x3D;&#x3D;&#x3D; &#x27;ServerStatusCodeError&#x27;) return false;
throw err;
}
}, channelId);
}
/**
* Get all current Labels
* @returns {Promise&amp;lt;Array&amp;lt;Label&gt;&gt;}
@ -1863,7 +2220,7 @@ module.exports &#x3D; Client;
<footer id="jsdoc-footer" class="jsdoc-footer">
<div id="jsdoc-footer-container">
<p>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on May 30, 2025.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on May 31, 2025.
</p>
</div>
</footer>