#webhook #discord-webhook #footer #discord-webhook-rs

discord-webhook-rs

Rust library to send Discord webhooks

5 stable releases

Uses new Rust 2024

new 1.0.4 Apr 18, 2025
1.0.3 Apr 15, 2025
1.0.2 Apr 14, 2025
1.0.1 Apr 13, 2025

#565 in Web programming

Download history 238/week @ 2025-04-11

238 downloads per month

MIT license

16KB
423 lines

discord-webhook-rs

A Rust library for sending Discord webhooks easily.

Features

  • Send rich embeds with customizable fields, authors, and footers.
  • Set custom content, username, and avatar for your webhook.
  • Add up to 10 files to your webhook.
  • Simple and intuitive API for sending messages to Discord channels.

Installation

Add this to your Cargo.toml:

[dependencies]
discord-webhook-rs = "1.0.4"

Example Usage

use discord_webhook_rs::{Webhook, Error, Embed, Author, Field, Footer};

const WEBHOOK_URL: &str = "https://discord.com/api/webhooks/...";

fn main() -> Result<(), Error> {
    Webhook::new(WEBHOOK_URL)
        .content("Hello from Rust!")
        .username("Étienne")
        .avatar_url("https://avatars.githubusercontent.com/u/145381924")
        .add_embed(
            Embed::new()
                .title("Thanks")
                .description("Thanks for using **discord-webhook-rs**!")
                .author(Author::new().name("Crab"))
                .add_field(Field::new().name("Field 1").value("Value 1").inline(true))
                .add_field(Field::new().name("Field 2").value("Value 2").inline(false))
                .footer(Footer::new().text("footer"))
        )
        .add_file("my_file.txt")
        .send()?;

    Ok(())
}

License

This project is licensed under the MIT License, see the LICENSE file for details.

Dependencies

~4–16MB
~228K SLoC