2022-08-12 20:32:22 +00:00
|
|
|
use crate::plugins::prelude::*;
|
2022-06-04 11:58:21 +00:00
|
|
|
|
2022-08-12 20:32:22 +00:00
|
|
|
pub struct Help;
|
2022-06-04 11:58:21 +00:00
|
|
|
|
|
|
|
#[async_trait]
|
2022-08-12 20:32:22 +00:00
|
|
|
impl Command for Help {
|
2022-06-04 11:58:21 +00:00
|
|
|
fn name(&self) -> &'static str {
|
|
|
|
"/help"
|
|
|
|
}
|
|
|
|
|
2022-08-12 20:32:22 +00:00
|
|
|
fn aliases(&self) -> Vec<&'static str> {
|
|
|
|
vec!["/h", "/?", "?"]
|
|
|
|
}
|
|
|
|
|
2022-06-04 11:58:21 +00:00
|
|
|
fn help(&self) -> &'static str {
|
2022-08-12 20:32:22 +00:00
|
|
|
"Show commands help menu"
|
2022-06-04 11:58:21 +00:00
|
|
|
}
|
|
|
|
|
2022-08-12 20:32:22 +00:00
|
|
|
fn usage(&self) -> &'static str {
|
|
|
|
"/help"
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn execute(&self, client: &Client, _args: Vec<&str>) -> anyhow::Result<()> {
|
|
|
|
let mut msg = Vec::new();
|
|
|
|
|
|
|
|
for cmd in client.plugins_manager.commands.iter() {
|
|
|
|
let aliases = cmd.aliases();
|
|
|
|
|
|
|
|
let aliases = if !aliases.is_empty() {
|
|
|
|
cmd.aliases().join(", ")
|
|
|
|
} else {
|
|
|
|
"none".to_string()
|
|
|
|
};
|
|
|
|
|
|
|
|
msg.push(format!(
|
|
|
|
"{name} - {help} (Aliases: {aliases})",
|
|
|
|
name = cmd.name(),
|
|
|
|
help = cmd.help(),
|
|
|
|
aliases = aliases,
|
|
|
|
))
|
2022-06-04 11:58:21 +00:00
|
|
|
}
|
2022-06-23 09:07:42 +00:00
|
|
|
|
2022-08-12 20:52:47 +00:00
|
|
|
client.send(msg.join("\n"))
|
2022-06-04 11:58:21 +00:00
|
|
|
}
|
|
|
|
}
|