#discord #webhook #embed #hook #field #service #blurple

blurple_hook

Discord webhook implementation in Rust

11 releases

0.3.8 Nov 2, 2024
0.3.7 Jul 18, 2024
0.3.3 Mar 8, 2024
0.3.1 Feb 19, 2024
0.1.1 Jan 30, 2024

#1307 in Web programming

Download history 9/week @ 2024-09-21 4/week @ 2024-09-28 1/week @ 2024-10-12 163/week @ 2024-11-02 4/week @ 2024-11-09 3/week @ 2024-11-16

170 downloads per month

WTFPL license

26KB
607 lines

Blurple Hook

Discord Webhook implementation built in Rust.

Notice

This is a personal library used for my own projects, This is only intended to work for me, but feel free to fork and make your own versions as you please if this doesn't suit your needs.

This package will probably work for other services that implement similar systems, such as Slack, but is only intended to support Discord currently.

Installation

cargo add blurple_hook

Example

use blurple_hook::{Webhook, Embed, Field, ColourType};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let webhook = Webhook::new("https://discord.com/webhook/")
            .set_username("Blurple Hook")
            .set_content("Example Content");
    
    let embed = Embed::new()
            .set_title("Example")
            .set_timestamp(None)
            .set_url("https://example.com/")
            .set_colour(ColourType::Hex("#5865F2"))
            .add_fields(vec![
                Field {
                    name: "Field Title 1",
                    value: "Field Value 1",
                    inline: true,
                },
                Field {
                    name: "Field Title 2",
                    value: "Field Value 2",
                    inline: true,
                }
            ]);
    
    let webhook = webhook.add_embed(embed);
    webhook.send().await?;
    
    Ok(())
}

Some methods such as set_colour have both spellings available for their method names (ie set_colourand set_color), however types are in Australian/British English spelling for now.

Dependencies

~6–19MB
~261K SLoC