aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorAdelyn Breelove <[email protected]>2019-01-21 13:50:14 -0700
committerAdelyn Breelove <[email protected]>2019-01-21 13:50:14 -0700
commit3dfa0c4d0247bfddae476372414808cd219004f8 (patch)
tree2b0b4b8f7846918c55b6b698454c9d63251dbd1a /bin
parentFix sharding logic (diff)
downloaddisml-3dfa0c4d0247bfddae476372414808cd219004f8.tar.xz
disml-3dfa0c4d0247bfddae476372414808cd219004f8.zip
Add status change command example
Diffstat (limited to 'bin')
-rw-r--r--bin/bot.ml17
1 files changed, 14 insertions, 3 deletions
diff --git a/bin/bot.ml b/bin/bot.ml
index 1aae20b..0acc0a1 100644
--- a/bin/bot.ml
+++ b/bin/bot.ml
@@ -2,6 +2,8 @@ open Async
open Core
open Disml
+let client = Ivar.create ()
+
let check_command (msg:Message.t) =
let cmd, rest = match String.split ~on:' ' msg.content with
| hd::tl -> hd, tl
@@ -49,18 +51,27 @@ let check_command (msg:Message.t) =
|> field ("field 1", "test", true)
) in
Message.reply_with ~embed msg >>> ignore
+ | "!status" ->
+ let status = List.fold ~init:"" ~f:(^) rest in
+ Ivar.read client >>> fun client ->
+ Client.set_status ~status:(`String status) client
+ >>> ignore
| _ -> ()
-let main () =
+let setup_logger () =
Logs.set_reporter (Logs_fmt.reporter ());
- Logs.set_level ~all:true (Some Logs.Debug);
+ Logs.set_level ~all:true (Some Logs.Debug)
+
+let main () =
+ setup_logger ();
Client.message_create := check_command;
let token = match Sys.getenv "DISCORD_TOKEN" with
| Some t -> t
| None -> failwith "No token in env"
in
Client.start token
- >>> ignore
+ >>> fun c ->
+ Ivar.fill client c
let _ =
Scheduler.go_main ~main ()