Struct twilight_http::request::channel::webhook::execute_webhook::ExecuteWebhook [−][src]
pub struct ExecuteWebhook<'a> { /* fields omitted */ }Expand description
Execute a webhook, sending a message to its channel.
You can only specify one of content, embeds, or files.
Examples
use twilight_http::Client;
use twilight_model::id::WebhookId;
let client = Client::new("my token".to_owned());
let id = WebhookId::new(432).expect("non zero");
client
.execute_webhook(id, "webhook token")
.content("Pinkie...")
.exec()
.await?;Implementations
Specify the AllowedMentions for the webhook message.
The URL of the avatar of the webhook.
Add multiple Components to a message.
Calling this method multiple times will clear previous calls.
Errors
Returns an ExecuteWebhookErrorType::ComponentCount error
type if too many components are provided.
Returns an ExecuteWebhookErrorType::ComponentInvalid error
type if one of the provided components is invalid.
The content of the webhook’s message.
Up to 2000 UTF-16 codepoints, same as a message.
Set the list of embeds of the webhook’s message.
Attach multiple files to the webhook.
JSON encoded body of any additional request fields.
If this method is called, all other fields are ignored, except for
file. See Discord Docs/Create Message.
Examples
Without payload_json:
use twilight_embed_builder::EmbedBuilder;
use twilight_model::id::{MessageId, WebhookId};
let message = client.execute_webhook(WebhookId::new(1).expect("non zero"), "token here")
.content("some content")
.embeds(&[EmbedBuilder::new().title("title").build()?])
.wait()
.exec()
.await?
.model()
.await?;
assert_eq!(message.content, "some content");With payload_json:
use twilight_model::id::{MessageId, WebhookId};
let message = client.execute_webhook(WebhookId::new(1).expect("non zero"), "token here")
.content("some content")
.payload_json(br#"{ "content": "other content", "embeds": [ { "title": "title" } ] }"#)
.wait()
.exec()
.await?
.model()
.await?;
assert_eq!(message.content, "other content");Execute in a thread belonging to the channel instead of the channel itself.
Specify the username of the webhook’s message.
Wait for the message to send before sending a response. See Discord Docs/Execute Webhook.
Using this will result in receiving the created message.
pub fn exec(self) -> ResponseFuture<EmptyBody>ⓘNotable traits for ResponseFuture<T>impl<T: Unpin> Future for ResponseFuture<T> type Output = Result<Response<T>, Error>;
pub fn exec(self) -> ResponseFuture<EmptyBody>ⓘNotable traits for ResponseFuture<T>impl<T: Unpin> Future for ResponseFuture<T> type Output = Result<Response<T>, Error>;
impl<T: Unpin> Future for ResponseFuture<T> type Output = Result<Response<T>, Error>;Execute the request, returning a future resolving to a Response.
Auto Trait Implementations
impl<'a> !RefUnwindSafe for ExecuteWebhook<'a>
impl<'a> Send for ExecuteWebhook<'a>
impl<'a> Sync for ExecuteWebhook<'a>
impl<'a> Unpin for ExecuteWebhook<'a>
impl<'a> !UnwindSafe for ExecuteWebhook<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more