aboutsummaryrefslogtreecommitdiff
path: root/bin/bot.ml
diff options
context:
space:
mode:
authorAdelyn Breedlove <[email protected]>2018-11-14 01:44:29 +0000
committerAdelyn Breedlove <[email protected]>2018-11-14 01:44:29 +0000
commit5bf5b020ae2b95d924cc4e39e73dd98490c7cc2d (patch)
tree9da8fb076a861afc5d21fff705484a0a57e9ab9a /bin/bot.ml
parentMerge branch 'dev' into 'master' (diff)
parentNew name who dis (diff)
downloaddisml-5bf5b020ae2b95d924cc4e39e73dd98490c7cc2d.tar.xz
disml-5bf5b020ae2b95d924cc4e39e73dd98490c7cc2d.zip
Merge branch 'dev' into 'master'
Dev See merge request Mishio595/disml!3
Diffstat (limited to 'bin/bot.ml')
-rw-r--r--bin/bot.ml40
1 files changed, 15 insertions, 25 deletions
diff --git a/bin/bot.ml b/bin/bot.ml
index c08218d..bf9f36e 100644
--- a/bin/bot.ml
+++ b/bin/bot.ml
@@ -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