rory: handle errors from api

This commit is contained in:
seth 2023-12-08 11:09:40 -05:00
parent 7e96bced41
commit 026d4cb607
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86
5 changed files with 31 additions and 13 deletions

View file

@ -9,14 +9,18 @@ pub async fn rory(
ctx: Context<'_>,
#[description = "specify a Rory ID"] id: Option<u64>,
) -> Result<()> {
let resp = get_rory(id).await?;
let rory = get_rory(id).await?;
ctx.send(|m| {
m.embed(|e| {
e.title("Rory :3")
.url(&resp.url)
.image(resp.url)
.footer(|f| f.text(format!("ID {}", resp.id)))
if let Some(error) = rory.error {
e.title("Error!").description(error)
} else {
e.title("Rory :3")
.url(&rory.url)
.image(rory.url)
.footer(|f| f.text(format!("ID {}", rory.id)))
}
})
})
.await?;