Message
Source: structures/
Represents a Message on WhatsApp
Properties
new Message()
- Extends
- Base
Properties
ack MessageAck
ACK status for the message
author string
If the message was sent to a group, this field will contain the user that sent the message.
body string
Message content
broadcast boolean
Indicates if the message was a broadcast
from string
ID for the Chat that this message was sent to, except if the message was sent by the current user.
fromMe boolean
Indicates if the message was sent by the current user
hasMedia boolean
Indicates if the message has media available for download
hasQuotedMsg boolean
Indicates if the message was sent as a reply to another message.
id object
ID that represents the message
isForwarded boolean
Indicates if the message was forwarded
location Location
Location information contained in the message, if the message is type "location"
mediaKey string
MediaKey that represents the sticker 'ID'
mentionedIds Array of string
Indicates the mentions in the message body.
timestamp number
Unix timestamp for when the message was created
to string
ID for who this message is for.
If the message is sent by the current user, it will be the Chat to which the message is being sent. If the message is sent by another user, it will be the ID for the current user.
type MessageTypes
Message type
Methods
delete(everyone)
Deletes a message from the chat
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
everyone |
boolean |
|
If true and the message is sent by the current user, will delete it for everyone in the chat. Value can be null. |
downloadMedia() → Promise containing MessageMedia
Downloads and returns the attatched message media
- Returns
-
Promise containing MessageMedia
getChat() → Promise containing Chat
Returns the Chat this message was sent in
- Returns
-
Promise containing Chat
getContact() → Promise containing Contact
Returns the Contact this message was sent from
- Returns
-
Promise containing Contact
getMentions() → Promise containing Array of Contact
Returns the Contacts mentioned in this message
- Returns
-
Promise containing Array of Contact
getQuotedMessage() → Promise containing Message
Returns the quoted message, if any
- Returns
-
Promise containing Message
reply(content, chatId, options) → Promise containing Message
Sends a message as a reply to this message. If chatId is specified, it will be sent through the specified Chat. If not, it will send the message in the same Chat as the original message was sent.
Parameters
| Name | Type | Optional | Description |
|---|---|---|---|
|
content |
(string, MessageMedia, or Location) |
|
|
|
chatId |
string |
|
Value can be null. |
|
options |
object |
|
- Returns
-
Promise containing Message