use serenity::{model::channel::Message, prelude::Context};
fn get_image_url(text: &str) -> Result<String, Box<dyn std::error::Error>> {
let logs = env::var("IMGFLIP")?;
let logs: Vec<&str> = logs.splitn(2, ':').collect();
let username = logs[0];
let password = logs[1];
let url = format!(
"username={}&password={}&template_id=102156234&boxes[0][text]=&boxes[1][text]={}",
username, password, text
);
let resp = ureq::post("https://api.imgflip.com/caption_image")
.set("Content-Type", "application/x-www-form-urlencoded")
.send_string(&url);
let url = &resp.into_json()?["data"]["url"];
if let Some(url) = url.as_str() {
Ok(url.to_string())
} else {
Err("Could not as str".into())
}
}