Chat
Source: structures/
Represents a Chat on WhatsApp
Properties
Methods
new Chat()
- Extends
- Base
Properties
archived boolean
Indicates if the Chat is archived
id object
ID that represents the chat
isGroup boolean
Indicates if the Chat is a Group Chat
isMuted boolean
Indicates if the chat is muted or not
isReadOnly boolean
Indicates if the Chat is readonly
lastMessage Message
Last message fo chat
muteExpiration number
Unix timestamp for when the mute expires
name string
Title of the chat
pinned boolean
Indicates if the Chat is pinned
timestamp number
Unix timestamp for when the last activity occurred
unreadCount number
Amount of messages unread
Methods
archive()
Archives this chat
changeLabels(labelIds) → Promise containing void
Add or remove labels to this Chat
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
labelIds |
Array of (number or string) |
|
- Returns
-
Promise containing void
clearMessages() → Promise containing boolean
Clears all messages from the chat
- Returns
-
Promise containing booleanresult
clearState()
Stops typing or recording in chat immediately.
delete() → Promise containing Boolean
Deletes the chat
- Returns
-
Promise containing Booleanresult
fetchMessages(searchOptions) → Promise containing Array of Message
Loads chat 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
getContact() → Promise containing Contact
Returns the Contact that corresponds to this Chat.
- Returns
-
Promise containing Contact
getLabels() → Promise containing Array of Label
Returns array of all Labels assigned to this Chat
- Returns
-
Promise containing Array of Label
getPinnedMessages()
Gets instances of all pinned messages in a chat
- Returns
markUnread()
Mark this chat as unread
mute(unmuteDate) → Promise containing {isMuted: boolean, muteExpiration: number}
Mutes this chat forever, unless a date is specified
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
unmuteDate |
Date |
|
Date when the chat will be unmuted, don't provide a value to mute forever Value can be null. |
- Returns
-
Promise containing {isMuted: boolean, muteExpiration: number}
pin() → Promise containing boolean
Pins this chat
- Returns
-
Promise containing booleanNew pin state. Could be false if the max number of pinned chats was reached.
sendMessage(content[, options]) → Promise containing Message
Send a message to this chat
Parameters
| Name | Type | Optional | Description |
|---|---|---|---|
|
content |
(string, MessageMedia, or Location) |
|
|
|
options |
Yes |
- Returns
-
Promise containing MessageMessage that was just sent
sendSeen() → Promise containing Boolean
Sets the chat as seen
- Returns
-
Promise containing Booleanresult
sendStateRecording()
Simulate recording audio in chat. This will last for 25 seconds.
sendStateTyping()
Simulate typing in chat. This will last for 25 seconds.
syncHistory() → Promise containing boolean
Sync chat history conversation
- Returns
-
Promise containing booleanTrue if operation completed successfully, false otherwise.
unarchive()
un-archives this chat
unmute() → Promise containing {isMuted: boolean, muteExpiration: number}
Unmutes this chat
- Returns
-
Promise containing {isMuted: boolean, muteExpiration: number}
unpin() → Promise containing boolean
Unpins this chat
- Returns
-
Promise containing booleanNew pin state