refactor!: use poise 0.6.1

This commit is contained in:
seth 2024-01-27 22:29:56 -05:00
parent 203ba111cc
commit 7252ced3cb
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86
16 changed files with 700 additions and 512 deletions

View file

@ -2,6 +2,8 @@ use crate::api::rory::get_rory;
use crate::Context;
use color_eyre::eyre::Result;
use poise::serenity_prelude::{CreateEmbed, CreateEmbedFooter};
use poise::CreateReply;
/// Gets a Rory photo!
#[poise::command(slash_command, prefix_command)]
@ -11,19 +13,22 @@ pub async fn rory(
) -> Result<()> {
let rory = get_rory(id).await?;
ctx.send(|m| {
m.embed(|e| {
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?;
let embed = {
let embed = CreateEmbed::new();
if let Some(error) = rory.error {
embed.title("Error!").description(error)
} else {
let footer = CreateEmbedFooter::new(format!("ID {}", rory.id));
embed
.title("Rory :3")
.url(&rory.url)
.image(rory.url)
.footer(footer)
}
};
let reply = CreateReply::default().embed(embed);
ctx.send(reply).await?;
Ok(())
}