servers/src/commands/help.rs

26 lines
616 B
Rust
Raw Normal View History

2022-06-04 11:58:21 +00:00
use async_trait::async_trait;
2022-06-04 19:34:53 +00:00
use crate::{command_handler::Command, tcp::Client, CommandManagerType};
2022-06-04 11:58:21 +00:00
pub struct CommandHelp;
#[async_trait]
impl Command for CommandHelp {
fn name(&self) -> &'static str {
"/help"
}
fn help(&self) -> &'static str {
"show help"
}
2022-06-04 19:34:53 +00:00
async fn execute(&self, client: &mut Client, _args: Vec<&str>, commands: &CommandManagerType) {
2022-06-04 18:10:21 +00:00
for command in commands.iter() {
2022-06-04 11:58:21 +00:00
client
.send(&format!("{} - {}", command.name(), command.help()))
.await
.expect("send message");
}
}
}