diff options
| author | Adelyn Breelove <[email protected]> | 2019-01-17 10:50:19 -0700 |
|---|---|---|
| committer | Adelyn Breelove <[email protected]> | 2019-01-17 10:50:19 -0700 |
| commit | 43810b9bc49b6c45f143fb8a458ceb4d691bd20f (patch) | |
| tree | 40013f3a7750f5a320fe8f7cc3a8de56e64c04a2 | |
| parent | Fix mli files and add member methods back (diff) | |
| download | disml-43810b9bc49b6c45f143fb8a458ceb4d691bd20f.tar.xz disml-43810b9bc49b6c45f143fb8a458ceb4d691bd20f.zip | |
fix up the example
| -rw-r--r-- | bin/bot.ml | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -2,6 +2,26 @@ open Async open Core open Disml +let check_command (msg:Message.t) = + if String.is_prefix ~prefix:"!ping" msg.content then + Message.reply msg "Pong!" >>> ignore + else if String.is_prefix ~prefix:"!spam" msg.content then + let count = String.chop_prefix_exn ~prefix:"!spam" msg.content |> String.strip |> Int.of_string in + List.range 0 count + |> List.iter ~f:(fun i -> Message.reply msg (string_of_int i) >>> ignore) + else if String.is_prefix ~prefix:"!list" msg.content then + let count = String.chop_prefix_exn ~prefix:"!list" msg.content |> String.strip |> Int.of_string in + let list = List.range 0 count + |> List.sexp_of_t Int.sexp_of_t + |> Sexp.to_string_hum in + Message.reply msg list >>> ignore + else if String.is_prefix ~prefix:"!fold" msg.content then + let count = String.chop_prefix_exn ~prefix:"!fold" msg.content |> String.strip |> Int.of_string in + let list = List.range 0 count + |> List.fold ~init:0 ~f:(+) + |> Int.to_string in + Message.reply msg list >>> ignore + let main () = let token = match Sys.getenv "DISCORD_TOKEN" with | Some t -> t @@ -11,5 +31,5 @@ let main () = >>> ignore let _ = - Client.message_create := (fun msg -> print_endline msg.content); + Client.message_create := check_command; Scheduler.go_main ~main () |