#[non_exhaustive]pub struct ExecuteWebhook {Show 15 fields
pub content: Option<CompactString>,
pub username: Option<CompactString>,
pub avatar_url: Option<CompactString>,
pub tts: bool,
pub embeds: Vec<Embed>,
pub allowed_mentions: Option<AllowedMentions>,
pub components: Vec<Component>,
pub attachments: Option<Vec<AttachmentRequest>>,
pub flags: Option<MessageFlags>,
pub thread_name: Option<CompactString>,
pub applied_tags: Vec<TagId>,
pub poll: Option<CreatePoll>,
pub files: Vec<FileUpload>,
pub thread_id: Option<ChannelId>,
pub with_components: Option<bool>,
}Expand description
The body of Execute Webhook: a message sent through a webhook.
At least one of content, embeds, components, files or poll is required. In a
forum or media channel, set thread_id or
thread_name. Files get their attachments entries automatically
(D-094); thread_id and with_components
are sent in the query string (D-119).
discord.js counterpart: WebhookMessageCreateOptions.
§Examples
use djs_model::rest::ExecuteWebhook;
let body = ExecuteWebhook::from("Build #42 passed").username("CI");
assert_eq!(
serde_json::to_string(&body).unwrap(),
r#"{"content":"Build #42 passed","username":"CI"}"#
);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.content: Option<CompactString>The text (up to 2000 characters).
username: Option<CompactString>Overrides the webhook’s name for this message.
avatar_url: Option<CompactString>Overrides the webhook’s avatar for this message (an image URL).
tts: boolWhether the message is read aloud.
embeds: Vec<Embed>Up to 10 rich embeds.
allowed_mentions: Option<AllowedMentions>Which mentions in the content notify.
components: Vec<Component>The components; webhooks not owned by an application need
with_components and can only send non-interactive ones.
attachments: Option<Vec<AttachmentRequest>>Explicit attachment entries; files get theirs automatically (D-094).
flags: Option<MessageFlags>Only SUPPRESS_EMBEDS,
SUPPRESS_NOTIFICATIONS and
IS_COMPONENTS_V2 can be set.
thread_name: Option<CompactString>In a forum or media channel: creates a post with this name.
The tags of the post created with thread_name.
poll: Option<CreatePoll>A poll to create with the message.
files: Vec<FileUpload>Files to upload with the message (D-087).
thread_id: Option<ChannelId>Sends the message in this thread of the webhook’s channel (unarchiving it); sent in the query string.
with_components: Option<bool>Whether Discord uses components (Discord’s default: only for
application-owned webhooks); sent in the query string.
Implementations§
Source§impl ExecuteWebhook
impl ExecuteWebhook
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 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.
Source§impl ExecuteWebhook
The setters of the fields only ExecuteWebhook has (D-290).
impl ExecuteWebhook
The setters of the fields only ExecuteWebhook has (D-290).
Sourcepub fn username(self, username: impl Into<CompactString>) -> Self
pub fn username(self, username: impl Into<CompactString>) -> Self
Overrides the webhook’s name for this message.
discord.js counterpart: the username option.
Sourcepub fn avatar_url(self, url: impl Into<CompactString>) -> Self
pub fn avatar_url(self, url: impl Into<CompactString>) -> Self
Overrides the webhook’s avatar for this message (an image URL).
discord.js counterpart: the avatarURL option.
Sourcepub fn thread_name(self, name: impl Into<CompactString>) -> Self
pub fn thread_name(self, name: impl Into<CompactString>) -> Self
In a forum or media channel: creates a post with this name.
discord.js counterpart: the threadName option.
Sets the tags of the post created with thread_name.
discord.js counterpart: the appliedTags option.
Sourcepub const fn thread_id(self, thread_id: ChannelId) -> Self
pub const fn thread_id(self, thread_id: ChannelId) -> Self
Sends the message in this thread of the webhook’s channel (unarchiving it).
discord.js counterpart: the threadId option.
Sourcepub const fn with_components(self, with_components: bool) -> Self
pub const fn with_components(self, with_components: bool) -> Self
Sets whether Discord uses the components (by default only for
application-owned webhooks; others can send only non-interactive components).
discord.js counterpart: the withComponents option.