aboutsummaryrefslogtreecommitdiff
path: root/lib/models/channel/message
diff options
context:
space:
mode:
authorAdelyn Breelove <[email protected]>2019-01-23 10:40:04 -0700
committerAdelyn Breelove <[email protected]>2019-01-23 10:40:04 -0700
commitf23a12be25f819b9cc9ae05829b14edb6807082f (patch)
treee90bf9fa5a469c9707feccce9bf3926858c67f35 /lib/models/channel/message
parentfix a doc typo (diff)
downloaddisml-f23a12be25f819b9cc9ae05829b14edb6807082f.tar.xz
disml-f23a12be25f819b9cc9ae05829b14edb6807082f.zip
Guild ID and Channel ID abstractions
Diffstat (limited to 'lib/models/channel/message')
-rw-r--r--lib/models/channel/message/embed.mli49
-rw-r--r--lib/models/channel/message/message_t.mli2
-rw-r--r--lib/models/channel/message/reaction_t.mli2
3 files changed, 53 insertions, 0 deletions
diff --git a/lib/models/channel/message/embed.mli b/lib/models/channel/message/embed.mli
index d15c9fd..411d8cc 100644
--- a/lib/models/channel/message/embed.mli
+++ b/lib/models/channel/message/embed.mli
@@ -1,9 +1,11 @@
+(** A footer object belonging to an embed. *)
type footer = {
text: string;
icon_url: string option;
proxy_icon_url: string option;
} [@@deriving sexp, yojson]
+(** An image object belonging to an embed. *)
type image = {
url: string option;
proxy_url: string option;
@@ -11,17 +13,20 @@ type image = {
width: int option;
} [@@deriving sexp, yojson]
+(** A video object belonging to an embed. *)
type video = {
url: string option;
height: int option;
width: int option;
} [@@deriving sexp, yojson]
+(** A provider object belonging to an embed. *)
type provider = {
name: string option;
url: string option;
} [@@deriving sexp, yojson]
+(** An author object belonging to an embed. *)
type author = {
name: string option;
url: string option;
@@ -29,12 +34,14 @@ type author = {
proxy_icon_url: string option;
} [@@deriving sexp, yojson]
+(** A field object belonging to an embed. *)
type field = {
name: string;
value: string;
inline: bool;
} [@@deriving sexp, yojson]
+(** An embed object. See this {{:https://leovoel.github.io/embed-visualizer/}embed visualiser} if you need help understanding each component. *)
type t = {
title: string option;
kind: string option[@key "type"];
@@ -51,29 +58,71 @@ type t = {
fields: field list [@default []];
} [@@deriving sexp, yojson { strict = false }]
+(** An embed where all values are empty. *)
val default : t
+
+(** A footer where all values are empty. *)
val default_footer : footer
+
+(** An image where all values are empty. *)
val default_image : image
+
+(** A video where all values are empty. *)
val default_video : video
+
+(** A provider where all values are empty. *)
val default_provider : provider
+
+(** An author where all values are empty. *)
val default_author : author
+(** Set the title of an embed. *)
val title : string -> t -> t
+
+(** Set the description of an embed. *)
val description : string -> t -> t
+
+(** Set the URL of an embed. *)
val url : string -> t -> t
+
+(** Set the timestamp of an embed. *)
val timestamp : string -> t -> t
+
+(** Set the colour of an embed. *)
val colour : int -> t -> t
+
+(** Identical to {!colour} but with US English spelling. *)
val color : int -> t -> t
+
+(** Set the footer of an embed. The function passes {!default_footer} and must return a footer. *)
val footer : (footer -> footer) -> t -> t
+
+(** Set the image URL of an embed. *)
val image : string -> t -> t
+
+(** Set the thumbnail URL of an embed. *)
val thumbnail : string -> t -> t
+
+(** Set the author of an embed. The function passes {!default_author} and must return an author. *)
val author : (author -> author) -> t -> t
+
+(** Add a field to an embed. Takes a tuple in [(name, value, inline)] order. {b Fields added this way will appear in reverse order in the embed.} *)
val field : string * string * bool -> t -> t
+
+(** Set the fields of an embed. Similar to {!val:field}, but because a complete list is passed, fields preserve order. *)
val fields : (string * string * bool) list -> t -> t
+(** Set the footer text. Typically used in the closure passed to {!val:footer}. *)
val footer_text : string -> footer -> footer
+
+(** Set the footer icon URL. Typically used in the closure passed to {!val:footer}. *)
val footer_icon : string -> footer -> footer
+(** Set the author name. Typically used in the closure passed to {!val:author}. *)
val author_name : string -> author -> author
+
+(** Set the author URL. Typically used in the closure passed to {!val:author}. *)
val author_url : string -> author -> author
+
+(** Set the author icon URL. Typically used in the closure passed to {!val:author}. *)
val author_icon : string -> author -> author \ No newline at end of file
diff --git a/lib/models/channel/message/message_t.mli b/lib/models/channel/message/message_t.mli
index 20360e8..097a705 100644
--- a/lib/models/channel/message/message_t.mli
+++ b/lib/models/channel/message/message_t.mli
@@ -1,3 +1,4 @@
+(** Represents data sent on {{!Dispatch.member_update}member update} events. *)
type message_update = {
id: Snowflake.t;
author: User_t.t option;
@@ -20,6 +21,7 @@ type message_update = {
kind: int option;
} [@@deriving sexp, yojson]
+(** Represents a message object. *)
type t = {
id: Snowflake.t;
author: User_t.t;
diff --git a/lib/models/channel/message/reaction_t.mli b/lib/models/channel/message/reaction_t.mli
index 5bdd275..db95521 100644
--- a/lib/models/channel/message/reaction_t.mli
+++ b/lib/models/channel/message/reaction_t.mli
@@ -1,3 +1,4 @@
+(** Represents a single reaction as received over the gateway. *)
type reaction_event = {
user_id: Snowflake.t;
channel_id: Snowflake.t;
@@ -6,6 +7,7 @@ type reaction_event = {
emoji: Emoji.partial_emoji;
} [@@deriving sexp, yojson]
+(** Represents a number of emojis used as a reaction on a message. *)
type t = {
count: int;
emoji: Emoji.t;