From 131d64e7b8b92ca63608bcfbcd564ec0cb592aa9 Mon Sep 17 00:00:00 2001 From: Adelyn Breedlove Date: Sun, 3 Mar 2019 20:27:19 -0700 Subject: Add a restart command --- bin/bot.ml | 3 ++- bin/commands.ml | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/bot.ml b/bin/bot.ml index d28c8be..8be038d 100644 --- a/bin/bot.ml +++ b/bin/bot.ml @@ -7,7 +7,7 @@ module String = Base.String (* Define a function to handle message_create *) let check_command (message:Message.t) = (* Simple example of command parsing. *) - let cmd, rest = match String.split ~on:' ' message.content with + let cmd, rest = match String.split ~on:' ' (String.lowercase message.content) with | hd::tl -> hd, tl | [] -> "", [] in match cmd with @@ -19,6 +19,7 @@ let check_command (message:Message.t) = | "!echo" -> Commands.echo message rest (* | "!cache" -> Commands.cache message rest *) | "!shutdown" -> Commands.shutdown message rest + | "!restart" -> Commands.restart message rest | "!rgm" -> Commands.request_members message rest (* | "!new" -> Commands.new_guild message rest *) (* | "!delall" -> Commands.delete_guilds message rest *) diff --git a/bin/commands.ml b/bin/commands.ml index a278b5d..1becccc 100644 --- a/bin/commands.ml +++ b/bin/commands.ml @@ -108,6 +108,11 @@ let shutdown (message:Message.t) _args = exit 0 else Lwt.return_unit +let restart (message:Message.t) _args = + if message.author.id = `User_id 242675474927583232 then + client >>= Client.shutdown_all + else Lwt.return_unit + (* Request guild members to be sent over the gateway for the guild the command is run in. This will cause multiple GUILD_MEMBERS_CHUNK events. *) let request_members (message:Message.t) _args = client >>= fun client -> -- cgit v1.2.3