aboutsummaryrefslogtreecommitdiff
path: root/lib/models/channel/channel.ml
diff options
context:
space:
mode:
authorAdelyn Breelove <[email protected]>2019-01-23 10:40:04 -0700
committerAdelyn Breelove <[email protected]>2019-01-23 10:40:04 -0700
commitf23a12be25f819b9cc9ae05829b14edb6807082f (patch)
treee90bf9fa5a469c9707feccce9bf3926858c67f35 /lib/models/channel/channel.ml
parentfix a doc typo (diff)
downloaddisml-f23a12be25f819b9cc9ae05829b14edb6807082f.tar.xz
disml-f23a12be25f819b9cc9ae05829b14edb6807082f.zip
Guild ID and Channel ID abstractions
Diffstat (limited to 'lib/models/channel/channel.ml')
-rw-r--r--lib/models/channel/channel.ml56
1 files changed, 1 insertions, 55 deletions
diff --git a/lib/models/channel/channel.ml b/lib/models/channel/channel.ml
index 972f888..68b3a97 100644
--- a/lib/models/channel/channel.ml
+++ b/lib/models/channel/channel.ml
@@ -1,57 +1,3 @@
-open Async
-open Core
include Channel_t
-exception Invalid_message
-exception No_message_found
-
-let say ~content ch =
- Http.create_message (get_id ch) (`Assoc [("content", `String content)])
- >>| Result.map ~f:Message_t.of_yojson_exn
-
-let send_message ?embed ?content ?file ?(tts=false) ch =
- let embed = match embed with
- | Some e -> Embed.to_yojson e
- | None -> `Null in
- let content = match content with
- | Some c -> `String c
- | None -> `Null in
- let file = match file with
- | Some f -> `String f
- | None -> `Null in
- let () = match embed, content with
- | `Null, `Null -> raise Invalid_message
- | _ -> () in
- Http.create_message (get_id ch) (`Assoc [
- ("embed", embed);
- ("content", content);
- ("file", file);
- ("tts", `Bool tts);
- ]) >>| Result.map ~f:Message_t.of_yojson_exn
-
-let delete ch =
- Http.delete_channel (get_id ch) >>| Result.map ~f:ignore
-
-let get_message ~id ch =
- Http.get_message (get_id ch) id >>| Result.map ~f:Message_t.of_yojson_exn
-
-let get_messages ?(mode=`Around) ?id ?(limit=50) ch =
- let kind = match mode with
- | `Around -> "around", limit
- | `Before -> "before", limit
- | `After -> "after", limit
- in
- let id = match id with
- | Some id -> id
- | None -> raise No_message_found in
- Http.get_messages (get_id ch) id kind >>| Result.map ~f:(fun l ->
- Yojson.Safe.Util.to_list l
- |> List.map ~f:Message_t.of_yojson_exn)
-
-let broadcast_typing ch =
- Http.broadcast_typing (get_id ch) >>| Result.map ~f:ignore
-
-let get_pins ch =
- Http.get_pinned_messages (get_id ch) >>| Result.map ~f:(fun l ->
- Yojson.Safe.Util.to_list l
- |> List.map ~f:Message_t.of_yojson_exn) \ No newline at end of file
+include Impl.Channel(Channel_t) \ No newline at end of file