diff options
| author | Mishio595 <[email protected]> | 2018-11-18 12:04:19 -0700 |
|---|---|---|
| committer | Mishio595 <[email protected]> | 2018-11-18 12:04:19 -0700 |
| commit | a7340eba42bcef93a4e6f9ece7c86043f9a01747 (patch) | |
| tree | 7ec65e89673ad8d9e70b12482206e27e9fa77704 /bin | |
| parent | Rewrite from Lwt to Async (diff) | |
| download | disml-a7340eba42bcef93a4e6f9ece7c86043f9a01747.tar.xz disml-a7340eba42bcef93a4e6f9ece7c86043f9a01747.zip | |
Event dispatch and client abstraction
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/bot.ml | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -1,4 +1,5 @@ open Async +open Core open Disml let main () = @@ -6,8 +7,24 @@ let main () = | Some s -> s | None -> failwith "No token" in - Sharder.start token - |> ignore + let client = Client.make token in + Client.on "MESSAGE_CREATE" client (fun msg -> + let content = Yojson.Basic.Util.(member "content" msg |> to_string) in + let channel = Yojson.Basic.Util.(member "channel_id" msg |> to_string) in + if String.is_prefix ~prefix:"!?ping" content then + Http.create_message channel @@ `Assoc [ + ("content", `String "Pong!"); + ("tts", `Bool false); + ] + >>> fun _ -> print_endline "Message sent!"; + ); + Client.start client + >>> fun client -> + Clock.every + (Time.Span.create ~sec:60 ()) + (fun () -> + Client.set_status_with client (fun shard -> `String ("Current seq: " ^ (Int.to_string shard.seq))) + |> ignore) let _ = - Scheduler.go_main ~main:(main) ()
\ No newline at end of file + Scheduler.go_main ~main ()
\ No newline at end of file |