aboutsummaryrefslogtreecommitdiff
path: root/lib/models
diff options
context:
space:
mode:
authorAdelyn Breelove <[email protected]>2018-12-17 16:09:35 -0700
committerAdelyn Breelove <[email protected]>2018-12-17 16:09:35 -0700
commit792c8c437f45d9fd2529f1ccab27faf79d98ba91 (patch)
tree3c8f5e59d617219a3d442083c29d5cbdfa6ffdb5 /lib/models
parentMore stuff (diff)
downloaddisml-792c8c437f45d9fd2529f1ccab27faf79d98ba91.tar.xz
disml-792c8c437f45d9fd2529f1ccab27faf79d98ba91.zip
Some refactoring of http code
Diffstat (limited to 'lib/models')
-rw-r--r--lib/models/guild.ml8
-rw-r--r--lib/models/message.ml1
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/models/guild.ml b/lib/models/guild.ml
index 7364327..381de15 100644
--- a/lib/models/guild.ml
+++ b/lib/models/guild.ml
@@ -48,18 +48,18 @@ module Make(Http : S.Http) = struct
let get_channel ~id guild =
match List.find ~f:(fun c -> c.id = id) guild.channels with
- | Some c -> return c
+ | Some c -> Deferred.Or_error.return c
| None -> Http.get_channel id >>| fun c ->
- c |> Yojson.Safe.to_string |> Channel_j.t_of_string
+ Result.(c >>| Channel_j.t_of_string)
let get_emoji ~id guild = Http.get_emoji guild.id id
let get_invites guild = Http.get_guild_invites guild.id
let get_member ~id guild =
match List.find ~f:(fun m -> m.user.id = id) guild.members with
- | Some m -> return m
+ | Some m -> Deferred.Or_error.return m
| None -> Http.get_member guild.id id >>| fun m ->
- m |> Yojson.Safe.to_string |> Member_j.t_of_string
+ Result.(m >>| Member_j.t_of_string)
let get_prune_count ~days guild = Http.guild_prune_count guild.id days
diff --git a/lib/models/message.ml b/lib/models/message.ml
index 29148ee..222edf8 100644
--- a/lib/models/message.ml
+++ b/lib/models/message.ml
@@ -1,4 +1,5 @@
module Make(Http : S.Http) = struct
+ open Async
open Message_t
let add_reaction msg (emoji:Emoji_t.t) =