27 lines
875 B
Rust
27 lines
875 B
Rust
use crate::error::{ManifoldError, ManifoldResult};
|
|
use crate::{ManifoldContext, ManifoldData};
|
|
use crate::models::dadjoke::{DadJoke, DadJokeWrapper};
|
|
|
|
#[poise::command(slash_command, prefix_command, aliases("dad"))]
|
|
async fn dad_joke(ctx: ManifoldContext<'_>) -> ManifoldResult<()> {
|
|
|
|
debug!("Processing tip");
|
|
|
|
if let Some(tank) = ctx.data().bot_config.services.get("dad_jokes") {
|
|
let tip: &DadJoke = &tank.next_or_fill::<DadJoke, DadJokeWrapper>().await?;
|
|
|
|
debug!("Tip: {:?}", tip);
|
|
|
|
ctx.send(|f| f.content(format!("{}", tip)).reply(true)).await?;
|
|
} else {
|
|
error!("No such fuel tank dad_jokes");
|
|
ctx.send(|f| f.content("Can't find any dad jokes. Maybe your dad isn't funny.".to_string()).reply(true)).await?;
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
pub fn commands() -> [poise::Command<ManifoldData, ManifoldError>; 1] {
|
|
[dad_joke()]
|
|
}
|