Skip to content

Message

Defined in: packages/structures/src/index.ts:32

Common Discord snowflake-backed structure.

new Message(data, context?): Message

Defined in: packages/structures/src/index.ts:66

Creates a message structure from Discord message data.

APIMessage

ResourceContext

Message

BaseStructure.constructor

readonly attachments: APIAttachment[]

Defined in: packages/structures/src/index.ts:41


author: User

Defined in: packages/structures/src/index.ts:34


readonly channel: Channel

Defined in: packages/structures/src/index.ts:36


channelId: string

Defined in: packages/structures/src/index.ts:35


readonly components: APIMessageComponent[]

Defined in: packages/structures/src/index.ts:49


content: string

Defined in: packages/structures/src/index.ts:33


readonly embeds: APIEmbed[]

Defined in: packages/structures/src/index.ts:42


flags: number

Defined in: packages/structures/src/index.ts:38


optional guildId?: string

Defined in: packages/structures/src/index.ts:37


readonly id: string

Defined in: packages/structures/src/base.ts:12

BaseStructure.id


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: boolean

Defined in: packages/structures/src/index.ts:46


readonly mentionRoles: string[]

Defined in: packages/structures/src/index.ts:44


readonly mentions: User[]

Defined in: packages/structures/src/index.ts:43


readonly messageSnapshots: APIMessageSnapshot[]

Defined in: packages/structures/src/index.ts:56

For a forwarded message, the snapshot of the original.


pinned: boolean

Defined in: packages/structures/src/index.ts:45


readonly poll: APIPoll | null

Defined in: packages/structures/src/index.ts:54

The poll, when the message is one.


readonly optional reference?: APIMessageReference

Defined in: packages/structures/src/index.ts:48


readonly optional referencedMessage?: Message | null

Defined in: packages/structures/src/index.ts:50


readonly stickers: APIStickerItem[]

Defined in: packages/structures/src/index.ts:52

Stickers sent with the message (sticker_items).


readonly timestamp: 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

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.

Date

BaseStructure.createdAt


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.

number

BaseStructure.createdTimestamp


get embedsSuppressed(): boolean

Defined in: packages/structures/src/index.ts:130

Whether embeds are suppressed on this message.

boolean


get hasAttachments(): boolean

Defined in: packages/structures/src/index.ts:303

Whether this message has file attachments.

boolean


get hasComponents(): boolean

Defined in: packages/structures/src/index.ts:313

Whether this message contains interactive components.

boolean


get hasEmbeds(): boolean

Defined in: packages/structures/src/index.ts:308

Whether this message contains embeds.

boolean


get isCrosspost(): boolean

Defined in: packages/structures/src/index.ts:298

Whether this message was crossposted from an announcement channel.

boolean


get isEphemeral(): boolean

Defined in: packages/structures/src/index.ts:281

Whether this message was sent ephemerally (only visible to the recipient).

boolean


get isPinned(): boolean

Defined in: packages/structures/src/index.ts:286

Whether this message is currently pinned in its channel.

boolean


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).

boolean

awaitComponent(options?): Promise<ComponentInteraction>

Defined in: packages/structures/src/index.ts:220

Waits for the next click or pick on this message’s components.

Omit<ComponentCollectorOptions, "max"> = {}

time (default 15 minutes), filter, componentType.

Promise<ComponentInteraction>

The interaction.

When time runs out first.


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.

ComponentCollectorOptions = {}

Collector<string, ComponentInteraction>

const collector = message.createComponentCollector({ filter: (i) => i.user?.id === authorId, time: 60_000 });
collector.on("collect", (i) => i.update({ content: `Picked ${i.customId}` }));

crosspost(): Promise<Message>

Defined in: packages/structures/src/index.ts:180

Crossposts this message.

Promise<Message>

The resulting message.

If the message is not attached to a client.


delete(reason?): Promise<void>

Defined in: packages/structures/src/index.ts:159

Deletes this message.

string

Audit-log reason (shown when deleting someone else’s message).

Promise<void>

A promise fulfilled when Discord confirms deletion.

If the message is not attached to a client.


edit(options): Promise<Message>

Defined in: packages/structures/src/index.ts:147

Edits this message.

MessageEditOptions

Message fields to change.

Promise<Message>

The updated message.

If the message is not attached to a client.


pin(reason?): Promise<void>

Defined in: packages/structures/src/index.ts:265

Pins this message.

string

Audit-log reason.

Promise<void>

A promise fulfilled when the message is pinned.

If pin operations are unavailable.


react(emoji): Promise<void>

Defined in: packages/structures/src/index.ts:227

Adds a reaction to this message.

string

Emoji identifier.

Promise<void>

A promise fulfilled when the reaction is added.

If reactions are unavailable.


removeAllReactions(): Promise<void>

Defined in: packages/structures/src/index.ts:258

Removes all reactions from this message.

Promise<void>

A promise fulfilled when reactions are removed.

If reaction operations are unavailable.


removeReaction(emoji, userId?): Promise<void>

Defined in: packages/structures/src/index.ts:234

Removes a reaction from this message.

string

Emoji identifier.

string

User whose reaction should be removed; omit to remove the current user’s reaction.

Promise<void>

A promise fulfilled when the reaction is removed.

If reaction operations are unavailable.


reply(options): Promise<Message>

Defined in: packages/structures/src/index.ts:166

Replies to this message.

string | MessageCreateOptions

Message content or payload.

Promise<Message>

The created reply message.

If the message is not attached to a client.


suppressEmbeds(): Promise<Message>

Defined in: packages/structures/src/index.ts:318

Edits this message to suppress its embeds.

Promise<Message>

The updated message.


toJSON(): Record<string, unknown>

Defined in: packages/structures/src/index.ts:323

Returns a plain-object snapshot of all message fields.

Record<string, unknown>


toString(): string

Defined in: packages/structures/src/base.ts:21

Returns the snowflake ID as a string.

string

BaseStructure.toString


unpin(reason?): Promise<void>

Defined in: packages/structures/src/index.ts:272

Unpins this message.

string

Audit-log reason.

Promise<void>

A promise fulfilled when the message is unpinned.

If pin operations are unavailable.


update(options): Promise<Message>

Defined in: packages/structures/src/index.ts:154

Updates this message using the same resource operation as edit.

MessageEditOptions

Message fields to change.

Promise<Message>

The updated message.

If the message is not attached to a client.