Add !pb help/!pacbot help command

This commit is contained in:
kageru 2019-10-31 22:35:07 +01:00
parent 258c6dbc9a
commit ef4c01dfb3
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

View File

@ -45,6 +45,18 @@ impl EventHandler for Handler {
}
}
fn help(ctx: Context, msg: Message, _args: Vec<&str>) {
let command_triggers = COMMANDS
.iter()
.filter(|&c| !c.trigger.contains("help"))
.map(|c| c.trigger.clone())
.collect::<Vec<_>>()
.join(", ");
send(msg.channel_id,
&format!("Usage: `<command> <search term>`\nSupported commands: `{}`\nSource code: https://git.kageru.moe/kageru/pacbot",
command_triggers), &ctx)
}
lazy_static! {
static ref COMMANDS: Vec<Command> = {
let mut command_list = Vec::new();
@ -52,6 +64,8 @@ lazy_static! {
command_list.push(Command::new("apt", apt::query_apt));
command_list.push(Command::new("nix", nix::query_nix));
command_list.push(Command::new("dnf", dnf::query_dnf));
command_list.push(Command::new("pacbot help", help));
command_list.push(Command::new("pb help", help));
command_list
};
}