Implement Command for ShortHelp

This commit is contained in:
Joscha 2023-02-26 19:52:28 +01:00
parent 8b8d281f8a
commit f5c5043896
2 changed files with 25 additions and 5 deletions

View file

@ -15,6 +15,7 @@ Procedure when bumping the version number:
### Added
- `bot::botrulez::Ping` now implements `bot::command::Command`
- `bot::botrulez::ShortHelp` now implements `bot::command::Command`
### Changed
- Instances log to target `euphoxide::live::<name>`

View file

@ -2,13 +2,9 @@ use async_trait::async_trait;
use clap::Parser;
use crate::api::Message;
use crate::bot::command::{ClapCommand, Context};
use crate::bot::command::{ClapCommand, Command, Context};
use crate::conn;
/// Show short bot help.
#[derive(Parser)]
pub struct Args {}
pub struct ShortHelp(pub String);
impl ShortHelp {
@ -17,6 +13,29 @@ impl ShortHelp {
}
}
#[async_trait]
impl<B, E> Command<B, E> for ShortHelp
where
E: From<conn::Error>,
{
async fn execute(
&self,
arg: &str,
msg: &Message,
ctx: &Context,
_bot: &mut B,
) -> Result<(), E> {
if arg.trim().is_empty() {
ctx.reply(msg.id, &self.0).await?;
}
Ok(())
}
}
/// Show short bot help.
#[derive(Parser)]
pub struct Args {}
#[async_trait]
impl<B, E> ClapCommand<B, E> for ShortHelp
where