Class: Message
The base class for all structures.
Extends
Constructors
Constructor
new Message(
client,data):Message
Parameters
| Parameter | Type |
|---|---|
client | Client |
data | { } |
Returns
Message
Overrides
Properties
attachments
attachments:
Attachment[] =[]
authorId
authorId:
string
cachedAt
cachedAt:
number
Inherited from
channelId
channelId:
string
client
protectedreadonlyclient:Client
Inherited from
content
content:
string|null=null
createdAt
createdAt:
Date|null=null
editedAt
editedAt:
Date|null=null
embeds
embeds: ({ } | { } | { } | { } | { })[] |
null=[]
flags
flags:
number=0
id
readonlyid:string
Inherited from
interactions
interactions:
Interaction|null=null
masquerade
masquerade:
Masquerade|null=null
mentions
mentions:
MessageMentions
pinned
pinned:
boolean|null=false
reactions
reactions:
Record<string,string[]> ={}
replies
replies:
string[] |null=[]
Accessors
author
Get Signature
get author():
User|undefined
Gets the Global User object from cache
Returns
User | undefined
channel
Get Signature
get channel():
BaseChannel|undefined
Gets the Channel object from cache
Returns
BaseChannel | undefined
member
Get Signature
get member():
Member|undefined
Gets the Server Member object (if sent in a server)
Returns
Member | undefined
server
Get Signature
get server():
Server|undefined
Gets the Server object from cache
Returns
Server | undefined
serverId
Get Signature
get serverId():
string|undefined
Gets the Server ID if this message was sent in a server channel
Returns
string | undefined
Methods
_clone()
_clone():
this
Helper to quickly clone a structure
Returns
this
Inherited from
_patch()
_patch(
data):void
Parameters
| Parameter | Type |
|---|---|
data | { } |
Returns
void
[custom]()
[custom](
depth,options,inspect):string
Parameters
| Parameter | Type |
|---|---|
depth | number |
options | InspectOptions |
inspect | typeof inspect |
Returns
string
awaitReactions()
awaitReactions(
options?):Promise<Collection<string,MessageReaction>>
Awaits reactions on this message.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | ReactionCollectorOptions | The options for the collector. |
Returns
Promise<Collection<string, MessageReaction>>
A promise that resolves to a collection of reactions collected.
Example
// Await reactions
const filter = (reaction) => reaction.emoji.id === '123' && reaction.users.has(author.id);
message.awaitReactions({ filter, max: 1, time: 60000 })
.then(collected => console.log(collected.size))
.catch(console.error);
clearReactions()
clearReactions():
Promise<void>
Remove all reactions from this message
Returns
Promise<void>
Throws
If the API request fails.
Example
await message.clearReactions();
createReactionCollector()
createReactionCollector(
options?):ReactionCollector
Creates a ReactionCollector to collect reactions on this message.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | ReactionCollectorOptions | The options for the collector. |
Returns
A new ReactionCollector instance.
Example
const collector = message.createReactionCollector({ time: 15000 });
collector.on('collect', (reaction) => console.log(`Collected ${reaction.emojiId} from ${reaction.userId}`));
collector.on('end', (collected) => console.log(`Collected ${collected.size} items`));
delete()
delete():
Promise<void>
Deletes this message.
Returns
Promise<void>
edit()
edit(
contentOrOptions):Promise<Message>
Edits this message.
Parameters
| Parameter | Type | Description |
|---|---|---|
contentOrOptions | string | MessageOptions | The new content or options for the message. |
Returns
Promise<Message>
equals()
equals(
other):boolean
Compares this object with another to see if they represent the same entity.
Parameters
| Parameter | Type |
|---|---|
other | string | Base |
Returns
boolean
Inherited from
pin()
pin():
Promise<void>
Pins this message.
Returns
Promise<void>
react()
react(
reaction):Promise<void>
React to this message
Parameters
| Parameter | Type | Description |
|---|---|---|
reaction | string | The emoji to react with. Can be a Unicode emoji or a custom emoji ID. |
Returns
Promise<void>
Throws
If the API request fails.
Example
await message.react("👍");
await message.react("customEmojiId");
removeReaction()
removeReaction(
reaction,userId?,removeAll?):Promise<void>
Remove a reaction from this message
Parameters
| Parameter | Type | Description |
|---|---|---|
reaction | string | The emoji to remove. Can be a Unicode emoji or a custom emoji ID. |
userId? | UserResolvable | The ID of the user whose reaction to remove. If not provided, removes the current user's reaction. |
removeAll? | boolean | Remove all reactions of this type. |
Returns
Promise<void>
Throws
If both userId and removeAll are provided, or if the API request fails.
Example
// Remove the current user's reaction
await message.removeReaction("👍");
// Remove a specific user's reaction
await message.removeReaction("👍", userId);
// Remove all reactions of this type
await message.removeReaction("👍", undefined, true);
reply()
reply(
contentOrOptions):Promise<Message>
Parameters
| Parameter | Type |
|---|---|
contentOrOptions | string | MessageOptions |
Returns
Promise<Message>
toString()
toString():
string
Returns the UUID string when the object is cast to a string.
Returns
string
Inherited from
unpin()
unpin():
Promise<void>
Unpins this message.
Returns
Promise<void>