Back to Whatsapp Web Js

whatsapp

docs/Channel.html

1.34.79.5 KB
Original Source

Properties

descriptionidisChannelisGroup

isMutedisReadOnlylastMessagemuteExpiration

nametimestampunreadCount

Methods

_muteUnmuteChannel(action)_setChannelMetadata(value, property)acceptChannelAdminInvite()deleteChannel()demoteChannelAdmin(userId)fetchMessages(searchOptions)

getSubscribers(limit)mute()revokeChannelAdminInvite(userId)sendChannelAdminInvite(chatId, options)sendMessage(content, options)sendSeen()

setDescription(newDescription)setProfilePicture(newProfilePicture)setReactionSetting(reactionCode)setSubject(newSubject)transferChannelOwnership(newOwnerId, options)unmute()

new Channel()

ExtendsBase

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

async

_muteUnmuteChannel(action) → Promise containing boolean

Internal method to mute or unmute the channel

Parameter

NameTypeOptionalDescription

action

|

string

|

|

The action: 'MUTE' or 'UNMUTE'

|

Returns

Promise containing boolean

Returns true if the operation completed successfully, false otherwise

async

_setChannelMetadata(value, property) → Promise containing boolean

Internal method to change the channel metadata

Parameters

NameTypeOptionalDescription

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

async

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

async

deleteChannel() → Promise containing boolean

Deletes the channel you created

Returns

Promise containing boolean

Returns true if the operation completed successfully, false otherwise

async

demoteChannelAdmin(userId) → Promise containing boolean

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

Parameter

NameTypeOptionalDescription

userId

|

string

|

|

The user ID to demote

|

Returns

Promise containing boolean

Returns true if the operation completed successfully, false otherwise

async

fetchMessages(searchOptions) → Promise containing Array of Message

Loads channel messages, sorted from earliest to latest

Parameters

NameTypeOptionalDescription

searchOptions

|

Object

|

|

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

Values in searchOptions have the following properties:

NameTypeOptionalDescription

limit

|

Number

|

Yes

|

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

|

Yes

|

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

|

|

Returns

Promise containing Array of Message

async

getSubscribers(limit) → Promise containing Array of {contact: Contact, role: string}

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

Parameter

NameTypeOptionalDescription

limit

|

number

|

|

Optional parameter to specify the limit of subscribers to retrieve

Value can be null.

|

Returns

Promise containing Array of {contact: Contact, role: string}

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

async

mute() → Promise containing boolean

Mutes the channel

Returns

Promise containing boolean

Returns true if the operation completed successfully, false otherwise

async

revokeChannelAdminInvite(userId) → Promise containing boolean

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

Parameter

NameTypeOptionalDescription

userId

|

string

|

|

The user ID the invitation was sent to

|

Returns

Promise containing boolean

Returns true if the operation completed successfully, false otherwise

async

sendChannelAdminInvite(chatId, options) → Promise containing boolean

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

Parameters

NameTypeOptionalDescription

chatId

|

string

|

|

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

| |

options

|

SendChannelAdminInviteOptions

|

| |

Returns

Promise containing boolean

Returns true if an invitation was sent successfully, false otherwise

async

sendMessage(content, options) → Promise containing Message

Sends a message to this channel

Parameters

NameTypeOptionalDescription

content

|

(string or MessageMedia)

|

| | |

options

|

MessageSendOptions

|

|

Value can be null.

|

Returns

Promise containing Message

Message that was just sent

async

sendSeen() → Promise containing boolean

Sets the channel as seen

Returns

Promise containing boolean

async

setDescription(newDescription) → Promise containing boolean

Updates the channel description

Parameter

NameTypeOptionalDescription

newDescription

|

string

|

| |

Returns

Promise containing boolean

Returns true if the operation completed successfully, false otherwise

async

setProfilePicture(newProfilePicture) → Promise containing boolean

Updates the channel profile picture

Parameter

NameTypeOptionalDescription

newProfilePicture

|

MessageMedia

|

| |

Returns

Promise containing boolean

Returns true if the operation completed successfully, false otherwise

async

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

NameTypeOptionalDescription

reactionCode

|

number

|

| |

Returns

Promise containing boolean

Returns true if the operation completed successfully, false otherwise

async

setSubject(newSubject) → Promise containing boolean

Updates the channel subject

Parameter

NameTypeOptionalDescription

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.

async

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

NameTypeOptionalDescription

newOwnerId

|

string

|

| | |

options

|

TransferChannelOwnershipOptions

|

| |

Returns

Promise containing boolean

Returns true if the operation completed successfully, false otherwise

async

unmute() → Promise containing boolean

Unmutes the channel

Returns

Promise containing boolean

Returns true if the operation completed successfully, false otherwise