use crate::config::AlbatrossConfig; use discord_hooks_rs::DiscordWebhook; use log::{debug, error}; /// Sends a webhook to Discord if its configured /// /// # Params /// * `msg` - Message to send to discord /// * `cfg` - Albatross config pub fn send_webhook(msg: &str, cfg: &AlbatrossConfig) { if let Some(webhook) = &cfg.backup.discord_webhook { let json = DiscordWebhook::new().content(msg); let client = reqwest::blocking::Client::new(); match client.post(webhook).json(&json).send() { Ok(_) => { debug!("Sent webhook with message '{msg}'") } Err(err) => { error!("Failed to send webhook: '{err:?}'") } } } }