Back to Whatsapp Web Js

whatsapp

docs/GroupChat.html

1.34.716.0 KB
Original Source

Properties

archivedcreatedAtdescriptionidisGroupisLocked

isMutedisReadOnlylastMessagemuteExpirationnameowner

participantspinnedtimestampunreadCount

Methods

addOrEditCustomerNote(note)addParticipants(participantIds, options)approveGroupMembershipRequests(options)archive()changeLabels(labelIds)clearMessages()clearState()delete()deletePicture()demoteParticipants(participantIds)fetchMessages(searchOptions)getContact()getCustomerNote()

getGroupMembershipRequests()getInviteCode()getLabels()getPinnedMessages()leave()markUnread()mute(unmuteDate)pin()promoteParticipants(participantIds)rejectGroupMembershipRequests(options)removeParticipants(participantIds)revokeInvite()sendMessage(content[, options])

sendSeen()sendStateRecording()sendStateTyping()setAddMembersAdminsOnly([adminsOnly])setDescription(description)setInfoAdminsOnly([adminsOnly])setMessagesAdminsOnly([adminsOnly])setPicture(media)setSubject(subject)syncHistory()unarchive()unmute()unpin()

new GroupChat()

ExtendsChat

Properties

archived unknown

Indicates if the Chat is archived

Inherited fromChat#archived

createdAt date

Gets the date at which the group was created

description string

Gets the group description

id unknown

ID that represents the chat

Inherited fromChat#id

isGroup unknown

Indicates if the Chat is a Group Chat

Inherited fromChat#isGroup

isLocked unknown

Indicates if the Chat is locked

Inherited fromChat#isLocked

isMuted unknown

Indicates if the chat is muted or not

Inherited fromChat#isMuted

isReadOnly unknown

Indicates if the Chat is readonly

Inherited fromChat#isReadOnly

lastMessage unknown

Last message fo chat

Inherited fromChat#lastMessage

muteExpiration unknown

Unix timestamp for when the mute expires

Inherited fromChat#muteExpiration

name unknown

Title of the chat

Inherited fromChat#name

owner ContactId

Gets the group owner

participants Array of GroupParticipant

Gets the group participants

pinned unknown

Indicates if the Chat is pinned

Inherited fromChat#pinned

timestamp unknown

Unix timestamp for when the last activity occurred

Inherited fromChat#timestamp

unreadCount unknown

Amount of messages unread

Inherited fromChat#unreadCount

Methods

async

addOrEditCustomerNote(note) → Promise containing void

Add or edit a customer note

Parameter

NameTypeOptionalDescription

note

|

|

|

The note to add

|

Inherited fromChat#addOrEditCustomerNoteSee alsohttps://faq.whatsapp.com/1433099287594476Returns async

addParticipants(participantIds, options) → Promise containing (Object with AddParticipantsResult properties or string)

Adds a list of participants by ID to the group

Parameters

NameTypeOptionalDescription

participantIds

|

(string or Array of string)

|

| | |

options

|

AddParticipnatsOptions

|

|

An object thay handles options for adding participants

|

Returns

Promise containing (Object with AddParticipantsResult properties or string)

Returns an object with the resulting data or an error message as a string

async

approveGroupMembershipRequests(options) → Promise containing Array of MembershipRequestActionResult

Approves membership requests if any

Parameter

NameTypeOptionalDescription

options

|

MembershipRequestActionOptions

|

|

Options for performing a membership request action

|

Returns

Promise containing Array of 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

async

archive()

Archives this chat

Inherited fromChat#archive async

changeLabels(labelIds) → Promise containing void

Add or remove labels to this Chat

Parameter

NameTypeOptionalDescription

labelIds

|

|

| |

Inherited fromChat#changeLabelsReturns async

clearMessages() → Promise containing boolean

Clears all messages from the chat

Inherited fromChat#clearMessagesReturns

result

async

clearState()

Stops typing or recording in chat immediately.

Inherited fromChat#clearState async

delete() → Promise containing Boolean

Deletes the chat

Inherited fromChat#deleteReturns

result

async

deletePicture() → Promise containing boolean

Deletes the group's picture.

Returns

Promise containing boolean

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

async

demoteParticipants(participantIds) → Promise containing {status: number}

Demotes participants by IDs to regular users

Parameter

NameTypeOptionalDescription

participantIds

|

Array of string

|

| |

Returns

Promise containing {status: number}

Object with status code indicating if the operation was successful

async

fetchMessages(searchOptions) → Promise containing Array of Message

Loads chat messages, sorted from earliest to latest.

Parameters

NameTypeOptionalDescription

searchOptions

|

|

|

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

Values in searchOptions have the following properties:

NameTypeOptionalDescription

limit

|

|

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

|

|

Yes

|

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

|

|

Inherited fromChat#fetchMessagesReturns async

getContact() → Promise containing Contact

Returns the Contact that corresponds to this Chat.

Inherited fromChat#getContactReturns async

