Rust_Discord_API/utils/
embed.rs1use reqwest::Client;
2use serde_json::json;
3use std::error::Error;
4
5#[allow(dead_code)]
19pub async fn send_embed_message(client: &Client, token: &str, channel_id: &str, title: &str, description: &str) -> Result<(), Box<dyn Error>> {
20 let url = format!("https://discord.com/api/v9/channels/{}/messages", channel_id);
21 let embed = json!({
22 "title": title,
23 "description": description,
24 "color": 0x3498db });
26 let body = json!({ "embed": embed });
27
28 client.post(&url)
29 .bearer_auth(token)
30 .json(&body)
31 .send()
32 .await?
33 .error_for_status()?;
34
35 Ok(())
36}