diff options
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | bin/README.md | 1 | ||||
| -rw-r--r-- | bin/bot.ml | 30 |
3 files changed, 32 insertions, 2 deletions
@@ -1,3 +1,2 @@ .merlin -_build/ -bin/
\ No newline at end of file +_build/
\ No newline at end of file diff --git a/bin/README.md b/bin/README.md new file mode 100644 index 0000000..b1315e8 --- /dev/null +++ b/bin/README.md @@ -0,0 +1 @@ +# This is a test executable
\ No newline at end of file diff --git a/bin/bot.ml b/bin/bot.ml new file mode 100644 index 0000000..c08218d --- /dev/null +++ b/bin/bot.ml @@ -0,0 +1,30 @@ +open Lwt.Infix +open Animus + +let _ = + let data = Lwt_main.run (Http.get_gateway_bot ()) in + (* Yojson.Basic.pretty_print Format.std_formatter data; + print_newline (); *) + let url, _shards = match data with + | `Assoc [ + ("url", `String url); + ("shards", `Int shards); + _ + ] -> (url, shards) + | _ -> ("wss://gateway.discord.gg/", 1) + in + (Sharder.Shard.create { + url; + shards = [0; 1;]; + token = Sys.getenv "DISCORD_TOKEN"; + } + >|= fun (shard, recv_loop) -> + Lwt_engine.on_timer 60.0 true @@ begin + fun _ev -> Sharder.Shard.set_status shard + ("Current seq: " ^ string_of_int shard.seq) + >|= (fun _ -> print_endline "Status set!") + |> ignore; + end + |> ignore; + Lwt_main.run recv_loop) + |> Lwt_main.run
\ No newline at end of file |