getCustomerNote() → Promise containing {chatId: string, content: string, createdAt: number, id: string, modifiedAt: number, type: string}

Get a customer note

Inherited fromChat#getCustomerNoteSee alsohttps://faq.whatsapp.com/1433099287594476Returns async

getGroupMembershipRequests() → Promise containing Array of GroupMembershipRequest

Gets an array of membership requests

Returns

Promise containing Array of GroupMembershipRequest

An array of membership requests

async

getInviteCode() → Promise containing string

Gets the invite code for a specific group

Returns

Promise containing string

Group's invite code

async

getLabels() → Promise containing Array of Label

Returns array of all Labels assigned to this Chat

Inherited fromChat#getLabelsReturns async

getPinnedMessages() → Promise containing Array of Message

Gets instances of all pinned messages in a chat

Inherited fromChat#getPinnedMessagesReturns async

leave() → Promise

Makes the bot leave the group

Returns

Promise

async

markUnread()

Mark this chat as unread

Inherited fromChat#markUnread async

mute(unmuteDate) → Promise containing {isMuted: boolean, muteExpiration: number}

Mutes this chat forever, unless a date is specified

Parameter

NameTypeOptionalDescription

unmuteDate

|

|

|

Date when the chat will be unmuted, don't provide a value to mute forever

Value can be null.

|

Inherited fromChat#muteReturns async

pin() → Promise containing boolean

Pins this chat

Inherited fromChat#pinReturns

New pin state. Could be false if the max number of pinned chats was reached.

async

promoteParticipants(participantIds) → Promise containing {status: number}

Promotes participants by IDs to admins

Parameter

NameTypeOptionalDescription

participantIds

|

Array of string

|

| |

Returns

Promise containing {status: number}

Object with status code indicating if the operation was successful

async

rejectGroupMembershipRequests(options) → Promise containing Array of MembershipRequestActionResult

Rejects membership requests if any

Parameter

NameTypeOptionalDescription

options

|

MembershipRequestActionOptions

|

|

Options for performing a membership request action

|

Returns

Promise containing Array of 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

async

removeParticipants(participantIds) → Promise containing {status: number}

Removes a list of participants by ID to the group

Parameter

NameTypeOptionalDescription

participantIds

|

Array of string

|

| |

Returns

Promise containing {status: number}

async

revokeInvite() → Promise containing string

Invalidates the current group invite code and generates a new one

Returns

Promise containing string

New invite code

async

sendMessage(content[, options]) → Promise containing Message

Send a message to this chat

Parameters

NameTypeOptionalDescription

content

|

|

| | |

options

|

|

Yes

| |

Inherited fromChat#sendMessageReturns

Message that was just sent

async

sendSeen() → Promise containing Boolean

Sets the chat as seen

Inherited fromChat#sendSeenReturns

result

async

sendStateRecording()

Simulate recording audio in chat. This will last for 25 seconds.

Inherited fromChat#sendStateRecording async

sendStateTyping()

Simulate typing in chat. This will last for 25 seconds.

Inherited fromChat#sendStateTyping async

setAddMembersAdminsOnly([adminsOnly]) → Promise containing boolean

Updates the group setting to allow only admins to add members to the group.

Parameter

NameTypeOptionalDescription

adminsOnly

|

boolean

|

Yes

|

Enable or disable this option

Defaults to true.

|

Returns

Promise containing boolean

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

async

setDescription(description) → Promise containing boolean

Updates the group description

Parameter

NameTypeOptionalDescription

description

|

string

|

| |

Returns

Promise containing boolean

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

async

setInfoAdminsOnly([adminsOnly]) → Promise containing boolean

Updates the group settings to only allow admins to edit group info (title, description, photo).

Parameter

NameTypeOptionalDescription

adminsOnly

|

boolean

|

Yes

|

Enable or disable this option

Defaults to true.

|

Returns

Promise containing boolean

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

async

setMessagesAdminsOnly([adminsOnly]) → Promise containing boolean

Updates the group settings to only allow admins to send messages.

Parameter

NameTypeOptionalDescription

adminsOnly

|

boolean

|

Yes

|

Enable or disable this option

Defaults to true.

|

Returns

Promise containing boolean

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

async

setPicture(media) → Promise containing boolean

Sets the group's picture.

Parameter

NameTypeOptionalDescription

media

|

MessageMedia

|

| |

Returns

Promise containing boolean

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

async

setSubject(subject) → Promise containing boolean

Updates the group subject

Parameter

NameTypeOptionalDescription

subject

|

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

syncHistory() → Promise containing boolean

Sync chat history conversation

Inherited fromChat#syncHistoryReturns

True if operation completed successfully, false otherwise.

async

unarchive()

un-archives this chat

Inherited fromChat#unarchive async

unmute() → Promise containing {isMuted: boolean, muteExpiration: number}

Unmutes this chat

Inherited fromChat#unmuteReturns async

unpin() → Promise containing boolean

Unpins this chat

Inherited fromChat#unpinReturns

New pin state