diff options
| author | Adelyn Breedlove <[email protected]> | 2018-11-14 01:44:29 +0000 |
|---|---|---|
| committer | Adelyn Breedlove <[email protected]> | 2018-11-14 01:44:29 +0000 |
| commit | 5bf5b020ae2b95d924cc4e39e73dd98490c7cc2d (patch) | |
| tree | 9da8fb076a861afc5d21fff705484a0a57e9ab9a /bin | |
| parent | Merge branch 'dev' into 'master' (diff) | |
| parent | New name who dis (diff) | |
| download | disml-5bf5b020ae2b95d924cc4e39e73dd98490c7cc2d.tar.xz disml-5bf5b020ae2b95d924cc4e39e73dd98490c7cc2d.zip | |
Merge branch 'dev' into 'master'
Dev
See merge request Mishio595/disml!3
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/bot.ml | 40 |
1 files changed, 15 insertions, 25 deletions
@@ -1,30 +1,20 @@ open Lwt.Infix -open Animus +open Disml -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; +let main sharder = + Lwt_engine.on_timer 60.0 true begin + fun _ev -> Sharder.set_status_with sharder @@ begin + fun shard -> + `String ("Current seq: " ^ string_of_int shard.seq) + end + >|= (fun _ -> print_endline "Status set!") + |> ignore; end + +let _ = + Sharder.start @@ Sys.getenv "DISCORD_TOKEN" + >>= (fun sharder -> + main sharder |> ignore; - Lwt_main.run recv_loop) + sharder.promise) |> Lwt_main.run
\ No newline at end of file |