use async_trait::async_trait; use clap::Parser; use crate::api::Message; use crate::bot::command::{ClapCommand, Command, Context}; use crate::conn; pub struct Ping(pub String); impl Ping { pub fn new(reply: S) -> Self { Self(reply.to_string()) } } impl Default for Ping { fn default() -> Self { Self::new("Pong!") } } #[async_trait] impl Command for Ping where E: From, { async fn execute( &self, arg: &str, msg: &Message, ctx: &Context, _bot: &mut B, ) -> Result { if arg.trim().is_empty() { ctx.reply(msg.id, &self.0).await?; Ok(true) } else { Ok(false) } } } /// Trigger a short reply. #[derive(Parser)] pub struct Args {} #[async_trait] impl ClapCommand for Ping where E: From, { type Args = Args; async fn execute( &self, _args: Self::Args, msg: &Message, ctx: &Context, _bot: &mut B, ) -> Result { ctx.reply(msg.id, &self.0).await?; Ok(true) } }