discord-webhook-rs

Crates.iodiscord-webhook-rs
lib.rsdiscord-webhook-rs
version
sourcesrc
created_at2025-04-13 22:01:10.926431+00
updated_at2025-04-21 15:33:43.007076+00
descriptionRust library to send Discord webhooks.
homepage
repository
max_upload_size
id1632187
Cargo.toml error:TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Étienne Hodé (etienne-hd)

documentation

README

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.5"

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.

Commit count: 0

cargo fmt