Expand description
Discord webhook client for Hookburn.
This crate provides a client for sending messages to Discord via incoming webhooks.
It implements the WebhookSender trait and can be used directly or through
the unified hookburn crate.
§Examples
§Direct usage
use hookburn_discord::{WebhookClient, WebhookMessage, Embed};
#[tokio::main]
async fn main() -> Result<(), hookburn_discord::WebhookError> {
let client = WebhookClient::new("https://discord.com/api/webhooks/ID/TOKEN")?;
let message = WebhookMessage::builder()
.content("Hello from Discord!")
.username("MyBot")
.build()?;
client.send(&message).await
}§With the unified Hookburn client
use hookburn::Hookburn;
use hookburn_core::{ServiceConfig, GenericMessage};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let hookburn = Hookburn::new();
let config = ServiceConfig::new("https://discord.com/api/webhooks/ID/TOKEN");
let sender = hookburn.create_sender("discord", config)?;
let msg = GenericMessage::new("Hello from Hookburn!");
sender.send(&msg).await?;
Ok(())
}Re-exports§
pub use client::WebhookClient;pub use client::WebhookClientBuilder;pub use error::WebhookError;pub use message::AllowedMentionType;pub use message::AllowedMentions;pub use message::Embed;pub use message::EmbedAuthor;pub use message::EmbedBuilder;pub use message::EmbedField;pub use message::EmbedImage;pub use message::EmbedThumbnail;pub use message::WebhookMessage;pub use message::WebhookMessageBuilder;pub use message::flags;pub use message::json_code_block;
Modules§
- client
- Discord webhook client implementation.
- error
- Error types for Discord webhook operations.
- macros
- Convenience macros for building Discord messages and embeds.
- message
- Message types and builders for Discord webhook payloads.
- service
- Service registration for the Hookburn ecosystem.
Macros§
- discord_
message - Build a [
WebhookMessage] using key=value syntax. - embed
- Build an [
Embed] using key=value syntax.
Traits§
- Webhook
Sender - Core trait for sending webhook messages to any service. A unified interface for sending messages to webhook services.
Functions§
- register_
service - Register the Discord service with the global registry.