feat(webhook): add discord webhook

This commit is contained in:
MedzikUser 2022-03-04 18:57:02 +01:00
parent 572899509f
commit 6abb99d50a
No known key found for this signature in database
GPG Key ID: A5FAC1E185C112DB
1 changed files with 19 additions and 0 deletions

19
src/cli/webhook.rs Normal file
View File

@ -0,0 +1,19 @@
use std::error::Error;
use webhook::client::WebhookClient;
use crate::config::toml;
pub async fn send_discord_webhook(link: String, deletehash: String) -> Result<bool, Box<dyn Error + Send + Sync>> {
let url = toml::parse().discord_webhook.uri;
let client: WebhookClient = WebhookClient::new(&url);
let webhook = client.send(|message| message
.username("Imgurs")
.embed(|embed| embed
.title("Imgurs")
.description(&format!("Delete Hash ||{deletehash}||"))
.image(&link)
.footer(&format!("Imgurs v{}", option_env!("CARGO_PKG_VERSION").unwrap_or("unknown")), None))).await;
webhook
}