diff options
| author | Adelyn Breedlove <[email protected]> | 2018-12-21 16:22:49 +0000 |
|---|---|---|
| committer | Adelyn Breedlove <[email protected]> | 2018-12-21 16:22:49 +0000 |
| commit | c23f6b323a7231cd2caee6520dc709799508c87e (patch) | |
| tree | 4c238d53d2cbd9362f04044351582dd5f5e56d79 | |
| parent | Merge branch 'dev' into 'master' (diff) | |
| parent | Update README (diff) | |
| download | disml-c23f6b323a7231cd2caee6520dc709799508c87e.tar.xz disml-c23f6b323a7231cd2caee6520dc709799508c87e.zip | |
Merge branch 'dev' into 'master'
Merge work from dev
See merge request Mishio595/disml!11
102 files changed, 1181 insertions, 12782 deletions
@@ -3,11 +3,11 @@ This is a library for creating bots on [Discord](https://discordapp.com/). Dis.ml uses JaneStreet's Async and Core libs and I highly recommend having a solid understanding of both of these before using this library. ## State of the project -This is being actively developed and is definitely still in the early stages. While you definitely could create a bot with this in its current state, you would be writing a lot of boilerplate still. +The dev branch is fully capable of creating a simple bot at this point in time. #### What is implemented? * The full Discord REST API -* Rudimentary gateway support +* Complete gateway support (sans voice) * Automatic sharding * Event dispatch to a user-defined consumer * Automatic reconnection of dropped gateway connections @@ -19,8 +19,8 @@ This is being actively developed and is definitely still in the early stages. Wh * Cache ## Getting started -In order to get started you'll first need to install OCaml (of course). I recommend using OPAM and Dune as a package manage and build tool respectively. +In order to get started you'll first need to install OCaml (of course). I recommend using OPAM and Dune as a package manager and build tool respectively. -I currently don't provide an opam build file nor is the project uploaded to opam. This will happen with the first stable release. +The project is not currently uploaded to opam. This will happen with the first stable release. If you do not use opam, see `disml.opam` for build instructions. You'll find an example bot in /bin directory. diff --git a/bin/dune b/bin/dune new file mode 100644 index 0000000..96be393 --- /dev/null +++ b/bin/dune @@ -0,0 +1,5 @@ +(executable + (name bot) + (modules bot handler) + (libraries core async_ssl disml) +)
\ No newline at end of file diff --git a/bin/handler.ml b/bin/handler.ml index 74eaefb..5b22527 100644 --- a/bin/handler.ml +++ b/bin/handler.ml @@ -6,7 +6,22 @@ module Make(Models : Disml.S.Models) = struct let check_command (msg:Disml.Message_t.t) = if String.is_prefix ~prefix:"!ping" msg.content then - Message.reply msg "Hello!" >>> ignore + Message.reply msg "Pong!" >>> ignore + else if String.is_prefix ~prefix:"!spam" msg.content then + List.range 0 20 + |> 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 handle_event = function | HELLO _ -> print_endline "Received HELLO" diff --git a/disml.install b/disml.install index f80895d..71598ec 100644 --- a/disml.install +++ b/disml.install @@ -1,4 +1,289 @@ lib: [ "_build/install/default/lib/disml/META" {"META"} + "_build/install/default/lib/disml/activity.ml" {"activity.ml"} + "_build/install/default/lib/disml/activity_j.ml" {"activity_j.ml"} + "_build/install/default/lib/disml/activity_j.mli" {"activity_j.mli"} + "_build/install/default/lib/disml/activity_t.ml" {"activity_t.ml"} + "_build/install/default/lib/disml/activity_t.mli" {"activity_t.mli"} + "_build/install/default/lib/disml/attachment.ml" {"attachment.ml"} + "_build/install/default/lib/disml/attachment_j.ml" {"attachment_j.ml"} + "_build/install/default/lib/disml/attachment_j.mli" {"attachment_j.mli"} + "_build/install/default/lib/disml/attachment_t.ml" {"attachment_t.ml"} + "_build/install/default/lib/disml/attachment_t.mli" {"attachment_t.mli"} + "_build/install/default/lib/disml/ban.ml" {"ban.ml"} + "_build/install/default/lib/disml/ban_j.ml" {"ban_j.ml"} + "_build/install/default/lib/disml/ban_j.mli" {"ban_j.mli"} + "_build/install/default/lib/disml/ban_t.ml" {"ban_t.ml"} + "_build/install/default/lib/disml/ban_t.mli" {"ban_t.mli"} + "_build/install/default/lib/disml/channel.ml" {"channel.ml"} + "_build/install/default/lib/disml/channel_j.ml" {"channel_j.ml"} + "_build/install/default/lib/disml/channel_j.mli" {"channel_j.mli"} + "_build/install/default/lib/disml/channel_t.ml" {"channel_t.ml"} + "_build/install/default/lib/disml/channel_t.mli" {"channel_t.mli"} + "_build/install/default/lib/disml/client.ml" {"client.ml"} + "_build/install/default/lib/disml/disml.a" {"disml.a"} + "_build/install/default/lib/disml/disml.cma" {"disml.cma"} + "_build/install/default/lib/disml/disml.cmi" {"disml.cmi"} + "_build/install/default/lib/disml/disml.cmt" {"disml.cmt"} + "_build/install/default/lib/disml/disml.cmx" {"disml.cmx"} + "_build/install/default/lib/disml/disml.cmxa" {"disml.cmxa"} + "_build/install/default/lib/disml/disml.cmxs" {"disml.cmxs"} + "_build/install/default/lib/disml/disml.dune" {"disml.dune"} + "_build/install/default/lib/disml/disml.ml" {"disml.ml"} + "_build/install/default/lib/disml/disml__Activity.cmi" {"disml__Activity.cmi"} + "_build/install/default/lib/disml/disml__Activity.cmt" {"disml__Activity.cmt"} + "_build/install/default/lib/disml/disml__Activity.cmx" {"disml__Activity.cmx"} + "_build/install/default/lib/disml/disml__Activity_j.cmi" {"disml__Activity_j.cmi"} + "_build/install/default/lib/disml/disml__Activity_j.cmt" {"disml__Activity_j.cmt"} + "_build/install/default/lib/disml/disml__Activity_j.cmti" {"disml__Activity_j.cmti"} + "_build/install/default/lib/disml/disml__Activity_j.cmx" {"disml__Activity_j.cmx"} + "_build/install/default/lib/disml/disml__Activity_t.cmi" {"disml__Activity_t.cmi"} + "_build/install/default/lib/disml/disml__Activity_t.cmt" {"disml__Activity_t.cmt"} + "_build/install/default/lib/disml/disml__Activity_t.cmti" {"disml__Activity_t.cmti"} + "_build/install/default/lib/disml/disml__Activity_t.cmx" {"disml__Activity_t.cmx"} + "_build/install/default/lib/disml/disml__Attachment.cmi" {"disml__Attachment.cmi"} + "_build/install/default/lib/disml/disml__Attachment.cmt" {"disml__Attachment.cmt"} + "_build/install/default/lib/disml/disml__Attachment.cmx" {"disml__Attachment.cmx"} + "_build/install/default/lib/disml/disml__Attachment_j.cmi" {"disml__Attachment_j.cmi"} + "_build/install/default/lib/disml/disml__Attachment_j.cmt" {"disml__Attachment_j.cmt"} + "_build/install/default/lib/disml/disml__Attachment_j.cmti" {"disml__Attachment_j.cmti"} + "_build/install/default/lib/disml/disml__Attachment_j.cmx" {"disml__Attachment_j.cmx"} + "_build/install/default/lib/disml/disml__Attachment_t.cmi" {"disml__Attachment_t.cmi"} + "_build/install/default/lib/disml/disml__Attachment_t.cmt" {"disml__Attachment_t.cmt"} + "_build/install/default/lib/disml/disml__Attachment_t.cmti" {"disml__Attachment_t.cmti"} + "_build/install/default/lib/disml/disml__Attachment_t.cmx" {"disml__Attachment_t.cmx"} + "_build/install/default/lib/disml/disml__Ban.cmi" {"disml__Ban.cmi"} + "_build/install/default/lib/disml/disml__Ban.cmt" {"disml__Ban.cmt"} + "_build/install/default/lib/disml/disml__Ban.cmx" {"disml__Ban.cmx"} + "_build/install/default/lib/disml/disml__Ban_j.cmi" {"disml__Ban_j.cmi"} + "_build/install/default/lib/disml/disml__Ban_j.cmt" {"disml__Ban_j.cmt"} + "_build/install/default/lib/disml/disml__Ban_j.cmti" {"disml__Ban_j.cmti"} + "_build/install/default/lib/disml/disml__Ban_j.cmx" {"disml__Ban_j.cmx"} + "_build/install/default/lib/disml/disml__Ban_t.cmi" {"disml__Ban_t.cmi"} + "_build/install/default/lib/disml/disml__Ban_t.cmt" {"disml__Ban_t.cmt"} + "_build/install/default/lib/disml/disml__Ban_t.cmti" {"disml__Ban_t.cmti"} + "_build/install/default/lib/disml/disml__Ban_t.cmx" {"disml__Ban_t.cmx"} + "_build/install/default/lib/disml/disml__Channel.cmi" {"disml__Channel.cmi"} + "_build/install/default/lib/disml/disml__Channel.cmt" {"disml__Channel.cmt"} + "_build/install/default/lib/disml/disml__Channel.cmx" {"disml__Channel.cmx"} + "_build/install/default/lib/disml/disml__Channel_j.cmi" {"disml__Channel_j.cmi"} + "_build/install/default/lib/disml/disml__Channel_j.cmt" {"disml__Channel_j.cmt"} + "_build/install/default/lib/disml/disml__Channel_j.cmti" {"disml__Channel_j.cmti"} + "_build/install/default/lib/disml/disml__Channel_j.cmx" {"disml__Channel_j.cmx"} + "_build/install/default/lib/disml/disml__Channel_t.cmi" {"disml__Channel_t.cmi"} + "_build/install/default/lib/disml/disml__Channel_t.cmt" {"disml__Channel_t.cmt"} + "_build/install/default/lib/disml/disml__Channel_t.cmti" {"disml__Channel_t.cmti"} + "_build/install/default/lib/disml/disml__Channel_t.cmx" {"disml__Channel_t.cmx"} + "_build/install/default/lib/disml/disml__Client.cmi" {"disml__Client.cmi"} + "_build/install/default/lib/disml/disml__Client.cmt" {"disml__Client.cmt"} + "_build/install/default/lib/disml/disml__Client.cmx" {"disml__Client.cmx"} + "_build/install/default/lib/disml/disml__Dispatch.cmi" {"disml__Dispatch.cmi"} + "_build/install/default/lib/disml/disml__Dispatch.cmt" {"disml__Dispatch.cmt"} + "_build/install/default/lib/disml/disml__Dispatch.cmti" {"disml__Dispatch.cmti"} + "_build/install/default/lib/disml/disml__Dispatch.cmx" {"disml__Dispatch.cmx"} + "_build/install/default/lib/disml/disml__Embed.cmi" {"disml__Embed.cmi"} + "_build/install/default/lib/disml/disml__Embed.cmt" {"disml__Embed.cmt"} + "_build/install/default/lib/disml/disml__Embed.cmx" {"disml__Embed.cmx"} + "_build/install/default/lib/disml/disml__Embed_j.cmi" {"disml__Embed_j.cmi"} + "_build/install/default/lib/disml/disml__Embed_j.cmt" {"disml__Embed_j.cmt"} + "_build/install/default/lib/disml/disml__Embed_j.cmti" {"disml__Embed_j.cmti"} + "_build/install/default/lib/disml/disml__Embed_j.cmx" {"disml__Embed_j.cmx"} + "_build/install/default/lib/disml/disml__Embed_t.cmi" {"disml__Embed_t.cmi"} + "_build/install/default/lib/disml/disml__Embed_t.cmt" {"disml__Embed_t.cmt"} + "_build/install/default/lib/disml/disml__Embed_t.cmti" {"disml__Embed_t.cmti"} + "_build/install/default/lib/disml/disml__Embed_t.cmx" {"disml__Embed_t.cmx"} + "_build/install/default/lib/disml/disml__Emoji.cmi" {"disml__Emoji.cmi"} + "_build/install/default/lib/disml/disml__Emoji.cmt" {"disml__Emoji.cmt"} + "_build/install/default/lib/disml/disml__Emoji.cmx" {"disml__Emoji.cmx"} + "_build/install/default/lib/disml/disml__Emoji_j.cmi" {"disml__Emoji_j.cmi"} + "_build/install/default/lib/disml/disml__Emoji_j.cmt" {"disml__Emoji_j.cmt"} + "_build/install/default/lib/disml/disml__Emoji_j.cmti" {"disml__Emoji_j.cmti"} + "_build/install/default/lib/disml/disml__Emoji_j.cmx" {"disml__Emoji_j.cmx"} + "_build/install/default/lib/disml/disml__Emoji_t.cmi" {"disml__Emoji_t.cmi"} + "_build/install/default/lib/disml/disml__Emoji_t.cmt" {"disml__Emoji_t.cmt"} + "_build/install/default/lib/disml/disml__Emoji_t.cmti" {"disml__Emoji_t.cmti"} + "_build/install/default/lib/disml/disml__Emoji_t.cmx" {"disml__Emoji_t.cmx"} + "_build/install/default/lib/disml/disml__Endpoints.cmi" {"disml__Endpoints.cmi"} + "_build/install/default/lib/disml/disml__Endpoints.cmt" {"disml__Endpoints.cmt"} + "_build/install/default/lib/disml/disml__Endpoints.cmx" {"disml__Endpoints.cmx"} + "_build/install/default/lib/disml/disml__Event.cmi" {"disml__Event.cmi"} + "_build/install/default/lib/disml/disml__Event.cmt" {"disml__Event.cmt"} + "_build/install/default/lib/disml/disml__Event.cmx" {"disml__Event.cmx"} + "_build/install/default/lib/disml/disml__Guild.cmi" {"disml__Guild.cmi"} + "_build/install/default/lib/disml/disml__Guild.cmt" {"disml__Guild.cmt"} + "_build/install/default/lib/disml/disml__Guild.cmx" {"disml__Guild.cmx"} + "_build/install/default/lib/disml/disml__Guild_j.cmi" {"disml__Guild_j.cmi"} + "_build/install/default/lib/disml/disml__Guild_j.cmt" {"disml__Guild_j.cmt"} + "_build/install/default/lib/disml/disml__Guild_j.cmti" {"disml__Guild_j.cmti"} + "_build/install/default/lib/disml/disml__Guild_j.cmx" {"disml__Guild_j.cmx"} + "_build/install/default/lib/disml/disml__Guild_t.cmi" {"disml__Guild_t.cmi"} + "_build/install/default/lib/disml/disml__Guild_t.cmt" {"disml__Guild_t.cmt"} + "_build/install/default/lib/disml/disml__Guild_t.cmti" {"disml__Guild_t.cmti"} + "_build/install/default/lib/disml/disml__Guild_t.cmx" {"disml__Guild_t.cmx"} + "_build/install/default/lib/disml/disml__Http.cmi" {"disml__Http.cmi"} + "_build/install/default/lib/disml/disml__Http.cmt" {"disml__Http.cmt"} + "_build/install/default/lib/disml/disml__Http.cmti" {"disml__Http.cmti"} + "_build/install/default/lib/disml/disml__Http.cmx" {"disml__Http.cmx"} + "_build/install/default/lib/disml/disml__Member.cmi" {"disml__Member.cmi"} + "_build/install/default/lib/disml/disml__Member.cmt" {"disml__Member.cmt"} + "_build/install/default/lib/disml/disml__Member.cmx" {"disml__Member.cmx"} + "_build/install/default/lib/disml/disml__Member_j.cmi" {"disml__Member_j.cmi"} + "_build/install/default/lib/disml/disml__Member_j.cmt" {"disml__Member_j.cmt"} + "_build/install/default/lib/disml/disml__Member_j.cmti" {"disml__Member_j.cmti"} + "_build/install/default/lib/disml/disml__Member_j.cmx" {"disml__Member_j.cmx"} + "_build/install/default/lib/disml/disml__Member_t.cmi" {"disml__Member_t.cmi"} + "_build/install/default/lib/disml/disml__Member_t.cmt" {"disml__Member_t.cmt"} + "_build/install/default/lib/disml/disml__Member_t.cmti" {"disml__Member_t.cmti"} + "_build/install/default/lib/disml/disml__Member_t.cmx" {"disml__Member_t.cmx"} + "_build/install/default/lib/disml/disml__Message.cmi" {"disml__Message.cmi"} + "_build/install/default/lib/disml/disml__Message.cmt" {"disml__Message.cmt"} + "_build/install/default/lib/disml/disml__Message.cmx" {"disml__Message.cmx"} + "_build/install/default/lib/disml/disml__Message_j.cmi" {"disml__Message_j.cmi"} + "_build/install/default/lib/disml/disml__Message_j.cmt" {"disml__Message_j.cmt"} + "_build/install/default/lib/disml/disml__Message_j.cmti" {"disml__Message_j.cmti"} + "_build/install/default/lib/disml/disml__Message_j.cmx" {"disml__Message_j.cmx"} + "_build/install/default/lib/disml/disml__Message_t.cmi" {"disml__Message_t.cmi"} + "_build/install/default/lib/disml/disml__Message_t.cmt" {"disml__Message_t.cmt"} + "_build/install/default/lib/disml/disml__Message_t.cmti" {"disml__Message_t.cmti"} + "_build/install/default/lib/disml/disml__Message_t.cmx" {"disml__Message_t.cmx"} + "_build/install/default/lib/disml/disml__Models.cmi" {"disml__Models.cmi"} + "_build/install/default/lib/disml/disml__Models.cmt" {"disml__Models.cmt"} + "_build/install/default/lib/disml/disml__Models.cmti" {"disml__Models.cmti"} + "_build/install/default/lib/disml/disml__Models.cmx" {"disml__Models.cmx"} + "_build/install/default/lib/disml/disml__Opcode.cmi" {"disml__Opcode.cmi"} + "_build/install/default/lib/disml/disml__Opcode.cmt" {"disml__Opcode.cmt"} + "_build/install/default/lib/disml/disml__Opcode.cmx" {"disml__Opcode.cmx"} + "_build/install/default/lib/disml/disml__Presence.cmi" {"disml__Presence.cmi"} + "_build/install/default/lib/disml/disml__Presence.cmt" {"disml__Presence.cmt"} + "_build/install/default/lib/disml/disml__Presence.cmx" {"disml__Presence.cmx"} + "_build/install/default/lib/disml/disml__Presence_j.cmi" {"disml__Presence_j.cmi"} + "_build/install/default/lib/disml/disml__Presence_j.cmt" {"disml__Presence_j.cmt"} + "_build/install/default/lib/disml/disml__Presence_j.cmti" {"disml__Presence_j.cmti"} + "_build/install/default/lib/disml/disml__Presence_j.cmx" {"disml__Presence_j.cmx"} + "_build/install/default/lib/disml/disml__Presence_t.cmi" {"disml__Presence_t.cmi"} + "_build/install/default/lib/disml/disml__Presence_t.cmt" {"disml__Presence_t.cmt"} + "_build/install/default/lib/disml/disml__Presence_t.cmti" {"disml__Presence_t.cmti"} + "_build/install/default/lib/disml/disml__Presence_t.cmx" {"disml__Presence_t.cmx"} + "_build/install/default/lib/disml/disml__Reaction.cmi" {"disml__Reaction.cmi"} + "_build/install/default/lib/disml/disml__Reaction.cmt" {"disml__Reaction.cmt"} + "_build/install/default/lib/disml/disml__Reaction.cmx" {"disml__Reaction.cmx"} + "_build/install/default/lib/disml/disml__Reaction_j.cmi" {"disml__Reaction_j.cmi"} + "_build/install/default/lib/disml/disml__Reaction_j.cmt" {"disml__Reaction_j.cmt"} + "_build/install/default/lib/disml/disml__Reaction_j.cmti" {"disml__Reaction_j.cmti"} + "_build/install/default/lib/disml/disml__Reaction_j.cmx" {"disml__Reaction_j.cmx"} + "_build/install/default/lib/disml/disml__Reaction_t.cmi" {"disml__Reaction_t.cmi"} + "_build/install/default/lib/disml/disml__Reaction_t.cmt" {"disml__Reaction_t.cmt"} + "_build/install/default/lib/disml/disml__Reaction_t.cmti" {"disml__Reaction_t.cmti"} + "_build/install/default/lib/disml/disml__Reaction_t.cmx" {"disml__Reaction_t.cmx"} + "_build/install/default/lib/disml/disml__Rl.cmi" {"disml__Rl.cmi"} + "_build/install/default/lib/disml/disml__Rl.cmt" {"disml__Rl.cmt"} + "_build/install/default/lib/disml/disml__Rl.cmx" {"disml__Rl.cmx"} + "_build/install/default/lib/disml/disml__Role.cmi" {"disml__Role.cmi"} + "_build/install/default/lib/disml/disml__Role.cmt" {"disml__Role.cmt"} + "_build/install/default/lib/disml/disml__Role.cmx" {"disml__Role.cmx"} + "_build/install/default/lib/disml/disml__Role_j.cmi" {"disml__Role_j.cmi"} + "_build/install/default/lib/disml/disml__Role_j.cmt" {"disml__Role_j.cmt"} + "_build/install/default/lib/disml/disml__Role_j.cmti" {"disml__Role_j.cmti"} + "_build/install/default/lib/disml/disml__Role_j.cmx" {"disml__Role_j.cmx"} + "_build/install/default/lib/disml/disml__Role_t.cmi" {"disml__Role_t.cmi"} + "_build/install/default/lib/disml/disml__Role_t.cmt" {"disml__Role_t.cmt"} + "_build/install/default/lib/disml/disml__Role_t.cmti" {"disml__Role_t.cmti"} + "_build/install/default/lib/disml/disml__Role_t.cmx" {"disml__Role_t.cmx"} + "_build/install/default/lib/disml/disml__S.cmi" {"disml__S.cmi"} + "_build/install/default/lib/disml/disml__S.cmt" {"disml__S.cmt"} + "_build/install/default/lib/disml/disml__S.cmx" {"disml__S.cmx"} + "_build/install/default/lib/disml/disml__Sharder.cmi" {"disml__Sharder.cmi"} + "_build/install/default/lib/disml/disml__Sharder.cmt" {"disml__Sharder.cmt"} + "_build/install/default/lib/disml/disml__Sharder.cmti" {"disml__Sharder.cmti"} + "_build/install/default/lib/disml/disml__Sharder.cmx" {"disml__Sharder.cmx"} + "_build/install/default/lib/disml/disml__Snowflake.cmi" {"disml__Snowflake.cmi"} + "_build/install/default/lib/disml/disml__Snowflake.cmt" {"disml__Snowflake.cmt"} + "_build/install/default/lib/disml/disml__Snowflake.cmx" {"disml__Snowflake.cmx"} + "_build/install/default/lib/disml/disml__Snowflake_j.cmi" {"disml__Snowflake_j.cmi"} + "_build/install/default/lib/disml/disml__Snowflake_j.cmt" {"disml__Snowflake_j.cmt"} + "_build/install/default/lib/disml/disml__Snowflake_j.cmti" {"disml__Snowflake_j.cmti"} + "_build/install/default/lib/disml/disml__Snowflake_j.cmx" {"disml__Snowflake_j.cmx"} + "_build/install/default/lib/disml/disml__Snowflake_t.cmi" {"disml__Snowflake_t.cmi"} + "_build/install/default/lib/disml/disml__Snowflake_t.cmt" {"disml__Snowflake_t.cmt"} + "_build/install/default/lib/disml/disml__Snowflake_t.cmti" {"disml__Snowflake_t.cmti"} + "_build/install/default/lib/disml/disml__Snowflake_t.cmx" {"disml__Snowflake_t.cmx"} + "_build/install/default/lib/disml/disml__User.cmi" {"disml__User.cmi"} + "_build/install/default/lib/disml/disml__User.cmt" {"disml__User.cmt"} + "_build/install/default/lib/disml/disml__User.cmx" {"disml__User.cmx"} + "_build/install/default/lib/disml/disml__User_j.cmi" {"disml__User_j.cmi"} + "_build/install/default/lib/disml/disml__User_j.cmt" {"disml__User_j.cmt"} + "_build/install/default/lib/disml/disml__User_j.cmti" {"disml__User_j.cmti"} + "_build/install/default/lib/disml/disml__User_j.cmx" {"disml__User_j.cmx"} + "_build/install/default/lib/disml/disml__User_t.cmi" {"disml__User_t.cmi"} + "_build/install/default/lib/disml/disml__User_t.cmt" {"disml__User_t.cmt"} + "_build/install/default/lib/disml/disml__User_t.cmti" {"disml__User_t.cmti"} + "_build/install/default/lib/disml/disml__User_t.cmx" {"disml__User_t.cmx"} + "_build/install/default/lib/disml/dispatch.ml" {"dispatch.ml"} + "_build/install/default/lib/disml/dispatch.mli" {"dispatch.mli"} + "_build/install/default/lib/disml/embed.ml" {"embed.ml"} + "_build/install/default/lib/disml/embed_j.ml" {"embed_j.ml"} + "_build/install/default/lib/disml/embed_j.mli" {"embed_j.mli"} + "_build/install/default/lib/disml/embed_t.ml" {"embed_t.ml"} + "_build/install/default/lib/disml/embed_t.mli" {"embed_t.mli"} + "_build/install/default/lib/disml/emoji.ml" {"emoji.ml"} + "_build/install/default/lib/disml/emoji_j.ml" {"emoji_j.ml"} + "_build/install/default/lib/disml/emoji_j.mli" {"emoji_j.mli"} + "_build/install/default/lib/disml/emoji_t.ml" {"emoji_t.ml"} + "_build/install/default/lib/disml/emoji_t.mli" {"emoji_t.mli"} + "_build/install/default/lib/disml/endpoints.ml" {"endpoints.ml"} + "_build/install/default/lib/disml/event.ml" {"event.ml"} + "_build/install/default/lib/disml/guild.ml" {"guild.ml"} + "_build/install/default/lib/disml/guild_j.ml" {"guild_j.ml"} + "_build/install/default/lib/disml/guild_j.mli" {"guild_j.mli"} + "_build/install/default/lib/disml/guild_t.ml" {"guild_t.ml"} + "_build/install/default/lib/disml/guild_t.mli" {"guild_t.mli"} + "_build/install/default/lib/disml/http.ml" {"http.ml"} + "_build/install/default/lib/disml/http.mli" {"http.mli"} + "_build/install/default/lib/disml/member.ml" {"member.ml"} + "_build/install/default/lib/disml/member_j.ml" {"member_j.ml"} + "_build/install/default/lib/disml/member_j.mli" {"member_j.mli"} + "_build/install/default/lib/disml/member_t.ml" {"member_t.ml"} + "_build/install/default/lib/disml/member_t.mli" {"member_t.mli"} + "_build/install/default/lib/disml/message.ml" {"message.ml"} + "_build/install/default/lib/disml/message_j.ml" {"message_j.ml"} + "_build/install/default/lib/disml/message_j.mli" {"message_j.mli"} + "_build/install/default/lib/disml/message_t.ml" {"message_t.ml"} + "_build/install/default/lib/disml/message_t.mli" {"message_t.mli"} + "_build/install/default/lib/disml/models.ml" {"models.ml"} + "_build/install/default/lib/disml/models.mli" {"models.mli"} "_build/install/default/lib/disml/opam" {"opam"} + "_build/install/default/lib/disml/opcode.ml" {"opcode.ml"} + "_build/install/default/lib/disml/presence.ml" {"presence.ml"} + "_build/install/default/lib/disml/presence_j.ml" {"presence_j.ml"} + "_build/install/default/lib/disml/presence_j.mli" {"presence_j.mli"} + "_build/install/default/lib/disml/presence_t.ml" {"presence_t.ml"} + "_build/install/default/lib/disml/presence_t.mli" {"presence_t.mli"} + "_build/install/default/lib/disml/reaction.ml" {"reaction.ml"} + "_build/install/default/lib/disml/reaction_j.ml" {"reaction_j.ml"} + "_build/install/default/lib/disml/reaction_j.mli" {"reaction_j.mli"} + "_build/install/default/lib/disml/reaction_t.ml" {"reaction_t.ml"} + "_build/install/default/lib/disml/reaction_t.mli" {"reaction_t.mli"} + "_build/install/default/lib/disml/rl.ml" {"rl.ml"} + "_build/install/default/lib/disml/role.ml" {"role.ml"} + "_build/install/default/lib/disml/role_j.ml" {"role_j.ml"} + "_build/install/default/lib/disml/role_j.mli" {"role_j.mli"} + "_build/install/default/lib/disml/role_t.ml" {"role_t.ml"} + "_build/install/default/lib/disml/role_t.mli" {"role_t.mli"} + "_build/install/default/lib/disml/s.ml" {"s.ml"} + "_build/install/default/lib/disml/sharder.ml" {"sharder.ml"} + "_build/install/default/lib/disml/sharder.mli" {"sharder.mli"} + "_build/install/default/lib/disml/snowflake.ml" {"snowflake.ml"} + "_build/install/default/lib/disml/snowflake_j.ml" {"snowflake_j.ml"} + "_build/install/default/lib/disml/snowflake_j.mli" {"snowflake_j.mli"} + "_build/install/default/lib/disml/snowflake_t.ml" {"snowflake_t.ml"} + "_build/install/default/lib/disml/snowflake_t.mli" {"snowflake_t.mli"} + "_build/install/default/lib/disml/user.ml" {"user.ml"} + "_build/install/default/lib/disml/user_j.ml" {"user_j.ml"} + "_build/install/default/lib/disml/user_j.mli" {"user_j.mli"} + "_build/install/default/lib/disml/user_t.ml" {"user_t.ml"} + "_build/install/default/lib/disml/user_t.mli" {"user_t.mli"} +] +doc: [ + "_build/install/default/doc/disml/LICENSE" + "_build/install/default/doc/disml/README.md" ] @@ -1,7 +1,7 @@ opam-version: "2.0" name: "disml" version: "~dev" -synopsis: ""An OCaml library for interfacing with the Discord API"" +synopsis: "An OCaml library for interfacing with the Discord API" maintainer: "Adelyn Breedlove <[email protected]>" authors: "Adelyn Breedlove <[email protected]>" license: "MIT" @@ -11,5 +11,5 @@ build: [ ["dune" "subst"] {pinned} ["dune" "build" "-p" name "-j" jobs] ] -install: [dune install disml] +install: [] dev-repo: "git+https://gitlab.com/Mishio595/disml"
\ No newline at end of file @@ -1,42 +0,0 @@ -(library - (name disml) - (public_name disml) - (synopsis "An OCaml library for interfacing with the Discord API") - (modules - activity activity_t activity_j - attachment attachment_t attachment_j - ban ban_t ban_j - channel channel_t channel_j - embed embed_t embed_j - emoji emoji_t emoji_j - guild guild_t guild_j - member member_t member_j - message message_t message_j - presence presence_t presence_j - reaction reaction_t reaction_j - role role_t role_j - snowflake snowflake_t snowflake_j - user user_t user_j - client - dispatch - endpoints - event - http - models - opcode - rl - s - sharder - ) - (libraries core async_ssl cohttp-async yojson websocket-async zlib atdgen) - ;(preprocess (pps ppx_jane)) -) - -; Test executable -(executable - (name bot) - (modules bot handler) - (libraries core async_ssl disml) -) - -(include_subdirs unqualified) diff --git a/dune-project b/dune-project index 31a7429..67d26c0 100644 --- a/dune-project +++ b/dune-project @@ -1 +1,2 @@ (lang dune 1.3) +(name disml) diff --git a/generate_json.sh b/generate_json.sh deleted file mode 100644 index a9c497b..0000000 --- a/generate_json.sh +++ /dev/null @@ -1,7 +0,0 @@ -# Helper script for running atdgen - -for filename in ./lib/models/gen/*.atd; do - [ -e "$filename" ] || continue - atdgen -t $filename - atdgen -j $filename -done
\ No newline at end of file diff --git a/lib/models/gen/activity.atd b/lib/activity.atd index 8e02191..8e02191 100644 --- a/lib/models/gen/activity.atd +++ b/lib/activity.atd diff --git a/lib/models/gen/attachment.atd b/lib/attachment.atd index 9757b49..9757b49 100644 --- a/lib/models/gen/attachment.atd +++ b/lib/attachment.atd diff --git a/lib/models/gen/ban.atd b/lib/ban.atd index 0a87338..0a87338 100644 --- a/lib/models/gen/ban.atd +++ b/lib/ban.atd diff --git a/lib/channel.atd b/lib/channel.atd new file mode 100644 index 0000000..4094ff1 --- /dev/null +++ b/lib/channel.atd @@ -0,0 +1,79 @@ +type snowflake <ocaml from="Snowflake" t="t"> = abstract +type user <ocaml from="User" t="t"> = abstract + +type group = { + id: snowflake; + ?last_message_id: snowflake option; + ?last_pin_timestamp: string option; + ?icon: string option; + ?name: string option; + owner_id: snowflake; + recipients: user list; +} + +type dm = { + id: snowflake; + ?last_message_id: snowflake option; + ?last_pin_timestamp: string option; +} + +type guild_text = { + id: snowflake; + ?last_message_id: snowflake option; + ?last_pin_timestamp: string option; + ?category_id <json name="parent_id">: snowflake option; + guild_id: snowflake; + name: string; + position: int; + ?topic: string option; + nsfw: bool; + ?slow_mode_timeout <json name="rate_limit_per_user">: int option; +} + +type guild_voice = { + id: snowflake; + ?category_id <json name="parent_id">: snowflake option; + guild_id: snowflake; + name: string; + position: int; + ?topic: string option; + nsfw: bool; + ?user_limit: int option; + ?bitrate: int option; +} + +type category = { + id: snowflake; + ?category_id <json name="parent_id">: snowflake option; + position: int; + name: string; + nsfw: bool; +} + +type t = [ + Group of group + | Private of dm + | GuildText of guild_text + | GuildVoice of guild_voice + | Category of category +] + +type channel_wrapper = { + id: snowflake; + kind <json name="type">: int; + ?guild_id: snowflake option; + ?position: int option; + ?name: string option; + ?topic: string option; + ?nsfw: bool option; + ?last_message_id: snowflake option; + ?bitrate: int option; + ?user_limit: int option; + ?rate_limit_per_user: int option; + ?recipients: user list option; + ?icon: string option; + ?owner_id: snowflake option; + ?application_id: snowflake option; + ?category_id <json name="parent_id">: snowflake option; + ?last_pin_timestamp: string option; +}
\ No newline at end of file diff --git a/lib/dispatch.ml b/lib/dispatch.ml index c38afe2..66c6fee 100644 --- a/lib/dispatch.ml +++ b/lib/dispatch.ml @@ -1,6 +1,7 @@ module Make(H : S.Handler) : S.Dispatch = struct let dispatch ~ev contents = - print_endline (Yojson.Safe.prettify contents); + Printf.printf "Dispatching %s\n%!" ev; + (* print_endline (Yojson.Safe.prettify contents); *) Event.event_of_string ~contents ev |> H.handle_event end
\ No newline at end of file diff --git a/lib/dune b/lib/dune new file mode 100644 index 0000000..667d021 --- /dev/null +++ b/lib/dune @@ -0,0 +1,139 @@ +(rule + (targets activity_t.ml activity_t.mli) + (deps activity.atd) + (action (run atdgen -t %{deps}))) +(rule + (targets activity_j.ml activity_j.mli) + (deps activity.atd) + (action (run atdgen -j %{deps}))) +(rule + (targets attachment_t.ml attachment_t.mli) + (deps attachment.atd) + (action (run atdgen -t %{deps}))) +(rule + (targets attachment_j.ml attachment_j.mli) + (deps attachment.atd) + (action (run atdgen -j %{deps}))) +(rule + (targets ban_t.ml ban_t.mli) + (deps ban.atd) + (action (run atdgen -t %{deps}))) +(rule + (targets ban_j.ml ban_j.mli) + (deps ban.atd) + (action (run atdgen -j %{deps}))) +(rule + (targets channel_t.ml channel_t.mli) + (deps channel.atd) + (action (run atdgen -t %{deps}))) +(rule + (targets channel_j.ml channel_j.mli) + (deps channel.atd) + (action (run atdgen -j %{deps}))) +(rule + (targets embed_t.ml embed_t.mli) + (deps embed.atd) + (action (run atdgen -t %{deps}))) +(rule + (targets embed_j.ml embed_j.mli) + (deps embed.atd) + (action (run atdgen -j %{deps}))) +(rule + (targets emoji_t.ml emoji_t.mli) + (deps emoji.atd) + (action (run atdgen -t %{deps}))) +(rule + (targets emoji_j.ml emoji_j.mli) + (deps emoji.atd) + (action (run atdgen -j %{deps}))) +(rule + (targets guild_t.ml guild_t.mli) + (deps guild.atd) + (action (run atdgen -t %{deps}))) +(rule + (targets guild_j.ml guild_j.mli) + (deps guild.atd) + (action (run atdgen -j %{deps}))) +(rule + (targets member_t.ml member_t.mli) + (deps member.atd) + (action (run atdgen -t %{deps}))) +(rule + (targets member_j.ml member_j.mli) + (deps member.atd) + (action (run atdgen -j %{deps}))) +(rule + (targets message_t.ml message_t.mli) + (deps message.atd) + (action (run atdgen -t %{deps}))) +(rule + (targets message_j.ml message_j.mli) + (deps message.atd) + (action (run atdgen -j %{deps}))) +(rule + (targets presence_t.ml presence_t.mli) + (deps presence.atd) + (action (run atdgen -t %{deps}))) +(rule + (targets presence_j.ml presence_j.mli) + (deps presence.atd) + (action (run atdgen -j %{deps}))) +(rule + (targets reaction_t.ml reaction_t.mli) + (deps reaction.atd) + (action (run atdgen -t %{deps}))) +(rule + (targets reaction_j.ml reaction_j.mli) + (deps reaction.atd) + (action (run atdgen -j %{deps}))) +(rule + (targets role_t.ml role_t.mli) + (deps role.atd) + (action (run atdgen -t %{deps}))) +(rule + (targets role_j.ml role_j.mli) + (deps role.atd) + (action (run atdgen -j %{deps}))) +(rule + (targets snowflake_t.ml snowflake_t.mli) + (deps snowflake.atd) + (action (run atdgen -t %{deps}))) +(rule + (targets snowflake_j.ml snowflake_j.mli) + (deps snowflake.atd) + (action (run atdgen -j %{deps}))) +(rule + (targets user_t.ml user_t.mli) + (deps user.atd) + (action (run atdgen -t %{deps}))) +(rule + (targets user_j.ml user_j.mli) + (deps user.atd) + (action (run atdgen -j %{deps}))) + +(library + (name disml) + (public_name disml) + (synopsis "An OCaml library for interfacing with the Discord API") + (modules + activity_t activity_j + attachment_t attachment_j + ban_t ban_j + channel_t channel_j + embed_t embed_j + emoji_t emoji_j + guild_t guild_j + member_t member_j + message_t message_j + presence_t presence_j + reaction_t reaction_j + role_t role_j + snowflake_t snowflake_j + user_t user_j + activity attachment ban channel embed emoji guild member message presence reaction role snowflake user client dispatch endpoints event http models opcode rl s sharder + ) + (libraries core async_ssl cohttp-async yojson websocket-async zlib atdgen) + (preprocess (pps ppx_jane)) +) + +(include_subdirs unqualified) diff --git a/lib/models/gen/embed.atd b/lib/embed.atd index 0d3aed4..0d3aed4 100644 --- a/lib/models/gen/embed.atd +++ b/lib/embed.atd diff --git a/lib/models/gen/emoji.atd b/lib/emoji.atd index 877323b..877323b 100644 --- a/lib/models/gen/emoji.atd +++ b/lib/emoji.atd diff --git a/lib/endpoints.ml b/lib/endpoints.ml index 12563b0..c23ae88 100644 --- a/lib/endpoints.ml +++ b/lib/endpoints.ml @@ -59,4 +59,5 @@ let guild_audit_logs = sprintf "/guilds/%d/audit-logs" let cdn_embed_avatar = sprintf "/embed/avatars/%s.png" let cdn_emoji = sprintf "/emojis/%s.%s" let cdn_icon = sprintf "/icons/%d/%s.%s" -let cdn_avatar = sprintf "/splashes/%d/%s.%s"
\ No newline at end of file +let cdn_avatar = sprintf "/avatars/%d/%s.%s" +let cdn_default_avatar = sprintf "/embed/avatars/%d"
\ No newline at end of file diff --git a/lib/event.ml b/lib/event.ml index 6e35c75..8e04fee 100644 --- a/lib/event.ml +++ b/lib/event.ml @@ -39,14 +39,34 @@ type t = exception Invalid_event of string +let wrap_role ~guild_id role = + let open Role_t in + let {id;name;colour;hoist;position;permissions;managed;mentionable} = role in + {id;name;colour;hoist;position;permissions;managed;mentionable;guild_id} + +let wrap_member ~guild_id member = + let open Member_t in + let {nick;roles;joined_at;deaf;mute;user} = member in + {nick;roles;joined_at;deaf;mute;user;guild_id} + +let wrap_channel s : Channel_t.t = + let module J = Yojson.Safe in + match J.(from_string s |> Util.member "kind" |> Util.to_int) with + | 0 -> `GuildText (Channel_j.guild_text_of_string s) + | 1 -> `Private (Channel_j.dm_of_string s) + | 2 -> `GuildVoice (Channel_j.guild_voice_of_string s) + | 3 -> `Group (Channel_j.group_of_string s) + | 4 -> `Category (Channel_j.category_of_string s) + | _ -> raise (Invalid_event s) + let event_of_string ~contents t = match t with | "HELLO" -> HELLO (Yojson.Safe.from_string contents) | "READY" -> READY (Yojson.Safe.from_string contents) | "RESUMED" -> RESUMED (Yojson.Safe.from_string contents) | "INVALID_SESSION" -> INVALID_SESSION (Yojson.Safe.from_string contents) - | "CHANNEL_CREATE" -> CHANNEL_CREATE (Channel_j.t_of_string contents) - | "CHANNEL_UPDATE" -> CHANNEL_UPDATE (Channel_j.t_of_string contents) - | "CHANNEL_DELETE" -> CHANNEL_DELETE (Channel_j.t_of_string contents) + | "CHANNEL_CREATE" -> CHANNEL_CREATE (wrap_channel contents) + | "CHANNEL_UPDATE" -> CHANNEL_UPDATE (wrap_channel contents) + | "CHANNEL_DELETE" -> CHANNEL_DELETE (wrap_channel contents) | "CHANNEL_PINS_UPDATE" -> CHANNEL_PINS_UPDATE (Yojson.Safe.from_string contents) | "GUILD_CREATE" -> GUILD_CREATE (Guild_j.t_of_string contents) | "GUILD_UPDATE" -> GUILD_UPDATE (Guild_j.t_of_string contents) @@ -55,13 +75,13 @@ let event_of_string ~contents t = match t with | "GUILD_BAN_REMOVE" -> GUILD_BAN_REMOVE (Ban_j.t_of_string contents) | "GUILD_EMOJIS_UPDATE" -> GUILD_EMOJIS_UPDATE (Yojson.Safe.from_string contents) | "GUILD_INTEGRATIONS_UPDATE" -> GUILD_INTEGRATIONS_UPDATE (Yojson.Safe.from_string contents) - | "GUILD_MEMBER_ADD" -> GUILD_MEMBER_ADD (Member_j.t_of_string contents) - | "GUILD_MEMBER_REMOVE" -> GUILD_MEMBER_REMOVE (Member_j.t_of_string contents) - | "GUILD_MEMBER_UPDATE" -> GUILD_MEMBER_UPDATE (Member_j.t_of_string contents) + | "GUILD_MEMBER_ADD" -> GUILD_MEMBER_ADD (let Member_t.{guild_id;member} = Member_j.member_update_of_string contents in wrap_member ~guild_id member) + | "GUILD_MEMBER_REMOVE" -> GUILD_MEMBER_REMOVE (let Member_t.{guild_id;member} = Member_j.member_update_of_string contents in wrap_member ~guild_id member) + | "GUILD_MEMBER_UPDATE" -> GUILD_MEMBER_UPDATE (let Member_t.{guild_id;member} = Member_j.member_update_of_string contents in wrap_member ~guild_id member) | "GUILD_MEMBERS_CHUNK" -> GUILD_MEMBERS_CHUNK (Yojson.Safe.(from_string contents |> Util.to_list) |> List.map ~f:(fun m -> Yojson.Safe.to_string m |> Member_j.t_of_string)) - | "GUILD_ROLE_CREATE" -> GUILD_ROLE_CREATE (Role_j.t_of_string contents) - | "GUILD_ROLE_UPDATE" -> GUILD_ROLE_UPDATE (Role_j.t_of_string contents) - | "GUILD_ROLE_DELETE" -> GUILD_ROLE_DELETE (Role_j.t_of_string contents) + | "GUILD_ROLE_CREATE" -> GUILD_ROLE_CREATE (let Role_t.{guild_id;role} = Role_j.role_update_of_string contents in wrap_role ~guild_id role) + | "GUILD_ROLE_UPDATE" -> GUILD_ROLE_UPDATE (let Role_t.{guild_id;role} = Role_j.role_update_of_string contents in wrap_role ~guild_id role) + | "GUILD_ROLE_DELETE" -> GUILD_ROLE_DELETE (let Role_t.{guild_id;role} = Role_j.role_update_of_string contents in wrap_role ~guild_id role) | "MESSAGE_CREATE" -> MESSAGE_CREATE (Message_j.t_of_string contents) | "MESSAGE_UPDATE" -> MESSAGE_UPDATE (Message_j.t_of_string contents) | "MESSAGE_DELETE" -> MESSAGE_DELETE (Message_j.t_of_string contents) diff --git a/lib/models/gen/guild.atd b/lib/guild.atd index c622eea..c290b5f 100644 --- a/lib/models/gen/guild.atd +++ b/lib/guild.atd @@ -1,8 +1,8 @@ type snowflake <ocaml from="Snowflake" t="t"> = abstract type user <ocaml from="User" t="t"> = abstract -type member <ocaml from="Member" t="t"> = abstract -type role <ocaml from="Role" t="t"> = abstract -type channel <ocaml from="Channel" t="t"> = abstract +type member <ocaml from="Member" t="member"> = abstract +type role <ocaml from="Role" t="role"> = abstract +type channel <ocaml from="Channel" t="channel_wrapper"> = abstract type emoji <ocaml from="Emoji" t="t"> = abstract @@ -28,9 +28,9 @@ type t = { ?widget_enabled: bool option; ?widget_channel: channel option; ?system_channel: channel option; - ?large: bool option; - ?unavailable: bool option; + ~large: bool; + ~unavailable: bool; ?member_count: int option; - ?members: member list option; - ?channels: channel list option; + ~members: member list; + ~channels: channel list; }
\ No newline at end of file diff --git a/lib/http.ml b/lib/http.ml index 810bdc3..f04a49f 100644 --- a/lib/http.ml +++ b/lib/http.ml @@ -1,4 +1,5 @@ module Make(T : S.Token) = struct + open Core open Async open Cohttp include T @@ -33,7 +34,12 @@ module Make(T : S.Token) = struct | Some r -> Mvar.put (Rl.find_exn !rl path) r | None -> raise Bad_response_headers) >>= fun () -> - body |> Cohttp_async.Body.to_string >>| Yojson.Safe.from_string + match resp |> Response.status |> Code.code_of_status with + | 200 -> body |> Cohttp_async.Body.to_string >>= Deferred.Or_error.return + | code -> + body |> Cohttp_async.Body.to_string >>= fun body -> + Deferred.Or_error.errorf "Unsuccessful response received: %d - %s" code body + let request ?(body=`Null) m path = rl := Rl.update ~f:(function @@ -76,8 +82,8 @@ module Make(T : S.Token) = struct let delete_channel channel_id = Base.request `DELETE (Endpoints.channel channel_id) - let get_messages channel_id = - Base.request `GET (Endpoints.channel_messages channel_id) + let get_messages channel_id limit (kind, id) = + Base.request `GET (Printf.sprintf "%s?%s=%d&limit=%d" (Endpoints.channel_messages channel_id) kind id limit) let get_message channel_id message_id = Base.request `GET (Endpoints.channel_message channel_id message_id) @@ -187,8 +193,8 @@ module Make(T : S.Token) = struct let edit_member guild_id user_id body = Base.request ~body `PATCH (Endpoints.guild_member guild_id user_id) - let remove_member guild_id user_id = - Base.request `DELETE (Endpoints.guild_member guild_id user_id) + let remove_member guild_id user_id body = + Base.request ~body `DELETE (Endpoints.guild_member guild_id user_id) let change_nickname guild_id body = Base.request ~body `PATCH (Endpoints.guild_me_nick guild_id) @@ -208,8 +214,8 @@ module Make(T : S.Token) = struct let guild_ban_add guild_id user_id body = Base.request ~body `PUT (Endpoints.guild_ban guild_id user_id) - let guild_ban_remove guild_id user_id = - Base.request `DELETE (Endpoints.guild_ban guild_id user_id) + let guild_ban_remove guild_id user_id body = + Base.request ~body `DELETE (Endpoints.guild_ban guild_id user_id) let get_roles guild_id = Base.request `GET (Endpoints.guild_roles guild_id) @@ -226,11 +232,11 @@ module Make(T : S.Token) = struct let guild_role_remove guild_id role_id = Base.request `DELETE (Endpoints.guild_role guild_id role_id) - let guild_prune_count guild_id = - Base.request `GET (Endpoints.guild_prune guild_id) + let guild_prune_count guild_id days = + Base.request `GET ((Endpoints.guild_prune guild_id) ^ "?days=" ^ Int.to_string days) - let guild_prune_start guild_id body = - Base.request ~body `POST (Endpoints.guild_prune guild_id) + let guild_prune_start guild_id days = + Base.request `POST ((Endpoints.guild_prune guild_id) ^ "?days=" ^ Int.to_string days) let get_guild_voice_regions guild_id = Base.request `GET (Endpoints.guild_voice_regions guild_id) diff --git a/lib/models/gen/member.atd b/lib/member.atd index 11d8b62..c87e40c 100644 --- a/lib/models/gen/member.atd +++ b/lib/member.atd @@ -9,7 +9,17 @@ type partial_member = { mute: bool; } -type t = { +type member = { inherit partial_member; user: user; +} + +type member_update = { + guild_id <json name="id">: snowflake; + member: member; +} + +type t = { + inherit member; + guild_id: snowflake; }
\ No newline at end of file diff --git a/lib/models/gen/message.atd b/lib/message.atd index 8611f6a..8611f6a 100644 --- a/lib/models/gen/message.atd +++ b/lib/message.atd diff --git a/lib/models.mli b/lib/models.mli new file mode 100644 index 0000000..01a8893 --- /dev/null +++ b/lib/models.mli @@ -0,0 +1 @@ +module Make(H : S.Http) : S.Models
\ No newline at end of file diff --git a/lib/models/activity.ml b/lib/models/activity.ml index 36b7d4b..6fe69b8 100644 --- a/lib/models/activity.ml +++ b/lib/models/activity.ml @@ -1,2 +1,3 @@ module Make(Http : S.Http) = struct + type t = Activity_t.t end
\ No newline at end of file diff --git a/lib/models/attachment.ml b/lib/models/attachment.ml index 36b7d4b..cd04da8 100644 --- a/lib/models/attachment.ml +++ b/lib/models/attachment.ml @@ -1,2 +1,3 @@ module Make(Http : S.Http) = struct + type t = Attachment_t.t end
\ No newline at end of file diff --git a/lib/models/ban.ml b/lib/models/ban.ml index 36b7d4b..f84fe62 100644 --- a/lib/models/ban.ml +++ b/lib/models/ban.ml @@ -1,2 +1,3 @@ module Make(Http : S.Http) = struct + type t = Ban_t.t end
\ No newline at end of file diff --git a/lib/models/channel.ml b/lib/models/channel.ml index 36b7d4b..15202b1 100644 --- a/lib/models/channel.ml +++ b/lib/models/channel.ml @@ -1,2 +1,73 @@ +exception Invalid_message +exception No_message_found + +let get_id (ch:Channel_t.t) = match ch with +| `Group g -> g.id +| `Private p -> p.id +| `GuildText t -> t.id +| `GuildVoice v -> v.id +| `Category c -> c.id + module Make(Http : S.Http) = struct + open Async + open Core + + type t = Channel_t.t + + let say ~content ch = + Http.create_message (get_id ch) (`Assoc [("content", `String content)]) + >>| Result.map ~f:Message_j.t_of_string + + let send_message ?embed ?content ?file ?(tts=false) ch = + let embed = match embed with + | Some e -> 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_j.t_of_string + + 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_j.t_of_string + + 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.(from_string l + |> Util.to_list) + |> List.map ~f:(fun i -> + Yojson.Safe.to_string i + |> Message_j.t_of_string)) + + 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.(from_string l + |> Util.to_list) + |> List.map ~f:(fun i -> + Yojson.Safe.to_string i + |> Message_j.t_of_string)) end
\ No newline at end of file diff --git a/lib/models/embed.ml b/lib/models/embed.ml index 36b7d4b..ce25e78 100644 --- a/lib/models/embed.ml +++ b/lib/models/embed.ml @@ -1,2 +1,8 @@ module Make(Http : S.Http) = struct + type footer = Embed_t.footer + type image = Embed_t.image + type video = Embed_t.video + type provider = Embed_t.provider + type field = Embed_t.field + type t = Embed_t.t end
\ No newline at end of file diff --git a/lib/models/emoji.ml b/lib/models/emoji.ml index 36b7d4b..ece5bcd 100644 --- a/lib/models/emoji.ml +++ b/lib/models/emoji.ml @@ -1,2 +1,3 @@ module Make(Http : S.Http) = struct + type t = Emoji_t.t end
\ No newline at end of file diff --git a/lib/models/gen/activity_j.ml b/lib/models/gen/activity_j.ml deleted file mode 100644 index eb1a62e..0000000 --- a/lib/models/gen/activity_j.ml +++ /dev/null @@ -1,274 +0,0 @@ -(* Auto-generated from "activity.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type t = Activity_t.t = { name: string; kind: int; url: string option } - -let write__1 = ( - Atdgen_runtime.Oj_run.write_option ( - Yojson.Safe.write_string - ) -) -let string_of__1 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__1 ob x; - Bi_outbuf.contents ob -let read__1 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _1_of_string s = - read__1 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_t : _ -> t -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"name\":"; - ( - Yojson.Safe.write_string - ) - ob x.name; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"type\":"; - ( - Yojson.Safe.write_int - ) - ob x.kind; - (match x.url with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"url\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - Bi_outbuf.add_char ob '}'; -) -let string_of_t ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_t ob x; - Bi_outbuf.contents ob -let read_t = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_name = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_kind = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_url = ref (None) in - let bits0 = ref 0 in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 3 -> ( - if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( - 2 - ) - else ( - -1 - ) - ) - | 4 -> ( - match String.unsafe_get s pos with - | 'n' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 0 - ) - else ( - -1 - ) - ) - | 't' -> ( - if String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_name := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_kind := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_url := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 3 -> ( - if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( - 2 - ) - else ( - -1 - ) - ) - | 4 -> ( - match String.unsafe_get s pos with - | 'n' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 0 - ) - else ( - -1 - ) - ) - | 't' -> ( - if String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_name := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_kind := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_url := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0x3 then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "name"; "kind" |]; - ( - { - name = !field_name; - kind = !field_kind; - url = !field_url; - } - : t) - ) -) -let t_of_string s = - read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s) diff --git a/lib/models/gen/activity_j.mli b/lib/models/gen/activity_j.mli deleted file mode 100644 index c179efb..0000000 --- a/lib/models/gen/activity_j.mli +++ /dev/null @@ -1,25 +0,0 @@ -(* Auto-generated from "activity.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type t = Activity_t.t = { name: string; kind: int; url: string option } - -val write_t : - Bi_outbuf.t -> t -> unit - (** Output a JSON value of type {!t}. *) - -val string_of_t : - ?len:int -> t -> string - (** Serialize a value of type {!t} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_t : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> t - (** Input JSON data of type {!t}. *) - -val t_of_string : - string -> t - (** Deserialize JSON data of type {!t}. *) - diff --git a/lib/models/gen/activity_t.ml b/lib/models/gen/activity_t.ml deleted file mode 100644 index 6bb2049..0000000 --- a/lib/models/gen/activity_t.ml +++ /dev/null @@ -1,4 +0,0 @@ -(* Auto-generated from "activity.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type t = { name: string; kind: int; url: string option } diff --git a/lib/models/gen/activity_t.mli b/lib/models/gen/activity_t.mli deleted file mode 100644 index 6bb2049..0000000 --- a/lib/models/gen/activity_t.mli +++ /dev/null @@ -1,4 +0,0 @@ -(* Auto-generated from "activity.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type t = { name: string; kind: int; url: string option } diff --git a/lib/models/gen/attachment_j.ml b/lib/models/gen/attachment_j.ml deleted file mode 100644 index 28f909d..0000000 --- a/lib/models/gen/attachment_j.ml +++ /dev/null @@ -1,456 +0,0 @@ -(* Auto-generated from "attachment.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type snowflake = Snowflake_t.t - -type t = Attachment_t.t = { - id: snowflake; - filename: string; - size: int; - url: string; - proxy_url: string; - height: int option; - width: int option -} - -let write_snowflake = ( - Snowflake_j.write_t -) -let string_of_snowflake ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_snowflake ob x; - Bi_outbuf.contents ob -let read_snowflake = ( - Snowflake_j.read_t -) -let snowflake_of_string s = - read_snowflake (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__1 = ( - Atdgen_runtime.Oj_run.write_option ( - Yojson.Safe.write_int - ) -) -let string_of__1 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__1 ob x; - Bi_outbuf.contents ob -let read__1 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - Atdgen_runtime.Oj_run.read_int - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_int - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _1_of_string s = - read__1 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_t : _ -> t -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"id\":"; - ( - write_snowflake - ) - ob x.id; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"filename\":"; - ( - Yojson.Safe.write_string - ) - ob x.filename; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"size\":"; - ( - Yojson.Safe.write_int - ) - ob x.size; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"url\":"; - ( - Yojson.Safe.write_string - ) - ob x.url; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"proxy_url\":"; - ( - Yojson.Safe.write_string - ) - ob x.proxy_url; - (match x.height with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"height\":"; - ( - Yojson.Safe.write_int - ) - ob x; - ); - (match x.width with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"width\":"; - ( - Yojson.Safe.write_int - ) - ob x; - ); - Bi_outbuf.add_char ob '}'; -) -let string_of_t ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_t ob x; - Bi_outbuf.contents ob -let read_t = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_id = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_filename = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_size = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_url = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_proxy_url = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_height = ref (None) in - let field_width = ref (None) in - let bits0 = ref 0 in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 3 -> ( - if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( - 3 - ) - else ( - -1 - ) - ) - | 4 -> ( - if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'z' && String.unsafe_get s (pos+3) = 'e' then ( - 2 - ) - else ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'w' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'h' then ( - 6 - ) - else ( - -1 - ) - ) - | 6 -> ( - if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'h' && String.unsafe_get s (pos+5) = 't' then ( - 5 - ) - else ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | 9 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'x' && String.unsafe_get s (pos+4) = 'y' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'u' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 'l' then ( - 4 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_filename := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - field_size := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 3 -> - field_url := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x8; - | 4 -> - field_proxy_url := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x10; - | 5 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_height := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | 6 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_width := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 3 -> ( - if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( - 3 - ) - else ( - -1 - ) - ) - | 4 -> ( - if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'z' && String.unsafe_get s (pos+3) = 'e' then ( - 2 - ) - else ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'w' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'h' then ( - 6 - ) - else ( - -1 - ) - ) - | 6 -> ( - if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'h' && String.unsafe_get s (pos+5) = 't' then ( - 5 - ) - else ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'f' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | 9 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'x' && String.unsafe_get s (pos+4) = 'y' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'u' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 'l' then ( - 4 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_filename := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - field_size := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 3 -> - field_url := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x8; - | 4 -> - field_proxy_url := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x10; - | 5 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_height := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | 6 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_width := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0x1f then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "id"; "filename"; "size"; "url"; "proxy_url" |]; - ( - { - id = !field_id; - filename = !field_filename; - size = !field_size; - url = !field_url; - proxy_url = !field_proxy_url; - height = !field_height; - width = !field_width; - } - : t) - ) -) -let t_of_string s = - read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s) diff --git a/lib/models/gen/attachment_j.mli b/lib/models/gen/attachment_j.mli deleted file mode 100644 index 6b11b08..0000000 --- a/lib/models/gen/attachment_j.mli +++ /dev/null @@ -1,55 +0,0 @@ -(* Auto-generated from "attachment.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type snowflake = Snowflake_t.t - -type t = Attachment_t.t = { - id: snowflake; - filename: string; - size: int; - url: string; - proxy_url: string; - height: int option; - width: int option -} - -val write_snowflake : - Bi_outbuf.t -> snowflake -> unit - (** Output a JSON value of type {!snowflake}. *) - -val string_of_snowflake : - ?len:int -> snowflake -> string - (** Serialize a value of type {!snowflake} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_snowflake : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> snowflake - (** Input JSON data of type {!snowflake}. *) - -val snowflake_of_string : - string -> snowflake - (** Deserialize JSON data of type {!snowflake}. *) - -val write_t : - Bi_outbuf.t -> t -> unit - (** Output a JSON value of type {!t}. *) - -val string_of_t : - ?len:int -> t -> string - (** Serialize a value of type {!t} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_t : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> t - (** Input JSON data of type {!t}. *) - -val t_of_string : - string -> t - (** Deserialize JSON data of type {!t}. *) - diff --git a/lib/models/gen/attachment_t.ml b/lib/models/gen/attachment_t.ml deleted file mode 100644 index 0485dcc..0000000 --- a/lib/models/gen/attachment_t.ml +++ /dev/null @@ -1,14 +0,0 @@ -(* Auto-generated from "attachment.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type snowflake = Snowflake_t.t - -type t = { - id: snowflake; - filename: string; - size: int; - url: string; - proxy_url: string; - height: int option; - width: int option -} diff --git a/lib/models/gen/attachment_t.mli b/lib/models/gen/attachment_t.mli deleted file mode 100644 index 0485dcc..0000000 --- a/lib/models/gen/attachment_t.mli +++ /dev/null @@ -1,14 +0,0 @@ -(* Auto-generated from "attachment.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type snowflake = Snowflake_t.t - -type t = { - id: snowflake; - filename: string; - size: int; - url: string; - proxy_url: string; - height: int option; - width: int option -} diff --git a/lib/models/gen/ban_j.ml b/lib/models/gen/ban_j.ml deleted file mode 100644 index e608f67..0000000 --- a/lib/models/gen/ban_j.ml +++ /dev/null @@ -1,235 +0,0 @@ -(* Auto-generated from "ban.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type t = Ban_t.t = { reason: string option; user: user } - -let write_user = ( - User_j.write_t -) -let string_of_user ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_user ob x; - Bi_outbuf.contents ob -let read_user = ( - User_j.read_t -) -let user_of_string s = - read_user (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__1 = ( - Atdgen_runtime.Oj_run.write_option ( - Yojson.Safe.write_string - ) -) -let string_of__1 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__1 ob x; - Bi_outbuf.contents ob -let read__1 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _1_of_string s = - read__1 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_t : _ -> t -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - (match x.reason with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"reason\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"user\":"; - ( - write_user - ) - ob x.user; - Bi_outbuf.add_char ob '}'; -) -let string_of_t ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_t ob x; - Bi_outbuf.contents ob -let read_t = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_reason = ref (None) in - let field_user = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let bits0 = ref 0 in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 4 -> ( - if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'r' then ( - 1 - ) - else ( - -1 - ) - ) - | 6 -> ( - if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'n' then ( - 0 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_reason := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 1 -> - field_user := ( - ( - read_user - ) p lb - ); - bits0 := !bits0 lor 0x1; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 4 -> ( - if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'r' then ( - 1 - ) - else ( - -1 - ) - ) - | 6 -> ( - if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'n' then ( - 0 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_reason := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 1 -> - field_user := ( - ( - read_user - ) p lb - ); - bits0 := !bits0 lor 0x1; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0x1 then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "user" |]; - ( - { - reason = !field_reason; - user = !field_user; - } - : t) - ) -) -let t_of_string s = - read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s) diff --git a/lib/models/gen/ban_j.mli b/lib/models/gen/ban_j.mli deleted file mode 100644 index 9449b5c..0000000 --- a/lib/models/gen/ban_j.mli +++ /dev/null @@ -1,47 +0,0 @@ -(* Auto-generated from "ban.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type t = Ban_t.t = { reason: string option; user: user } - -val write_user : - Bi_outbuf.t -> user -> unit - (** Output a JSON value of type {!user}. *) - -val string_of_user : - ?len:int -> user -> string - (** Serialize a value of type {!user} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_user : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> user - (** Input JSON data of type {!user}. *) - -val user_of_string : - string -> user - (** Deserialize JSON data of type {!user}. *) - -val write_t : - Bi_outbuf.t -> t -> unit - (** Output a JSON value of type {!t}. *) - -val string_of_t : - ?len:int -> t -> string - (** Serialize a value of type {!t} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_t : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> t - (** Input JSON data of type {!t}. *) - -val t_of_string : - string -> t - (** Deserialize JSON data of type {!t}. *) - diff --git a/lib/models/gen/ban_t.ml b/lib/models/gen/ban_t.ml deleted file mode 100644 index 7d9c5a0..0000000 --- a/lib/models/gen/ban_t.ml +++ /dev/null @@ -1,6 +0,0 @@ -(* Auto-generated from "ban.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type t = { reason: string option; user: user } diff --git a/lib/models/gen/ban_t.mli b/lib/models/gen/ban_t.mli deleted file mode 100644 index 7d9c5a0..0000000 --- a/lib/models/gen/ban_t.mli +++ /dev/null @@ -1,6 +0,0 @@ -(* Auto-generated from "ban.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type t = { reason: string option; user: user } diff --git a/lib/models/gen/channel.atd b/lib/models/gen/channel.atd deleted file mode 100644 index 6ab58cf..0000000 --- a/lib/models/gen/channel.atd +++ /dev/null @@ -1,19 +0,0 @@ -type snowflake <ocaml from="Snowflake" t="t"> = abstract -type user <ocaml from="User" t="t"> = abstract - -type t = { - id: snowflake; - kind <json name="type">: int; - ?guild_id: snowflake option; - ?position: int option; - ?name: string option; - ?topic: string option; - ?nsfw: bool option; - ?bitrate: int option; - ?user_limit: int option; - ?recipients: user list option; - ?icon: string option; - ?owner_id: snowflake option; - ?application_id: snowflake option; - ?parent_id: snowflake option; -}
\ No newline at end of file diff --git a/lib/models/gen/channel_j.ml b/lib/models/gen/channel_j.ml deleted file mode 100644 index 7369230..0000000 --- a/lib/models/gen/channel_j.ml +++ /dev/null @@ -1,1136 +0,0 @@ -(* Auto-generated from "channel.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type t = Channel_t.t = { - id: snowflake; - kind: int; - guild_id: snowflake option; - position: int option; - name: string option; - topic: string option; - nsfw: bool option; - bitrate: int option; - user_limit: int option; - recipients: user list option; - icon: string option; - owner_id: snowflake option; - application_id: snowflake option; - parent_id: snowflake option -} - -let write_user = ( - User_j.write_t -) -let string_of_user ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_user ob x; - Bi_outbuf.contents ob -let read_user = ( - User_j.read_t -) -let user_of_string s = - read_user (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_snowflake = ( - Snowflake_j.write_t -) -let string_of_snowflake ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_snowflake ob x; - Bi_outbuf.contents ob -let read_snowflake = ( - Snowflake_j.read_t -) -let snowflake_of_string s = - read_snowflake (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__5 = ( - Atdgen_runtime.Oj_run.write_list ( - write_user - ) -) -let string_of__5 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__5 ob x; - Bi_outbuf.contents ob -let read__5 = ( - Atdgen_runtime.Oj_run.read_list ( - read_user - ) -) -let _5_of_string s = - read__5 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__6 = ( - Atdgen_runtime.Oj_run.write_option ( - write__5 - ) -) -let string_of__6 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__6 ob x; - Bi_outbuf.contents ob -let read__6 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read__5 - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read__5 - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _6_of_string s = - read__6 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__4 = ( - Atdgen_runtime.Oj_run.write_option ( - Yojson.Safe.write_bool - ) -) -let string_of__4 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__4 ob x; - Bi_outbuf.contents ob -let read__4 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _4_of_string s = - read__4 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__3 = ( - Atdgen_runtime.Oj_run.write_option ( - Yojson.Safe.write_string - ) -) -let string_of__3 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__3 ob x; - Bi_outbuf.contents ob -let read__3 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _3_of_string s = - read__3 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__2 = ( - Atdgen_runtime.Oj_run.write_option ( - Yojson.Safe.write_int - ) -) -let string_of__2 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__2 ob x; - Bi_outbuf.contents ob -let read__2 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - Atdgen_runtime.Oj_run.read_int - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_int - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _2_of_string s = - read__2 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__1 = ( - Atdgen_runtime.Oj_run.write_option ( - write_snowflake - ) -) -let string_of__1 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__1 ob x; - Bi_outbuf.contents ob -let read__1 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read_snowflake - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_snowflake - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _1_of_string s = - read__1 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_t : _ -> t -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"id\":"; - ( - write_snowflake - ) - ob x.id; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"type\":"; - ( - Yojson.Safe.write_int - ) - ob x.kind; - (match x.guild_id with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"guild_id\":"; - ( - write_snowflake - ) - ob x; - ); - (match x.position with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"position\":"; - ( - Yojson.Safe.write_int - ) - ob x; - ); - (match x.name with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"name\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.topic with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"topic\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.nsfw with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"nsfw\":"; - ( - Yojson.Safe.write_bool - ) - ob x; - ); - (match x.bitrate with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"bitrate\":"; - ( - Yojson.Safe.write_int - ) - ob x; - ); - (match x.user_limit with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"user_limit\":"; - ( - Yojson.Safe.write_int - ) - ob x; - ); - (match x.recipients with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"recipients\":"; - ( - write__5 - ) - ob x; - ); - (match x.icon with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"icon\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.owner_id with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"owner_id\":"; - ( - write_snowflake - ) - ob x; - ); - (match x.application_id with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"application_id\":"; - ( - write_snowflake - ) - ob x; - ); - (match x.parent_id with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"parent_id\":"; - ( - write_snowflake - ) - ob x; - ); - Bi_outbuf.add_char ob '}'; -) -let string_of_t ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_t ob x; - Bi_outbuf.contents ob -let read_t = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_id = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_kind = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_guild_id = ref (None) in - let field_position = ref (None) in - let field_name = ref (None) in - let field_topic = ref (None) in - let field_nsfw = ref (None) in - let field_bitrate = ref (None) in - let field_user_limit = ref (None) in - let field_recipients = ref (None) in - let field_icon = ref (None) in - let field_owner_id = ref (None) in - let field_application_id = ref (None) in - let field_parent_id = ref (None) in - let bits0 = ref 0 in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 4 -> ( - match String.unsafe_get s pos with - | 'i' -> ( - if String.unsafe_get s (pos+1) = 'c' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'n' then ( - 10 - ) - else ( - -1 - ) - ) - | 'n' -> ( - match String.unsafe_get s (pos+1) with - | 'a' -> ( - if String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 4 - ) - else ( - -1 - ) - ) - | 's' -> ( - if String.unsafe_get s (pos+2) = 'f' && String.unsafe_get s (pos+3) = 'w' then ( - 6 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 't' -> ( - if String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'c' then ( - 5 - ) - else ( - -1 - ) - ) - | 7 -> ( - if String.unsafe_get s pos = 'b' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'e' then ( - 7 - ) - else ( - -1 - ) - ) - | 8 -> ( - match String.unsafe_get s pos with - | 'g' -> ( - if String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( - 2 - ) - else ( - -1 - ) - ) - | 'o' -> ( - if String.unsafe_get s (pos+1) = 'w' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( - 11 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' then ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 9 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'd' then ( - 13 - ) - else ( - -1 - ) - ) - | 10 -> ( - match String.unsafe_get s pos with - | 'r' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'c' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'p' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 's' then ( - 9 - ) - else ( - -1 - ) - ) - | 'u' -> ( - if String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'l' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'm' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 't' then ( - 8 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 14 -> ( - if String.unsafe_get s pos = 'a' && String.unsafe_get s (pos+1) = 'p' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 'i' && String.unsafe_get s (pos+13) = 'd' then ( - 12 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_kind := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_guild_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_position := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_name := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 5 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_topic := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 6 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_nsfw := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | 7 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_bitrate := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | 8 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_user_limit := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | 9 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_recipients := ( - Some ( - ( - read__5 - ) p lb - ) - ); - ) - | 10 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_icon := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 11 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_owner_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 12 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_application_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 13 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_parent_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 4 -> ( - match String.unsafe_get s pos with - | 'i' -> ( - if String.unsafe_get s (pos+1) = 'c' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'n' then ( - 10 - ) - else ( - -1 - ) - ) - | 'n' -> ( - match String.unsafe_get s (pos+1) with - | 'a' -> ( - if String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 4 - ) - else ( - -1 - ) - ) - | 's' -> ( - if String.unsafe_get s (pos+2) = 'f' && String.unsafe_get s (pos+3) = 'w' then ( - 6 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 't' -> ( - if String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'c' then ( - 5 - ) - else ( - -1 - ) - ) - | 7 -> ( - if String.unsafe_get s pos = 'b' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'e' then ( - 7 - ) - else ( - -1 - ) - ) - | 8 -> ( - match String.unsafe_get s pos with - | 'g' -> ( - if String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( - 2 - ) - else ( - -1 - ) - ) - | 'o' -> ( - if String.unsafe_get s (pos+1) = 'w' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( - 11 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' then ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 9 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'd' then ( - 13 - ) - else ( - -1 - ) - ) - | 10 -> ( - match String.unsafe_get s pos with - | 'r' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'c' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'p' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 's' then ( - 9 - ) - else ( - -1 - ) - ) - | 'u' -> ( - if String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'l' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'm' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 't' then ( - 8 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 14 -> ( - if String.unsafe_get s pos = 'a' && String.unsafe_get s (pos+1) = 'p' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 'i' && String.unsafe_get s (pos+13) = 'd' then ( - 12 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_kind := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_guild_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_position := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_name := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 5 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_topic := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 6 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_nsfw := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | 7 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_bitrate := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | 8 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_user_limit := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | 9 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_recipients := ( - Some ( - ( - read__5 - ) p lb - ) - ); - ) - | 10 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_icon := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 11 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_owner_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 12 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_application_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 13 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_parent_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0x3 then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "id"; "kind" |]; - ( - { - id = !field_id; - kind = !field_kind; - guild_id = !field_guild_id; - position = !field_position; - name = !field_name; - topic = !field_topic; - nsfw = !field_nsfw; - bitrate = !field_bitrate; - user_limit = !field_user_limit; - recipients = !field_recipients; - icon = !field_icon; - owner_id = !field_owner_id; - application_id = !field_application_id; - parent_id = !field_parent_id; - } - : t) - ) -) -let t_of_string s = - read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s) diff --git a/lib/models/gen/channel_j.mli b/lib/models/gen/channel_j.mli deleted file mode 100644 index ec4048c..0000000 --- a/lib/models/gen/channel_j.mli +++ /dev/null @@ -1,84 +0,0 @@ -(* Auto-generated from "channel.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type t = Channel_t.t = { - id: snowflake; - kind: int; - guild_id: snowflake option; - position: int option; - name: string option; - topic: string option; - nsfw: bool option; - bitrate: int option; - user_limit: int option; - recipients: user list option; - icon: string option; - owner_id: snowflake option; - application_id: snowflake option; - parent_id: snowflake option -} - -val write_user : - Bi_outbuf.t -> user -> unit - (** Output a JSON value of type {!user}. *) - -val string_of_user : - ?len:int -> user -> string - (** Serialize a value of type {!user} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_user : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> user - (** Input JSON data of type {!user}. *) - -val user_of_string : - string -> user - (** Deserialize JSON data of type {!user}. *) - -val write_snowflake : - Bi_outbuf.t -> snowflake -> unit - (** Output a JSON value of type {!snowflake}. *) - -val string_of_snowflake : - ?len:int -> snowflake -> string - (** Serialize a value of type {!snowflake} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_snowflake : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> snowflake - (** Input JSON data of type {!snowflake}. *) - -val snowflake_of_string : - string -> snowflake - (** Deserialize JSON data of type {!snowflake}. *) - -val write_t : - Bi_outbuf.t -> t -> unit - (** Output a JSON value of type {!t}. *) - -val string_of_t : - ?len:int -> t -> string - (** Serialize a value of type {!t} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_t : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> t - (** Input JSON data of type {!t}. *) - -val t_of_string : - string -> t - (** Deserialize JSON data of type {!t}. *) - diff --git a/lib/models/gen/channel_t.ml b/lib/models/gen/channel_t.ml deleted file mode 100644 index a5c9ce4..0000000 --- a/lib/models/gen/channel_t.ml +++ /dev/null @@ -1,23 +0,0 @@ -(* Auto-generated from "channel.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type t = { - id: snowflake; - kind: int; - guild_id: snowflake option; - position: int option; - name: string option; - topic: string option; - nsfw: bool option; - bitrate: int option; - user_limit: int option; - recipients: user list option; - icon: string option; - owner_id: snowflake option; - application_id: snowflake option; - parent_id: snowflake option -} diff --git a/lib/models/gen/channel_t.mli b/lib/models/gen/channel_t.mli deleted file mode 100644 index a5c9ce4..0000000 --- a/lib/models/gen/channel_t.mli +++ /dev/null @@ -1,23 +0,0 @@ -(* Auto-generated from "channel.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type t = { - id: snowflake; - kind: int; - guild_id: snowflake option; - position: int option; - name: string option; - topic: string option; - nsfw: bool option; - bitrate: int option; - user_limit: int option; - recipients: user list option; - icon: string option; - owner_id: snowflake option; - application_id: snowflake option; - parent_id: snowflake option -} diff --git a/lib/models/gen/embed_j.ml b/lib/models/gen/embed_j.ml deleted file mode 100644 index 560c517..0000000 --- a/lib/models/gen/embed_j.ml +++ /dev/null @@ -1,2283 +0,0 @@ -(* Auto-generated from "embed.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type video = Embed_t.video = { - url: string option; - height: int option; - width: int option -} - -type provider = Embed_t.provider = { - name: string option; - url: string option -} - -type image = Embed_t.image = { - url: string option; - proxy_url: string option; - height: int option; - width: int option -} - -type footer = Embed_t.footer = { - text: string; - icon_url: string option; - proxy_icon_url: string option -} - -type field = Embed_t.field = { - name: string; - value: string; - inline: bool option -} - -type t = Embed_t.t = { - title: string option; - kind: string option; - description: string option; - url: string option; - timestamp: string option; - colour: int option; - footer: footer option; - image: image option; - thumbnail: image option; - video: video option; - provider: provider option; - fields: field list option -} - -let write__2 = ( - Atdgen_runtime.Oj_run.write_option ( - Yojson.Safe.write_int - ) -) -let string_of__2 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__2 ob x; - Bi_outbuf.contents ob -let read__2 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - Atdgen_runtime.Oj_run.read_int - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_int - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _2_of_string s = - read__2 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__1 = ( - Atdgen_runtime.Oj_run.write_option ( - Yojson.Safe.write_string - ) -) -let string_of__1 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__1 ob x; - Bi_outbuf.contents ob -let read__1 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _1_of_string s = - read__1 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_video : _ -> video -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - (match x.url with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"url\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.height with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"height\":"; - ( - Yojson.Safe.write_int - ) - ob x; - ); - (match x.width with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"width\":"; - ( - Yojson.Safe.write_int - ) - ob x; - ); - Bi_outbuf.add_char ob '}'; -) -let string_of_video ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_video ob x; - Bi_outbuf.contents ob -let read_video = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_url = ref (None) in - let field_height = ref (None) in - let field_width = ref (None) in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 3 -> ( - if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( - 0 - ) - else ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'w' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'h' then ( - 2 - ) - else ( - -1 - ) - ) - | 6 -> ( - if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'h' && String.unsafe_get s (pos+5) = 't' then ( - 1 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_url := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 1 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_height := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_width := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 3 -> ( - if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( - 0 - ) - else ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'w' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'h' then ( - 2 - ) - else ( - -1 - ) - ) - | 6 -> ( - if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'h' && String.unsafe_get s (pos+5) = 't' then ( - 1 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_url := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 1 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_height := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_width := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - ( - { - url = !field_url; - height = !field_height; - width = !field_width; - } - : video) - ) -) -let video_of_string s = - read_video (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_provider : _ -> provider -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - (match x.name with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"name\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.url with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"url\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - Bi_outbuf.add_char ob '}'; -) -let string_of_provider ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_provider ob x; - Bi_outbuf.contents ob -let read_provider = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_name = ref (None) in - let field_url = ref (None) in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 3 -> ( - if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( - 1 - ) - else ( - -1 - ) - ) - | 4 -> ( - if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 0 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_name := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 1 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_url := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 3 -> ( - if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( - 1 - ) - else ( - -1 - ) - ) - | 4 -> ( - if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 0 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_name := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 1 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_url := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - ( - { - name = !field_name; - url = !field_url; - } - : provider) - ) -) -let provider_of_string s = - read_provider (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_image : _ -> image -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - (match x.url with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"url\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.proxy_url with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"proxy_url\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.height with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"height\":"; - ( - Yojson.Safe.write_int - ) - ob x; - ); - (match x.width with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"width\":"; - ( - Yojson.Safe.write_int - ) - ob x; - ); - Bi_outbuf.add_char ob '}'; -) -let string_of_image ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_image ob x; - Bi_outbuf.contents ob -let read_image = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_url = ref (None) in - let field_proxy_url = ref (None) in - let field_height = ref (None) in - let field_width = ref (None) in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 3 -> ( - if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( - 0 - ) - else ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'w' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'h' then ( - 3 - ) - else ( - -1 - ) - ) - | 6 -> ( - if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'h' && String.unsafe_get s (pos+5) = 't' then ( - 2 - ) - else ( - -1 - ) - ) - | 9 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'x' && String.unsafe_get s (pos+4) = 'y' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'u' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 'l' then ( - 1 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_url := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 1 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_proxy_url := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_height := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_width := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 3 -> ( - if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( - 0 - ) - else ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'w' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'h' then ( - 3 - ) - else ( - -1 - ) - ) - | 6 -> ( - if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'h' && String.unsafe_get s (pos+5) = 't' then ( - 2 - ) - else ( - -1 - ) - ) - | 9 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'x' && String.unsafe_get s (pos+4) = 'y' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'u' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 'l' then ( - 1 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_url := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 1 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_proxy_url := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_height := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_width := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - ( - { - url = !field_url; - proxy_url = !field_proxy_url; - height = !field_height; - width = !field_width; - } - : image) - ) -) -let image_of_string s = - read_image (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_footer : _ -> footer -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"text\":"; - ( - Yojson.Safe.write_string - ) - ob x.text; - (match x.icon_url with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"icon_url\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.proxy_icon_url with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"proxy_icon_url\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - Bi_outbuf.add_char ob '}'; -) -let string_of_footer ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_footer ob x; - Bi_outbuf.contents ob -let read_footer = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_text = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_icon_url = ref (None) in - let field_proxy_icon_url = ref (None) in - let bits0 = ref 0 in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 4 -> ( - if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = 't' then ( - 0 - ) - else ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'c' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'u' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 'l' then ( - 1 - ) - else ( - -1 - ) - ) - | 14 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'x' && String.unsafe_get s (pos+4) = 'y' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'u' && String.unsafe_get s (pos+12) = 'r' && String.unsafe_get s (pos+13) = 'l' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_text := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_icon_url := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_proxy_icon_url := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 4 -> ( - if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = 't' then ( - 0 - ) - else ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'c' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'u' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 'l' then ( - 1 - ) - else ( - -1 - ) - ) - | 14 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'x' && String.unsafe_get s (pos+4) = 'y' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'u' && String.unsafe_get s (pos+12) = 'r' && String.unsafe_get s (pos+13) = 'l' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_text := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_icon_url := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_proxy_icon_url := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0x1 then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "text" |]; - ( - { - text = !field_text; - icon_url = !field_icon_url; - proxy_icon_url = !field_proxy_icon_url; - } - : footer) - ) -) -let footer_of_string s = - read_footer (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__3 = ( - Atdgen_runtime.Oj_run.write_option ( - Yojson.Safe.write_bool - ) -) -let string_of__3 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__3 ob x; - Bi_outbuf.contents ob -let read__3 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _3_of_string s = - read__3 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_field : _ -> field -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"name\":"; - ( - Yojson.Safe.write_string - ) - ob x.name; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"value\":"; - ( - Yojson.Safe.write_string - ) - ob x.value; - (match x.inline with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"inline\":"; - ( - Yojson.Safe.write_bool - ) - ob x; - ); - Bi_outbuf.add_char ob '}'; -) -let string_of_field ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_field ob x; - Bi_outbuf.contents ob -let read_field = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_name = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_value = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_inline = ref (None) in - let bits0 = ref 0 in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 4 -> ( - if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 0 - ) - else ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'v' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'u' && String.unsafe_get s (pos+4) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | 6 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'e' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_name := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_value := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_inline := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 4 -> ( - if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 0 - ) - else ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'v' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'u' && String.unsafe_get s (pos+4) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | 6 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'e' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_name := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_value := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_inline := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0x3 then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "name"; "value" |]; - ( - { - name = !field_name; - value = !field_value; - inline = !field_inline; - } - : field) - ) -) -let field_of_string s = - read_field (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__8 = ( - Atdgen_runtime.Oj_run.write_list ( - write_field - ) -) -let string_of__8 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__8 ob x; - Bi_outbuf.contents ob -let read__8 = ( - Atdgen_runtime.Oj_run.read_list ( - read_field - ) -) -let _8_of_string s = - read__8 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__9 = ( - Atdgen_runtime.Oj_run.write_option ( - write__8 - ) -) -let string_of__9 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__9 ob x; - Bi_outbuf.contents ob -let read__9 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read__8 - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read__8 - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _9_of_string s = - read__9 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__7 = ( - Atdgen_runtime.Oj_run.write_option ( - write_provider - ) -) -let string_of__7 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__7 ob x; - Bi_outbuf.contents ob -let read__7 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read_provider - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_provider - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _7_of_string s = - read__7 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__6 = ( - Atdgen_runtime.Oj_run.write_option ( - write_video - ) -) -let string_of__6 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__6 ob x; - Bi_outbuf.contents ob -let read__6 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read_video - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_video - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _6_of_string s = - read__6 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__5 = ( - Atdgen_runtime.Oj_run.write_option ( - write_image - ) -) -let string_of__5 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__5 ob x; - Bi_outbuf.contents ob -let read__5 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read_image - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_image - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _5_of_string s = - read__5 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__4 = ( - Atdgen_runtime.Oj_run.write_option ( - write_footer - ) -) -let string_of__4 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__4 ob x; - Bi_outbuf.contents ob -let read__4 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read_footer - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_footer - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _4_of_string s = - read__4 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_t : _ -> t -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - (match x.title with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"title\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.kind with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"kind\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.description with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"description\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.url with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"url\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.timestamp with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"timestamp\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.colour with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"colour\":"; - ( - Yojson.Safe.write_int - ) - ob x; - ); - (match x.footer with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"footer\":"; - ( - write_footer - ) - ob x; - ); - (match x.image with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"image\":"; - ( - write_image - ) - ob x; - ); - (match x.thumbnail with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"thumbnail\":"; - ( - write_image - ) - ob x; - ); - (match x.video with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"video\":"; - ( - write_video - ) - ob x; - ); - (match x.provider with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"provider\":"; - ( - write_provider - ) - ob x; - ); - (match x.fields with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"fields\":"; - ( - write__8 - ) - ob x; - ); - Bi_outbuf.add_char ob '}'; -) -let string_of_t ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_t ob x; - Bi_outbuf.contents ob -let read_t = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_title = ref (None) in - let field_kind = ref (None) in - let field_description = ref (None) in - let field_url = ref (None) in - let field_timestamp = ref (None) in - let field_colour = ref (None) in - let field_footer = ref (None) in - let field_image = ref (None) in - let field_thumbnail = ref (None) in - let field_video = ref (None) in - let field_provider = ref (None) in - let field_fields = ref (None) in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 3 -> ( - if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( - 3 - ) - else ( - -1 - ) - ) - | 4 -> ( - if String.unsafe_get s pos = 'k' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'd' then ( - 1 - ) - else ( - -1 - ) - ) - | 5 -> ( - match String.unsafe_get s pos with - | 'i' -> ( - if String.unsafe_get s (pos+1) = 'm' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' then ( - 7 - ) - else ( - -1 - ) - ) - | 't' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'e' then ( - 0 - ) - else ( - -1 - ) - ) - | 'v' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'o' then ( - 9 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 6 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'o' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 'r' then ( - 5 - ) - else ( - -1 - ) - ) - | 'f' -> ( - match String.unsafe_get s (pos+1) with - | 'i' -> ( - if String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 's' then ( - 11 - ) - else ( - -1 - ) - ) - | 'o' -> ( - if String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' then ( - 6 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'v' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'r' then ( - 10 - ) - else ( - -1 - ) - ) - | 9 -> ( - if String.unsafe_get s pos = 't' then ( - match String.unsafe_get s (pos+1) with - | 'h' -> ( - if String.unsafe_get s (pos+2) = 'u' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'b' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'l' then ( - 8 - ) - else ( - -1 - ) - ) - | 'i' -> ( - if String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 'm' && String.unsafe_get s (pos+8) = 'p' then ( - 4 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - else ( - -1 - ) - ) - | 11 -> ( - if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_title := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 1 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_kind := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_description := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_url := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_timestamp := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 5 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_colour := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | 6 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_footer := ( - Some ( - ( - read_footer - ) p lb - ) - ); - ) - | 7 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_image := ( - Some ( - ( - read_image - ) p lb - ) - ); - ) - | 8 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_thumbnail := ( - Some ( - ( - read_image - ) p lb - ) - ); - ) - | 9 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_video := ( - Some ( - ( - read_video - ) p lb - ) - ); - ) - | 10 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_provider := ( - Some ( - ( - read_provider - ) p lb - ) - ); - ) - | 11 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_fields := ( - Some ( - ( - read__8 - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 3 -> ( - if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( - 3 - ) - else ( - -1 - ) - ) - | 4 -> ( - if String.unsafe_get s pos = 'k' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'd' then ( - 1 - ) - else ( - -1 - ) - ) - | 5 -> ( - match String.unsafe_get s pos with - | 'i' -> ( - if String.unsafe_get s (pos+1) = 'm' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' then ( - 7 - ) - else ( - -1 - ) - ) - | 't' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'e' then ( - 0 - ) - else ( - -1 - ) - ) - | 'v' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'o' then ( - 9 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 6 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'o' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 'r' then ( - 5 - ) - else ( - -1 - ) - ) - | 'f' -> ( - match String.unsafe_get s (pos+1) with - | 'i' -> ( - if String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 's' then ( - 11 - ) - else ( - -1 - ) - ) - | 'o' -> ( - if String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' then ( - 6 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'v' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'r' then ( - 10 - ) - else ( - -1 - ) - ) - | 9 -> ( - if String.unsafe_get s pos = 't' then ( - match String.unsafe_get s (pos+1) with - | 'h' -> ( - if String.unsafe_get s (pos+2) = 'u' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'b' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'l' then ( - 8 - ) - else ( - -1 - ) - ) - | 'i' -> ( - if String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 'm' && String.unsafe_get s (pos+8) = 'p' then ( - 4 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - else ( - -1 - ) - ) - | 11 -> ( - if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_title := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 1 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_kind := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_description := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_url := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_timestamp := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 5 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_colour := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | 6 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_footer := ( - Some ( - ( - read_footer - ) p lb - ) - ); - ) - | 7 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_image := ( - Some ( - ( - read_image - ) p lb - ) - ); - ) - | 8 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_thumbnail := ( - Some ( - ( - read_image - ) p lb - ) - ); - ) - | 9 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_video := ( - Some ( - ( - read_video - ) p lb - ) - ); - ) - | 10 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_provider := ( - Some ( - ( - read_provider - ) p lb - ) - ); - ) - | 11 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_fields := ( - Some ( - ( - read__8 - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - ( - { - title = !field_title; - kind = !field_kind; - description = !field_description; - url = !field_url; - timestamp = !field_timestamp; - colour = !field_colour; - footer = !field_footer; - image = !field_image; - thumbnail = !field_thumbnail; - video = !field_video; - provider = !field_provider; - fields = !field_fields; - } - : t) - ) -) -let t_of_string s = - read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s) diff --git a/lib/models/gen/embed_j.mli b/lib/models/gen/embed_j.mli deleted file mode 100644 index 8872d89..0000000 --- a/lib/models/gen/embed_j.mli +++ /dev/null @@ -1,168 +0,0 @@ -(* Auto-generated from "embed.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type video = Embed_t.video = { - url: string option; - height: int option; - width: int option -} - -type provider = Embed_t.provider = { - name: string option; - url: string option -} - -type image = Embed_t.image = { - url: string option; - proxy_url: string option; - height: int option; - width: int option -} - -type footer = Embed_t.footer = { - text: string; - icon_url: string option; - proxy_icon_url: string option -} - -type field = Embed_t.field = { - name: string; - value: string; - inline: bool option -} - -type t = Embed_t.t = { - title: string option; - kind: string option; - description: string option; - url: string option; - timestamp: string option; - colour: int option; - footer: footer option; - image: image option; - thumbnail: image option; - video: video option; - provider: provider option; - fields: field list option -} - -val write_video : - Bi_outbuf.t -> video -> unit - (** Output a JSON value of type {!video}. *) - -val string_of_video : - ?len:int -> video -> string - (** Serialize a value of type {!video} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_video : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> video - (** Input JSON data of type {!video}. *) - -val video_of_string : - string -> video - (** Deserialize JSON data of type {!video}. *) - -val write_provider : - Bi_outbuf.t -> provider -> unit - (** Output a JSON value of type {!provider}. *) - -val string_of_provider : - ?len:int -> provider -> string - (** Serialize a value of type {!provider} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_provider : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> provider - (** Input JSON data of type {!provider}. *) - -val provider_of_string : - string -> provider - (** Deserialize JSON data of type {!provider}. *) - -val write_image : - Bi_outbuf.t -> image -> unit - (** Output a JSON value of type {!image}. *) - -val string_of_image : - ?len:int -> image -> string - (** Serialize a value of type {!image} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_image : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> image - (** Input JSON data of type {!image}. *) - -val image_of_string : - string -> image - (** Deserialize JSON data of type {!image}. *) - -val write_footer : - Bi_outbuf.t -> footer -> unit - (** Output a JSON value of type {!footer}. *) - -val string_of_footer : - ?len:int -> footer -> string - (** Serialize a value of type {!footer} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_footer : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> footer - (** Input JSON data of type {!footer}. *) - -val footer_of_string : - string -> footer - (** Deserialize JSON data of type {!footer}. *) - -val write_field : - Bi_outbuf.t -> field -> unit - (** Output a JSON value of type {!field}. *) - -val string_of_field : - ?len:int -> field -> string - (** Serialize a value of type {!field} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_field : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> field - (** Input JSON data of type {!field}. *) - -val field_of_string : - string -> field - (** Deserialize JSON data of type {!field}. *) - -val write_t : - Bi_outbuf.t -> t -> unit - (** Output a JSON value of type {!t}. *) - -val string_of_t : - ?len:int -> t -> string - (** Serialize a value of type {!t} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_t : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> t - (** Input JSON data of type {!t}. *) - -val t_of_string : - string -> t - (** Deserialize JSON data of type {!t}. *) - diff --git a/lib/models/gen/embed_t.ml b/lib/models/gen/embed_t.ml deleted file mode 100644 index 9eb5059..0000000 --- a/lib/models/gen/embed_t.ml +++ /dev/null @@ -1,36 +0,0 @@ -(* Auto-generated from "embed.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type video = { url: string option; height: int option; width: int option } - -type provider = { name: string option; url: string option } - -type image = { - url: string option; - proxy_url: string option; - height: int option; - width: int option -} - -type footer = { - text: string; - icon_url: string option; - proxy_icon_url: string option -} - -type field = { name: string; value: string; inline: bool option } - -type t = { - title: string option; - kind: string option; - description: string option; - url: string option; - timestamp: string option; - colour: int option; - footer: footer option; - image: image option; - thumbnail: image option; - video: video option; - provider: provider option; - fields: field list option -} diff --git a/lib/models/gen/embed_t.mli b/lib/models/gen/embed_t.mli deleted file mode 100644 index 9eb5059..0000000 --- a/lib/models/gen/embed_t.mli +++ /dev/null @@ -1,36 +0,0 @@ -(* Auto-generated from "embed.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type video = { url: string option; height: int option; width: int option } - -type provider = { name: string option; url: string option } - -type image = { - url: string option; - proxy_url: string option; - height: int option; - width: int option -} - -type footer = { - text: string; - icon_url: string option; - proxy_icon_url: string option -} - -type field = { name: string; value: string; inline: bool option } - -type t = { - title: string option; - kind: string option; - description: string option; - url: string option; - timestamp: string option; - colour: int option; - footer: footer option; - image: image option; - thumbnail: image option; - video: video option; - provider: provider option; - fields: field list option -} diff --git a/lib/models/gen/emoji_j.ml b/lib/models/gen/emoji_j.ml deleted file mode 100644 index d621de2..0000000 --- a/lib/models/gen/emoji_j.ml +++ /dev/null @@ -1,701 +0,0 @@ -(* Auto-generated from "emoji.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type t = Emoji_t.t = { - id: snowflake option; - name: string; - roles: snowflake list option; - user: user option; - require_colons: bool option; - managed: bool option; - animated: bool option -} - -let write_user = ( - User_j.write_t -) -let string_of_user ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_user ob x; - Bi_outbuf.contents ob -let read_user = ( - User_j.read_t -) -let user_of_string s = - read_user (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_snowflake = ( - Snowflake_j.write_t -) -let string_of_snowflake ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_snowflake ob x; - Bi_outbuf.contents ob -let read_snowflake = ( - Snowflake_j.read_t -) -let snowflake_of_string s = - read_snowflake (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__5 = ( - Atdgen_runtime.Oj_run.write_option ( - Yojson.Safe.write_bool - ) -) -let string_of__5 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__5 ob x; - Bi_outbuf.contents ob -let read__5 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _5_of_string s = - read__5 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__4 = ( - Atdgen_runtime.Oj_run.write_option ( - write_user - ) -) -let string_of__4 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__4 ob x; - Bi_outbuf.contents ob -let read__4 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read_user - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_user - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _4_of_string s = - read__4 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__2 = ( - Atdgen_runtime.Oj_run.write_list ( - write_snowflake - ) -) -let string_of__2 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__2 ob x; - Bi_outbuf.contents ob -let read__2 = ( - Atdgen_runtime.Oj_run.read_list ( - read_snowflake - ) -) -let _2_of_string s = - read__2 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__3 = ( - Atdgen_runtime.Oj_run.write_option ( - write__2 - ) -) -let string_of__3 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__3 ob x; - Bi_outbuf.contents ob -let read__3 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read__2 - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read__2 - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _3_of_string s = - read__3 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__1 = ( - Atdgen_runtime.Oj_run.write_option ( - write_snowflake - ) -) -let string_of__1 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__1 ob x; - Bi_outbuf.contents ob -let read__1 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read_snowflake - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_snowflake - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _1_of_string s = - read__1 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_t : _ -> t -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - (match x.id with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"id\":"; - ( - write_snowflake - ) - ob x; - ); - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"name\":"; - ( - Yojson.Safe.write_string - ) - ob x.name; - (match x.roles with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"roles\":"; - ( - write__2 - ) - ob x; - ); - (match x.user with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"user\":"; - ( - write_user - ) - ob x; - ); - (match x.require_colons with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"require_colons\":"; - ( - Yojson.Safe.write_bool - ) - ob x; - ); - (match x.managed with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"managed\":"; - ( - Yojson.Safe.write_bool - ) - ob x; - ); - (match x.animated with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"animated\":"; - ( - Yojson.Safe.write_bool - ) - ob x; - ); - Bi_outbuf.add_char ob '}'; -) -let string_of_t ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_t ob x; - Bi_outbuf.contents ob -let read_t = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_id = ref (None) in - let field_name = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_roles = ref (None) in - let field_user = ref (None) in - let field_require_colons = ref (None) in - let field_managed = ref (None) in - let field_animated = ref (None) in - let bits0 = ref 0 in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 4 -> ( - match String.unsafe_get s pos with - | 'n' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | 'u' -> ( - if String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'r' then ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( - 2 - ) - else ( - -1 - ) - ) - | 7 -> ( - if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'g' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'd' then ( - 5 - ) - else ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'a' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'd' then ( - 6 - ) - else ( - -1 - ) - ) - | 14 -> ( - if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'q' && String.unsafe_get s (pos+3) = 'u' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'l' && String.unsafe_get s (pos+11) = 'o' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = 's' then ( - 4 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 1 -> - field_name := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_roles := ( - Some ( - ( - read__2 - ) p lb - ) - ); - ) - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_user := ( - Some ( - ( - read_user - ) p lb - ) - ); - ) - | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_require_colons := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | 5 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_managed := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | 6 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_animated := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 4 -> ( - match String.unsafe_get s pos with - | 'n' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | 'u' -> ( - if String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'r' then ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( - 2 - ) - else ( - -1 - ) - ) - | 7 -> ( - if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'g' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'd' then ( - 5 - ) - else ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'a' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'd' then ( - 6 - ) - else ( - -1 - ) - ) - | 14 -> ( - if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'q' && String.unsafe_get s (pos+3) = 'u' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'c' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'l' && String.unsafe_get s (pos+11) = 'o' && String.unsafe_get s (pos+12) = 'n' && String.unsafe_get s (pos+13) = 's' then ( - 4 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 1 -> - field_name := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_roles := ( - Some ( - ( - read__2 - ) p lb - ) - ); - ) - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_user := ( - Some ( - ( - read_user - ) p lb - ) - ); - ) - | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_require_colons := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | 5 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_managed := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | 6 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_animated := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0x1 then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "name" |]; - ( - { - id = !field_id; - name = !field_name; - roles = !field_roles; - user = !field_user; - require_colons = !field_require_colons; - managed = !field_managed; - animated = !field_animated; - } - : t) - ) -) -let t_of_string s = - read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s) diff --git a/lib/models/gen/emoji_j.mli b/lib/models/gen/emoji_j.mli deleted file mode 100644 index 596deeb..0000000 --- a/lib/models/gen/emoji_j.mli +++ /dev/null @@ -1,77 +0,0 @@ -(* Auto-generated from "emoji.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type t = Emoji_t.t = { - id: snowflake option; - name: string; - roles: snowflake list option; - user: user option; - require_colons: bool option; - managed: bool option; - animated: bool option -} - -val write_user : - Bi_outbuf.t -> user -> unit - (** Output a JSON value of type {!user}. *) - -val string_of_user : - ?len:int -> user -> string - (** Serialize a value of type {!user} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_user : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> user - (** Input JSON data of type {!user}. *) - -val user_of_string : - string -> user - (** Deserialize JSON data of type {!user}. *) - -val write_snowflake : - Bi_outbuf.t -> snowflake -> unit - (** Output a JSON value of type {!snowflake}. *) - -val string_of_snowflake : - ?len:int -> snowflake -> string - (** Serialize a value of type {!snowflake} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_snowflake : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> snowflake - (** Input JSON data of type {!snowflake}. *) - -val snowflake_of_string : - string -> snowflake - (** Deserialize JSON data of type {!snowflake}. *) - -val write_t : - Bi_outbuf.t -> t -> unit - (** Output a JSON value of type {!t}. *) - -val string_of_t : - ?len:int -> t -> string - (** Serialize a value of type {!t} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_t : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> t - (** Input JSON data of type {!t}. *) - -val t_of_string : - string -> t - (** Deserialize JSON data of type {!t}. *) - diff --git a/lib/models/gen/emoji_t.ml b/lib/models/gen/emoji_t.ml deleted file mode 100644 index 333939d..0000000 --- a/lib/models/gen/emoji_t.ml +++ /dev/null @@ -1,16 +0,0 @@ -(* Auto-generated from "emoji.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type t = { - id: snowflake option; - name: string; - roles: snowflake list option; - user: user option; - require_colons: bool option; - managed: bool option; - animated: bool option -} diff --git a/lib/models/gen/emoji_t.mli b/lib/models/gen/emoji_t.mli deleted file mode 100644 index 333939d..0000000 --- a/lib/models/gen/emoji_t.mli +++ /dev/null @@ -1,16 +0,0 @@ -(* Auto-generated from "emoji.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type t = { - id: snowflake option; - name: string; - roles: snowflake list option; - user: user option; - require_colons: bool option; - managed: bool option; - animated: bool option -} diff --git a/lib/models/gen/guild_j.ml b/lib/models/gen/guild_j.ml deleted file mode 100644 index 9f7b069..0000000 --- a/lib/models/gen/guild_j.ml +++ /dev/null @@ -1,1948 +0,0 @@ -(* Auto-generated from "guild.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type role = Role_t.t - -type member = Member_t.t - -type emoji = Emoji_t.t - -type channel = Channel_t.t - -type t = Guild_t.t = { - id: snowflake; - name: string; - icon: string option; - splash: string option; - owner_id: snowflake; - region: string; - afk_channel_id: snowflake option; - afk_timeout: int; - embed_enabled: bool option; - embed_channel_id: snowflake option; - verification_level: int; - default_message_notifications: int; - explicit_content_filter: int; - roles: role list; - emojis: emoji list; - features: string list; - mfa_level: int; - application_id: snowflake option; - widget_enabled: bool option; - widget_channel: channel option; - system_channel: channel option; - large: bool option; - unavailable: bool option; - member_count: int option; - members: member list option; - channels: channel list option -} - -let write_user = ( - User_j.write_t -) -let string_of_user ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_user ob x; - Bi_outbuf.contents ob -let read_user = ( - User_j.read_t -) -let user_of_string s = - read_user (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_snowflake = ( - Snowflake_j.write_t -) -let string_of_snowflake ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_snowflake ob x; - Bi_outbuf.contents ob -let read_snowflake = ( - Snowflake_j.read_t -) -let snowflake_of_string s = - read_snowflake (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_role = ( - Role_j.write_t -) -let string_of_role ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_role ob x; - Bi_outbuf.contents ob -let read_role = ( - Role_j.read_t -) -let role_of_string s = - read_role (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_member = ( - Member_j.write_t -) -let string_of_member ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_member ob x; - Bi_outbuf.contents ob -let read_member = ( - Member_j.read_t -) -let member_of_string s = - read_member (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_emoji = ( - Emoji_j.write_t -) -let string_of_emoji ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_emoji ob x; - Bi_outbuf.contents ob -let read_emoji = ( - Emoji_j.read_t -) -let emoji_of_string s = - read_emoji (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_channel = ( - Channel_j.write_t -) -let string_of_channel ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_channel ob x; - Bi_outbuf.contents ob -let read_channel = ( - Channel_j.read_t -) -let channel_of_string s = - read_channel (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__9 = ( - Atdgen_runtime.Oj_run.write_list ( - write_member - ) -) -let string_of__9 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__9 ob x; - Bi_outbuf.contents ob -let read__9 = ( - Atdgen_runtime.Oj_run.read_list ( - read_member - ) -) -let _9_of_string s = - read__9 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__8 = ( - Atdgen_runtime.Oj_run.write_option ( - Yojson.Safe.write_int - ) -) -let string_of__8 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__8 ob x; - Bi_outbuf.contents ob -let read__8 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - Atdgen_runtime.Oj_run.read_int - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_int - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _8_of_string s = - read__8 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__7 = ( - Atdgen_runtime.Oj_run.write_option ( - write_channel - ) -) -let string_of__7 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__7 ob x; - Bi_outbuf.contents ob -let read__7 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read_channel - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_channel - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _7_of_string s = - read__7 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__6 = ( - Atdgen_runtime.Oj_run.write_list ( - Yojson.Safe.write_string - ) -) -let string_of__6 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__6 ob x; - Bi_outbuf.contents ob -let read__6 = ( - Atdgen_runtime.Oj_run.read_list ( - Atdgen_runtime.Oj_run.read_string - ) -) -let _6_of_string s = - read__6 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__5 = ( - Atdgen_runtime.Oj_run.write_list ( - write_emoji - ) -) -let string_of__5 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__5 ob x; - Bi_outbuf.contents ob -let read__5 = ( - Atdgen_runtime.Oj_run.read_list ( - read_emoji - ) -) -let _5_of_string s = - read__5 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__4 = ( - Atdgen_runtime.Oj_run.write_list ( - write_role - ) -) -let string_of__4 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__4 ob x; - Bi_outbuf.contents ob -let read__4 = ( - Atdgen_runtime.Oj_run.read_list ( - read_role - ) -) -let _4_of_string s = - read__4 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__3 = ( - Atdgen_runtime.Oj_run.write_option ( - Yojson.Safe.write_bool - ) -) -let string_of__3 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__3 ob x; - Bi_outbuf.contents ob -let read__3 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _3_of_string s = - read__3 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__2 = ( - Atdgen_runtime.Oj_run.write_option ( - write_snowflake - ) -) -let string_of__2 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__2 ob x; - Bi_outbuf.contents ob -let read__2 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read_snowflake - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_snowflake - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _2_of_string s = - read__2 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__11 = ( - Atdgen_runtime.Oj_run.write_list ( - write_channel - ) -) -let string_of__11 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__11 ob x; - Bi_outbuf.contents ob -let read__11 = ( - Atdgen_runtime.Oj_run.read_list ( - read_channel - ) -) -let _11_of_string s = - read__11 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__12 = ( - Atdgen_runtime.Oj_run.write_option ( - write__11 - ) -) -let string_of__12 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__12 ob x; - Bi_outbuf.contents ob -let read__12 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read__11 - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read__11 - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _12_of_string s = - read__12 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__10 = ( - Atdgen_runtime.Oj_run.write_option ( - write__9 - ) -) -let string_of__10 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__10 ob x; - Bi_outbuf.contents ob -let read__10 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read__9 - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read__9 - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _10_of_string s = - read__10 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__1 = ( - Atdgen_runtime.Oj_run.write_option ( - Yojson.Safe.write_string - ) -) -let string_of__1 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__1 ob x; - Bi_outbuf.contents ob -let read__1 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _1_of_string s = - read__1 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_t : _ -> t -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"id\":"; - ( - write_snowflake - ) - ob x.id; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"name\":"; - ( - Yojson.Safe.write_string - ) - ob x.name; - (match x.icon with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"icon\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - (match x.splash with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"splash\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"owner_id\":"; - ( - write_snowflake - ) - ob x.owner_id; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"region\":"; - ( - Yojson.Safe.write_string - ) - ob x.region; - (match x.afk_channel_id with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"afk_channel_id\":"; - ( - write_snowflake - ) - ob x; - ); - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"afk_timeout\":"; - ( - Yojson.Safe.write_int - ) - ob x.afk_timeout; - (match x.embed_enabled with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"embed_enabled\":"; - ( - Yojson.Safe.write_bool - ) - ob x; - ); - (match x.embed_channel_id with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"embed_channel_id\":"; - ( - write_snowflake - ) - ob x; - ); - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"verification_level\":"; - ( - Yojson.Safe.write_int - ) - ob x.verification_level; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"default_message_notifications\":"; - ( - Yojson.Safe.write_int - ) - ob x.default_message_notifications; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"explicit_content_filter\":"; - ( - Yojson.Safe.write_int - ) - ob x.explicit_content_filter; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"roles\":"; - ( - write__4 - ) - ob x.roles; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"emojis\":"; - ( - write__5 - ) - ob x.emojis; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"features\":"; - ( - write__6 - ) - ob x.features; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"mfa_level\":"; - ( - Yojson.Safe.write_int - ) - ob x.mfa_level; - (match x.application_id with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"application_id\":"; - ( - write_snowflake - ) - ob x; - ); - (match x.widget_enabled with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"widget_enabled\":"; - ( - Yojson.Safe.write_bool - ) - ob x; - ); - (match x.widget_channel with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"widget_channel\":"; - ( - write_channel - ) - ob x; - ); - (match x.system_channel with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"system_channel\":"; - ( - write_channel - ) - ob x; - ); - (match x.large with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"large\":"; - ( - Yojson.Safe.write_bool - ) - ob x; - ); - (match x.unavailable with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"unavailable\":"; - ( - Yojson.Safe.write_bool - ) - ob x; - ); - (match x.member_count with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"member_count\":"; - ( - Yojson.Safe.write_int - ) - ob x; - ); - (match x.members with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"members\":"; - ( - write__9 - ) - ob x; - ); - (match x.channels with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"channels\":"; - ( - write__11 - ) - ob x; - ); - Bi_outbuf.add_char ob '}'; -) -let string_of_t ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_t ob x; - Bi_outbuf.contents ob -let read_t = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_id = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_name = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_icon = ref (None) in - let field_splash = ref (None) in - let field_owner_id = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_region = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_afk_channel_id = ref (None) in - let field_afk_timeout = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_embed_enabled = ref (None) in - let field_embed_channel_id = ref (None) in - let field_verification_level = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_default_message_notifications = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_explicit_content_filter = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_roles = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_emojis = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_features = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_mfa_level = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_application_id = ref (None) in - let field_widget_enabled = ref (None) in - let field_widget_channel = ref (None) in - let field_system_channel = ref (None) in - let field_large = ref (None) in - let field_unavailable = ref (None) in - let field_member_count = ref (None) in - let field_members = ref (None) in - let field_channels = ref (None) in - let bits0 = ref 0 in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 4 -> ( - match String.unsafe_get s pos with - | 'i' -> ( - if String.unsafe_get s (pos+1) = 'c' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'n' then ( - 2 - ) - else ( - -1 - ) - ) - | 'n' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 5 -> ( - match String.unsafe_get s pos with - | 'l' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' then ( - 21 - ) - else ( - -1 - ) - ) - | 'r' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( - 13 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 6 -> ( - match String.unsafe_get s pos with - | 'e' -> ( - if String.unsafe_get s (pos+1) = 'm' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'j' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 's' then ( - 14 - ) - else ( - -1 - ) - ) - | 'r' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'g' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'n' then ( - 5 - ) - else ( - -1 - ) - ) - | 's' -> ( - if String.unsafe_get s (pos+1) = 'p' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = 'h' then ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 7 -> ( - if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'b' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 's' then ( - 24 - ) - else ( - -1 - ) - ) - | 8 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 's' then ( - 25 - ) - else ( - -1 - ) - ) - | 'f' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 's' then ( - 15 - ) - else ( - -1 - ) - ) - | 'o' -> ( - if String.unsafe_get s (pos+1) = 'w' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( - 4 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 9 -> ( - if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'f' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'v' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'l' then ( - 16 - ) - else ( - -1 - ) - ) - | 11 -> ( - match String.unsafe_get s pos with - | 'a' -> ( - if String.unsafe_get s (pos+1) = 'f' && String.unsafe_get s (pos+2) = 'k' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'u' && String.unsafe_get s (pos+10) = 't' then ( - 7 - ) - else ( - -1 - ) - ) - | 'u' -> ( - if String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'v' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'b' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = 'e' then ( - 22 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 12 -> ( - if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'b' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'u' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = 't' then ( - 23 - ) - else ( - -1 - ) - ) - | 13 -> ( - if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'm' && String.unsafe_get s (pos+2) = 'b' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'b' && String.unsafe_get s (pos+10) = 'l' && String.unsafe_get s (pos+11) = 'e' && String.unsafe_get s (pos+12) = 'd' then ( - 8 - ) - else ( - -1 - ) - ) - | 14 -> ( - match String.unsafe_get s pos with - | 'a' -> ( - match String.unsafe_get s (pos+1) with - | 'f' -> ( - if String.unsafe_get s (pos+2) = 'k' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'c' && String.unsafe_get s (pos+5) = 'h' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 'l' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 'i' && String.unsafe_get s (pos+13) = 'd' then ( - 6 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 'i' && String.unsafe_get s (pos+13) = 'd' then ( - 17 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 's' -> ( - if String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'm' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'h' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = 'n' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'l' then ( - 20 - ) - else ( - -1 - ) - ) - | 'w' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' then ( - match String.unsafe_get s (pos+7) with - | 'c' -> ( - if String.unsafe_get s (pos+8) = 'h' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = 'n' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'l' then ( - 19 - ) - else ( - -1 - ) - ) - | 'e' -> ( - if String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 'b' && String.unsafe_get s (pos+11) = 'l' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'd' then ( - 18 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 16 -> ( - if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'm' && String.unsafe_get s (pos+2) = 'b' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'c' && String.unsafe_get s (pos+7) = 'h' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = 'e' && String.unsafe_get s (pos+12) = 'l' && String.unsafe_get s (pos+13) = '_' && String.unsafe_get s (pos+14) = 'i' && String.unsafe_get s (pos+15) = 'd' then ( - 9 - ) - else ( - -1 - ) - ) - | 18 -> ( - if String.unsafe_get s pos = 'v' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'f' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'c' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'n' && String.unsafe_get s (pos+12) = '_' && String.unsafe_get s (pos+13) = 'l' && String.unsafe_get s (pos+14) = 'e' && String.unsafe_get s (pos+15) = 'v' && String.unsafe_get s (pos+16) = 'e' && String.unsafe_get s (pos+17) = 'l' then ( - 10 - ) - else ( - -1 - ) - ) - | 23 -> ( - if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'x' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 'c' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'n' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 'n' && String.unsafe_get s (pos+15) = 't' && String.unsafe_get s (pos+16) = '_' && String.unsafe_get s (pos+17) = 'f' && String.unsafe_get s (pos+18) = 'i' && String.unsafe_get s (pos+19) = 'l' && String.unsafe_get s (pos+20) = 't' && String.unsafe_get s (pos+21) = 'e' && String.unsafe_get s (pos+22) = 'r' then ( - 12 - ) - else ( - -1 - ) - ) - | 29 -> ( - if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'f' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 'l' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'm' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 's' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 'a' && String.unsafe_get s (pos+13) = 'g' && String.unsafe_get s (pos+14) = 'e' && String.unsafe_get s (pos+15) = '_' && String.unsafe_get s (pos+16) = 'n' && String.unsafe_get s (pos+17) = 'o' && String.unsafe_get s (pos+18) = 't' && String.unsafe_get s (pos+19) = 'i' && String.unsafe_get s (pos+20) = 'f' && String.unsafe_get s (pos+21) = 'i' && String.unsafe_get s (pos+22) = 'c' && String.unsafe_get s (pos+23) = 'a' && String.unsafe_get s (pos+24) = 't' && String.unsafe_get s (pos+25) = 'i' && String.unsafe_get s (pos+26) = 'o' && String.unsafe_get s (pos+27) = 'n' && String.unsafe_get s (pos+28) = 's' then ( - 11 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_name := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_icon := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_splash := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 4 -> - field_owner_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 5 -> - field_region := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x8; - | 6 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_afk_channel_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 7 -> - field_afk_timeout := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x10; - | 8 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_embed_enabled := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | 9 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_embed_channel_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 10 -> - field_verification_level := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x20; - | 11 -> - field_default_message_notifications := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x40; - | 12 -> - field_explicit_content_filter := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x80; - | 13 -> - field_roles := ( - ( - read__4 - ) p lb - ); - bits0 := !bits0 lor 0x100; - | 14 -> - field_emojis := ( - ( - read__5 - ) p lb - ); - bits0 := !bits0 lor 0x200; - | 15 -> - field_features := ( - ( - read__6 - ) p lb - ); - bits0 := !bits0 lor 0x400; - | 16 -> - field_mfa_level := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x800; - | 17 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_application_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 18 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_widget_enabled := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | 19 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_widget_channel := ( - Some ( - ( - read_channel - ) p lb - ) - ); - ) - | 20 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_system_channel := ( - Some ( - ( - read_channel - ) p lb - ) - ); - ) - | 21 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_large := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | 22 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_unavailable := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | 23 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_member_count := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | 24 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_members := ( - Some ( - ( - read__9 - ) p lb - ) - ); - ) - | 25 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_channels := ( - Some ( - ( - read__11 - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 4 -> ( - match String.unsafe_get s pos with - | 'i' -> ( - if String.unsafe_get s (pos+1) = 'c' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'n' then ( - 2 - ) - else ( - -1 - ) - ) - | 'n' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 5 -> ( - match String.unsafe_get s pos with - | 'l' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' then ( - 21 - ) - else ( - -1 - ) - ) - | 'r' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( - 13 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 6 -> ( - match String.unsafe_get s pos with - | 'e' -> ( - if String.unsafe_get s (pos+1) = 'm' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'j' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 's' then ( - 14 - ) - else ( - -1 - ) - ) - | 'r' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'g' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'n' then ( - 5 - ) - else ( - -1 - ) - ) - | 's' -> ( - if String.unsafe_get s (pos+1) = 'p' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = 'h' then ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 7 -> ( - if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'b' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 's' then ( - 24 - ) - else ( - -1 - ) - ) - | 8 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 's' then ( - 25 - ) - else ( - -1 - ) - ) - | 'f' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 's' then ( - 15 - ) - else ( - -1 - ) - ) - | 'o' -> ( - if String.unsafe_get s (pos+1) = 'w' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( - 4 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 9 -> ( - if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'f' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'l' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'v' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'l' then ( - 16 - ) - else ( - -1 - ) - ) - | 11 -> ( - match String.unsafe_get s pos with - | 'a' -> ( - if String.unsafe_get s (pos+1) = 'f' && String.unsafe_get s (pos+2) = 'k' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'u' && String.unsafe_get s (pos+10) = 't' then ( - 7 - ) - else ( - -1 - ) - ) - | 'u' -> ( - if String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'v' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'b' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = 'e' then ( - 22 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 12 -> ( - if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'b' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'u' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = 't' then ( - 23 - ) - else ( - -1 - ) - ) - | 13 -> ( - if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'm' && String.unsafe_get s (pos+2) = 'b' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'b' && String.unsafe_get s (pos+10) = 'l' && String.unsafe_get s (pos+11) = 'e' && String.unsafe_get s (pos+12) = 'd' then ( - 8 - ) - else ( - -1 - ) - ) - | 14 -> ( - match String.unsafe_get s pos with - | 'a' -> ( - match String.unsafe_get s (pos+1) with - | 'f' -> ( - if String.unsafe_get s (pos+2) = 'k' && String.unsafe_get s (pos+3) = '_' && String.unsafe_get s (pos+4) = 'c' && String.unsafe_get s (pos+5) = 'h' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 'l' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 'i' && String.unsafe_get s (pos+13) = 'd' then ( - 6 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = '_' && String.unsafe_get s (pos+12) = 'i' && String.unsafe_get s (pos+13) = 'd' then ( - 17 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 's' -> ( - if String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'm' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'h' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = 'n' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'l' then ( - 20 - ) - else ( - -1 - ) - ) - | 'w' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = '_' then ( - match String.unsafe_get s (pos+7) with - | 'c' -> ( - if String.unsafe_get s (pos+8) = 'h' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = 'n' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'l' then ( - 19 - ) - else ( - -1 - ) - ) - | 'e' -> ( - if String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 'b' && String.unsafe_get s (pos+11) = 'l' && String.unsafe_get s (pos+12) = 'e' && String.unsafe_get s (pos+13) = 'd' then ( - 18 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 16 -> ( - if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'm' && String.unsafe_get s (pos+2) = 'b' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'c' && String.unsafe_get s (pos+7) = 'h' && String.unsafe_get s (pos+8) = 'a' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 'n' && String.unsafe_get s (pos+11) = 'e' && String.unsafe_get s (pos+12) = 'l' && String.unsafe_get s (pos+13) = '_' && String.unsafe_get s (pos+14) = 'i' && String.unsafe_get s (pos+15) = 'd' then ( - 9 - ) - else ( - -1 - ) - ) - | 18 -> ( - if String.unsafe_get s pos = 'v' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'f' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'c' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'n' && String.unsafe_get s (pos+12) = '_' && String.unsafe_get s (pos+13) = 'l' && String.unsafe_get s (pos+14) = 'e' && String.unsafe_get s (pos+15) = 'v' && String.unsafe_get s (pos+16) = 'e' && String.unsafe_get s (pos+17) = 'l' then ( - 10 - ) - else ( - -1 - ) - ) - | 23 -> ( - if String.unsafe_get s pos = 'e' && String.unsafe_get s (pos+1) = 'x' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'c' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = '_' && String.unsafe_get s (pos+9) = 'c' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'n' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'e' && String.unsafe_get s (pos+14) = 'n' && String.unsafe_get s (pos+15) = 't' && String.unsafe_get s (pos+16) = '_' && String.unsafe_get s (pos+17) = 'f' && String.unsafe_get s (pos+18) = 'i' && String.unsafe_get s (pos+19) = 'l' && String.unsafe_get s (pos+20) = 't' && String.unsafe_get s (pos+21) = 'e' && String.unsafe_get s (pos+22) = 'r' then ( - 12 - ) - else ( - -1 - ) - ) - | 29 -> ( - if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'f' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 'l' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'm' && String.unsafe_get s (pos+9) = 'e' && String.unsafe_get s (pos+10) = 's' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 'a' && String.unsafe_get s (pos+13) = 'g' && String.unsafe_get s (pos+14) = 'e' && String.unsafe_get s (pos+15) = '_' && String.unsafe_get s (pos+16) = 'n' && String.unsafe_get s (pos+17) = 'o' && String.unsafe_get s (pos+18) = 't' && String.unsafe_get s (pos+19) = 'i' && String.unsafe_get s (pos+20) = 'f' && String.unsafe_get s (pos+21) = 'i' && String.unsafe_get s (pos+22) = 'c' && String.unsafe_get s (pos+23) = 'a' && String.unsafe_get s (pos+24) = 't' && String.unsafe_get s (pos+25) = 'i' && String.unsafe_get s (pos+26) = 'o' && String.unsafe_get s (pos+27) = 'n' && String.unsafe_get s (pos+28) = 's' then ( - 11 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_name := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_icon := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_splash := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 4 -> - field_owner_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 5 -> - field_region := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x8; - | 6 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_afk_channel_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 7 -> - field_afk_timeout := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x10; - | 8 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_embed_enabled := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | 9 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_embed_channel_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 10 -> - field_verification_level := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x20; - | 11 -> - field_default_message_notifications := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x40; - | 12 -> - field_explicit_content_filter := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x80; - | 13 -> - field_roles := ( - ( - read__4 - ) p lb - ); - bits0 := !bits0 lor 0x100; - | 14 -> - field_emojis := ( - ( - read__5 - ) p lb - ); - bits0 := !bits0 lor 0x200; - | 15 -> - field_features := ( - ( - read__6 - ) p lb - ); - bits0 := !bits0 lor 0x400; - | 16 -> - field_mfa_level := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x800; - | 17 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_application_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 18 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_widget_enabled := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | 19 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_widget_channel := ( - Some ( - ( - read_channel - ) p lb - ) - ); - ) - | 20 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_system_channel := ( - Some ( - ( - read_channel - ) p lb - ) - ); - ) - | 21 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_large := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | 22 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_unavailable := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ) - ); - ) - | 23 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_member_count := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ) - ); - ) - | 24 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_members := ( - Some ( - ( - read__9 - ) p lb - ) - ); - ) - | 25 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_channels := ( - Some ( - ( - read__11 - ) p lb - ) - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0xfff then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "id"; "name"; "owner_id"; "region"; "afk_timeout"; "verification_level"; "default_message_notifications"; "explicit_content_filter"; "roles"; "emojis"; "features"; "mfa_level" |]; - ( - { - id = !field_id; - name = !field_name; - icon = !field_icon; - splash = !field_splash; - owner_id = !field_owner_id; - region = !field_region; - afk_channel_id = !field_afk_channel_id; - afk_timeout = !field_afk_timeout; - embed_enabled = !field_embed_enabled; - embed_channel_id = !field_embed_channel_id; - verification_level = !field_verification_level; - default_message_notifications = !field_default_message_notifications; - explicit_content_filter = !field_explicit_content_filter; - roles = !field_roles; - emojis = !field_emojis; - features = !field_features; - mfa_level = !field_mfa_level; - application_id = !field_application_id; - widget_enabled = !field_widget_enabled; - widget_channel = !field_widget_channel; - system_channel = !field_system_channel; - large = !field_large; - unavailable = !field_unavailable; - member_count = !field_member_count; - members = !field_members; - channels = !field_channels; - } - : t) - ) -) -let t_of_string s = - read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s) diff --git a/lib/models/gen/guild_j.mli b/lib/models/gen/guild_j.mli deleted file mode 100644 index d430b2a..0000000 --- a/lib/models/gen/guild_j.mli +++ /dev/null @@ -1,184 +0,0 @@ -(* Auto-generated from "guild.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type role = Role_t.t - -type member = Member_t.t - -type emoji = Emoji_t.t - -type channel = Channel_t.t - -type t = Guild_t.t = { - id: snowflake; - name: string; - icon: string option; - splash: string option; - owner_id: snowflake; - region: string; - afk_channel_id: snowflake option; - afk_timeout: int; - embed_enabled: bool option; - embed_channel_id: snowflake option; - verification_level: int; - default_message_notifications: int; - explicit_content_filter: int; - roles: role list; - emojis: emoji list; - features: string list; - mfa_level: int; - application_id: snowflake option; - widget_enabled: bool option; - widget_channel: channel option; - system_channel: channel option; - large: bool option; - unavailable: bool option; - member_count: int option; - members: member list option; - channels: channel list option -} - -val write_user : - Bi_outbuf.t -> user -> unit - (** Output a JSON value of type {!user}. *) - -val string_of_user : - ?len:int -> user -> string - (** Serialize a value of type {!user} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_user : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> user - (** Input JSON data of type {!user}. *) - -val user_of_string : - string -> user - (** Deserialize JSON data of type {!user}. *) - -val write_snowflake : - Bi_outbuf.t -> snowflake -> unit - (** Output a JSON value of type {!snowflake}. *) - -val string_of_snowflake : - ?len:int -> snowflake -> string - (** Serialize a value of type {!snowflake} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_snowflake : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> snowflake - (** Input JSON data of type {!snowflake}. *) - -val snowflake_of_string : - string -> snowflake - (** Deserialize JSON data of type {!snowflake}. *) - -val write_role : - Bi_outbuf.t -> role -> unit - (** Output a JSON value of type {!role}. *) - -val string_of_role : - ?len:int -> role -> string - (** Serialize a value of type {!role} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_role : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> role - (** Input JSON data of type {!role}. *) - -val role_of_string : - string -> role - (** Deserialize JSON data of type {!role}. *) - -val write_member : - Bi_outbuf.t -> member -> unit - (** Output a JSON value of type {!member}. *) - -val string_of_member : - ?len:int -> member -> string - (** Serialize a value of type {!member} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_member : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> member - (** Input JSON data of type {!member}. *) - -val member_of_string : - string -> member - (** Deserialize JSON data of type {!member}. *) - -val write_emoji : - Bi_outbuf.t -> emoji -> unit - (** Output a JSON value of type {!emoji}. *) - -val string_of_emoji : - ?len:int -> emoji -> string - (** Serialize a value of type {!emoji} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_emoji : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> emoji - (** Input JSON data of type {!emoji}. *) - -val emoji_of_string : - string -> emoji - (** Deserialize JSON data of type {!emoji}. *) - -val write_channel : - Bi_outbuf.t -> channel -> unit - (** Output a JSON value of type {!channel}. *) - -val string_of_channel : - ?len:int -> channel -> string - (** Serialize a value of type {!channel} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_channel : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> channel - (** Input JSON data of type {!channel}. *) - -val channel_of_string : - string -> channel - (** Deserialize JSON data of type {!channel}. *) - -val write_t : - Bi_outbuf.t -> t -> unit - (** Output a JSON value of type {!t}. *) - -val string_of_t : - ?len:int -> t -> string - (** Serialize a value of type {!t} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_t : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> t - (** Input JSON data of type {!t}. *) - -val t_of_string : - string -> t - (** Deserialize JSON data of type {!t}. *) - diff --git a/lib/models/gen/guild_t.ml b/lib/models/gen/guild_t.ml deleted file mode 100644 index 9ffe83f..0000000 --- a/lib/models/gen/guild_t.ml +++ /dev/null @@ -1,43 +0,0 @@ -(* Auto-generated from "guild.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type role = Role_t.t - -type member = Member_t.t - -type emoji = Emoji_t.t - -type channel = Channel_t.t - -type t = { - id: snowflake; - name: string; - icon: string option; - splash: string option; - owner_id: snowflake; - region: string; - afk_channel_id: snowflake option; - afk_timeout: int; - embed_enabled: bool option; - embed_channel_id: snowflake option; - verification_level: int; - default_message_notifications: int; - explicit_content_filter: int; - roles: role list; - emojis: emoji list; - features: string list; - mfa_level: int; - application_id: snowflake option; - widget_enabled: bool option; - widget_channel: channel option; - system_channel: channel option; - large: bool option; - unavailable: bool option; - member_count: int option; - members: member list option; - channels: channel list option -} diff --git a/lib/models/gen/guild_t.mli b/lib/models/gen/guild_t.mli deleted file mode 100644 index 9ffe83f..0000000 --- a/lib/models/gen/guild_t.mli +++ /dev/null @@ -1,43 +0,0 @@ -(* Auto-generated from "guild.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type role = Role_t.t - -type member = Member_t.t - -type emoji = Emoji_t.t - -type channel = Channel_t.t - -type t = { - id: snowflake; - name: string; - icon: string option; - splash: string option; - owner_id: snowflake; - region: string; - afk_channel_id: snowflake option; - afk_timeout: int; - embed_enabled: bool option; - embed_channel_id: snowflake option; - verification_level: int; - default_message_notifications: int; - explicit_content_filter: int; - roles: role list; - emojis: emoji list; - features: string list; - mfa_level: int; - application_id: snowflake option; - widget_enabled: bool option; - widget_channel: channel option; - system_channel: channel option; - large: bool option; - unavailable: bool option; - member_count: int option; - members: member list option; - channels: channel list option -} diff --git a/lib/models/gen/member_j.ml b/lib/models/gen/member_j.ml deleted file mode 100644 index 7fd4aec..0000000 --- a/lib/models/gen/member_j.ml +++ /dev/null @@ -1,750 +0,0 @@ -(* Auto-generated from "member.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type t = Member_t.t = { - nick: string option; - roles: snowflake list; - joined_at: string; - deaf: bool; - mute: bool; - user: user -} - -type partial_member = Member_t.partial_member = { - nick: string option; - roles: snowflake list; - joined_at: string; - deaf: bool; - mute: bool -} - -let write_user = ( - User_j.write_t -) -let string_of_user ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_user ob x; - Bi_outbuf.contents ob -let read_user = ( - User_j.read_t -) -let user_of_string s = - read_user (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_snowflake = ( - Snowflake_j.write_t -) -let string_of_snowflake ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_snowflake ob x; - Bi_outbuf.contents ob -let read_snowflake = ( - Snowflake_j.read_t -) -let snowflake_of_string s = - read_snowflake (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__2 = ( - Atdgen_runtime.Oj_run.write_list ( - write_snowflake - ) -) -let string_of__2 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__2 ob x; - Bi_outbuf.contents ob -let read__2 = ( - Atdgen_runtime.Oj_run.read_list ( - read_snowflake - ) -) -let _2_of_string s = - read__2 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__1 = ( - Atdgen_runtime.Oj_run.write_option ( - Yojson.Safe.write_string - ) -) -let string_of__1 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__1 ob x; - Bi_outbuf.contents ob -let read__1 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _1_of_string s = - read__1 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_t : _ -> t -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - (match x.nick with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"nick\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"roles\":"; - ( - write__2 - ) - ob x.roles; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"joined_at\":"; - ( - Yojson.Safe.write_string - ) - ob x.joined_at; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"deaf\":"; - ( - Yojson.Safe.write_bool - ) - ob x.deaf; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"mute\":"; - ( - Yojson.Safe.write_bool - ) - ob x.mute; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"user\":"; - ( - write_user - ) - ob x.user; - Bi_outbuf.add_char ob '}'; -) -let string_of_t ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_t ob x; - Bi_outbuf.contents ob -let read_t = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_nick = ref (None) in - let field_roles = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_joined_at = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_deaf = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_mute = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_user = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let bits0 = ref 0 in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 4 -> ( - match String.unsafe_get s pos with - | 'd' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'f' then ( - 3 - ) - else ( - -1 - ) - ) - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'e' then ( - 4 - ) - else ( - -1 - ) - ) - | 'n' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'c' && String.unsafe_get s (pos+3) = 'k' then ( - 0 - ) - else ( - -1 - ) - ) - | 'u' -> ( - if String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'r' then ( - 5 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( - 1 - ) - else ( - -1 - ) - ) - | 9 -> ( - if String.unsafe_get s pos = 'j' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 't' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_nick := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 1 -> - field_roles := ( - ( - read__2 - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 2 -> - field_joined_at := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 3 -> - field_deaf := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 4 -> - field_mute := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x8; - | 5 -> - field_user := ( - ( - read_user - ) p lb - ); - bits0 := !bits0 lor 0x10; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 4 -> ( - match String.unsafe_get s pos with - | 'd' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'f' then ( - 3 - ) - else ( - -1 - ) - ) - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'e' then ( - 4 - ) - else ( - -1 - ) - ) - | 'n' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'c' && String.unsafe_get s (pos+3) = 'k' then ( - 0 - ) - else ( - -1 - ) - ) - | 'u' -> ( - if String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'r' then ( - 5 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( - 1 - ) - else ( - -1 - ) - ) - | 9 -> ( - if String.unsafe_get s pos = 'j' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 't' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_nick := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 1 -> - field_roles := ( - ( - read__2 - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 2 -> - field_joined_at := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 3 -> - field_deaf := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 4 -> - field_mute := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x8; - | 5 -> - field_user := ( - ( - read_user - ) p lb - ); - bits0 := !bits0 lor 0x10; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0x1f then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "roles"; "joined_at"; "deaf"; "mute"; "user" |]; - ( - { - nick = !field_nick; - roles = !field_roles; - joined_at = !field_joined_at; - deaf = !field_deaf; - mute = !field_mute; - user = !field_user; - } - : t) - ) -) -let t_of_string s = - read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_partial_member : _ -> partial_member -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - (match x.nick with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"nick\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"roles\":"; - ( - write__2 - ) - ob x.roles; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"joined_at\":"; - ( - Yojson.Safe.write_string - ) - ob x.joined_at; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"deaf\":"; - ( - Yojson.Safe.write_bool - ) - ob x.deaf; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"mute\":"; - ( - Yojson.Safe.write_bool - ) - ob x.mute; - Bi_outbuf.add_char ob '}'; -) -let string_of_partial_member ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_partial_member ob x; - Bi_outbuf.contents ob -let read_partial_member = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_nick = ref (None) in - let field_roles = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_joined_at = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_deaf = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_mute = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let bits0 = ref 0 in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 4 -> ( - match String.unsafe_get s pos with - | 'd' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'f' then ( - 3 - ) - else ( - -1 - ) - ) - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'e' then ( - 4 - ) - else ( - -1 - ) - ) - | 'n' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'c' && String.unsafe_get s (pos+3) = 'k' then ( - 0 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( - 1 - ) - else ( - -1 - ) - ) - | 9 -> ( - if String.unsafe_get s pos = 'j' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 't' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_nick := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 1 -> - field_roles := ( - ( - read__2 - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 2 -> - field_joined_at := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 3 -> - field_deaf := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 4 -> - field_mute := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x8; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 4 -> ( - match String.unsafe_get s pos with - | 'd' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'f' then ( - 3 - ) - else ( - -1 - ) - ) - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'e' then ( - 4 - ) - else ( - -1 - ) - ) - | 'n' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'c' && String.unsafe_get s (pos+3) = 'k' then ( - 0 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( - 1 - ) - else ( - -1 - ) - ) - | 9 -> ( - if String.unsafe_get s pos = 'j' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 't' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_nick := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 1 -> - field_roles := ( - ( - read__2 - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 2 -> - field_joined_at := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 3 -> - field_deaf := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 4 -> - field_mute := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x8; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0xf then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "roles"; "joined_at"; "deaf"; "mute" |]; - ( - { - nick = !field_nick; - roles = !field_roles; - joined_at = !field_joined_at; - deaf = !field_deaf; - mute = !field_mute; - } - : partial_member) - ) -) -let partial_member_of_string s = - read_partial_member (Yojson.Safe.init_lexer ()) (Lexing.from_string s) diff --git a/lib/models/gen/member_j.mli b/lib/models/gen/member_j.mli deleted file mode 100644 index f160b6d..0000000 --- a/lib/models/gen/member_j.mli +++ /dev/null @@ -1,104 +0,0 @@ -(* Auto-generated from "member.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type t = Member_t.t = { - nick: string option; - roles: snowflake list; - joined_at: string; - deaf: bool; - mute: bool; - user: user -} - -type partial_member = Member_t.partial_member = { - nick: string option; - roles: snowflake list; - joined_at: string; - deaf: bool; - mute: bool -} - -val write_user : - Bi_outbuf.t -> user -> unit - (** Output a JSON value of type {!user}. *) - -val string_of_user : - ?len:int -> user -> string - (** Serialize a value of type {!user} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_user : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> user - (** Input JSON data of type {!user}. *) - -val user_of_string : - string -> user - (** Deserialize JSON data of type {!user}. *) - -val write_snowflake : - Bi_outbuf.t -> snowflake -> unit - (** Output a JSON value of type {!snowflake}. *) - -val string_of_snowflake : - ?len:int -> snowflake -> string - (** Serialize a value of type {!snowflake} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_snowflake : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> snowflake - (** Input JSON data of type {!snowflake}. *) - -val snowflake_of_string : - string -> snowflake - (** Deserialize JSON data of type {!snowflake}. *) - -val write_t : - Bi_outbuf.t -> t -> unit - (** Output a JSON value of type {!t}. *) - -val string_of_t : - ?len:int -> t -> string - (** Serialize a value of type {!t} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_t : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> t - (** Input JSON data of type {!t}. *) - -val t_of_string : - string -> t - (** Deserialize JSON data of type {!t}. *) - -val write_partial_member : - Bi_outbuf.t -> partial_member -> unit - (** Output a JSON value of type {!partial_member}. *) - -val string_of_partial_member : - ?len:int -> partial_member -> string - (** Serialize a value of type {!partial_member} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_partial_member : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> partial_member - (** Input JSON data of type {!partial_member}. *) - -val partial_member_of_string : - string -> partial_member - (** Deserialize JSON data of type {!partial_member}. *) - diff --git a/lib/models/gen/member_t.ml b/lib/models/gen/member_t.ml deleted file mode 100644 index 6262e1b..0000000 --- a/lib/models/gen/member_t.ml +++ /dev/null @@ -1,23 +0,0 @@ -(* Auto-generated from "member.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type t = { - nick: string option; - roles: snowflake list; - joined_at: string; - deaf: bool; - mute: bool; - user: user -} - -type partial_member = { - nick: string option; - roles: snowflake list; - joined_at: string; - deaf: bool; - mute: bool -} diff --git a/lib/models/gen/member_t.mli b/lib/models/gen/member_t.mli deleted file mode 100644 index 6262e1b..0000000 --- a/lib/models/gen/member_t.mli +++ /dev/null @@ -1,23 +0,0 @@ -(* Auto-generated from "member.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type t = { - nick: string option; - roles: snowflake list; - joined_at: string; - deaf: bool; - mute: bool; - user: user -} - -type partial_member = { - nick: string option; - roles: snowflake list; - joined_at: string; - deaf: bool; - mute: bool -} diff --git a/lib/models/gen/message_j.ml b/lib/models/gen/message_j.ml deleted file mode 100644 index faea836..0000000 --- a/lib/models/gen/message_j.ml +++ /dev/null @@ -1,1363 +0,0 @@ -(* Auto-generated from "message.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type partial_member = Member_t.partial_member - -type embed = Embed_t.t - -type attachment = Attachment_t.t - -type t = Message_t.t = { - id: snowflake; - author: user; - channel_id: snowflake; - member: partial_member option; - guild_id: snowflake option; - content: string; - timestamp: string; - edited_timestamp: string option; - tts: bool; - mention_everyone: bool; - mentions: snowflake list; - role_mentions: snowflake list option; - attachments: attachment list; - embeds: embed list; - reactions: snowflake list option; - nonce: snowflake option; - pinned: bool; - webhook_id: snowflake option; - kind: int -} - -type reaction = Reaction_t.t - -type member = Member_t.t - -let write_user = ( - User_j.write_t -) -let string_of_user ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_user ob x; - Bi_outbuf.contents ob -let read_user = ( - User_j.read_t -) -let user_of_string s = - read_user (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_snowflake = ( - Snowflake_j.write_t -) -let string_of_snowflake ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_snowflake ob x; - Bi_outbuf.contents ob -let read_snowflake = ( - Snowflake_j.read_t -) -let snowflake_of_string s = - read_snowflake (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_partial_member = ( - Member_j.write_partial_member -) -let string_of_partial_member ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_partial_member ob x; - Bi_outbuf.contents ob -let read_partial_member = ( - Member_j.read_partial_member -) -let partial_member_of_string s = - read_partial_member (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_embed = ( - Embed_j.write_t -) -let string_of_embed ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_embed ob x; - Bi_outbuf.contents ob -let read_embed = ( - Embed_j.read_t -) -let embed_of_string s = - read_embed (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_attachment = ( - Attachment_j.write_t -) -let string_of_attachment ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_attachment ob x; - Bi_outbuf.contents ob -let read_attachment = ( - Attachment_j.read_t -) -let attachment_of_string s = - read_attachment (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__7 = ( - Atdgen_runtime.Oj_run.write_list ( - write_embed - ) -) -let string_of__7 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__7 ob x; - Bi_outbuf.contents ob -let read__7 = ( - Atdgen_runtime.Oj_run.read_list ( - read_embed - ) -) -let _7_of_string s = - read__7 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__6 = ( - Atdgen_runtime.Oj_run.write_list ( - write_attachment - ) -) -let string_of__6 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__6 ob x; - Bi_outbuf.contents ob -let read__6 = ( - Atdgen_runtime.Oj_run.read_list ( - read_attachment - ) -) -let _6_of_string s = - read__6 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__4 = ( - Atdgen_runtime.Oj_run.write_list ( - write_snowflake - ) -) -let string_of__4 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__4 ob x; - Bi_outbuf.contents ob -let read__4 = ( - Atdgen_runtime.Oj_run.read_list ( - read_snowflake - ) -) -let _4_of_string s = - read__4 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__5 = ( - Atdgen_runtime.Oj_run.write_option ( - write__4 - ) -) -let string_of__5 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__5 ob x; - Bi_outbuf.contents ob -let read__5 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read__4 - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read__4 - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _5_of_string s = - read__5 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__3 = ( - Atdgen_runtime.Oj_run.write_option ( - Yojson.Safe.write_string - ) -) -let string_of__3 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__3 ob x; - Bi_outbuf.contents ob -let read__3 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _3_of_string s = - read__3 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__2 = ( - Atdgen_runtime.Oj_run.write_option ( - write_snowflake - ) -) -let string_of__2 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__2 ob x; - Bi_outbuf.contents ob -let read__2 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read_snowflake - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_snowflake - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _2_of_string s = - read__2 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__1 = ( - Atdgen_runtime.Oj_run.write_option ( - write_partial_member - ) -) -let string_of__1 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__1 ob x; - Bi_outbuf.contents ob -let read__1 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read_partial_member - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_partial_member - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _1_of_string s = - read__1 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_t : _ -> t -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"id\":"; - ( - write_snowflake - ) - ob x.id; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"author\":"; - ( - write_user - ) - ob x.author; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"channel_id\":"; - ( - write_snowflake - ) - ob x.channel_id; - (match x.member with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"member\":"; - ( - write_partial_member - ) - ob x; - ); - (match x.guild_id with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"guild_id\":"; - ( - write_snowflake - ) - ob x; - ); - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"content\":"; - ( - Yojson.Safe.write_string - ) - ob x.content; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"timestamp\":"; - ( - Yojson.Safe.write_string - ) - ob x.timestamp; - (match x.edited_timestamp with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"edited_timestamp\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"tts\":"; - ( - Yojson.Safe.write_bool - ) - ob x.tts; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"mention_everyone\":"; - ( - Yojson.Safe.write_bool - ) - ob x.mention_everyone; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"mentions\":"; - ( - write__4 - ) - ob x.mentions; - (match x.role_mentions with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"role_mentions\":"; - ( - write__4 - ) - ob x; - ); - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"attachments\":"; - ( - write__6 - ) - ob x.attachments; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"embeds\":"; - ( - write__7 - ) - ob x.embeds; - (match x.reactions with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"reactions\":"; - ( - write__4 - ) - ob x; - ); - (match x.nonce with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"nonce\":"; - ( - write_snowflake - ) - ob x; - ); - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"pinned\":"; - ( - Yojson.Safe.write_bool - ) - ob x.pinned; - (match x.webhook_id with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"webhook_id\":"; - ( - write_snowflake - ) - ob x; - ); - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"type\":"; - ( - Yojson.Safe.write_int - ) - ob x.kind; - Bi_outbuf.add_char ob '}'; -) -let string_of_t ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_t ob x; - Bi_outbuf.contents ob -let read_t = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_id = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_author = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_channel_id = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_member = ref (None) in - let field_guild_id = ref (None) in - let field_content = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_timestamp = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_edited_timestamp = ref (None) in - let field_tts = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_mention_everyone = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_mentions = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_role_mentions = ref (None) in - let field_attachments = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_embeds = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_reactions = ref (None) in - let field_nonce = ref (None) in - let field_pinned = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_webhook_id = ref (None) in - let field_kind = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let bits0 = ref 0 in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 3 -> ( - if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 's' then ( - 8 - ) - else ( - -1 - ) - ) - | 4 -> ( - if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'e' then ( - 18 - ) - else ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'e' then ( - 15 - ) - else ( - -1 - ) - ) - | 6 -> ( - match String.unsafe_get s pos with - | 'a' -> ( - if String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'r' then ( - 1 - ) - else ( - -1 - ) - ) - | 'e' -> ( - if String.unsafe_get s (pos+1) = 'm' && String.unsafe_get s (pos+2) = 'b' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 's' then ( - 13 - ) - else ( - -1 - ) - ) - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'b' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' then ( - 3 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'd' then ( - 16 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 7 -> ( - if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 't' then ( - 5 - ) - else ( - -1 - ) - ) - | 8 -> ( - match String.unsafe_get s pos with - | 'g' -> ( - if String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( - 4 - ) - else ( - -1 - ) - ) - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 's' then ( - 10 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 9 -> ( - match String.unsafe_get s pos with - | 'r' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 's' then ( - 14 - ) - else ( - -1 - ) - ) - | 't' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 'm' && String.unsafe_get s (pos+8) = 'p' then ( - 6 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 10 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'd' then ( - 2 - ) - else ( - -1 - ) - ) - | 'w' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'b' && String.unsafe_get s (pos+3) = 'h' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'k' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'd' then ( - 17 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 11 -> ( - if String.unsafe_get s pos = 'a' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'c' && String.unsafe_get s (pos+5) = 'h' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 's' then ( - 12 - ) - else ( - -1 - ) - ) - | 13 -> ( - if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'm' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'n' && String.unsafe_get s (pos+12) = 's' then ( - 11 - ) - else ( - -1 - ) - ) - | 16 -> ( - match String.unsafe_get s pos with - | 'e' -> ( - if String.unsafe_get s (pos+1) = 'd' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'm' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 'm' && String.unsafe_get s (pos+15) = 'p' then ( - 7 - ) - else ( - -1 - ) - ) - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 'v' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 'r' && String.unsafe_get s (pos+12) = 'y' && String.unsafe_get s (pos+13) = 'o' && String.unsafe_get s (pos+14) = 'n' && String.unsafe_get s (pos+15) = 'e' then ( - 9 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_author := ( - ( - read_user - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - field_channel_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_member := ( - Some ( - ( - read_partial_member - ) p lb - ) - ); - ) - | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_guild_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 5 -> - field_content := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x8; - | 6 -> - field_timestamp := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x10; - | 7 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_edited_timestamp := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 8 -> - field_tts := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x20; - | 9 -> - field_mention_everyone := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x40; - | 10 -> - field_mentions := ( - ( - read__4 - ) p lb - ); - bits0 := !bits0 lor 0x80; - | 11 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_role_mentions := ( - Some ( - ( - read__4 - ) p lb - ) - ); - ) - | 12 -> - field_attachments := ( - ( - read__6 - ) p lb - ); - bits0 := !bits0 lor 0x100; - | 13 -> - field_embeds := ( - ( - read__7 - ) p lb - ); - bits0 := !bits0 lor 0x200; - | 14 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_reactions := ( - Some ( - ( - read__4 - ) p lb - ) - ); - ) - | 15 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_nonce := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 16 -> - field_pinned := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x400; - | 17 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_webhook_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 18 -> - field_kind := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x800; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 3 -> ( - if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 's' then ( - 8 - ) - else ( - -1 - ) - ) - | 4 -> ( - if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'y' && String.unsafe_get s (pos+2) = 'p' && String.unsafe_get s (pos+3) = 'e' then ( - 18 - ) - else ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'e' then ( - 15 - ) - else ( - -1 - ) - ) - | 6 -> ( - match String.unsafe_get s pos with - | 'a' -> ( - if String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'h' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'r' then ( - 1 - ) - else ( - -1 - ) - ) - | 'e' -> ( - if String.unsafe_get s (pos+1) = 'm' && String.unsafe_get s (pos+2) = 'b' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 's' then ( - 13 - ) - else ( - -1 - ) - ) - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'b' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' then ( - 3 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'd' then ( - 16 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 7 -> ( - if String.unsafe_get s pos = 'c' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 't' then ( - 5 - ) - else ( - -1 - ) - ) - | 8 -> ( - match String.unsafe_get s pos with - | 'g' -> ( - if String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( - 4 - ) - else ( - -1 - ) - ) - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 's' then ( - 10 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 9 -> ( - match String.unsafe_get s pos with - | 'r' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 's' then ( - 14 - ) - else ( - -1 - ) - ) - | 't' -> ( - if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 'm' && String.unsafe_get s (pos+8) = 'p' then ( - 6 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 10 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'h' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'l' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'd' then ( - 2 - ) - else ( - -1 - ) - ) - | 'w' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'b' && String.unsafe_get s (pos+3) = 'h' && String.unsafe_get s (pos+4) = 'o' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'k' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'd' then ( - 17 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 11 -> ( - if String.unsafe_get s pos = 'a' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'c' && String.unsafe_get s (pos+5) = 'h' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 't' && String.unsafe_get s (pos+10) = 's' then ( - 12 - ) - else ( - -1 - ) - ) - | 13 -> ( - if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'm' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'n' && String.unsafe_get s (pos+8) = 't' && String.unsafe_get s (pos+9) = 'i' && String.unsafe_get s (pos+10) = 'o' && String.unsafe_get s (pos+11) = 'n' && String.unsafe_get s (pos+12) = 's' then ( - 11 - ) - else ( - -1 - ) - ) - | 16 -> ( - match String.unsafe_get s pos with - | 'e' -> ( - if String.unsafe_get s (pos+1) = 'd' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = '_' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'm' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 's' && String.unsafe_get s (pos+12) = 't' && String.unsafe_get s (pos+13) = 'a' && String.unsafe_get s (pos+14) = 'm' && String.unsafe_get s (pos+15) = 'p' then ( - 7 - ) - else ( - -1 - ) - ) - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = '_' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 'v' && String.unsafe_get s (pos+10) = 'e' && String.unsafe_get s (pos+11) = 'r' && String.unsafe_get s (pos+12) = 'y' && String.unsafe_get s (pos+13) = 'o' && String.unsafe_get s (pos+14) = 'n' && String.unsafe_get s (pos+15) = 'e' then ( - 9 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_author := ( - ( - read_user - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - field_channel_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_member := ( - Some ( - ( - read_partial_member - ) p lb - ) - ); - ) - | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_guild_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 5 -> - field_content := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x8; - | 6 -> - field_timestamp := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x10; - | 7 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_edited_timestamp := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 8 -> - field_tts := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x20; - | 9 -> - field_mention_everyone := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x40; - | 10 -> - field_mentions := ( - ( - read__4 - ) p lb - ); - bits0 := !bits0 lor 0x80; - | 11 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_role_mentions := ( - Some ( - ( - read__4 - ) p lb - ) - ); - ) - | 12 -> - field_attachments := ( - ( - read__6 - ) p lb - ); - bits0 := !bits0 lor 0x100; - | 13 -> - field_embeds := ( - ( - read__7 - ) p lb - ); - bits0 := !bits0 lor 0x200; - | 14 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_reactions := ( - Some ( - ( - read__4 - ) p lb - ) - ); - ) - | 15 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_nonce := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 16 -> - field_pinned := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x400; - | 17 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_webhook_id := ( - Some ( - ( - read_snowflake - ) p lb - ) - ); - ) - | 18 -> - field_kind := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x800; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0xfff then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "id"; "author"; "channel_id"; "content"; "timestamp"; "tts"; "mention_everyone"; "mentions"; "attachments"; "embeds"; "pinned"; "kind" |]; - ( - { - id = !field_id; - author = !field_author; - channel_id = !field_channel_id; - member = !field_member; - guild_id = !field_guild_id; - content = !field_content; - timestamp = !field_timestamp; - edited_timestamp = !field_edited_timestamp; - tts = !field_tts; - mention_everyone = !field_mention_everyone; - mentions = !field_mentions; - role_mentions = !field_role_mentions; - attachments = !field_attachments; - embeds = !field_embeds; - reactions = !field_reactions; - nonce = !field_nonce; - pinned = !field_pinned; - webhook_id = !field_webhook_id; - kind = !field_kind; - } - : t) - ) -) -let t_of_string s = - read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_reaction = ( - Reaction_j.write_t -) -let string_of_reaction ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_reaction ob x; - Bi_outbuf.contents ob -let read_reaction = ( - Reaction_j.read_t -) -let reaction_of_string s = - read_reaction (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_member = ( - Member_j.write_t -) -let string_of_member ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_member ob x; - Bi_outbuf.contents ob -let read_member = ( - Member_j.read_t -) -let member_of_string s = - read_member (Yojson.Safe.init_lexer ()) (Lexing.from_string s) diff --git a/lib/models/gen/message_j.mli b/lib/models/gen/message_j.mli deleted file mode 100644 index 04aa440..0000000 --- a/lib/models/gen/message_j.mli +++ /dev/null @@ -1,199 +0,0 @@ -(* Auto-generated from "message.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type partial_member = Member_t.partial_member - -type embed = Embed_t.t - -type attachment = Attachment_t.t - -type t = Message_t.t = { - id: snowflake; - author: user; - channel_id: snowflake; - member: partial_member option; - guild_id: snowflake option; - content: string; - timestamp: string; - edited_timestamp: string option; - tts: bool; - mention_everyone: bool; - mentions: snowflake list; - role_mentions: snowflake list option; - attachments: attachment list; - embeds: embed list; - reactions: snowflake list option; - nonce: snowflake option; - pinned: bool; - webhook_id: snowflake option; - kind: int -} - -type reaction = Reaction_t.t - -type member = Member_t.t - -val write_user : - Bi_outbuf.t -> user -> unit - (** Output a JSON value of type {!user}. *) - -val string_of_user : - ?len:int -> user -> string - (** Serialize a value of type {!user} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_user : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> user - (** Input JSON data of type {!user}. *) - -val user_of_string : - string -> user - (** Deserialize JSON data of type {!user}. *) - -val write_snowflake : - Bi_outbuf.t -> snowflake -> unit - (** Output a JSON value of type {!snowflake}. *) - -val string_of_snowflake : - ?len:int -> snowflake -> string - (** Serialize a value of type {!snowflake} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_snowflake : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> snowflake - (** Input JSON data of type {!snowflake}. *) - -val snowflake_of_string : - string -> snowflake - (** Deserialize JSON data of type {!snowflake}. *) - -val write_partial_member : - Bi_outbuf.t -> partial_member -> unit - (** Output a JSON value of type {!partial_member}. *) - -val string_of_partial_member : - ?len:int -> partial_member -> string - (** Serialize a value of type {!partial_member} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_partial_member : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> partial_member - (** Input JSON data of type {!partial_member}. *) - -val partial_member_of_string : - string -> partial_member - (** Deserialize JSON data of type {!partial_member}. *) - -val write_embed : - Bi_outbuf.t -> embed -> unit - (** Output a JSON value of type {!embed}. *) - -val string_of_embed : - ?len:int -> embed -> string - (** Serialize a value of type {!embed} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_embed : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> embed - (** Input JSON data of type {!embed}. *) - -val embed_of_string : - string -> embed - (** Deserialize JSON data of type {!embed}. *) - -val write_attachment : - Bi_outbuf.t -> attachment -> unit - (** Output a JSON value of type {!attachment}. *) - -val string_of_attachment : - ?len:int -> attachment -> string - (** Serialize a value of type {!attachment} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_attachment : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> attachment - (** Input JSON data of type {!attachment}. *) - -val attachment_of_string : - string -> attachment - (** Deserialize JSON data of type {!attachment}. *) - -val write_t : - Bi_outbuf.t -> t -> unit - (** Output a JSON value of type {!t}. *) - -val string_of_t : - ?len:int -> t -> string - (** Serialize a value of type {!t} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_t : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> t - (** Input JSON data of type {!t}. *) - -val t_of_string : - string -> t - (** Deserialize JSON data of type {!t}. *) - -val write_reaction : - Bi_outbuf.t -> reaction -> unit - (** Output a JSON value of type {!reaction}. *) - -val string_of_reaction : - ?len:int -> reaction -> string - (** Serialize a value of type {!reaction} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_reaction : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> reaction - (** Input JSON data of type {!reaction}. *) - -val reaction_of_string : - string -> reaction - (** Deserialize JSON data of type {!reaction}. *) - -val write_member : - Bi_outbuf.t -> member -> unit - (** Output a JSON value of type {!member}. *) - -val string_of_member : - ?len:int -> member -> string - (** Serialize a value of type {!member} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_member : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> member - (** Input JSON data of type {!member}. *) - -val member_of_string : - string -> member - (** Deserialize JSON data of type {!member}. *) - diff --git a/lib/models/gen/message_t.ml b/lib/models/gen/message_t.ml deleted file mode 100644 index ce2d5a4..0000000 --- a/lib/models/gen/message_t.ml +++ /dev/null @@ -1,38 +0,0 @@ -(* Auto-generated from "message.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type partial_member = Member_t.partial_member - -type embed = Embed_t.t - -type attachment = Attachment_t.t - -type t = { - id: snowflake; - author: user; - channel_id: snowflake; - member: partial_member option; - guild_id: snowflake option; - content: string; - timestamp: string; - edited_timestamp: string option; - tts: bool; - mention_everyone: bool; - mentions: snowflake list; - role_mentions: snowflake list option; - attachments: attachment list; - embeds: embed list; - reactions: snowflake list option; - nonce: snowflake option; - pinned: bool; - webhook_id: snowflake option; - kind: int -} - -type reaction = Reaction_t.t - -type member = Member_t.t diff --git a/lib/models/gen/message_t.mli b/lib/models/gen/message_t.mli deleted file mode 100644 index ce2d5a4..0000000 --- a/lib/models/gen/message_t.mli +++ /dev/null @@ -1,38 +0,0 @@ -(* Auto-generated from "message.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type partial_member = Member_t.partial_member - -type embed = Embed_t.t - -type attachment = Attachment_t.t - -type t = { - id: snowflake; - author: user; - channel_id: snowflake; - member: partial_member option; - guild_id: snowflake option; - content: string; - timestamp: string; - edited_timestamp: string option; - tts: bool; - mention_everyone: bool; - mentions: snowflake list; - role_mentions: snowflake list option; - attachments: attachment list; - embeds: embed list; - reactions: snowflake list option; - nonce: snowflake option; - pinned: bool; - webhook_id: snowflake option; - kind: int -} - -type reaction = Reaction_t.t - -type member = Member_t.t diff --git a/lib/models/gen/presence_j.ml b/lib/models/gen/presence_j.ml deleted file mode 100644 index b4ea497..0000000 --- a/lib/models/gen/presence_j.ml +++ /dev/null @@ -1,492 +0,0 @@ -(* Auto-generated from "presence.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type partial_user = User_t.partial_user - -type activity = Activity_t.t - -type t = Presence_t.t = { - user: partial_user; - roles: snowflake list; - game: activity option; - guild_id: snowflake; - status: string; - activities: activity list -} - -let write_user = ( - User_j.write_t -) -let string_of_user ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_user ob x; - Bi_outbuf.contents ob -let read_user = ( - User_j.read_t -) -let user_of_string s = - read_user (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_snowflake = ( - Snowflake_j.write_t -) -let string_of_snowflake ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_snowflake ob x; - Bi_outbuf.contents ob -let read_snowflake = ( - Snowflake_j.read_t -) -let snowflake_of_string s = - read_snowflake (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_partial_user = ( - User_j.write_partial_user -) -let string_of_partial_user ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_partial_user ob x; - Bi_outbuf.contents ob -let read_partial_user = ( - User_j.read_partial_user -) -let partial_user_of_string s = - read_partial_user (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_activity = ( - Activity_j.write_t -) -let string_of_activity ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_activity ob x; - Bi_outbuf.contents ob -let read_activity = ( - Activity_j.read_t -) -let activity_of_string s = - read_activity (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__3 = ( - Atdgen_runtime.Oj_run.write_list ( - write_activity - ) -) -let string_of__3 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__3 ob x; - Bi_outbuf.contents ob -let read__3 = ( - Atdgen_runtime.Oj_run.read_list ( - read_activity - ) -) -let _3_of_string s = - read__3 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__2 = ( - Atdgen_runtime.Oj_run.write_option ( - write_activity - ) -) -let string_of__2 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__2 ob x; - Bi_outbuf.contents ob -let read__2 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - read_activity - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - read_activity - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _2_of_string s = - read__2 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__1 = ( - Atdgen_runtime.Oj_run.write_list ( - write_snowflake - ) -) -let string_of__1 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__1 ob x; - Bi_outbuf.contents ob -let read__1 = ( - Atdgen_runtime.Oj_run.read_list ( - read_snowflake - ) -) -let _1_of_string s = - read__1 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_t : _ -> t -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"user\":"; - ( - write_partial_user - ) - ob x.user; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"roles\":"; - ( - write__1 - ) - ob x.roles; - (match x.game with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"game\":"; - ( - write_activity - ) - ob x; - ); - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"guild_id\":"; - ( - write_snowflake - ) - ob x.guild_id; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"status\":"; - ( - Yojson.Safe.write_string - ) - ob x.status; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"activities\":"; - ( - write__3 - ) - ob x.activities; - Bi_outbuf.add_char ob '}'; -) -let string_of_t ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_t ob x; - Bi_outbuf.contents ob -let read_t = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_user = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_roles = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_game = ref (None) in - let field_guild_id = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_status = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_activities = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let bits0 = ref 0 in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 4 -> ( - match String.unsafe_get s pos with - | 'g' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 2 - ) - else ( - -1 - ) - ) - | 'u' -> ( - if String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'r' then ( - 0 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( - 1 - ) - else ( - -1 - ) - ) - | 6 -> ( - if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 's' then ( - 4 - ) - else ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'g' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( - 3 - ) - else ( - -1 - ) - ) - | 10 -> ( - if String.unsafe_get s pos = 'a' && String.unsafe_get s (pos+1) = 'c' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'v' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 's' then ( - 5 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_user := ( - ( - read_partial_user - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_roles := ( - ( - read__1 - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_game := ( - Some ( - ( - read_activity - ) p lb - ) - ); - ) - | 3 -> - field_guild_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 4 -> - field_status := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x8; - | 5 -> - field_activities := ( - ( - read__3 - ) p lb - ); - bits0 := !bits0 lor 0x10; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 4 -> ( - match String.unsafe_get s pos with - | 'g' -> ( - if String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 2 - ) - else ( - -1 - ) - ) - | 'u' -> ( - if String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'r' then ( - 0 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 5 -> ( - if String.unsafe_get s pos = 'r' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' then ( - 1 - ) - else ( - -1 - ) - ) - | 6 -> ( - if String.unsafe_get s pos = 's' && String.unsafe_get s (pos+1) = 't' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 's' then ( - 4 - ) - else ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'g' && String.unsafe_get s (pos+1) = 'u' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'd' then ( - 3 - ) - else ( - -1 - ) - ) - | 10 -> ( - if String.unsafe_get s pos = 'a' && String.unsafe_get s (pos+1) = 'c' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'v' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 't' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'e' && String.unsafe_get s (pos+9) = 's' then ( - 5 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_user := ( - ( - read_partial_user - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_roles := ( - ( - read__1 - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_game := ( - Some ( - ( - read_activity - ) p lb - ) - ); - ) - | 3 -> - field_guild_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 4 -> - field_status := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x8; - | 5 -> - field_activities := ( - ( - read__3 - ) p lb - ); - bits0 := !bits0 lor 0x10; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0x1f then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "user"; "roles"; "guild_id"; "status"; "activities" |]; - ( - { - user = !field_user; - roles = !field_roles; - game = !field_game; - guild_id = !field_guild_id; - status = !field_status; - activities = !field_activities; - } - : t) - ) -) -let t_of_string s = - read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s) diff --git a/lib/models/gen/presence_j.mli b/lib/models/gen/presence_j.mli deleted file mode 100644 index be68b3f..0000000 --- a/lib/models/gen/presence_j.mli +++ /dev/null @@ -1,120 +0,0 @@ -(* Auto-generated from "presence.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type partial_user = User_t.partial_user - -type activity = Activity_t.t - -type t = Presence_t.t = { - user: partial_user; - roles: snowflake list; - game: activity option; - guild_id: snowflake; - status: string; - activities: activity list -} - -val write_user : - Bi_outbuf.t -> user -> unit - (** Output a JSON value of type {!user}. *) - -val string_of_user : - ?len:int -> user -> string - (** Serialize a value of type {!user} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_user : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> user - (** Input JSON data of type {!user}. *) - -val user_of_string : - string -> user - (** Deserialize JSON data of type {!user}. *) - -val write_snowflake : - Bi_outbuf.t -> snowflake -> unit - (** Output a JSON value of type {!snowflake}. *) - -val string_of_snowflake : - ?len:int -> snowflake -> string - (** Serialize a value of type {!snowflake} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_snowflake : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> snowflake - (** Input JSON data of type {!snowflake}. *) - -val snowflake_of_string : - string -> snowflake - (** Deserialize JSON data of type {!snowflake}. *) - -val write_partial_user : - Bi_outbuf.t -> partial_user -> unit - (** Output a JSON value of type {!partial_user}. *) - -val string_of_partial_user : - ?len:int -> partial_user -> string - (** Serialize a value of type {!partial_user} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_partial_user : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> partial_user - (** Input JSON data of type {!partial_user}. *) - -val partial_user_of_string : - string -> partial_user - (** Deserialize JSON data of type {!partial_user}. *) - -val write_activity : - Bi_outbuf.t -> activity -> unit - (** Output a JSON value of type {!activity}. *) - -val string_of_activity : - ?len:int -> activity -> string - (** Serialize a value of type {!activity} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_activity : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> activity - (** Input JSON data of type {!activity}. *) - -val activity_of_string : - string -> activity - (** Deserialize JSON data of type {!activity}. *) - -val write_t : - Bi_outbuf.t -> t -> unit - (** Output a JSON value of type {!t}. *) - -val string_of_t : - ?len:int -> t -> string - (** Serialize a value of type {!t} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_t : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> t - (** Input JSON data of type {!t}. *) - -val t_of_string : - string -> t - (** Deserialize JSON data of type {!t}. *) - diff --git a/lib/models/gen/presence_t.ml b/lib/models/gen/presence_t.ml deleted file mode 100644 index 940d986..0000000 --- a/lib/models/gen/presence_t.ml +++ /dev/null @@ -1,19 +0,0 @@ -(* Auto-generated from "presence.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type partial_user = User_t.partial_user - -type activity = Activity_t.t - -type t = { - user: partial_user; - roles: snowflake list; - game: activity option; - guild_id: snowflake; - status: string; - activities: activity list -} diff --git a/lib/models/gen/presence_t.mli b/lib/models/gen/presence_t.mli deleted file mode 100644 index 940d986..0000000 --- a/lib/models/gen/presence_t.mli +++ /dev/null @@ -1,19 +0,0 @@ -(* Auto-generated from "presence.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type user = User_t.t - -type snowflake = Snowflake_t.t - -type partial_user = User_t.partial_user - -type activity = Activity_t.t - -type t = { - user: partial_user; - roles: snowflake list; - game: activity option; - guild_id: snowflake; - status: string; - activities: activity list -} diff --git a/lib/models/gen/reaction_j.ml b/lib/models/gen/reaction_j.ml deleted file mode 100644 index fe91833..0000000 --- a/lib/models/gen/reaction_j.ml +++ /dev/null @@ -1,180 +0,0 @@ -(* Auto-generated from "reaction.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type emoji = Emoji_t.t - -type t = Reaction_t.t = { count: int; emoji: emoji } - -let write_emoji = ( - Emoji_j.write_t -) -let string_of_emoji ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_emoji ob x; - Bi_outbuf.contents ob -let read_emoji = ( - Emoji_j.read_t -) -let emoji_of_string s = - read_emoji (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_t : _ -> t -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"count\":"; - ( - Yojson.Safe.write_int - ) - ob x.count; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"emoji\":"; - ( - write_emoji - ) - ob x.emoji; - Bi_outbuf.add_char ob '}'; -) -let string_of_t ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_t ob x; - Bi_outbuf.contents ob -let read_t = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_count = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_emoji = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let bits0 = ref 0 in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - if len = 5 then ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'u' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 't' then ( - 0 - ) - else ( - -1 - ) - ) - | 'e' -> ( - if String.unsafe_get s (pos+1) = 'm' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'j' && String.unsafe_get s (pos+4) = 'i' then ( - 1 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - else ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_count := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_emoji := ( - ( - read_emoji - ) p lb - ); - bits0 := !bits0 lor 0x2; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - if len = 5 then ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'u' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = 't' then ( - 0 - ) - else ( - -1 - ) - ) - | 'e' -> ( - if String.unsafe_get s (pos+1) = 'm' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'j' && String.unsafe_get s (pos+4) = 'i' then ( - 1 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - else ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_count := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_emoji := ( - ( - read_emoji - ) p lb - ); - bits0 := !bits0 lor 0x2; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0x3 then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "count"; "emoji" |]; - ( - { - count = !field_count; - emoji = !field_emoji; - } - : t) - ) -) -let t_of_string s = - read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s) diff --git a/lib/models/gen/reaction_j.mli b/lib/models/gen/reaction_j.mli deleted file mode 100644 index 0d6a598..0000000 --- a/lib/models/gen/reaction_j.mli +++ /dev/null @@ -1,47 +0,0 @@ -(* Auto-generated from "reaction.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type emoji = Emoji_t.t - -type t = Reaction_t.t = { count: int; emoji: emoji } - -val write_emoji : - Bi_outbuf.t -> emoji -> unit - (** Output a JSON value of type {!emoji}. *) - -val string_of_emoji : - ?len:int -> emoji -> string - (** Serialize a value of type {!emoji} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_emoji : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> emoji - (** Input JSON data of type {!emoji}. *) - -val emoji_of_string : - string -> emoji - (** Deserialize JSON data of type {!emoji}. *) - -val write_t : - Bi_outbuf.t -> t -> unit - (** Output a JSON value of type {!t}. *) - -val string_of_t : - ?len:int -> t -> string - (** Serialize a value of type {!t} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_t : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> t - (** Input JSON data of type {!t}. *) - -val t_of_string : - string -> t - (** Deserialize JSON data of type {!t}. *) - diff --git a/lib/models/gen/reaction_t.ml b/lib/models/gen/reaction_t.ml deleted file mode 100644 index 666030b..0000000 --- a/lib/models/gen/reaction_t.ml +++ /dev/null @@ -1,6 +0,0 @@ -(* Auto-generated from "reaction.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type emoji = Emoji_t.t - -type t = { count: int; emoji: emoji } diff --git a/lib/models/gen/reaction_t.mli b/lib/models/gen/reaction_t.mli deleted file mode 100644 index 666030b..0000000 --- a/lib/models/gen/reaction_t.mli +++ /dev/null @@ -1,6 +0,0 @@ -(* Auto-generated from "reaction.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type emoji = Emoji_t.t - -type t = { count: int; emoji: emoji } diff --git a/lib/models/gen/role_j.ml b/lib/models/gen/role_j.ml deleted file mode 100644 index a15b6cf..0000000 --- a/lib/models/gen/role_j.ml +++ /dev/null @@ -1,449 +0,0 @@ -(* Auto-generated from "role.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type snowflake = Snowflake_t.t - -type t = Role_t.t = { - id: snowflake; - name: string; - colour: int; - hoist: bool; - position: int; - permissions: int; - managed: bool; - mentionable: bool -} - -let write_snowflake = ( - Snowflake_j.write_t -) -let string_of_snowflake ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_snowflake ob x; - Bi_outbuf.contents ob -let read_snowflake = ( - Snowflake_j.read_t -) -let snowflake_of_string s = - read_snowflake (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_t : _ -> t -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"id\":"; - ( - write_snowflake - ) - ob x.id; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"name\":"; - ( - Yojson.Safe.write_string - ) - ob x.name; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"color\":"; - ( - Yojson.Safe.write_int - ) - ob x.colour; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"hoist\":"; - ( - Yojson.Safe.write_bool - ) - ob x.hoist; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"position\":"; - ( - Yojson.Safe.write_int - ) - ob x.position; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"permissions\":"; - ( - Yojson.Safe.write_int - ) - ob x.permissions; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"managed\":"; - ( - Yojson.Safe.write_bool - ) - ob x.managed; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"mentionable\":"; - ( - Yojson.Safe.write_bool - ) - ob x.mentionable; - Bi_outbuf.add_char ob '}'; -) -let string_of_t ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_t ob x; - Bi_outbuf.contents ob -let read_t = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_id = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_name = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_colour = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_hoist = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_position = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_permissions = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_managed = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_mentionable = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let bits0 = ref 0 in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 4 -> ( - if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | 5 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'o' && String.unsafe_get s (pos+4) = 'r' then ( - 2 - ) - else ( - -1 - ) - ) - | 'h' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 't' then ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 7 -> ( - if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'g' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'd' then ( - 6 - ) - else ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' then ( - 4 - ) - else ( - -1 - ) - ) - | 11 -> ( - match String.unsafe_get s pos with - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'b' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = 'e' then ( - 7 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 's' && String.unsafe_get s (pos+6) = 's' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 's' then ( - 5 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_name := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - field_colour := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 3 -> - field_hoist := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x8; - | 4 -> - field_position := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x10; - | 5 -> - field_permissions := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x20; - | 6 -> - field_managed := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x40; - | 7 -> - field_mentionable := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x80; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 4 -> ( - if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | 5 -> ( - match String.unsafe_get s pos with - | 'c' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'o' && String.unsafe_get s (pos+4) = 'r' then ( - 2 - ) - else ( - -1 - ) - ) - | 'h' -> ( - if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 's' && String.unsafe_get s (pos+4) = 't' then ( - 3 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | 7 -> ( - if String.unsafe_get s pos = 'm' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'a' && String.unsafe_get s (pos+4) = 'g' && String.unsafe_get s (pos+5) = 'e' && String.unsafe_get s (pos+6) = 'd' then ( - 6 - ) - else ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 't' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'o' && String.unsafe_get s (pos+7) = 'n' then ( - 4 - ) - else ( - -1 - ) - ) - | 11 -> ( - match String.unsafe_get s pos with - | 'm' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'o' && String.unsafe_get s (pos+6) = 'n' && String.unsafe_get s (pos+7) = 'a' && String.unsafe_get s (pos+8) = 'b' && String.unsafe_get s (pos+9) = 'l' && String.unsafe_get s (pos+10) = 'e' then ( - 7 - ) - else ( - -1 - ) - ) - | 'p' -> ( - if String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'r' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 's' && String.unsafe_get s (pos+6) = 's' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = 's' then ( - 5 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_name := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - field_colour := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 3 -> - field_hoist := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x8; - | 4 -> - field_position := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x10; - | 5 -> - field_permissions := ( - ( - Atdgen_runtime.Oj_run.read_int - ) p lb - ); - bits0 := !bits0 lor 0x20; - | 6 -> - field_managed := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x40; - | 7 -> - field_mentionable := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - bits0 := !bits0 lor 0x80; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0xff then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "id"; "name"; "colour"; "hoist"; "position"; "permissions"; "managed"; "mentionable" |]; - ( - { - id = !field_id; - name = !field_name; - colour = !field_colour; - hoist = !field_hoist; - position = !field_position; - permissions = !field_permissions; - managed = !field_managed; - mentionable = !field_mentionable; - } - : t) - ) -) -let t_of_string s = - read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s) diff --git a/lib/models/gen/role_j.mli b/lib/models/gen/role_j.mli deleted file mode 100644 index b4ea78c..0000000 --- a/lib/models/gen/role_j.mli +++ /dev/null @@ -1,56 +0,0 @@ -(* Auto-generated from "role.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type snowflake = Snowflake_t.t - -type t = Role_t.t = { - id: snowflake; - name: string; - colour: int; - hoist: bool; - position: int; - permissions: int; - managed: bool; - mentionable: bool -} - -val write_snowflake : - Bi_outbuf.t -> snowflake -> unit - (** Output a JSON value of type {!snowflake}. *) - -val string_of_snowflake : - ?len:int -> snowflake -> string - (** Serialize a value of type {!snowflake} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_snowflake : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> snowflake - (** Input JSON data of type {!snowflake}. *) - -val snowflake_of_string : - string -> snowflake - (** Deserialize JSON data of type {!snowflake}. *) - -val write_t : - Bi_outbuf.t -> t -> unit - (** Output a JSON value of type {!t}. *) - -val string_of_t : - ?len:int -> t -> string - (** Serialize a value of type {!t} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_t : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> t - (** Input JSON data of type {!t}. *) - -val t_of_string : - string -> t - (** Deserialize JSON data of type {!t}. *) - diff --git a/lib/models/gen/role_t.ml b/lib/models/gen/role_t.ml deleted file mode 100644 index a4e83c5..0000000 --- a/lib/models/gen/role_t.ml +++ /dev/null @@ -1,15 +0,0 @@ -(* Auto-generated from "role.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type snowflake = Snowflake_t.t - -type t = { - id: snowflake; - name: string; - colour: int; - hoist: bool; - position: int; - permissions: int; - managed: bool; - mentionable: bool -} diff --git a/lib/models/gen/role_t.mli b/lib/models/gen/role_t.mli deleted file mode 100644 index a4e83c5..0000000 --- a/lib/models/gen/role_t.mli +++ /dev/null @@ -1,15 +0,0 @@ -(* Auto-generated from "role.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type snowflake = Snowflake_t.t - -type t = { - id: snowflake; - name: string; - colour: int; - hoist: bool; - position: int; - permissions: int; - managed: bool; - mentionable: bool -} diff --git a/lib/models/gen/snowflake_j.ml b/lib/models/gen/snowflake_j.ml deleted file mode 100644 index 80f6f63..0000000 --- a/lib/models/gen/snowflake_j.ml +++ /dev/null @@ -1,17 +0,0 @@ -(* Auto-generated from "snowflake.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type t = Snowflake_t.t - -let write_t = ( - Yojson.Safe.write_int -) -let string_of_t ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_t ob x; - Bi_outbuf.contents ob -let read_t = ( - Atdgen_runtime.Oj_run.read_int -) -let t_of_string s = - read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s) diff --git a/lib/models/gen/snowflake_j.mli b/lib/models/gen/snowflake_j.mli deleted file mode 100644 index fed97a4..0000000 --- a/lib/models/gen/snowflake_j.mli +++ /dev/null @@ -1,25 +0,0 @@ -(* Auto-generated from "snowflake.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type t = Snowflake_t.t - -val write_t : - Bi_outbuf.t -> t -> unit - (** Output a JSON value of type {!t}. *) - -val string_of_t : - ?len:int -> t -> string - (** Serialize a value of type {!t} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_t : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> t - (** Input JSON data of type {!t}. *) - -val t_of_string : - string -> t - (** Deserialize JSON data of type {!t}. *) - diff --git a/lib/models/gen/snowflake_t.ml b/lib/models/gen/snowflake_t.ml deleted file mode 100644 index a7bdb08..0000000 --- a/lib/models/gen/snowflake_t.ml +++ /dev/null @@ -1,4 +0,0 @@ -(* Auto-generated from "snowflake.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type t = int diff --git a/lib/models/gen/snowflake_t.mli b/lib/models/gen/snowflake_t.mli deleted file mode 100644 index a7bdb08..0000000 --- a/lib/models/gen/snowflake_t.mli +++ /dev/null @@ -1,4 +0,0 @@ -(* Auto-generated from "snowflake.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type t = int diff --git a/lib/models/gen/user_j.ml b/lib/models/gen/user_j.ml deleted file mode 100644 index 552a20d..0000000 --- a/lib/models/gen/user_j.ml +++ /dev/null @@ -1,468 +0,0 @@ -(* Auto-generated from "user.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type snowflake = Snowflake_t.t - -type t = User_t.t = { - id: snowflake; - username: string; - discriminator: string; - avatar: string option; - bot: bool -} - -type partial_user = User_t.partial_user = { id: snowflake } - -let write_snowflake = ( - Snowflake_j.write_t -) -let string_of_snowflake ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_snowflake ob x; - Bi_outbuf.contents ob -let read_snowflake = ( - Snowflake_j.read_t -) -let snowflake_of_string s = - read_snowflake (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write__1 = ( - Atdgen_runtime.Oj_run.write_option ( - Yojson.Safe.write_string - ) -) -let string_of__1 ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write__1 ob x; - Bi_outbuf.contents ob -let read__1 = ( - fun p lb -> - Yojson.Safe.read_space p lb; - match Yojson.Safe.start_any_variant p lb with - | `Edgy_bracket -> ( - match Yojson.Safe.read_ident p lb with - | "None" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (None : _ option) - | "Some" -> - Atdgen_runtime.Oj_run.read_until_field_value p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_gt p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Double_quote -> ( - match Yojson.Safe.finish_string p lb with - | "None" -> - (None : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) - | `Square_bracket -> ( - match Atdgen_runtime.Oj_run.read_string p lb with - | "Some" -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_comma p lb; - Yojson.Safe.read_space p lb; - let x = ( - Atdgen_runtime.Oj_run.read_string - ) p lb - in - Yojson.Safe.read_space p lb; - Yojson.Safe.read_rbr p lb; - (Some x : _ option) - | x -> - Atdgen_runtime.Oj_run.invalid_variant_tag p x - ) -) -let _1_of_string s = - read__1 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_t : _ -> t -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"id\":"; - ( - write_snowflake - ) - ob x.id; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"username\":"; - ( - Yojson.Safe.write_string - ) - ob x.username; - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"discriminator\":"; - ( - Yojson.Safe.write_string - ) - ob x.discriminator; - (match x.avatar with None -> () | Some x -> - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"avatar\":"; - ( - Yojson.Safe.write_string - ) - ob x; - ); - if x.bot <> false then ( - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"bot\":"; - ( - Yojson.Safe.write_bool - ) - ob x.bot; - ); - Bi_outbuf.add_char ob '}'; -) -let string_of_t ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_t ob x; - Bi_outbuf.contents ob -let read_t = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_id = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_username = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_discriminator = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let field_avatar = ref (None) in - let field_bot = ref (false) in - let bits0 = ref 0 in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 3 -> ( - if String.unsafe_get s pos = 'b' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 't' then ( - 4 - ) - else ( - -1 - ) - ) - | 6 -> ( - if String.unsafe_get s pos = 'a' && String.unsafe_get s (pos+1) = 'v' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'r' then ( - 3 - ) - else ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | 13 -> ( - if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 't' && String.unsafe_get s (pos+11) = 'o' && String.unsafe_get s (pos+12) = 'r' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_username := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - field_discriminator := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_avatar := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_bot := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - match len with - | 2 -> ( - if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - ) - | 3 -> ( - if String.unsafe_get s pos = 'b' && String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 't' then ( - 4 - ) - else ( - -1 - ) - ) - | 6 -> ( - if String.unsafe_get s pos = 'a' && String.unsafe_get s (pos+1) = 'v' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'a' && String.unsafe_get s (pos+5) = 'r' then ( - 3 - ) - else ( - -1 - ) - ) - | 8 -> ( - if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 's' && String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'r' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'a' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'e' then ( - 1 - ) - else ( - -1 - ) - ) - | 13 -> ( - if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'm' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'n' && String.unsafe_get s (pos+9) = 'a' && String.unsafe_get s (pos+10) = 't' && String.unsafe_get s (pos+11) = 'o' && String.unsafe_get s (pos+12) = 'r' then ( - 2 - ) - else ( - -1 - ) - ) - | _ -> ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | 1 -> - field_username := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x2; - | 2 -> - field_discriminator := ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ); - bits0 := !bits0 lor 0x4; - | 3 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_avatar := ( - Some ( - ( - Atdgen_runtime.Oj_run.read_string - ) p lb - ) - ); - ) - | 4 -> - if not (Yojson.Safe.read_null_if_possible p lb) then ( - field_bot := ( - ( - Atdgen_runtime.Oj_run.read_bool - ) p lb - ); - ) - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0x7 then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "id"; "username"; "discriminator" |]; - ( - { - id = !field_id; - username = !field_username; - discriminator = !field_discriminator; - avatar = !field_avatar; - bot = !field_bot; - } - : t) - ) -) -let t_of_string s = - read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s) -let write_partial_user : _ -> partial_user -> _ = ( - fun ob x -> - Bi_outbuf.add_char ob '{'; - let is_first = ref true in - if !is_first then - is_first := false - else - Bi_outbuf.add_char ob ','; - Bi_outbuf.add_string ob "\"id\":"; - ( - write_snowflake - ) - ob x.id; - Bi_outbuf.add_char ob '}'; -) -let string_of_partial_user ?(len = 1024) x = - let ob = Bi_outbuf.create len in - write_partial_user ob x; - Bi_outbuf.contents ob -let read_partial_user = ( - fun p lb -> - Yojson.Safe.read_space p lb; - Yojson.Safe.read_lcurl p lb; - let field_id = ref (Obj.magic (Sys.opaque_identity 0.0)) in - let bits0 = ref 0 in - try - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_end lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - if len = 2 && String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - while true do - Yojson.Safe.read_space p lb; - Yojson.Safe.read_object_sep p lb; - Yojson.Safe.read_space p lb; - let f = - fun s pos len -> - if pos < 0 || len < 0 || pos + len > String.length s then - invalid_arg "out-of-bounds substring position or length"; - if len = 2 && String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'd' then ( - 0 - ) - else ( - -1 - ) - in - let i = Yojson.Safe.map_ident p f lb in - Atdgen_runtime.Oj_run.read_until_field_value p lb; - ( - match i with - | 0 -> - field_id := ( - ( - read_snowflake - ) p lb - ); - bits0 := !bits0 lor 0x1; - | _ -> ( - Yojson.Safe.skip_json p lb - ) - ); - done; - assert false; - with Yojson.End_of_object -> ( - if !bits0 <> 0x1 then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "id" |]; - ( - { - id = !field_id; - } - : partial_user) - ) -) -let partial_user_of_string s = - read_partial_user (Yojson.Safe.init_lexer ()) (Lexing.from_string s) diff --git a/lib/models/gen/user_j.mli b/lib/models/gen/user_j.mli deleted file mode 100644 index 576768e..0000000 --- a/lib/models/gen/user_j.mli +++ /dev/null @@ -1,75 +0,0 @@ -(* Auto-generated from "user.atd" *) -[@@@ocaml.warning "-27-32-35-39"] - -type snowflake = Snowflake_t.t - -type t = User_t.t = { - id: snowflake; - username: string; - discriminator: string; - avatar: string option; - bot: bool -} - -type partial_user = User_t.partial_user = { id: snowflake } - -val write_snowflake : - Bi_outbuf.t -> snowflake -> unit - (** Output a JSON value of type {!snowflake}. *) - -val string_of_snowflake : - ?len:int -> snowflake -> string - (** Serialize a value of type {!snowflake} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_snowflake : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> snowflake - (** Input JSON data of type {!snowflake}. *) - -val snowflake_of_string : - string -> snowflake - (** Deserialize JSON data of type {!snowflake}. *) - -val write_t : - Bi_outbuf.t -> t -> unit - (** Output a JSON value of type {!t}. *) - -val string_of_t : - ?len:int -> t -> string - (** Serialize a value of type {!t} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_t : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> t - (** Input JSON data of type {!t}. *) - -val t_of_string : - string -> t - (** Deserialize JSON data of type {!t}. *) - -val write_partial_user : - Bi_outbuf.t -> partial_user -> unit - (** Output a JSON value of type {!partial_user}. *) - -val string_of_partial_user : - ?len:int -> partial_user -> string - (** Serialize a value of type {!partial_user} - into a JSON string. - @param len specifies the initial length - of the buffer used internally. - Default: 1024. *) - -val read_partial_user : - Yojson.Safe.lexer_state -> Lexing.lexbuf -> partial_user - (** Input JSON data of type {!partial_user}. *) - -val partial_user_of_string : - string -> partial_user - (** Deserialize JSON data of type {!partial_user}. *) - diff --git a/lib/models/gen/user_t.ml b/lib/models/gen/user_t.ml deleted file mode 100644 index 294cf0a..0000000 --- a/lib/models/gen/user_t.ml +++ /dev/null @@ -1,14 +0,0 @@ -(* Auto-generated from "user.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type snowflake = Snowflake_t.t - -type t = { - id: snowflake; - username: string; - discriminator: string; - avatar: string option; - bot: bool -} - -type partial_user = { id: snowflake } diff --git a/lib/models/gen/user_t.mli b/lib/models/gen/user_t.mli deleted file mode 100644 index 294cf0a..0000000 --- a/lib/models/gen/user_t.mli +++ /dev/null @@ -1,14 +0,0 @@ -(* Auto-generated from "user.atd" *) - [@@@ocaml.warning "-27-32-35-39"] - -type snowflake = Snowflake_t.t - -type t = { - id: snowflake; - username: string; - discriminator: string; - avatar: string option; - bot: bool -} - -type partial_user = { id: snowflake } diff --git a/lib/models/guild.ml b/lib/models/guild.ml index 36b7d4b..733fc9f 100644 --- a/lib/models/guild.ml +++ b/lib/models/guild.ml @@ -1,2 +1,144 @@ module Make(Http : S.Http) = struct + open Core + open Async + open Guild_t + + type t = Guild_t.t + + let ban_user ~id ?(reason="") ?(days=0) guild = + Http.guild_ban_add guild.id id (`Assoc [ + ("delete-message-days", `Int days); + ("reason", `String reason); + ]) >>| Result.map ~f:ignore + + let create_emoji ~name ~image guild = + Http.create_emoji guild.id (`Assoc [ + ("name", `String name); + ("image", `String image); + ("roles", `List []); + ]) >>| Result.map ~f:Emoji_j.t_of_string + + let create_role ~name ?colour ?permissions ?hoist ?mentionable guild = + let payload = ("name", `String name) :: [] in + let payload = match permissions with + | Some p -> ("permissions", `Int p) :: payload + | None -> payload + in let payload = match colour with + | Some c -> ("color", `Int c) :: payload + | None -> payload + in let payload = match hoist with + | Some h -> ("hoist", `Bool h) :: payload + | None -> payload + in let payload = match mentionable with + | Some m -> ("mentionable", `Bool m) :: payload + | None -> payload + in Http.guild_role_add guild.id (`Assoc payload) + >>| Result.map ~f:(fun r -> + Role_j.role_of_string r + |> Event.wrap_role ~guild_id:guild.id) + + let create_channel ~mode ~name guild = + let kind = match mode with + | `Text -> 0 + | `Voice -> 2 + | `Category -> 4 + in Http.create_guild_channel guild.id (`Assoc [ + ("name", `String name); + ("type", `Int kind); + ]) >>| Result.map ~f:Channel_j.t_of_string + + let delete guild = + Http.delete_guild guild.id >>| Result.map ~f:ignore + + let get_ban ~id guild = + Http.get_ban guild.id id >>| Result.map ~f:Ban_j.t_of_string + + let get_bans guild = + Http.get_bans guild.id >>| Result.map ~f:(fun bans -> + Yojson.Safe.from_string bans + |> Yojson.Safe.Util.to_list + |> List.map ~f:(fun ban -> + Yojson.Safe.to_string ban + |> Ban_j.t_of_string)) + + let get_channel ~id guild = + match List.find ~f:(fun c -> c.id = id) guild.channels with + | Some c -> Channel_j.(string_of_channel_wrapper c |> t_of_string) |> Deferred.Or_error.return + | None -> Http.get_channel id >>| Result.map ~f:Event.wrap_channel + + let get_emoji ~id guild = + Http.get_emoji guild.id id >>| Result.map ~f:Emoji_j.t_of_string + + (* TODO add invite abstraction? *) + 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 -> Deferred.Or_error.return m + | None -> Http.get_member guild.id id >>| Result.map ~f:Member_j.member_of_string + + let get_prune_count ~days guild = + Http.guild_prune_count guild.id days >>| Result.map ~f:(fun prune -> + Yojson.Safe.(from_string prune + |> Util.member "pruned" + |> Util.to_int)) + + (* TODO add HTTP fallback *) + let get_role ~id guild = + let role = List.find ~f:(fun r -> r.id = id) guild.roles in + Option.(role >>| Event.wrap_role ~guild_id:guild.id) + + (* TODO add webhook abstraction? *) + let get_webhooks guild = + Http.get_guild_webhooks guild.id + + let kick_user ~id ?reason guild = + let payload = match reason with + | Some r -> `Assoc [("reason", `String r)] + | None -> `Null + in Http.remove_member guild.id id payload >>| Result.map ~f:ignore + + let leave guild = + Http.leave_guild guild.id + + (* TODO Voice region abstractions? *) + let list_voice_regions guild = + Http.get_guild_voice_regions guild.id + + let prune ~days guild = + Http.guild_prune_start guild.id days >>| Result.map ~f:(fun prune -> + Yojson.Safe.(from_string prune + |> Util.member "pruned" + |> Util.to_int)) + + let request_members guild = + Http.get_members guild.id >>| Result.map ~f:(fun members -> + Yojson.Safe.from_string members + |> Yojson.Safe.Util.to_list + |> List.map ~f:(fun ban -> + Yojson.Safe.to_string ban + |> Member_j.t_of_string)) + + let set_afk_channel ~id guild = Http.edit_guild guild.id (`Assoc [ + ("afk_channel_id", `Int id); + ]) >>| Result.map ~f:Guild_j.t_of_string + + let set_afk_timeout ~timeout guild = Http.edit_guild guild.id (`Assoc [ + ("afk_timeout", `Int timeout); + ]) >>| Result.map ~f:Guild_j.t_of_string + + let set_name ~name guild = Http.edit_guild guild.id (`Assoc [ + ("name", `String name); + ]) >>| Result.map ~f:Guild_j.t_of_string + + let set_icon ~icon guild = Http.edit_guild guild.id (`Assoc [ + ("icon", `String icon); + ]) >>| Result.map ~f:Guild_j.t_of_string + + let unban_user ~id ?reason guild = + let payload = match reason with + | Some r -> `Assoc [("reason", `String r)] + | None -> `Null + in Http.guild_ban_remove guild.id id payload >>| Result.map ~f:ignore end
\ No newline at end of file diff --git a/lib/models/member.ml b/lib/models/member.ml index 36b7d4b..7fa9c03 100644 --- a/lib/models/member.ml +++ b/lib/models/member.ml @@ -1,2 +1,12 @@ module Make(Http : S.Http) = struct + type t = Member_t.t + (* val add_role : Member_t.t -> Role_t.t -> Yojson.Safe.json Deferred.t + val remove_role : Member_t.t -> Role_t.t -> Yojson.Safe.json Deferred.t + val ban : ?reason:string -> ?days:int -> Member_t.t -> Yojson.Safe.json Deferred.t + val ban : ?reason:string -> Member_t.t -> Yojson.Safe.json Deferred.t + val kick : ?reason:string -> Member_t.t -> Yojson.Safe.json Deferred.t + val mute : Member_t.t -> Yojson.Safe.json Deferred.t + val deafen : Member_t.t -> Yojson.Safe.json Deferred.t + val unmute : Member_t.t -> Yojson.Safe.json Deferred.t + val undeafen : Member_t.t -> Yojson.Safe.json Deferred.t *) end
\ No newline at end of file diff --git a/lib/models/message.ml b/lib/models/message.ml index 29148ee..ffd7583 100644 --- a/lib/models/message.ml +++ b/lib/models/message.ml @@ -1,6 +1,9 @@ module Make(Http : S.Http) = struct + open Async open Message_t + type t = Message_t.t + let add_reaction msg (emoji:Emoji_t.t) = let e = match emoji.id with | Some i -> Printf.sprintf "%s:%d" emoji.name i diff --git a/lib/models/message.mli b/lib/models/message.mli deleted file mode 100644 index 6f6242f..0000000 --- a/lib/models/message.mli +++ /dev/null @@ -1 +0,0 @@ -module Make(Http : S.Http) : S.Message
\ No newline at end of file diff --git a/lib/models/presence.ml b/lib/models/presence.ml index 36b7d4b..2ce9a51 100644 --- a/lib/models/presence.ml +++ b/lib/models/presence.ml @@ -1,2 +1,3 @@ module Make(Http : S.Http) = struct + type t = Presence_t.t end
\ No newline at end of file diff --git a/lib/models/reaction.ml b/lib/models/reaction.ml index 36b7d4b..23de12f 100644 --- a/lib/models/reaction.ml +++ b/lib/models/reaction.ml @@ -1,2 +1,8 @@ module Make(Http : S.Http) = struct + (* open Reaction_t *) + + type t = Reaction_t.t + + (* let delete reaction user = + Http.delete_reaction *) end
\ No newline at end of file diff --git a/lib/models/role.ml b/lib/models/role.ml index 36b7d4b..aa931d6 100644 --- a/lib/models/role.ml +++ b/lib/models/role.ml @@ -1,2 +1,27 @@ module Make(Http : S.Http) = struct + open Role_t + + type t = Role_t.t + + let edit_role ~body (role:t) = Http.guild_role_edit role.guild_id role.id body + + let allow_mention role = + edit_role ~body:(`Assoc [("mentionable", `Bool true)]) role + + let delete (role:t) = Http.guild_role_remove role.guild_id role.id + + let disallow_mention role = + edit_role ~body:(`Assoc [("mentionable", `Bool false)]) role + + let hoist role = + edit_role ~body:(`Assoc [("hoist", `Bool true)]) role + + let set_colour ~colour role = + edit_role ~body:(`Assoc [("color", `Int colour)]) role + + let set_name ~name role = + edit_role ~body:(`Assoc [("name", `String name)]) role + + let unhoist role = + edit_role ~body:(`Assoc [("hoist", `Bool false)]) role end
\ No newline at end of file diff --git a/lib/models/snowflake.ml b/lib/models/snowflake.ml index 36b7d4b..6b52ec6 100644 --- a/lib/models/snowflake.ml +++ b/lib/models/snowflake.ml @@ -1,2 +1,16 @@ module Make(Http : S.Http) = struct + open Core + + type t = Snowflake_t.t + + let timestamp snowflake = + let offset = (snowflake lsr 22) / 1000 in + 1_420_070_400 + offset + + let timestamp_iso snowflake = + let t = timestamp snowflake in + Date.( + of_time ~zone:Time.Zone.utc + Time.(of_span_since_epoch @@ Span.of_int_sec t) + |> format) "%FT%T+00:00" end
\ No newline at end of file diff --git a/lib/models/user.ml b/lib/models/user.ml index 36b7d4b..cd91a39 100644 --- a/lib/models/user.ml +++ b/lib/models/user.ml @@ -1,2 +1,24 @@ module Make(Http : S.Http) = struct + open Core + open User_t + + type t = User_t.t + + let tag user = + Printf.sprintf "%s#%d" user.username user.discriminator + + let mention (user:User_t.t) = + Printf.sprintf "<@%d>" user.id + + let default_avatar user = + let avatar = user.discriminator % 5 in + Endpoints.cdn_default_avatar avatar + + let face user = match user.avatar with + | Some avatar -> + let ext = if String.is_substring ~substring:"a_" avatar + then "gif" + else "png" in + Endpoints.cdn_avatar user.id avatar ext + | None -> default_avatar user end
\ No newline at end of file diff --git a/lib/models/gen/presence.atd b/lib/presence.atd index da9b3fd..da9b3fd 100644 --- a/lib/models/gen/presence.atd +++ b/lib/presence.atd diff --git a/lib/models/gen/reaction.atd b/lib/reaction.atd index aa41483..aa41483 100644 --- a/lib/models/gen/reaction.atd +++ b/lib/reaction.atd diff --git a/lib/models/gen/role.atd b/lib/role.atd index a6bdcba..d442a92 100644 --- a/lib/models/gen/role.atd +++ b/lib/role.atd @@ -1,6 +1,6 @@ type snowflake <ocaml from="Snowflake" t="t"> = abstract -type t = { +type role = { id: snowflake; name: string; colour <json name="color">: int; @@ -9,4 +9,14 @@ type t = { permissions: int; managed: bool; mentionable: bool; -}
\ No newline at end of file +} + +type role_update = { + role: role; + guild_id: snowflake; +} + +type t = { + inherit role; + guild_id: snowflake; + }
\ No newline at end of file @@ -4,53 +4,153 @@ module type Token = sig val token : string end -module type Activity = sig end +module type Activity = sig + type t = Activity_t.t +end -module type Attachment = sig end +module type Attachment = sig + type t = Attachment_t.t +end -module type Ban = sig end +module type Ban = sig + type t = Ban_t.t +end -module type Channel = sig end +module type Channel = sig + type t = Channel_t.t + val say : content:string -> Channel_t.t -> Message_t.t Deferred.Or_error.t + val send_message : + ?embed:Yojson.Safe.json -> + ?content:string -> + ?file:string -> + ?tts:bool -> + Channel_t.t -> + Message_t.t Deferred.Or_error.t + val delete : Channel_t.t -> unit Deferred.Or_error.t + val get_message : id:Snowflake_t.t -> Channel_t.t -> Message_t.t Deferred.Or_error.t + val get_messages : + ?mode:[ `Before | `After | `Around ] -> + ?id:Snowflake_t.t -> + ?limit:int -> + Channel_t.t -> + Message_t.t list Deferred.Or_error.t + val broadcast_typing : Channel_t.t -> unit Deferred.Or_error.t + val get_pins : Channel_t.t -> Message_t.t list Deferred.Or_error.t + (* TODO more things related to guild channels *) +end -module type Embed = sig end +module type Embed = sig + type footer = Embed_t.footer + type image = Embed_t.image + type video = Embed_t.video + type provider = Embed_t.provider + type field = Embed_t.field + type t = Embed_t.t +end -module type Emoji = sig end +module type Emoji = sig + type t = Emoji_t.t +end -module type Guild = sig end +module type Guild = sig + type t = Guild_t.t + val ban_user : id:Snowflake_t.t -> ?reason:string -> ?days:int -> Guild_t.t -> unit Deferred.Or_error.t + val create_emoji : name:string -> image:string -> Guild_t.t -> Emoji_t.t Deferred.Or_error.t + val create_role : + name:string -> + ?colour:int -> + ?permissions:int -> + ?hoist:bool -> + ?mentionable:bool -> + Guild_t.t -> + Role_t.t Deferred.Or_error.t + val create_channel : mode:[ `Text | `Voice | `Category ] -> name:string -> Guild_t.t -> Channel_t.t Deferred.Or_error.t + val delete : Guild_t.t -> unit Deferred.Or_error.t + val get_ban : id:Snowflake_t.t -> Guild_t.t -> Ban_t.t Deferred.Or_error.t + val get_bans : Guild_t.t -> Ban_t.t list Deferred.Or_error.t + val get_channel : id:Snowflake_t.t -> Guild_t.t -> Channel_t.t Deferred.Or_error.t + val get_emoji : id:Snowflake_t.t -> Guild_t.t -> Emoji_t.t Deferred.Or_error.t + val get_invites : Guild_t.t -> string Deferred.Or_error.t + val get_member : id:Snowflake_t.t -> Guild_t.t -> Member_t.member Deferred.Or_error.t + val get_prune_count : days:int -> Guild_t.t -> int Deferred.Or_error.t + val get_role : id:Snowflake_t.t -> Guild_t.t -> Role_t.t option + val get_webhooks : Guild_t.t -> string Deferred.Or_error.t + val kick_user : id:Snowflake_t.t -> ?reason:string -> Guild_t.t -> unit Deferred.Or_error.t + val leave : Guild_t.t -> string Deferred.Or_error.t + val list_voice_regions : Guild_t.t -> string Deferred.Or_error.t + val prune : days:int -> Guild_t.t -> int Deferred.Or_error.t + val request_members : Guild_t.t -> Member_t.t list Deferred.Or_error.t + val set_afk_channel : id:Snowflake_t.t -> Guild_t.t -> Guild_t.t Deferred.Or_error.t + val set_afk_timeout : timeout:int -> Guild_t.t -> Guild_t.t Deferred.Or_error.t + val set_name : name:string -> Guild_t.t -> Guild_t.t Deferred.Or_error.t + val set_icon : icon:string -> Guild_t.t -> Guild_t.t Deferred.Or_error.t + val unban_user : id:Snowflake_t.t -> ?reason:string -> Guild_t.t -> unit Deferred.Or_error.t +end module type Member = sig - (* val add_role : Member_t.t -> Role_t.t -> Yojson.Safe.json Deferred.t - val remove_role : Member_t.t -> Role_t.t -> Yojson.Safe.json Deferred.t - val ban : ?reason:string -> ?days:int -> Member_t.t -> Yojson.Safe.json Deferred.t - val ban : ?reason:string -> Member_t.t -> Yojson.Safe.json Deferred.t - val kick : ?reason:string -> Member_t.t -> Yojson.Safe.json Deferred.t - val mute : Member_t.t -> Yojson.Safe.json Deferred.t - val deafen : Member_t.t -> Yojson.Safe.json Deferred.t - val unmute : Member_t.t -> Yojson.Safe.json Deferred.t - val undeafen : Member_t.t -> Yojson.Safe.json Deferred.t *) + type t = Member_t.t + (* val add_role : Member_t.t -> Role_t.t -> string Deferred.Or_error.t + val remove_role : Member_t.t -> Role_t.t -> string Deferred.Or_error.t + val ban : ?reason:string -> ?days:int -> Member_t.t -> string Deferred.Or_error.t + val ban : ?reason:string -> Member_t.t -> string Deferred.Or_error.t + val kick : ?reason:string -> Member_t.t -> string Deferred.Or_error.t + val mute : Member_t.t -> string Deferred.Or_error.t + val deafen : Member_t.t -> string Deferred.Or_error.t + val unmute : Member_t.t -> string Deferred.Or_error.t + val undeafen : Member_t.t -> string Deferred.Or_error.t *) end module type Message = sig - val add_reaction : Message_t.t -> Emoji_t.t -> Yojson.Safe.json Deferred.t - val remove_reaction : Message_t.t -> Emoji_t.t -> User_t.t -> Yojson.Safe.json Deferred.t - val clear_reactions : Message_t.t -> Yojson.Safe.json Deferred.t - val delete : Message_t.t -> Yojson.Safe.json Deferred.t - val pin : Message_t.t -> Yojson.Safe.json Deferred.t - val unpin : Message_t.t -> Yojson.Safe.json Deferred.t - val reply : Message_t.t -> string -> Yojson.Safe.json Deferred.t - val set_content : Message_t.t -> string -> Yojson.Safe.json Deferred.t - val set_embed : Message_t.t -> Embed_t.t -> Yojson.Safe.json Deferred.t + type t = Message_t.t + val add_reaction : Message_t.t -> Emoji_t.t -> string Deferred.Or_error.t + val remove_reaction : Message_t.t -> Emoji_t.t -> User_t.t -> string Deferred.Or_error.t + val clear_reactions : Message_t.t -> string Deferred.Or_error.t + val delete : Message_t.t -> string Deferred.Or_error.t + val pin : Message_t.t -> string Deferred.Or_error.t + val unpin : Message_t.t -> string Deferred.Or_error.t + val reply : Message_t.t -> string -> string Deferred.Or_error.t + val set_content : Message_t.t -> string -> string Deferred.Or_error.t + val set_embed : Message_t.t -> Embed_t.t -> string Deferred.Or_error.t end -module type Presence = sig end +module type Presence = sig + type t = Presence_t.t +end -module type Reaction = sig end +module type Reaction = sig + type t = Reaction_t.t + (* val delete : Reaction_t.t -> string Deferred.Or_error.t + val get_users : Reaction_t.t -> int -> User_t.t list Deferred.Or_error.t + val get_users_after : Reaction_t.t -> Snowflake_t.t -> int -> User_t.t list Deferred.Or_error.t + val get_users_before : Reaction_t.t -> Snowflake_t.t -> int -> User_t.t list Deferred.Or_error.t *) +end -module type Role = sig end +module type Role = sig + type t = Role_t.t + val allow_mention : Role_t.t -> string Deferred.Or_error.t + val delete : Role_t.t -> string Deferred.Or_error.t + val disallow_mention : Role_t.t -> string Deferred.Or_error.t + val hoist : Role_t.t -> string Deferred.Or_error.t + val set_colour : colour:int -> Role_t.t -> string Deferred.Or_error.t + val set_name : name:string -> Role_t.t -> string Deferred.Or_error.t + val unhoist : Role_t.t -> string Deferred.Or_error.t +end -module type Snowflake = sig end +module type Snowflake = sig + type t = Snowflake_t.t + val timestamp : Snowflake_t.t -> int + val timestamp_iso : Snowflake_t.t -> string +end -module type User = sig end +module type User = sig + type t = User_t.t + val tag : User_t.t -> string + val mention : User_t.t -> string + val default_avatar : User_t.t -> string + val face : User_t.t -> string + (* val private_channel : User_t.t -> Channel_t.t *) + (* val send : User_t.t -> string Deferred.Or_error.t *) +end module type Http = sig val token : string @@ -67,149 +167,176 @@ module type Http = sig val process_response : string -> Cohttp_async.Response.t * Cohttp_async.Body.t -> - Yojson.Safe.json Deferred.t + string Deferred.Or_error.t val request : ?body:Yojson.Safe.json -> [> `DELETE | `GET | `PATCH | `POST | `PUT ] -> string -> - Yojson.Safe.json Deferred.t + string Deferred.Or_error.t end (* Auto-generated signatures *) - val get_gateway : unit -> Yojson.Safe.json Conduit_async.io - val get_gateway_bot : unit -> Yojson.Safe.json Conduit_async.io - val get_channel : int -> Yojson.Safe.json Conduit_async.io + val get_gateway : unit -> string Core.Or_error.t Conduit_async.io + val get_gateway_bot : unit -> string Core.Or_error.t Conduit_async.io + val get_channel : int -> string Core.Or_error.t Conduit_async.io val modify_channel : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val delete_channel : int -> Yojson.Safe.json Conduit_async.io - val get_messages : int -> Yojson.Safe.json Conduit_async.io - val get_message : int -> int -> Yojson.Safe.json Conduit_async.io + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val delete_channel : int -> string Core.Or_error.t Conduit_async.io + val get_messages : int -> int -> string * int -> string Core.Or_error.t Conduit_async.io + val get_message : int -> int -> string Core.Or_error.t Conduit_async.io val create_message : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io val create_reaction : - int -> int -> string -> Yojson.Safe.json Conduit_async.io + int -> int -> string -> string Core.Or_error.t Conduit_async.io val delete_own_reaction : - int -> int -> string -> Yojson.Safe.json Conduit_async.io + int -> int -> string -> string Core.Or_error.t Conduit_async.io val delete_reaction : - int -> int -> string -> int -> Yojson.Safe.json Conduit_async.io + int -> int -> string -> int -> string Core.Or_error.t Conduit_async.io val get_reactions : - int -> int -> string -> Yojson.Safe.json Conduit_async.io - val delete_reactions : int -> int -> Yojson.Safe.json Conduit_async.io + int -> int -> string -> string Core.Or_error.t Conduit_async.io + val delete_reactions : + int -> int -> string Core.Or_error.t Conduit_async.io val edit_message : - int -> int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val delete_message : int -> int -> Yojson.Safe.json Conduit_async.io + int -> + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val delete_message : + int -> int -> string Core.Or_error.t Conduit_async.io val bulk_delete : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io val edit_channel_permissions : - int -> int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val get_channel_invites : int -> Yojson.Safe.json Conduit_async.io + int -> + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val get_channel_invites : int -> string Core.Or_error.t Conduit_async.io val create_channel_invite : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io val delete_channel_permission : - int -> int -> Yojson.Safe.json Conduit_async.io - val broadcast_typing : int -> Yojson.Safe.json Conduit_async.io - val get_pinned_messages : int -> Yojson.Safe.json Conduit_async.io - val pin_message : int -> int -> Yojson.Safe.json Conduit_async.io - val unpin_message : int -> int -> Yojson.Safe.json Conduit_async.io - val group_recipient_add : int -> int -> Yojson.Safe.json Conduit_async.io + int -> int -> string Core.Or_error.t Conduit_async.io + val broadcast_typing : int -> string Core.Or_error.t Conduit_async.io + val get_pinned_messages : int -> string Core.Or_error.t Conduit_async.io + val pin_message : int -> int -> string Core.Or_error.t Conduit_async.io + val unpin_message : int -> int -> string Core.Or_error.t Conduit_async.io + val group_recipient_add : + int -> int -> string Core.Or_error.t Conduit_async.io val group_recipient_remove : - int -> int -> Yojson.Safe.json Conduit_async.io - val get_emojis : int -> Yojson.Safe.json Conduit_async.io - val get_emoji : int -> int -> Yojson.Safe.json Conduit_async.io + int -> int -> string Core.Or_error.t Conduit_async.io + val get_emojis : int -> string Core.Or_error.t Conduit_async.io + val get_emoji : int -> int -> string Core.Or_error.t Conduit_async.io val create_emoji : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io val edit_emoji : - int -> int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val delete_emoji : int -> int -> Yojson.Safe.json Conduit_async.io - val create_guild : Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val get_guild : int -> Yojson.Safe.json Conduit_async.io + int -> + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val delete_emoji : int -> int -> string Core.Or_error.t Conduit_async.io + val create_guild : + Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val get_guild : int -> string Core.Or_error.t Conduit_async.io val edit_guild : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val delete_guild : int -> Yojson.Safe.json Conduit_async.io - val get_guild_channels : int -> Yojson.Safe.json Conduit_async.io + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val delete_guild : int -> string Core.Or_error.t Conduit_async.io + val get_guild_channels : int -> string Core.Or_error.t Conduit_async.io val create_guild_channel : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io val modify_guild_channel_positions : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val get_member : int -> int -> Yojson.Safe.json Conduit_async.io - val get_members : int -> Yojson.Safe.json Conduit_async.io + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val get_member : int -> int -> string Core.Or_error.t Conduit_async.io + val get_members : int -> string Core.Or_error.t Conduit_async.io val add_member : - int -> int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io + int -> + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io val edit_member : - int -> int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val remove_member : int -> int -> Yojson.Safe.json Conduit_async.io + int -> + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val remove_member : + int -> + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io val change_nickname : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io val add_member_role : - int -> int -> int -> Yojson.Safe.json Conduit_async.io + int -> int -> int -> string Core.Or_error.t Conduit_async.io val remove_member_role : - int -> int -> int -> Yojson.Safe.json Conduit_async.io - val get_bans : int -> Yojson.Safe.json Conduit_async.io - val get_ban : int -> int -> Yojson.Safe.json Conduit_async.io + int -> int -> int -> string Core.Or_error.t Conduit_async.io + val get_bans : int -> string Core.Or_error.t Conduit_async.io + val get_ban : int -> int -> string Core.Or_error.t Conduit_async.io val guild_ban_add : - int -> int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val guild_ban_remove : int -> int -> Yojson.Safe.json Conduit_async.io - val get_roles : int -> Yojson.Safe.json Conduit_async.io + int -> + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val guild_ban_remove : + int -> + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val get_roles : int -> string Core.Or_error.t Conduit_async.io val guild_role_add : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io val guild_roles_edit : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io val guild_role_edit : - int -> int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val guild_role_remove : int -> int -> Yojson.Safe.json Conduit_async.io - val guild_prune_count : int -> Yojson.Safe.json Conduit_async.io + int -> + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val guild_role_remove : + int -> int -> string Core.Or_error.t Conduit_async.io + val guild_prune_count : + int -> int -> string Core.Or_error.t Conduit_async.io val guild_prune_start : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val get_guild_voice_regions : int -> Yojson.Safe.json Conduit_async.io - val get_guild_invites : int -> Yojson.Safe.json Conduit_async.io - val get_integrations : int -> Yojson.Safe.json Conduit_async.io + int -> int -> string Core.Or_error.t Conduit_async.io + val get_guild_voice_regions : + int -> string Core.Or_error.t Conduit_async.io + val get_guild_invites : int -> string Core.Or_error.t Conduit_async.io + val get_integrations : int -> string Core.Or_error.t Conduit_async.io val add_integration : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io val edit_integration : - int -> int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val delete_integration : int -> int -> Yojson.Safe.json Conduit_async.io - val sync_integration : int -> int -> Yojson.Safe.json Conduit_async.io - val get_guild_embed : int -> Yojson.Safe.json Conduit_async.io + int -> + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val delete_integration : + int -> int -> string Core.Or_error.t Conduit_async.io + val sync_integration : + int -> int -> string Core.Or_error.t Conduit_async.io + val get_guild_embed : int -> string Core.Or_error.t Conduit_async.io val edit_guild_embed : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val get_vanity_url : int -> Yojson.Safe.json Conduit_async.io - val get_invite : string -> Yojson.Safe.json Conduit_async.io - val delete_invite : string -> Yojson.Safe.json Conduit_async.io - val get_current_user : unit -> Yojson.Safe.json Conduit_async.io + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val get_vanity_url : int -> string Core.Or_error.t Conduit_async.io + val get_invite : string -> string Core.Or_error.t Conduit_async.io + val delete_invite : string -> string Core.Or_error.t Conduit_async.io + val get_current_user : unit -> string Core.Or_error.t Conduit_async.io val edit_current_user : - Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val get_guilds : unit -> Yojson.Safe.json Conduit_async.io - val leave_guild : int -> Yojson.Safe.json Conduit_async.io - val get_private_channels : unit -> Yojson.Safe.json Conduit_async.io - val create_dm : Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io + Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val get_guilds : unit -> string Core.Or_error.t Conduit_async.io + val leave_guild : int -> string Core.Or_error.t Conduit_async.io + val get_private_channels : + unit -> string Core.Or_error.t Conduit_async.io + val create_dm : + Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io val create_group_dm : - Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val get_connections : unit -> Yojson.Safe.json Conduit_async.io - val get_user : int -> Yojson.Safe.json Conduit_async.io - val get_voice_regions : unit -> Yojson.Safe.json Conduit_async.io + Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val get_connections : unit -> string Core.Or_error.t Conduit_async.io + val get_user : int -> string Core.Or_error.t Conduit_async.io + val get_voice_regions : unit -> string Core.Or_error.t Conduit_async.io val create_webhook : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val get_channel_webhooks : int -> Yojson.Safe.json Conduit_async.io - val get_guild_webhooks : int -> Yojson.Safe.json Conduit_async.io - val get_webhook : int -> Yojson.Safe.json Conduit_async.io + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val get_channel_webhooks : int -> string Core.Or_error.t Conduit_async.io + val get_guild_webhooks : int -> string Core.Or_error.t Conduit_async.io + val get_webhook : int -> string Core.Or_error.t Conduit_async.io val get_webhook_with_token : - int -> string -> Yojson.Safe.json Conduit_async.io + int -> string -> string Core.Or_error.t Conduit_async.io val edit_webhook : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io val edit_webhook_with_token : - int -> string -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io - val delete_webhook : int -> Yojson.Safe.json Conduit_async.io + int -> + string -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io + val delete_webhook : int -> string Core.Or_error.t Conduit_async.io val delete_webhook_with_token : - int -> string -> Yojson.Safe.json Conduit_async.io + int -> string -> string Core.Or_error.t Conduit_async.io val execute_webhook : - int -> string -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io + int -> + string -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io val execute_slack_webhook : - int -> string -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io + int -> + string -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io val execute_git_webhook : - int -> string -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io + int -> + string -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io val get_audit_logs : - int -> Yojson.Safe.json -> Yojson.Safe.json Conduit_async.io + int -> Yojson.Safe.json -> string Core.Or_error.t Conduit_async.io end module type Models = sig diff --git a/lib/sharder.ml b/lib/sharder.ml index 98df132..b1c84a6 100644 --- a/lib/sharder.ml +++ b/lib/sharder.ml @@ -66,10 +66,10 @@ module Make(H : S.Http)(D : S.Dispatch) : S.Sharder = struct let seq = J.(member "s" payload |> to_int) in let t = J.(member "t" payload |> to_string) in let data = J.member "d" payload in - let session = J.(member "session_id" data |> to_string_option) in - if t = "READY" then begin - Ivar.fill_if_empty shard.ready () - end; + let session = if t = "READY" then begin + Ivar.fill_if_empty shard.ready (); + J.(member "session_id" data |> to_string_option) + end else None in D.dispatch ~ev:t (Yojson.Safe.to_string data); return { shard with seq = seq; @@ -288,6 +288,10 @@ module Make(H : S.Http)(D : S.Dispatch) : S.Sharder = struct let start ?count () = let module J = Yojson.Safe.Util in H.get_gateway_bot () >>= fun data -> + let data = match data with + | Ok d -> Yojson.Safe.from_string d + | Error e -> Error.raise e + in let url = J.(member "url" data |> to_string) in let count = match count with | Some c -> c diff --git a/lib/models/gen/snowflake.atd b/lib/snowflake.atd index 98dc032..98dc032 100644 --- a/lib/models/gen/snowflake.atd +++ b/lib/snowflake.atd diff --git a/lib/models/gen/user.atd b/lib/user.atd index 106b3b0..588242d 100644 --- a/lib/models/gen/user.atd +++ b/lib/user.atd @@ -1,13 +1,13 @@ type snowflake <ocaml from="Snowflake" t="t"> = abstract -type t = { +type partial_user = { id: snowflake; +} + +type t = { + inherit partial_user; username: string; - discriminator: string; + discriminator: int <json repr="string">; ?avatar: string option; ~bot <ocaml default="false">: bool; -} - -type partial_user = { - id: snowflake; }
\ No newline at end of file |