Skip to main content

WebhookExt

Trait WebhookExt 

Source
pub trait WebhookExt: Webhook {
    // Provided methods
    fn send<B: Backend>(
        &self,
        ctx: &Context<B>,
        body: impl Into<ExecuteWebhook>,
    ) -> impl Future<Output = Result<Arc<CachedMessage>, WebhookError>> + Send { ... }
    fn edit<B: Backend>(
        &self,
        ctx: &Context<B>,
        body: &ModifyWebhook,
        reason: Option<&str>,
    ) -> impl Future<Output = Result<Webhook, Error>> + Send { ... }
    fn delete<B: Backend>(
        &self,
        ctx: &Context<B>,
        reason: Option<&str>,
    ) -> impl Future<Output = Result<(), Error>> + Send { ... }
}
Expand description

Actions on a Webhook (D-237, D-240).

This trait is sealed.

discord.js counterpart: the methods of Webhook.

§Examples

let webhooks = ctx.webhooks().list_channel(channel).await?;
if let Some(webhook) = webhooks.values().find(|webhook| webhook.token.is_some()) {
    webhook.send(&ctx, "Hello from a webhook").await?;
}

Provided Methods§

Source

fn send<B: Backend>( &self, ctx: &Context<B>, body: impl Into<ExecuteWebhook>, ) -> impl Future<Output = Result<Arc<CachedMessage>, WebhookError>> + Send

Sends a message through this webhook with its token (WebhookManager::send).

discord.js counterpart: Webhook#send.

§Errors

Returns WebhookError::MissingToken for a webhook without a token (channel-follower and application webhooks), or the REST error if the request failed.

Source

fn edit<B: Backend>( &self, ctx: &Context<B>, body: &ModifyWebhook, reason: Option<&str>, ) -> impl Future<Output = Result<Webhook, Error>> + Send

Edits this webhook (WebhookManager::edit).

discord.js counterpart: Webhook#edit.

§Errors

Returns the REST error if the request failed.

Source

fn delete<B: Backend>( &self, ctx: &Context<B>, reason: Option<&str>, ) -> impl Future<Output = Result<(), Error>> + Send

Deletes this webhook (WebhookManager::delete).

discord.js counterpart: Webhook#delete.

§Errors

Returns the REST error if the request failed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl WebhookExt for Webhook

Implementors§