aboutsummaryrefslogtreecommitdiff
path: root/lib/models/id/guild_id_t.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/models/id/guild_id_t.ml')
-rw-r--r--lib/models/id/guild_id_t.ml12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/models/id/guild_id_t.ml b/lib/models/id/guild_id_t.ml
index 6fc3777..a39c07d 100644
--- a/lib/models/id/guild_id_t.ml
+++ b/lib/models/id/guild_id_t.ml
@@ -1,7 +1,15 @@
open Core
-type t = [ `Guild_id of Snowflake.t ] [@@deriving sexp, yojson]
+type t = [ `Guild_id of Snowflake.t ] [@@deriving sexp]
-let compare (`Guild_id t) (`Guild_id t') = Int64.compare t t'
+let compare (`Guild_id t) (`Guild_id t') = Int.compare t t'
+
+let of_yojson a : (t, string) result =
+ match Snowflake.of_yojson a with
+ | Ok id -> Ok (`Guild_id id)
+ | Error err -> Error err
+
+let of_yojson_exn a : t = `Guild_id (Snowflake.of_yojson_exn a)
+let to_yojson (`Guild_id id) = (Snowflake.to_yojson id)
let get_id (`Guild_id id) = id \ No newline at end of file