Class: Channel

Channel()

Represents a Channel on WhatsApp

Constructor

new Channel()

Source:

Extends

Members

description :string

The channel description

Type:
  • string
Source:

id :ChannelId

ID that represents the channel

Type:
Source:

isChannel :boolean

Indicates if it is a Channel

Type:
  • boolean
Source:

isGroup :boolean

Indicates if it is a Group

Type:
  • boolean
Source:

isMuted :boolean

Indicates if the channel is muted or not

Type:
  • boolean
Source:

isReadOnly :boolean

Indicates if the channel is readonly

Type:
  • boolean
Source:

lastMessage :Message

Last message in the channel

Type:
Source:

muteExpiration :number

Unix timestamp for when the mute expires

Type:
  • number
Source:

name :string

Title of the channel

Type:
  • string
Source:

timestamp :number

Unix timestamp for when the last activity occurred

Type:
  • number
Source:

unreadCount :number

Amount of messages unread

Type:
  • number
Source:

Methods

(async) _muteUnmuteChannel(action) → {Promise.<boolean>}

Internal method to mute or unmute the channel

Parameters:
Name Type Description
action string

The action: 'MUTE' or 'UNMUTE'

Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) _setChannelMetadata(value, property) → {Promise.<boolean>}

Internal method to change the channel metadata

Parameters:
Name Type Description
value string | number | MessageMedia

The new value to set

property string

The property of a channel metadata to change

Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) acceptChannelAdminInvite() → {Promise.<boolean>}

Accepts a channel admin invitation and promotes the current user to a channel admin

Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) deleteChannel() → {Promise.<boolean>}

Deletes the channel you created

Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) demoteChannelAdmin(userId) → {Promise.<boolean>}

Demotes a channel admin to a regular subscriber (can be used also for self-demotion)

Parameters:
Name Type Description
userId string

The user ID to demote

Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) fetchMessages(searchOptions) → {Promise.<Array.<Message>>}

Loads channel messages, sorted from earliest to latest

Parameters:
Name Type Description
searchOptions Object

Options for searching messages. Right now only limit and fromMe is supported

Properties
Name Type Attributes Description
limit Number <optional>

The amount of messages to return. If no limit is specified, the available messages will be returned. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages

fromMe Boolean <optional>

Return only messages from the bot number or vise versa. To get all messages, leave the option undefined

Source:
Returns:
Type
Promise.<Array.<Message>>

(async) getSubscribers(limitnullable) → {Promise.<Array.<{contact: Contact, role: string}>>}

Gets the subscribers of the channel (only those who are in your contact list)

Parameters:
Name Type Attributes Description
limit number <nullable>

Optional parameter to specify the limit of subscribers to retrieve

Source:
Returns:

Returns an array of objects that handle the subscribed contacts and their roles in the channel

Type
Promise.<Array.<{contact: Contact, role: string}>>

(async) mute() → {Promise.<boolean>}

Mutes the channel

Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) revokeChannelAdminInvite(userId) → {Promise.<boolean>}

Revokes a channel admin invitation sent to a user by a channel owner

Parameters:
Name Type Description
userId string

The user ID the invitation was sent to

Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) sendChannelAdminInvite(chatId, options) → {Promise.<boolean>}

Sends a channel admin invitation to a user, allowing them to become an admin of the channel

Parameters:
Name Type Description
chatId string

The ID of a user to send the channel admin invitation to

options SendChannelAdminInviteOptions
Source:
Returns:

Returns true if an invitation was sent successfully, false otherwise

Type
Promise.<boolean>

(async) sendMessage(content, optionsnullable) → {Promise.<(Message|null|undefined)>}

Sends a message to this channel

Parameters:
Name Type Attributes Description
content string | MessageMedia
options MessageSendOptions <nullable>
Source:
Returns:

Message that was just sent

Type
Promise.<(Message|null|undefined)>

(async) sendSeen() → {Promise.<boolean>}

Sets the channel as seen

Source:
Returns:
Type
Promise.<boolean>

(async) setDescription(newDescription) → {Promise.<boolean>}

Updates the channel description

Parameters:
Name Type Description
newDescription string
Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) setProfilePicture(newProfilePicture) → {Promise.<boolean>}

Updates the channel profile picture

Parameters:
Name Type Description
newProfilePicture MessageMedia
Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) setReactionSetting(reactionCode) → {Promise.<boolean>}

Updates available reactions to use in the channel

Valid values for passing to the method are: 0 for NONE reactions to be avaliable 1 for BASIC reactions to be available: 👍, ❤️, 😂, 😮, 😢, 🙏 2 for ALL reactions to be available

Parameters:
Name Type Description
reactionCode number
Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) setSubject(newSubject) → {Promise.<boolean>}

Updates the channel subject

Parameters:
Name Type Description
newSubject string
Source:
Returns:

Returns true if the subject was properly updated. This can return false if the user does not have the necessary permissions.

Type
Promise.<boolean>

(async) transferChannelOwnership(newOwnerId, options) → {Promise.<boolean>}

Transfers a channel ownership to another user. Note: the user you are transferring the channel ownership to must be a channel admin.

Parameters:
Name Type Description
newOwnerId string
options TransferChannelOwnershipOptions
Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) unmute() → {Promise.<boolean>}

Unmutes the channel

Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>