use crate::error::{ManifoldError, ManifoldResult}; use crate::{ManifoldContext, ManifoldData}; use crate::models::nasa::*; #[poise::command(slash_command, prefix_command, aliases("apod"))] async fn nasa_apod(ctx: ManifoldContext<'_>) -> ManifoldResult<()> { debug!("Processing tip"); if let Some(tank) = ctx.data().bot_config.services.get("nasa_apod") { let photo: &NasaAstroPhoto = &tank.next_or_fill::().await?; debug!("Tip: {:?}", photo); ctx.send(|f| { f.content(format!("{}", photo)) .reply(true) .embed(|e| { e.title(&photo.title); e.description(&photo.explanation); e.image(&photo.hdurl); e }) }).await?; } else { error!("No such fuel tank nasa_apod"); ctx.send(|f| f.content("The NASA Astronomy Photo of the Day was missing. Try looking up instead.".to_string()).reply(true)).await?; } Ok(()) } pub fn commands() -> [poise::Command; 1] { [nasa_apod()] }