rust_webhook

Crates.iorust_webhook
lib.rsrust_webhook
version0.1.6
sourcesrc
created_at2023-05-27 07:04:14.258356
updated_at2023-05-27 21:34:55.330437
descriptionThe program is a utility crate that provides a function to send a webhook request with JSON content using the Reqwest library in Rust. It simplifies the process of sending HTTP POST requests to webhook URLs by handling JSON serialization and request configuration.
homepagehttps://github.com/snekxs/Rust-Webhooks
repositoryhttps://github.com/snekxs/Rust-Webhooks
max_upload_size
id875807
size6,901
Snekxs (snekxs)

documentation

README

rust_webhook

The 'rust_webhook' crate is a Rust library that provides functionality for sending webhooks using the 'reqwest' and 'serde_json' libraries. It allows you to easily send POST requests with JSON payloads to webhook endpoints.

Installation

Add the crate as a dependency in your Cargo.toml file:

[dependencies]
rust_webhook = { version = "0.1.5" }
reqwest = "0.11"
serde_json = "1.0"

Quick Start

Sending Messages

use rust_webhook::DiscordWebhook;

#[tokio::main]
async fn main() {
    let webhook = DiscordWebhook::new("YOUR_WEBHOOK_URL");
    let content = "Hello, webhook!";

    webhook.send(content).await;
}

Sending Embeds

#[tokio::main]
async fn main() {
    let webhook = DiscordWebhook::new("YOUR_WEBHOOK_URL");
    let embed = webhook.create_embed(
        &[
            ("title", "Title Goes Here"),
            ("description", "Description Goes Here"),
        ],
        Some(0x00FFFF), //Set Color Code                 
        true, // Set Timestamp
        Some("Footer Goes Here") 
        
    );
    webhook.send_embed(embed).await
}
Commit count: 27

cargo fmt