From ef4c01dfb322fc2de74abdcdd9c97331c2475943 Mon Sep 17 00:00:00 2001 From: kageru Date: Thu, 31 Oct 2019 22:35:07 +0100 Subject: [PATCH] Add !pb help/!pacbot help command --- src/commands/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/commands/mod.rs b/src/commands/mod.rs index d238e9b..c30a678 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -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::>() + .join(", "); + send(msg.channel_id, + &format!("Usage: ` `\nSupported commands: `{}`\nSource code: https://git.kageru.moe/kageru/pacbot", + command_triggers), &ctx) +} + lazy_static! { static ref COMMANDS: Vec = { 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 }; }