aboutsummaryrefslogtreecommitdiff
path: root/lib/models/guild
diff options
context:
space:
mode:
authorAdelyn Breelove <[email protected]>2019-01-28 09:48:49 -0700
committerAdelyn Breelove <[email protected]>2019-01-28 09:48:49 -0700
commitf43c41dcf56a30f3fac0de07349b2c505203c380 (patch)
tree2d2e228a2dd1cd489927cfec547494a433bded42 /lib/models/guild
parentFix Message.t.mentions (diff)
downloaddisml-f43c41dcf56a30f3fac0de07349b2c505203c380.tar.xz
disml-f43c41dcf56a30f3fac0de07349b2c505203c380.zip
Add more docs
Diffstat (limited to 'lib/models/guild')
-rw-r--r--lib/models/guild/ban_t.ml2
-rw-r--r--lib/models/guild/ban_t.mli4
-rw-r--r--lib/models/guild/guild.mli5
-rw-r--r--lib/models/guild/guild_t.ml22
-rw-r--r--lib/models/guild/guild_t.mli62
-rw-r--r--lib/models/guild/member.mli15
-rw-r--r--lib/models/guild/member_t.mli15
-rw-r--r--lib/models/guild/role.mli17
-rw-r--r--lib/models/guild/role_t.mli21
9 files changed, 100 insertions, 63 deletions
diff --git a/lib/models/guild/ban_t.ml b/lib/models/guild/ban_t.ml
index b49eefc..7923b58 100644
--- a/lib/models/guild/ban_t.ml
+++ b/lib/models/guild/ban_t.ml
@@ -1,6 +1,6 @@
open Core
type t = {
- reason: string [@default ""];
+ reason: string option [@default None];
user: User_t.t;
} [@@deriving sexp, yojson { strict = false}] \ No newline at end of file
diff --git a/lib/models/guild/ban_t.mli b/lib/models/guild/ban_t.mli
index 95fb274..51d59e7 100644
--- a/lib/models/guild/ban_t.mli
+++ b/lib/models/guild/ban_t.mli
@@ -1,4 +1,4 @@
type t = {
- reason: string;
- user: User_t.t;
+ reason: string option; (** The reason for the ban. *)
+ user: User_t.t; (** The banned user. *)
} [@@deriving sexp, yojson] \ No newline at end of file
diff --git a/lib/models/guild/guild.mli b/lib/models/guild/guild.mli
index 81055a1..e6f272c 100644
--- a/lib/models/guild/guild.mli
+++ b/lib/models/guild/guild.mli
@@ -4,6 +4,11 @@ include module type of Guild_t
include S.GuildImpl with
type t := Guild_t.t
+(** Get a channel belonging to this guild. This does not make an HTTP request. *)
val get_channel : id:Channel_id_t.t -> t -> Channel_t.t Deferred.Or_error.t
+
+(** Get a member belonging to this guild. This does not make an HTTP request. *)
val get_member : id:User_id_t.t -> t -> Member_t.t Deferred.Or_error.t
+
+(** Get a role belonging to this guild. This does not make an HTTP request. *)
val get_role : id:Role_id.t -> t -> Role_t.t option \ No newline at end of file
diff --git a/lib/models/guild/guild_t.ml b/lib/models/guild/guild_t.ml
index 42e373c..fa62a8f 100644
--- a/lib/models/guild/guild_t.ml
+++ b/lib/models/guild/guild_t.ml
@@ -13,7 +13,7 @@ type pre = {
region: string;
afk_channel_id: Channel_id_t.t option [@default None];
afk_timeout: int;
- embed_enabled: bool option [@default None];
+ embed_enabled: bool [@default false];
embed_channel_id: Channel_id_t.t option [@default None];
verification_level: int;
default_message_notifications: int;
@@ -23,9 +23,9 @@ type pre = {
features: string list;
mfa_level: int;
application_id: Snowflake.t option [@default None];
- widget_enabled: bool option [@default None];
- widget_channel: Channel_t.channel_wrapper option [@default None];
- system_channel: Channel_t.channel_wrapper option [@default None];
+ widget_enabled: bool [@default false];
+ widget_channel_id: Channel_id_t.t option [@default None];
+ system_channel_id: Channel_id_t.t option [@default None];
large: bool;
unavailable: bool;
member_count: int option [@default None];
@@ -42,7 +42,7 @@ type t = {
region: string;
afk_channel_id: Channel_id_t.t option [@default None];
afk_timeout: int;
- embed_enabled: bool option [@default None];
+ embed_enabled: bool [@default false];
embed_channel_id: Channel_id_t.t option [@default None];
verification_level: int;
default_message_notifications: int;
@@ -52,9 +52,9 @@ type t = {
features: string list;
mfa_level: int;
application_id: Snowflake.t option [@default None];
- widget_enabled: bool option [@default None];
- widget_channel: Channel_t.t option [@default None];
- system_channel: Channel_t.t option [@default None];
+ widget_enabled: bool [@default false];
+ widget_channel_id: Channel_id_t.t option [@default None];
+ system_channel_id: Channel_id_t.t option [@default None];
large: bool;
unavailable: bool;
member_count: int option [@default None];
@@ -62,13 +62,11 @@ type t = {
channels: Channel_t.t list;
} [@@deriving sexp, yojson { strict = false }]
-let wrap ({id;name;icon;splash;owner_id;region;afk_channel_id;afk_timeout;embed_enabled;embed_channel_id;verification_level;default_message_notifications;explicit_content_filter;roles;emojis;features;mfa_level;application_id;widget_enabled;widget_channel;system_channel;large;unavailable;member_count;members;channels}:pre) =
+let wrap ({id;name;icon;splash;owner_id;region;afk_channel_id;afk_timeout;embed_enabled;embed_channel_id;verification_level;default_message_notifications;explicit_content_filter;roles;emojis;features;mfa_level;application_id;widget_enabled;widget_channel_id;system_channel_id;large;unavailable;member_count;members;channels}:pre) =
let `Guild_id id = id in
let roles = List.map ~f:(Role_t.wrap ~guild_id:id) roles in
let members = List.map ~f:(Member_t.wrap ~guild_id:id) members in
let channels = List.map ~f:Channel_t.wrap channels in
- let widget_channel = Option.map ~f:Channel_t.wrap widget_channel in
- let system_channel = Option.map ~f:Channel_t.wrap system_channel in
- {id = `Guild_id id;name;icon;splash;owner_id;region;afk_channel_id;afk_timeout;embed_enabled;embed_channel_id;verification_level;default_message_notifications;explicit_content_filter;roles;emojis;features;mfa_level;application_id;widget_enabled;widget_channel;system_channel;large;unavailable;member_count;members;channels}
+ {id = `Guild_id id;name;icon;splash;owner_id;region;afk_channel_id;afk_timeout;embed_enabled;embed_channel_id;verification_level;default_message_notifications;explicit_content_filter;roles;emojis;features;mfa_level;application_id;widget_enabled;widget_channel_id;system_channel_id;large;unavailable;member_count;members;channels}
let get_id guild = let `Guild_id id = guild.id in id \ No newline at end of file
diff --git a/lib/models/guild/guild_t.mli b/lib/models/guild/guild_t.mli
index 0b1ec92..e1c0718 100644
--- a/lib/models/guild/guild_t.mli
+++ b/lib/models/guild/guild_t.mli
@@ -2,6 +2,7 @@ type unavailable = {
id: Guild_id_t.t;
} [@@deriving sexp, yojson]
+(** Used internally. *)
type pre = {
id: Guild_id_t.t;
name: string;
@@ -11,7 +12,7 @@ type pre = {
region: string;
afk_channel_id: Channel_id_t.t option;
afk_timeout: int;
- embed_enabled: bool option;
+ embed_enabled: bool;
embed_channel_id: Channel_id_t.t option;
verification_level: int;
default_message_notifications: int;
@@ -21,9 +22,9 @@ type pre = {
features: string list;
mfa_level: int;
application_id: Snowflake.t option;
- widget_enabled: bool option;
- widget_channel: Channel_t.channel_wrapper option;
- system_channel: Channel_t.channel_wrapper option;
+ widget_enabled: bool;
+ widget_channel_id: Channel_id_t.t option;
+ system_channel_id: Channel_id_t.t option;
large: bool;
unavailable: bool;
member_count: int option;
@@ -31,33 +32,34 @@ type pre = {
channels: Channel_t.channel_wrapper list;
} [@@deriving sexp, yojson]
+(** A Guild object *)
type t = {
- id: Guild_id_t.t;
- name: string;
- icon: string option;
- splash: string option;
- owner_id: User_id_t.t;
- region: string;
- afk_channel_id: Channel_id_t.t option;
- afk_timeout: int;
- embed_enabled: bool option;
- embed_channel_id: Channel_id_t.t option;
- verification_level: int;
- default_message_notifications: int;
- explicit_content_filter: int;
- roles: Role_t.t list;
- emojis: Emoji.t list;
- features: string list;
- mfa_level: int;
- application_id: Snowflake.t option;
- widget_enabled: bool option;
- widget_channel: Channel_t.t option;
- system_channel: Channel_t.t option;
- large: bool;
- unavailable: bool;
- member_count: int option;
- members: Member_t.t list;
- channels: Channel_t.t list;
+ id: Guild_id_t.t; (** The guild's snowflake ID. *)
+ name: string; (** The guild name. *)
+ icon: string option; (** The guild icon hash, if one is set. *)
+ splash: string option; (** The guild splash hash, if one is set. *)
+ owner_id: User_id_t.t; (** The user ID of the owner. *)
+ region: string; (** The region the guild is in. *)
+ afk_channel_id: Channel_id_t.t option; (** The AFK channel ID, if one is set. *)
+ afk_timeout: int; (** The time before a user is moved to the AFK channel. *)
+ embed_enabled: bool; (** Whether the embed is enabled. *)
+ embed_channel_id: Channel_id_t.t option; (** The channel ID of the embed channel, if it is enabled. *)
+ verification_level: int; (** See {{:https://discordapp.com/developers/docs/resources/guild#guild-object-verification-level} the discord docs} for details. *)
+ default_message_notifications: int; (** 0 = All messages, 1 = Only mentions *)
+ explicit_content_filter: int; (** 0 = Disabled, 1 = For members with no roles, 2 = All members *)
+ roles: Role_t.t list; (** List of roles in the guild. *)
+ emojis: Emoji.t list; (** List of custom emojis in the guild. *)
+ features: string list; (** A List of features enabled for the guild. *)
+ mfa_level: int; (** 0 = None, 1 = Elevated *)
+ application_id: Snowflake.t option; (** Snowflake ID if the guild is bot-created. *)
+ widget_enabled: bool; (** Whether the widget is enabled. *)
+ widget_channel_id: Channel_id_t.t option; (** The channel ID for the widget, if enabled. *)
+ system_channel_id: Channel_id_t.t option; (** The channel ID where system messages are sent. *)
+ large: bool; (** Whether the guild exceeds the configured large threshold. *)
+ unavailable: bool; (** Whether the guild is unavailable or not. *)
+ member_count: int option; (** Total number of members in the guild. *)
+ members: Member_t.t list; (** List of guild members. *)
+ channels: Channel_t.t list; (** List of guild channels. *)
} [@@deriving sexp, yojson]
val wrap : pre -> t
diff --git a/lib/models/guild/member.mli b/lib/models/guild/member.mli
index 3ac786c..a3acc1b 100644
--- a/lib/models/guild/member.mli
+++ b/lib/models/guild/member.mli
@@ -2,11 +2,26 @@ open Async
include module type of Member_t
+(** Adds a role to the member. *)
val add_role : role:Role_t.t -> Member_t.t -> unit Deferred.Or_error.t
+
+(** Removes a role from the member. *)
val remove_role : role:Role_t.t -> Member_t.t -> unit Deferred.Or_error.t
+
+(** Bans the member with optional reason and days of messages to delete. *)
val ban : ?reason:string -> ?days:int -> Member_t.t -> unit Deferred.Or_error.t
+
+(** Kicks the member with the optional reason. *)
val kick : ?reason:string -> Member_t.t -> unit Deferred.Or_error.t
+
+(** Mutes the member, preventing them from speaking in voice chats. *)
val mute : Member_t.t -> unit Deferred.Or_error.t
+
+(** Deafens the member, preventing them from hearing others in voice chats. *)
val deafen : Member_t.t -> unit Deferred.Or_error.t
+
+(** Opposite of {!mute}. *)
val unmute : Member_t.t -> unit Deferred.Or_error.t
+
+(** Opposite of {!deafen}. *)
val undeafen : Member_t.t -> unit Deferred.Or_error.t \ No newline at end of file
diff --git a/lib/models/guild/member_t.mli b/lib/models/guild/member_t.mli
index 4f39b6c..918885e 100644
--- a/lib/models/guild/member_t.mli
+++ b/lib/models/guild/member_t.mli
@@ -27,14 +27,15 @@ type member_update = {
nick: string option;
} [@@deriving sexp, yojson]
+(** A member object. *)
type t = {
- nick: string option;
- roles: Role_id.t list;
- joined_at: string;
- deaf: bool;
- mute: bool;
- user: User_t.t;
- guild_id: Guild_id_t.t;
+ nick: string option; (** The nickname of the member, if they have one set. *)
+ roles: Role_id.t list; (** The roles the member has. *)
+ joined_at: string; (** An ISO8601 timestamp of when the user joined. *)
+ deaf: bool; (** Whether the user is deafened. *)
+ mute: bool; (** Whether the user is muted. *)
+ user: User_t.t; (** The underlying user object for the member. *)
+ guild_id: Guild_id_t.t; (** The guild ID in which the member exists. *)
} [@@deriving sexp, yojson]
val wrap : guild_id:Snowflake.t -> member -> t \ No newline at end of file
diff --git a/lib/models/guild/role.mli b/lib/models/guild/role.mli
index 4c4f2a9..b311a60 100644
--- a/lib/models/guild/role.mli
+++ b/lib/models/guild/role.mli
@@ -2,10 +2,23 @@ open Async
include module type of Role_t
-val allow_mention : t -> t Deferred.Or_error.t
+(** Deletes the role. This is permanent. *)
val delete : t -> unit Deferred.Or_error.t
+
+(** Edits the role to allow mentions. *)
+val allow_mention : t -> t Deferred.Or_error.t
+
+(** Opposite of {!allow_mention} *)
val disallow_mention : t -> t Deferred.Or_error.t
+
+(** Hoists the role. See {!Role.t.hoist}. *)
val hoist : t -> t Deferred.Or_error.t
+
+(** Opposite of {!hoist}. *)
+val unhoist : t -> t Deferred.Or_error.t
+
+(** Sets the colour of the role. *)
val set_colour : colour:int -> t -> t Deferred.Or_error.t
+
+(** Sets the name of the role. *)
val set_name : name:string -> t -> t Deferred.Or_error.t
-val unhoist : t -> t Deferred.Or_error.t \ No newline at end of file
diff --git a/lib/models/guild/role_t.mli b/lib/models/guild/role_t.mli
index 99517b8..6fd023f 100644
--- a/lib/models/guild/role_t.mli
+++ b/lib/models/guild/role_t.mli
@@ -1,3 +1,4 @@
+(** A role as Discord sends it. Only difference between this and {!t} is the lack of the guild_id field. *)
type role = {
id: Role_id.t;
name: string;
@@ -9,16 +10,18 @@ type role = {
mentionable: bool;
} [@@deriving sexp, yojson]
+(** A role object. *)
type t = {
- id: Role_id.t;
- name: string;
- colour: int;
- hoist: bool;
- position: int;
- permissions: int;
- managed: bool;
- mentionable: bool;
- guild_id: Guild_id_t.t;
+ id: Role_id.t; (** The role's snowflake ID. *)
+ name: string; (** The role's name. *)
+ colour: int; (** The integer representation of the role colour. *)
+ hoist: bool; (** Whether the role is hoisted. This property controls whether the role is separated on the sidebar. *)
+ position: int; (** The position of the role. [@everyone] begins the list at 0. *)
+ permissions: int; (** The integer representation of the permissions the role has. *)
+ managed: bool; (** Whether the guild is managed by an integration. *)
+ mentionable: bool; (** Whether the role can be mentioned. *)
+ guild_id: Guild_id_t.t; (** The guild ID this role belongs to. *)
} [@@deriving sexp, yojson]
+(** Convenience method to produce {!t} from {!role} and a snowflake. *)
val wrap : guild_id:Snowflake.t -> role -> t \ No newline at end of file