rory: handle errors from api
This commit is contained in:
parent
7e96bced41
commit
026d4cb607
5 changed files with 31 additions and 13 deletions
|
@ -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?;
|
||||
|
|
|
@ -17,6 +17,7 @@ pub async fn say(ctx: Context<'_>, #[description = "Just content?"] content: Str
|
|||
.await
|
||||
.ok_or_else(|| eyre!("Couldn't get channel!"))?;
|
||||
|
||||
ctx.defer_ephemeral().await?;
|
||||
channel.say(ctx, &content).await?;
|
||||
ctx.say("I said what you said!").await?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue