Implement Command for ShortHelp
This commit is contained in:
parent
8b8d281f8a
commit
f5c5043896
2 changed files with 25 additions and 5 deletions
|
|
@ -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>`
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue