#[non_exhaustive]pub struct MessageCallbackData {
pub tts: bool,
pub content: Option<CompactString>,
pub embeds: Option<Vec<Embed>>,
pub allowed_mentions: Option<AllowedMentions>,
pub flags: Option<MessageFlags>,
pub components: Option<Vec<Component>>,
pub attachments: Option<Vec<AttachmentRequest>>,
pub poll: Option<CreatePoll>,
pub files: Vec<FileUpload>,
}Expand description
The message data of a response:
a new message (ChannelMessageWithSource)
or the edit of the component’s message (UpdateMessage).
Every field is optional. For updates, an absent field keeps the message’s current value,
while Some(vec![]) removes all embeds, components or attachments.
discord.js counterpart: InteractionReplyOptions / InteractionUpdateOptions.
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.tts: boolWhether the message is read aloud.
content: Option<CompactString>The text (up to 2000 characters).
embeds: Option<Vec<Embed>>The embeds (up to 10).
allowed_mentions: Option<AllowedMentions>Which mentions in the content notify.
flags: Option<MessageFlags>Only EPHEMERAL, SUPPRESS_EMBEDS,
SUPPRESS_NOTIFICATIONS,
IS_COMPONENTS_V2 and
IS_VOICE_MESSAGE can be set.
components: Option<Vec<Component>>The components.
attachments: Option<Vec<AttachmentRequest>>Explicit attachment entries: for updates, the existing attachments to keep. Every file
in files gets an entry automatically, unless one with its files[n]
index is listed here (D-094).
poll: Option<CreatePoll>A poll to create with the message.
files: Vec<FileUpload>Files to upload with the response (sent as multipart/form-data, D-087). Not part of
the JSON; empty when decoded.
Implementations§
Source§impl MessageCallbackData
impl MessageCallbackData
Sourcepub fn content(self, content: impl Into<CompactString>) -> Self
pub fn content(self, content: impl Into<CompactString>) -> Self
Sets the text (up to 2000 characters).
discord.js counterpart: the content option.
Sourcepub fn embed(self, embed: Embed) -> Self
pub fn embed(self, embed: Embed) -> Self
Adds an embed after the ones set before (up to 10, 6000 characters in all; check
them with djs_builders::validate_embeds).
discord.js counterpart: an item of the embeds option.
Sourcepub fn embeds(self, embeds: impl IntoIterator<Item = Embed>) -> Self
pub fn embeds(self, embeds: impl IntoIterator<Item = Embed>) -> Self
Replaces the embeds. When editing a message (or updating it from a component), an empty list removes its embeds, while not calling this keeps them.
discord.js counterpart: the embeds option.
Sourcepub fn component(self, component: impl Into<Component>) -> Self
pub fn component(self, component: impl Into<Component>) -> Self
Adds a top-level component (an action row, or a Components V2 item with the
IS_COMPONENTS_V2 flag) after
the ones set before.
discord.js counterpart: an item of the components option.
Sourcepub fn components(self, components: impl IntoIterator<Item = Component>) -> Self
pub fn components(self, components: impl IntoIterator<Item = Component>) -> Self
Replaces the top-level components. When editing a message (or updating it from a component), an empty list removes its components, while not calling this keeps them.
discord.js counterpart: the components option.
Sourcepub fn allowed_mentions(self, mentions: AllowedMentions) -> Self
pub fn allowed_mentions(self, mentions: AllowedMentions) -> Self
Sets which mentions of the text notify their targets.
discord.js counterpart: the allowedMentions option.
Sourcepub fn no_mentions(self) -> Self
pub fn no_mentions(self) -> Self
Lets no mention notify anyone: no @everyone, role or user ping, whatever the text
contains. The safe choice for text that comes from users.
discord.js counterpart: allowedMentions: { parse: [] }.
Sourcepub fn flags(self, flags: MessageFlags) -> Self
pub fn flags(self, flags: MessageFlags) -> Self
Replaces the message flags (only some can be sent; see
MessageFlags).
discord.js counterpart: the flags option.
Sourcepub fn suppress_embeds(self) -> Self
pub fn suppress_embeds(self) -> Self
Hides the embeds Discord would generate for the links in the text (adds
SUPPRESS_EMBEDS to the flags).
discord.js counterpart: flags: MessageFlags.SuppressEmbeds.
Sourcepub fn ephemeral(self) -> Self
pub fn ephemeral(self) -> Self
Makes the message visible only to the user of the interaction (adds
EPHEMERAL to the flags).
discord.js counterpart: flags: MessageFlags.Ephemeral.
Sourcepub fn suppress_notifications(self) -> Self
pub fn suppress_notifications(self) -> Self
Sends the message without push and desktop notifications (adds
SUPPRESS_NOTIFICATIONS to
the flags; “@silent” in the client).
discord.js counterpart: flags: MessageFlags.SuppressNotifications.
Sourcepub fn file(self, file: FileUpload) -> Self
pub fn file(self, file: FileUpload) -> Self
Attaches a file, after the ones set before.
discord.js counterpart: an item of the files option.
Sourcepub fn files(self, files: impl IntoIterator<Item = FileUpload>) -> Self
pub fn files(self, files: impl IntoIterator<Item = FileUpload>) -> Self
Replaces the attached files.
discord.js counterpart: the files option.
Sourcepub fn attachments(
self,
attachments: impl IntoIterator<Item = AttachmentRequest>,
) -> Self
pub fn attachments( self, attachments: impl IntoIterator<Item = AttachmentRequest>, ) -> Self
Sets the attachment metadata: descriptions of the uploaded files, or, when editing, the existing attachments to keep (an empty list removes them all).
discord.js counterpart: the attachments option.
Sourcepub fn poll(self, poll: CreatePoll) -> Self
pub fn poll(self, poll: CreatePoll) -> Self
Attaches a poll.
discord.js counterpart: the poll option.