Skip to content

Discord

Send notifications to a Discord channel via an incoming webhook.

URL format: discord://<token>@<webhook_id>

The token and webhook ID come from the webhook URL Discord generates: https://discord.com/api/webhooks/<webhook_id>/<token>

ParameterAliasTypeDefaultDescription
usernamestringBuzzDisplay name shown as the webhook sender.
avataravatarurlstring(buzz default avatar)URL of the avatar image shown next to the message.
titlestringNew notification from BuzzEmbed title. Setting any embed parameter enables the embed.
colorstringFF9900Embed accent color as a hex string (e.g. FF9900 or 0xFF9900).
base_urlbaseurlstringhttps://discord.comBase URL for the webhook request. Primarily useful for testing.

When all of username, avatar, title, and color are left at their defaults, the message is sent as plain content with no embed. Changing any one of those parameters causes the message body to be sent inside a Discord embed instead.

use buzzrs::buzz;
#[tokio::main]
async fn main() {
buzz!(
"discord://KkoZlPa0cAVJRBa7kMuUEFff7zXDYgNDPk@1234567890123456789",
"Deployment finished."
);
}

username — override the sender display name

Section titled “username — override the sender display name”
buzz!(
"discord://KkoZlPa0cAVJRBa7kMuUEFff7zXDYgNDPk@1234567890123456789?username=Ops",
"Service restarted."
);

avatar / avatarurl — override the sender avatar

Section titled “avatar / avatarurl — override the sender avatar”
// using `avatar`
buzz!(
"discord://KkoZlPa0cAVJRBa7kMuUEFff7zXDYgNDPk@1234567890123456789\
?avatar=https%3A%2F%2Fexample.com%2Fbot.png",
"Service restarted."
);
// using the `avatarurl` alias
buzz!(
"discord://KkoZlPa0cAVJRBa7kMuUEFff7zXDYgNDPk@1234567890123456789\
?avatarurl=https%3A%2F%2Fexample.com%2Fbot.png",
"Service restarted."
);
buzz!(
"discord://KkoZlPa0cAVJRBa7kMuUEFff7zXDYgNDPk@1234567890123456789?title=Deployment",
"Build #42 succeeded."
);
// green embed
buzz!(
"discord://KkoZlPa0cAVJRBa7kMuUEFff7zXDYgNDPk@1234567890123456789?color=00FF00",
"All checks passed."
);
// using `0x` prefix
buzz!(
"discord://KkoZlPa0cAVJRBa7kMuUEFff7zXDYgNDPk@1234567890123456789?color=0x00FF00",
"All checks passed."
);
buzz!(
"discord://KkoZlPa0cAVJRBa7kMuUEFff7zXDYgNDPk@1234567890123456789\
?username=Ops\
&avatar=https%3A%2F%2Fexample.com%2Fbot.png\
&title=Deployment+Alert\
&color=0x8F7AAF",
"Production deployment completed."
);
use buzzrs::Buzz;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let buzz = Buzz::new();
let service = buzz.build_service(
"discord://KkoZlPa0cAVJRBa7kMuUEFff7zXDYgNDPk@1234567890123456789\
?username=Ops&title=Deployment+Alert&color=0x8F7AAF",
)?;
service.send("Production deployment completed.").await?;
Ok(())
}
use buzzrs::buzz_sync;
fn main() {
buzz_sync!(
"discord://KkoZlPa0cAVJRBa7kMuUEFff7zXDYgNDPk@1234567890123456789?title=Alert",
"Cron job finished."
);
}