use crate::models::frogtip::{Croak, Tip}; use crate::error::{ManifoldError, ManifoldResult}; use crate::{ManifoldContext, ManifoldData}; use crate::models::animalpics::{AnimalPic, AnimalPicWrapper}; #[poise::command(slash_command, prefix_command, aliases("ft"))] async fn frog_tip(ctx: ManifoldContext<'_>) -> ManifoldResult<()> { debug!("Processing tip"); if let Some(tank) = ctx.data().bot_config.services.get("frog_tips") { let tip: &Tip = &tank.next_or_fill::().await?; debug!("Tip: {:?}", tip); ctx.send(|f| f.content(format!("{}", tip)).reply(true)).await?; } else { error!("No such fuel tank frog_tips"); ctx.send(|f| f.content("No tips could be located. Try rubbing it.".to_string()).reply(true)).await?; } Ok(()) } #[poise::command(slash_command, prefix_command, aliases("dog"))] async fn dog_pic(ctx: ManifoldContext<'_>) -> ManifoldResult<()> { animal_pic(ctx, "dog_pics").await } #[poise::command(slash_command, prefix_command, aliases("cat"))] async fn cat_pic(ctx: ManifoldContext<'_>) -> ManifoldResult<()> { animal_pic(ctx, "cat_pics").await } async fn animal_pic(ctx: ManifoldContext<'_>, tank_name: &str) -> ManifoldResult<()> { if let Some(tank) = ctx.data().bot_config.services.get(tank_name) { let pic: &AnimalPic = &tank.next_or_fill::().await?; ctx.send(|f| f.content(format!("{}", pic)).reply(true)).await?; } else { error!("No such fuel tank {}", tank_name); ctx.send(|f| f.content("No frens here at the moment. Perhaps some bacon would help?".to_string()).reply(true)).await?; } Ok(()) } pub fn commands() -> [poise::Command; 3] { [frog_tip(), dog_pic(), cat_pic()] }