#[non_exhaustive]pub struct Message {Show 40 fields
pub id: MessageId,
pub channel_id: ChannelId,
pub guild_id: Option<GuildId>,
pub author: User,
pub member: Option<Box<PartialMember>>,
pub content: CompactString,
pub timestamp: Timestamp,
pub edited_timestamp: Option<Timestamp>,
pub tts: bool,
pub mention_everyone: bool,
pub mentions: Vec<Mention>,
pub mention_roles: Vec<RoleId>,
pub mention_channels: Vec<ChannelMention>,
pub attachments: Vec<Attachment>,
pub embeds: Vec<Embed>,
pub reactions: Vec<Reaction>,
pub nonce: Option<Nonce>,
pub pinned: bool,
pub webhook_id: Option<WebhookId>,
pub kind: MessageType,
pub activity: Option<Box<MessageActivity>>,
pub application: Option<Box<PartialApplication>>,
pub application_id: Option<ApplicationId>,
pub flags: MessageFlags,
pub message_reference: Option<MessageReference>,
pub message_snapshots: Vec<MessageSnapshot>,
pub referenced_message: ReferencedMessage,
pub interaction_metadata: Option<Box<InteractionMetadata>>,
pub interaction: Option<Box<MessageInteraction>>,
pub components: Vec<Component>,
pub thread: Option<Box<Channel>>,
pub resolved: Option<Box<Resolved>>,
pub sticker_items: Vec<StickerItem>,
pub stickers: Vec<Sticker>,
pub position: Option<u32>,
pub role_subscription_data: Option<Box<RoleSubscriptionData>>,
pub poll: Option<Box<Poll>>,
pub call: Option<Box<MessageCall>>,
pub shared_client_theme: Option<Box<SharedClientTheme>>,
pub channel_type: Option<ChannelType>,
}Expand description
A message sent in a channel.
The same type is used for messages received through the gateway (MESSAGE_CREATE,
MESSAGE_UPDATE) and from REST. The gateway adds a few fields (guild_id,
member, the members of mentions,
channel_type) that REST responses do not have.
Without the MESSAGE_CONTENT privileged intent, content,
embeds and attachments are empty and
poll is absent, except in DMs, in messages that mention the bot and in the
bot’s own messages.
Rare sub-objects are boxed so a typical message stays small (D-054).
Contains floats (through Attachment), so it is PartialEq but not Eq (D-064).
discord.js counterpart: Message.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: MessageIdThe message’s ID.
channel_id: ChannelIdThe ID of the channel the message was sent in.
guild_id: Option<GuildId>The ID of the guild the message was sent in (gateway only).
The author of the message.
For webhook messages this is a pseudo-user built from the webhook’s ID, name and avatar
(check webhook_id).
member: Option<Box<PartialMember>>The author’s member in the guild (gateway only, guild messages not sent by webhooks).
content: CompactStringThe text content of the message.
Empty without the MESSAGE_CONTENT privileged intent (see above).
timestamp: TimestampWhen the message was sent.
edited_timestamp: Option<Timestamp>When the message was last edited, if ever.
tts: boolWhether this was a text-to-speech message (always false in MESSAGE_UPDATE).
mention_everyone: boolWhether the message mentions @everyone (or @here).
mentions: Vec<Mention>The users mentioned in the message, with their members in guild messages received through the gateway (D-060).
mention_roles: Vec<RoleId>The roles mentioned in the message.
mention_channels: Vec<ChannelMention>The channels mentioned in the message. Only channels visible to everyone in public guilds are listed, and currently only on crossposted messages.
attachments: Vec<Attachment>The attached files (except those referenced in embeds or components).
embeds: Vec<Embed>The embeds.
reactions: Vec<Reaction>The reactions.
nonce: Option<Nonce>The value the sender used to check that the message was sent.
pinned: boolWhether the message is pinned.
webhook_id: Option<WebhookId>If the message was generated by a webhook, the webhook’s ID.
kind: MessageTypeThe kind of message.
activity: Option<Box<MessageActivity>>The Rich Presence activity of a Rich Presence chat embed.
application: Option<Box<PartialApplication>>The application of a Rich Presence chat embed.
application_id: Option<ApplicationId>The application of an interaction response or an application-owned webhook message.
flags: MessageFlagsThe message’s flags.
message_reference: Option<MessageReference>The source of a crosspost, channel follow, pin, reply, forward, … (see
MessageReference).
message_snapshots: Vec<MessageSnapshot>The forwarded message(s), when message_reference is a
forward.
referenced_message: ReferencedMessageThe message this one replies to (or starts a thread from, or a context menu command was
run on), for messages of type Reply,
ThreadStarterMessage and
ContextMenuCommand (D-061).
interaction_metadata: Option<Box<InteractionMetadata>>The interaction the message was sent for.
interaction: Option<Box<MessageInteraction>>The interaction the message responds to. Deprecated by Discord in favor of
interaction_metadata.
components: Vec<Component>The components (buttons, select menus, or Components V2 layout with
IS_COMPONENTS_V2). Empty without the
MESSAGE_CONTENT privileged intent (see above).
thread: Option<Box<Channel>>The thread started from this message (with the current user’s thread member, if any).
resolved: Option<Box<Resolved>>The users, members, channels and roles referenced by the message’s components (Components V2 messages with select menu default values or mentions).
sticker_items: Vec<StickerItem>The stickers sent with the message.
stickers: Vec<Sticker>The full stickers sent with the message. Deprecated by Discord in favor of
sticker_items.
position: Option<u32>The approximate position of the message in its thread: a generally increasing number (with possible gaps and duplicates) for messages in threads.
role_subscription_data: Option<Box<RoleSubscriptionData>>The role subscription purchase or renewal a
RoleSubscriptionPurchase message announces.
poll: Option<Box<Poll>>The poll.
call: Option<Box<MessageCall>>The call a Call message is about.
A client theme shared through the message.
channel_type: Option<ChannelType>The type of the channel the message was sent in (gateway only).