blob: c08218d424b666b5c1a91d8180e0bc3e36ccf7a5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
|