Channel
Source: structures/
Represents a Channel on WhatsApp
Properties
Methods
new Channel()
- Extends
- Base
Properties
description string
The channel description
id ChannelId
ID that represents the channel
isChannel boolean
Indicates if it is a Channel
isGroup boolean
Indicates if it is a Group
isMuted boolean
Indicates if the channel is muted or not
isReadOnly boolean
Indicates if the channel is readonly
lastMessage Message
Last message in the channel
muteExpiration number
Unix timestamp for when the mute expires
name string
Title of the channel
timestamp number
Unix timestamp for when the last activity occurred
unreadCount number
Amount of messages unread
Methods
_muteUnmuteChannel(action) → Promise containing boolean
Internal method to mute or unmute the channel
Parameter
Name | Type | Optional | Description |
---|---|---|---|
action |
string |
|
The action: 'MUTE' or 'UNMUTE' |
- Returns
-
Promise containing boolean
Returns true if the operation completed successfully, false otherwise
_setChannelMetadata(value, property) → Promise containing boolean
Internal method to change the channel metadata
Parameters
Name | Type | Optional | Description |
---|---|---|---|
value |
(string, number, or MessageMedia) |
|
The new value to set |
property |
string |
|
The property of a channel metadata to change |
- Returns
-
Promise containing boolean
Returns true if the operation completed successfully, false otherwise
acceptChannelAdminInvite() → Promise containing boolean
Accepts a channel admin invitation and promotes the current user to a channel admin
- Returns
-
Promise containing boolean
Returns true if the operation completed successfully, false otherwise
deleteChannel() → Promise containing boolean
Deletes the channel you created
- Returns
-
Promise containing boolean
Returns true if the operation completed successfully, false otherwise
demoteChannelAdmin(userId) → Promise containing boolean
Demotes a channel admin to a regular subscriber (can be used also for self-demotion)
Parameter
Name | Type | Optional | Description |
---|---|---|---|
userId |
string |
|
The user ID to demote |
- Returns
-
Promise containing boolean
Returns true if the operation completed successfully, false otherwise
fetchMessages(searchOptions) → Promise containing Array of Message
Loads channel messages, sorted from earliest to latest
Parameters
Name | Type | Optional | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
searchOptions |
Object |
|
Options for searching messages. Right now only limit and fromMe is supported Values in
|
- Returns
-
Promise containing Array of Message
getSubscribers(limit)
Gets the subscribers of the channel (only those who are in your contact list)
Parameter
Name | Type | Optional | Description |
---|---|---|---|
limit |
number |
|
Optional parameter to specify the limit of subscribers to retrieve Value can be null. |
- Returns
mute() → Promise containing boolean
Mutes the channel
- Returns
-
Promise containing boolean
Returns true if the operation completed successfully, false otherwise
revokeChannelAdminInvite(userId) → Promise containing boolean
Revokes a channel admin invitation sent to a user by a channel owner
Parameter
Name | Type | Optional | Description |
---|---|---|---|
userId |
string |
|
The user ID the invitation was sent to |
- Returns
-
Promise containing boolean
Returns true if the operation completed successfully, false otherwise
sendChannelAdminInvite(chatId, options) → Promise containing boolean
Sends a channel admin invitation to a user, allowing them to become an admin of the channel
Parameters
Name | Type | Optional | Description |
---|---|---|---|
chatId |
string |
|
The ID of a user to send the channel admin invitation to |
options |
|
- Returns
-
Promise containing boolean
Returns true if an invitation was sent successfully, false otherwise
sendMessage(content, options) → Promise containing Message
Sends a message to this channel
Parameters
Name | Type | Optional | Description |
---|---|---|---|
content |
(string or MessageMedia) |
|
|
options |
|
Value can be null. |
- Returns
-
Promise containing Message
Message that was just sent
sendSeen() → Promise containing boolean
Sets the channel as seen
- Returns
-
Promise containing boolean
setDescription(newDescription) → Promise containing boolean
Updates the channel description
Parameter
Name | Type | Optional | Description |
---|---|---|---|
newDescription |
string |
|
- Returns
-
Promise containing boolean
Returns true if the operation completed successfully, false otherwise
setProfilePicture(newProfilePicture) → Promise containing boolean
Updates the channel profile picture
Parameter
Name | Type | Optional | Description |
---|---|---|---|
newProfilePicture |
|
- Returns
-
Promise containing boolean
Returns true if the operation completed successfully, false otherwise
setReactionSetting(reactionCode) → Promise containing 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
Parameter
Name | Type | Optional | Description |
---|---|---|---|
reactionCode |
number |
|
- Returns
-
Promise containing boolean
Returns true if the operation completed successfully, false otherwise
setSubject(newSubject) → Promise containing boolean
Updates the channel subject
Parameter
Name | Type | Optional | Description |
---|---|---|---|
newSubject |
string |
|
- Returns
-
Promise containing boolean
Returns true if the subject was properly updated. This can return false if the user does not have the necessary permissions.
transferChannelOwnership(newOwnerId, options) → Promise containing 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 | Optional | Description |
---|---|---|---|
newOwnerId |
string |
|
|
options |
|
- Returns
-
Promise containing boolean
Returns true if the operation completed successfully, false otherwise
unmute() → Promise containing boolean
Unmutes the channel
- Returns
-
Promise containing boolean
Returns true if the operation completed successfully, false otherwise