Struct serenity::builder::ExecuteWebhook [−][src]
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; use serenity::model::channel::Embed; use serenity::utils::Colour; let id = 245037420704169985; let token = "ig5AO-wdVWpCBtUUMxmgsWryqgsW3DChbKYOINftJ4DCrUbnkedoYZD0VOH1QLr-S3sV"; let webhook = http::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(false, |w| w .content("Here's some information on Rust:") .embeds(vec![website, resources]));
Methods
impl ExecuteWebhook
[src]
impl ExecuteWebhook
pub fn avatar_url(self, avatar_url: &str) -> Self
[src]
pub fn avatar_url(self, avatar_url: &str) -> Self
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(false, |w| w .avatar_url(avatar_url) .content("Here's a webhook"));
pub fn content(self, content: &str) -> Self
[src]
pub fn content(self, content: &str) -> Self
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"
:
if let Err(why) = webhook.execute(false, |w| w.content("foo")) { println!("Err sending webhook: {:?}", why); }
pub fn embeds(self, embeds: Vec<Value>) -> Self
[src]
pub fn embeds(self, embeds: Vec<Value>) -> Self
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(self, tts: bool) -> Self
[src]
pub fn tts(self, tts: bool) -> Self
Whether the message is a text-to-speech message.
Examples
Sending a webhook with text-to-speech enabled:
if let Err(why) = webhook.execute(false, |w| w.content("hello").tts(true)) { println!("Err sending webhook: {:?}", why); }
pub fn username(self, username: &str) -> Self
[src]
pub fn username(self, username: &str) -> Self
Override the default username of the webhook.
Examples
Overriuding the username to "hakase"
:
if let Err(why) = webhook.execute(false, |w| w.content("hello").username("hakase")) { println!("Err sending webhook: {:?}", why); }
Trait Implementations
impl Clone for ExecuteWebhook
[src]
impl Clone for ExecuteWebhook
fn clone(&self) -> ExecuteWebhook
[src]
fn clone(&self) -> ExecuteWebhook
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for ExecuteWebhook
[src]
impl Debug for ExecuteWebhook
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Default for ExecuteWebhook
[src]
impl Default for ExecuteWebhook
Auto Trait Implementations
impl Send for ExecuteWebhook
impl Send for ExecuteWebhook
impl Sync for ExecuteWebhook
impl Sync for ExecuteWebhook