Message
Defined in: packages/structures/src/index.ts:32
Common Discord snowflake-backed structure.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Message(
data,context?):Message
Defined in: packages/structures/src/index.ts:66
Creates a message structure from Discord message data.
Parameters
Section titled “Parameters”context?
Section titled “context?”Returns
Section titled “Returns”Message
Overrides
Section titled “Overrides”Properties
Section titled “Properties”attachments
Section titled “attachments”
readonlyattachments:APIAttachment[]
Defined in: packages/structures/src/index.ts:41
author
Section titled “author”author:
User
Defined in: packages/structures/src/index.ts:34
channel
Section titled “channel”
readonlychannel:Channel
Defined in: packages/structures/src/index.ts:36
channelId
Section titled “channelId”channelId:
string
Defined in: packages/structures/src/index.ts:35
components
Section titled “components”
readonlycomponents:APIMessageComponent[]
Defined in: packages/structures/src/index.ts:49
content
Section titled “content”content:
string
Defined in: packages/structures/src/index.ts:33
embeds
Section titled “embeds”
readonlyembeds:APIEmbed[]
Defined in: packages/structures/src/index.ts:42
flags:
number
Defined in: packages/structures/src/index.ts:38
guildId?
Section titled “guildId?”
optionalguildId?:string
Defined in: packages/structures/src/index.ts:37
readonlyid:string
Defined in: packages/structures/src/base.ts:12
Inherited from
Section titled “Inherited from”member
Section titled “member”member:
GuildMember|null
Defined in: packages/structures/src/index.ts:62
The author as a guild member, on guild messages from the Gateway. Its
permissions are computed from the cached roles; member.kick() and the
other member actions work when the message came from a client.
mentionEveryone
Section titled “mentionEveryone”mentionEveryone:
boolean
Defined in: packages/structures/src/index.ts:46
mentionRoles
Section titled “mentionRoles”
readonlymentionRoles:string[]
Defined in: packages/structures/src/index.ts:44
mentions
Section titled “mentions”
readonlymentions:User[]
Defined in: packages/structures/src/index.ts:43
messageSnapshots
Section titled “messageSnapshots”
readonlymessageSnapshots:APIMessageSnapshot[]
Defined in: packages/structures/src/index.ts:56
For a forwarded message, the snapshot of the original.
pinned
Section titled “pinned”pinned:
boolean
Defined in: packages/structures/src/index.ts:45
readonlypoll:APIPoll|null
Defined in: packages/structures/src/index.ts:54
The poll, when the message is one.
reference?
Section titled “reference?”
readonlyoptionalreference?:APIMessageReference
Defined in: packages/structures/src/index.ts:48
referencedMessage?
Section titled “referencedMessage?”
readonlyoptionalreferencedMessage?:Message|null
Defined in: packages/structures/src/index.ts:50
stickers
Section titled “stickers”
readonlystickers:APIStickerItem[]
Defined in: packages/structures/src/index.ts:52
Stickers sent with the message (sticker_items).
timestamp
Section titled “timestamp”
readonlytimestamp:Date
Defined in: packages/structures/src/index.ts:40
Message creation timestamp (from timestamp field or snowflake).
type:
number
Defined in: packages/structures/src/index.ts:47
Accessors
Section titled “Accessors”createdAt
Section titled “createdAt”Get Signature
Section titled “Get Signature”get createdAt():
Date
Defined in: packages/structures/src/index.ts:142
Date at which the message was created. Overrides the
snowflake-only BaseStructure.createdAt to honour the message timestamp.
Returns
Section titled “Returns”Date
Overrides
Section titled “Overrides”createdTimestamp
Section titled “createdTimestamp”Get Signature
Section titled “Get Signature”get createdTimestamp():
number
Defined in: packages/structures/src/index.ts:136
Unix timestamp (ms) at which the message was created.
Derived from the message timestamp, which itself falls back to the id snowflake.
Returns
Section titled “Returns”number
Overrides
Section titled “Overrides”BaseStructure.createdTimestamp
embedsSuppressed
Section titled “embedsSuppressed”Get Signature
Section titled “Get Signature”get embedsSuppressed():
boolean
Defined in: packages/structures/src/index.ts:130
Whether embeds are suppressed on this message.
Returns
Section titled “Returns”boolean
hasAttachments
Section titled “hasAttachments”Get Signature
Section titled “Get Signature”get hasAttachments():
boolean
Defined in: packages/structures/src/index.ts:303
Whether this message has file attachments.
Returns
Section titled “Returns”boolean
hasComponents
Section titled “hasComponents”Get Signature
Section titled “Get Signature”get hasComponents():
boolean
Defined in: packages/structures/src/index.ts:313
Whether this message contains interactive components.
Returns
Section titled “Returns”boolean
hasEmbeds
Section titled “hasEmbeds”Get Signature
Section titled “Get Signature”get hasEmbeds():
boolean
Defined in: packages/structures/src/index.ts:308
Whether this message contains embeds.
Returns
Section titled “Returns”boolean
isCrosspost
Section titled “isCrosspost”Get Signature
Section titled “Get Signature”get isCrosspost():
boolean
Defined in: packages/structures/src/index.ts:298
Whether this message was crossposted from an announcement channel.
Returns
Section titled “Returns”boolean
isEphemeral
Section titled “isEphemeral”Get Signature
Section titled “Get Signature”get isEphemeral():
boolean
Defined in: packages/structures/src/index.ts:281
Whether this message was sent ephemerally (only visible to the recipient).
Returns
Section titled “Returns”boolean
isPinned
Section titled “isPinned”Get Signature
Section titled “Get Signature”get isPinned():
boolean
Defined in: packages/structures/src/index.ts:286
Whether this message is currently pinned in its channel.
Returns
Section titled “Returns”boolean
isSystemMessage
Section titled “isSystemMessage”Get Signature
Section titled “Get Signature”get isSystemMessage():
boolean
Defined in: packages/structures/src/index.ts:293
Whether this is a system-generated message (join, boost, etc). A message is “system” unless its type is one of the user-authored types — Default (0), Reply (19), ChatInputCommand (20) or ContextMenuCommand (23).
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”awaitComponent()
Section titled “awaitComponent()”awaitComponent(
options?):Promise<ComponentInteraction>
Defined in: packages/structures/src/index.ts:220
Waits for the next click or pick on this message’s components.
Parameters
Section titled “Parameters”options?
Section titled “options?”Omit<ComponentCollectorOptions, "max"> = {}
time (default 15 minutes), filter, componentType.
Returns
Section titled “Returns”Promise<ComponentInteraction>
The interaction.
Throws
Section titled “Throws”When time runs out first.
createComponentCollector()
Section titled “createComponentCollector()”createComponentCollector(
options?):Collector<string,ComponentInteraction>
Defined in: packages/structures/src/index.ts:194
Collects clicks and picks on this message’s components. It always ends:
after time, or 15 minutes (an interaction token’s life) when neither
time nor idle is set.
Parameters
Section titled “Parameters”options?
Section titled “options?”ComponentCollectorOptions = {}
Returns
Section titled “Returns”Collector<string, ComponentInteraction>
Example
Section titled “Example”const collector = message.createComponentCollector({ filter: (i) => i.user?.id === authorId, time: 60_000 });collector.on("collect", (i) => i.update({ content: `Picked ${i.customId}` }));crosspost()
Section titled “crosspost()”crosspost():
Promise<Message>
Defined in: packages/structures/src/index.ts:180
Crossposts this message.
Returns
Section titled “Returns”Promise<Message>
The resulting message.
Throws
Section titled “Throws”If the message is not attached to a client.
delete()
Section titled “delete()”delete(
reason?):Promise<void>
Defined in: packages/structures/src/index.ts:159
Deletes this message.
Parameters
Section titled “Parameters”reason?
Section titled “reason?”string
Audit-log reason (shown when deleting someone else’s message).
Returns
Section titled “Returns”Promise<void>
A promise fulfilled when Discord confirms deletion.
Throws
Section titled “Throws”If the message is not attached to a client.
edit()
Section titled “edit()”edit(
options):Promise<Message>
Defined in: packages/structures/src/index.ts:147
Edits this message.
Parameters
Section titled “Parameters”options
Section titled “options”Message fields to change.
Returns
Section titled “Returns”Promise<Message>
The updated message.
Throws
Section titled “Throws”If the message is not attached to a client.
pin(
reason?):Promise<void>
Defined in: packages/structures/src/index.ts:265
Pins this message.
Parameters
Section titled “Parameters”reason?
Section titled “reason?”string
Audit-log reason.
Returns
Section titled “Returns”Promise<void>
A promise fulfilled when the message is pinned.
Throws
Section titled “Throws”If pin operations are unavailable.
react()
Section titled “react()”react(
emoji):Promise<void>
Defined in: packages/structures/src/index.ts:227
Adds a reaction to this message.
Parameters
Section titled “Parameters”string
Emoji identifier.
Returns
Section titled “Returns”Promise<void>
A promise fulfilled when the reaction is added.
Throws
Section titled “Throws”If reactions are unavailable.
removeAllReactions()
Section titled “removeAllReactions()”removeAllReactions():
Promise<void>
Defined in: packages/structures/src/index.ts:258
Removes all reactions from this message.
Returns
Section titled “Returns”Promise<void>
A promise fulfilled when reactions are removed.
Throws
Section titled “Throws”If reaction operations are unavailable.
removeReaction()
Section titled “removeReaction()”removeReaction(
emoji,userId?):Promise<void>
Defined in: packages/structures/src/index.ts:234
Removes a reaction from this message.
Parameters
Section titled “Parameters”string
Emoji identifier.
userId?
Section titled “userId?”string
User whose reaction should be removed; omit to remove the current user’s reaction.
Returns
Section titled “Returns”Promise<void>
A promise fulfilled when the reaction is removed.
Throws
Section titled “Throws”If reaction operations are unavailable.
reply()
Section titled “reply()”reply(
options):Promise<Message>
Defined in: packages/structures/src/index.ts:166
Replies to this message.
Parameters
Section titled “Parameters”options
Section titled “options”string | MessageCreateOptions
Message content or payload.
Returns
Section titled “Returns”Promise<Message>
The created reply message.
Throws
Section titled “Throws”If the message is not attached to a client.
suppressEmbeds()
Section titled “suppressEmbeds()”suppressEmbeds():
Promise<Message>
Defined in: packages/structures/src/index.ts:318
Edits this message to suppress its embeds.
Returns
Section titled “Returns”Promise<Message>
The updated message.
toJSON()
Section titled “toJSON()”toJSON():
Record<string,unknown>
Defined in: packages/structures/src/index.ts:323
Returns a plain-object snapshot of all message fields.
Returns
Section titled “Returns”Record<string, unknown>
toString()
Section titled “toString()”toString():
string
Defined in: packages/structures/src/base.ts:21
Returns the snowflake ID as a string.
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”unpin()
Section titled “unpin()”unpin(
reason?):Promise<void>
Defined in: packages/structures/src/index.ts:272
Unpins this message.
Parameters
Section titled “Parameters”reason?
Section titled “reason?”string
Audit-log reason.
Returns
Section titled “Returns”Promise<void>
A promise fulfilled when the message is unpinned.
Throws
Section titled “Throws”If pin operations are unavailable.
update()
Section titled “update()”update(
options):Promise<Message>
Defined in: packages/structures/src/index.ts:154
Updates this message using the same resource operation as edit.
Parameters
Section titled “Parameters”options
Section titled “options”Message fields to change.
Returns
Section titled “Returns”Promise<Message>
The updated message.
Throws
Section titled “Throws”If the message is not attached to a client.