[−][src]Struct serenity::builder::ExecuteWebhook
A builder to create the inner content of a Webhook
's execution.
This is a structured way of cleanly creating the inner execution payload, to reduce potential argument counts.
Refer to the documentation for execute_webhook
on restrictions with
execution payloads and its fields.
Examples
Creating two embeds, and then sending them as part of the delivery
payload of Webhook::execute
:
use serenity::http::Http; use serenity::model::channel::Embed; use serenity::utils::Colour; let id = 245037420704169985; let token = "ig5AO-wdVWpCBtUUMxmgsWryqgsW3DChbKYOINftJ4DCrUbnkedoYZD0VOH1QLr-S3sV"; let webhook = http.as_ref().get_webhook_with_token(id, token) .expect("valid webhook"); let website = Embed::fake(|e| { e.title("The Rust Language Website") .description("Rust is a systems programming language.") .colour(Colour::from_rgb(222, 165, 132)) }); let resources = Embed::fake(|e| { e.title("Rust Resources") .description("A few resources to help with learning Rust") .colour(0xDEA584).field("The Rust Book", "A comprehensive resource for Rust.", false) .field("Rust by Example", "A collection of Rust examples", false) }); let _ = webhook.execute(&http, false, |w| { w.content("Here's some information on Rust:").embeds(vec![website, resources]) });
Methods
impl ExecuteWebhook
[src]
pub fn avatar_url<S: ToString>(&mut self, avatar_url: S) -> &mut Self
[src]
Override the default avatar of the webhook with an image URL.
Examples
Overriding the default avatar:
let avatar_url = "https://i.imgur.com/KTs6whd.jpg"; let _ = webhook.execute(&http, false, |w| { w.avatar_url(avatar_url).content("Here's a webhook") });
pub fn content<S: ToString>(&mut self, content: S) -> &mut Self
[src]
Set the content of the message.
Note that when setting at least one embed via embeds
, this may be
omitted.
Examples
Sending a webhook with a content of "foo"
:
let execution = webhook.execute(&http, false, |w| { w.content("foo") }); if let Err(why) = execution { println!("Err sending webhook: {:?}", why); }
pub fn embeds(&mut self, embeds: Vec<Value>) -> &mut Self
[src]
Set the embeds associated with the message.
This should be used in combination with Embed::fake
, creating one
or more fake embeds to send to the API.
Examples
Refer to the struct-level documentation for an example on how to use embeds.
pub fn tts(&mut self, tts: bool) -> &mut Self
[src]
Whether the message is a text-to-speech message.
Examples
Sending a webhook with text-to-speech enabled:
let execution = webhook.execute(&http, false, |w| { w.content("hello").tts(true) }); if let Err(why) = execution { println!("Err sending webhook: {:?}", why); }
pub fn username<S: ToString>(&mut self, username: S) -> &mut Self
[src]
Override the default username of the webhook.
Examples
Overriding the username to "hakase"
:
let execution = webhook.execute(&http, false, |w| { w.content("hello").username("hakase") }); if let Err(why) = execution { println!("Err sending webhook: {:?}", why); }
Trait Implementations
impl Clone for ExecuteWebhook
[src]
fn clone(&self) -> ExecuteWebhook
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ExecuteWebhook
[src]
impl Default for ExecuteWebhook
[src]
Auto Trait Implementations
impl RefUnwindSafe for ExecuteWebhook
impl Send for ExecuteWebhook
impl Sync for ExecuteWebhook
impl Unpin for ExecuteWebhook
impl UnwindSafe for ExecuteWebhook
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CloneAny for T where
T: Clone + Any,
[src]
T: Clone + Any,
fn clone_any(&self) -> Box<dyn CloneAny + 'static>
[src]
fn clone_any_send(&self) -> Box<dyn CloneAny + 'static + Send> where
T: Send,
[src]
T: Send,
fn clone_any_sync(&self) -> Box<dyn CloneAny + 'static + Sync> where
T: Sync,
[src]
T: Sync,
fn clone_any_send_sync(&self) -> Box<dyn CloneAny + 'static + Sync + Send> where
T: Send + Sync,
[src]
T: Send + Sync,
impl<T> DebugAny for T where
T: Any + Debug,
[src]
T: Any + Debug,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> UnsafeAny for T where
T: Any,
T: Any,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,