diff options
| author | Adelyn Breedlove <[email protected]> | 2019-01-28 10:31:51 -0700 |
|---|---|---|
| committer | Adelyn Breedlove <[email protected]> | 2019-01-28 10:31:51 -0700 |
| commit | 8662e92987c437f59d09896a247ec2b5d82c4528 (patch) | |
| tree | f004cc14598351d4ad6b19d8e993d2f629c5e738 /lib/models/guild | |
| parent | Add more docs (diff) | |
| download | disml-8662e92987c437f59d09896a247ec2b5d82c4528.tar.xz disml-8662e92987c437f59d09896a247ec2b5d82c4528.zip | |
Publish docs updates
Diffstat (limited to 'lib/models/guild')
| -rw-r--r-- | lib/models/guild/ban_t.mli | 6 | ||||
| -rw-r--r-- | lib/models/guild/guild.ml | 42 | ||||
| -rw-r--r-- | lib/models/guild/guild.mli | 26 | ||||
| -rw-r--r-- | lib/models/guild/guild_t.ml | 142 | ||||
| -rw-r--r-- | lib/models/guild/guild_t.mli | 130 | ||||
| -rw-r--r-- | lib/models/guild/member.ml | 114 | ||||
| -rw-r--r-- | lib/models/guild/member_t.ml | 84 | ||||
| -rw-r--r-- | lib/models/guild/member_t.mli | 80 | ||||
| -rw-r--r-- | lib/models/guild/role.ml | 56 | ||||
| -rw-r--r-- | lib/models/guild/role_t.ml | 52 | ||||
| -rw-r--r-- | lib/models/guild/role_t.mli | 52 |
11 files changed, 392 insertions, 392 deletions
diff --git a/lib/models/guild/ban_t.mli b/lib/models/guild/ban_t.mli index 51d59e7..37e5cfa 100644 --- a/lib/models/guild/ban_t.mli +++ b/lib/models/guild/ban_t.mli @@ -1,4 +1,4 @@ -type t = { - reason: string option; (** The reason for the ban. *) - user: User_t.t; (** The banned user. *) +type 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.ml b/lib/models/guild/guild.ml index 812a49e..b1e8bfe 100644 --- a/lib/models/guild/guild.ml +++ b/lib/models/guild/guild.ml @@ -1,22 +1,22 @@ -open Core -open Async - -include Guild_t -include Impl.Guild(Guild_t) - -let get_member ~(id:User_id_t.t) guild = - match List.find ~f:(fun m -> m.user.id = id) guild.members with - | Some m -> Deferred.Or_error.return m - | None -> - let `User_id id = id in - Http.get_member (get_id guild) id - -let get_channel ~(id:Channel_id_t.t) guild = - let `Channel_id id = id in - match List.find ~f:(fun c -> Channel_t.get_id c = id) guild.channels with - | Some c -> Deferred.Or_error.return c - | None -> Http.get_channel id - -(* TODO add HTTP fallback *) -let get_role ~(id:Role_id.t) guild = +open Core
+open Async
+
+include Guild_t
+include Impl.Guild(Guild_t)
+
+let get_member ~(id:User_id_t.t) guild =
+ match List.find ~f:(fun m -> m.user.id = id) guild.members with
+ | Some m -> Deferred.Or_error.return m
+ | None ->
+ let `User_id id = id in
+ Http.get_member (get_id guild) id
+
+let get_channel ~(id:Channel_id_t.t) guild =
+ let `Channel_id id = id in
+ match List.find ~f:(fun c -> Channel_t.get_id c = id) guild.channels with
+ | Some c -> Deferred.Or_error.return c
+ | None -> Http.get_channel id
+
+(* TODO add HTTP fallback *)
+let get_role ~(id:Role_id.t) guild =
List.find ~f:(fun r -> r.id = id) guild.roles
\ No newline at end of file diff --git a/lib/models/guild/guild.mli b/lib/models/guild/guild.mli index e6f272c..be9300a 100644 --- a/lib/models/guild/guild.mli +++ b/lib/models/guild/guild.mli @@ -1,14 +1,14 @@ -open Async - -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. *) +open Async
+
+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 fa62a8f..9ad7cb9 100644 --- a/lib/models/guild/guild_t.ml +++ b/lib/models/guild/guild_t.ml @@ -1,72 +1,72 @@ -open Core - -type unavailable = { - id: Guild_id_t.t; -} [@@deriving sexp, yojson { strict = false }] - -type pre = { - id: Guild_id_t.t; - name: string; - icon: string option [@default None]; - splash: string option [@default None]; - owner_id: User_id_t.t; - region: string; - afk_channel_id: Channel_id_t.t option [@default None]; - afk_timeout: int; - embed_enabled: bool [@default false]; - embed_channel_id: Channel_id_t.t option [@default None]; - verification_level: int; - default_message_notifications: int; - explicit_content_filter: int; - roles: Role_t.role list; - emojis: Emoji.t list; - features: string list; - mfa_level: int; - application_id: Snowflake.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]; - members: Member_t.member list; - channels: Channel_t.channel_wrapper list; -} [@@deriving sexp, yojson { strict = false }] - -type t = { - id: Guild_id_t.t; - name: string; - icon: string option [@default None]; - splash: string option [@default None]; - owner_id: User_id_t.t; - region: string; - afk_channel_id: Channel_id_t.t option [@default None]; - afk_timeout: int; - embed_enabled: bool [@default false]; - embed_channel_id: Channel_id_t.t option [@default None]; - 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 [@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]; - members: Member_t.t list; - 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_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 - {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} - +open Core
+
+type unavailable = {
+ id: Guild_id_t.t;
+} [@@deriving sexp, yojson { strict = false }]
+
+type pre = {
+ id: Guild_id_t.t;
+ name: string;
+ icon: string option [@default None];
+ splash: string option [@default None];
+ owner_id: User_id_t.t;
+ region: string;
+ afk_channel_id: Channel_id_t.t option [@default None];
+ afk_timeout: int;
+ embed_enabled: bool [@default false];
+ embed_channel_id: Channel_id_t.t option [@default None];
+ verification_level: int;
+ default_message_notifications: int;
+ explicit_content_filter: int;
+ roles: Role_t.role list;
+ emojis: Emoji.t list;
+ features: string list;
+ mfa_level: int;
+ application_id: Snowflake.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];
+ members: Member_t.member list;
+ channels: Channel_t.channel_wrapper list;
+} [@@deriving sexp, yojson { strict = false }]
+
+type t = {
+ id: Guild_id_t.t;
+ name: string;
+ icon: string option [@default None];
+ splash: string option [@default None];
+ owner_id: User_id_t.t;
+ region: string;
+ afk_channel_id: Channel_id_t.t option [@default None];
+ afk_timeout: int;
+ embed_enabled: bool [@default false];
+ embed_channel_id: Channel_id_t.t option [@default None];
+ 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 [@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];
+ members: Member_t.t list;
+ 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_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
+ {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 e1c0718..7296372 100644 --- a/lib/models/guild/guild_t.mli +++ b/lib/models/guild/guild_t.mli @@ -1,66 +1,66 @@ -type unavailable = { - id: Guild_id_t.t; -} [@@deriving sexp, yojson] - -(** Used internally. *) -type pre = { - 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; - embed_channel_id: Channel_id_t.t option; - verification_level: int; - default_message_notifications: int; - explicit_content_filter: int; - roles: Role_t.role list; - emojis: Emoji.t list; - features: string list; - mfa_level: int; - application_id: Snowflake.t 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; - members: Member_t.member list; - channels: Channel_t.channel_wrapper list; -} [@@deriving sexp, yojson] - -(** A Guild object *) -type t = { - 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 +type unavailable = {
+ id: Guild_id_t.t;
+} [@@deriving sexp, yojson]
+
+(** Used internally. *)
+type pre = {
+ 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;
+ embed_channel_id: Channel_id_t.t option;
+ verification_level: int;
+ default_message_notifications: int;
+ explicit_content_filter: int;
+ roles: Role_t.role list;
+ emojis: Emoji.t list;
+ features: string list;
+ mfa_level: int;
+ application_id: Snowflake.t 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;
+ members: Member_t.member list;
+ channels: Channel_t.channel_wrapper list;
+} [@@deriving sexp, yojson]
+
+(** A Guild object *)
+type t = {
+ 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
val get_id : t -> Snowflake.t
\ No newline at end of file diff --git a/lib/models/guild/member.ml b/lib/models/guild/member.ml index f083cce..c5a7455 100644 --- a/lib/models/guild/member.ml +++ b/lib/models/guild/member.ml @@ -1,57 +1,57 @@ -include Member_t - -let add_role ~(role:Role_t.t) member = - let `Guild_id guild_id = member.guild_id in - let `User_id user_id = member.user.id in - let `Role_id role_id = role.id in - Http.add_member_role guild_id user_id role_id - -let remove_role ~(role:Role_t.t) member = - let `Guild_id guild_id = member.guild_id in - let `User_id user_id = member.user.id in - let `Role_id role_id = role.id in - Http.remove_member_role guild_id user_id role_id - -let ban ?(reason="") ?(days=0) member = - let `Guild_id guild_id = member.guild_id in - let `User_id user_id = member.user.id in - Http.guild_ban_add guild_id user_id (`Assoc [ - ("delete-message-days", `Int days); - ("reason", `String reason); - ]) - -let kick ?reason member = - let `Guild_id guild_id = member.guild_id in - let `User_id user_id = member.user.id in - let payload = match reason with - | Some r -> `Assoc [("reason", `String r)] - | None -> `Null - in Http.remove_member guild_id user_id payload - -let mute member = - let `Guild_id guild_id = member.guild_id in - let `User_id user_id = member.user.id in - Http.edit_member guild_id user_id (`Assoc [ - ("mute", `Bool true); - ]) - -let deafen member = - let `Guild_id guild_id = member.guild_id in - let `User_id user_id = member.user.id in - Http.edit_member guild_id user_id (`Assoc [ - ("deaf", `Bool true); - ]) - -let unmute member = - let `Guild_id guild_id = member.guild_id in - let `User_id user_id = member.user.id in - Http.edit_member guild_id user_id (`Assoc [ - ("mute", `Bool false); - ]) - -let undeafen member = - let `Guild_id guild_id = member.guild_id in - let `User_id user_id = member.user.id in - Http.edit_member guild_id user_id (`Assoc [ - ("deaf", `Bool false); - ]) +include Member_t
+
+let add_role ~(role:Role_t.t) member =
+ let `Guild_id guild_id = member.guild_id in
+ let `User_id user_id = member.user.id in
+ let `Role_id role_id = role.id in
+ Http.add_member_role guild_id user_id role_id
+
+let remove_role ~(role:Role_t.t) member =
+ let `Guild_id guild_id = member.guild_id in
+ let `User_id user_id = member.user.id in
+ let `Role_id role_id = role.id in
+ Http.remove_member_role guild_id user_id role_id
+
+let ban ?(reason="") ?(days=0) member =
+ let `Guild_id guild_id = member.guild_id in
+ let `User_id user_id = member.user.id in
+ Http.guild_ban_add guild_id user_id (`Assoc [
+ ("delete-message-days", `Int days);
+ ("reason", `String reason);
+ ])
+
+let kick ?reason member =
+ let `Guild_id guild_id = member.guild_id in
+ let `User_id user_id = member.user.id in
+ let payload = match reason with
+ | Some r -> `Assoc [("reason", `String r)]
+ | None -> `Null
+ in Http.remove_member guild_id user_id payload
+
+let mute member =
+ let `Guild_id guild_id = member.guild_id in
+ let `User_id user_id = member.user.id in
+ Http.edit_member guild_id user_id (`Assoc [
+ ("mute", `Bool true);
+ ])
+
+let deafen member =
+ let `Guild_id guild_id = member.guild_id in
+ let `User_id user_id = member.user.id in
+ Http.edit_member guild_id user_id (`Assoc [
+ ("deaf", `Bool true);
+ ])
+
+let unmute member =
+ let `Guild_id guild_id = member.guild_id in
+ let `User_id user_id = member.user.id in
+ Http.edit_member guild_id user_id (`Assoc [
+ ("mute", `Bool false);
+ ])
+
+let undeafen member =
+ let `Guild_id guild_id = member.guild_id in
+ let `User_id user_id = member.user.id in
+ Http.edit_member guild_id user_id (`Assoc [
+ ("deaf", `Bool false);
+ ])
diff --git a/lib/models/guild/member_t.ml b/lib/models/guild/member_t.ml index 10f1cf0..ae6b894 100644 --- a/lib/models/guild/member_t.ml +++ b/lib/models/guild/member_t.ml @@ -1,43 +1,43 @@ -open Core - -type partial_member = { - nick: string option [@default None]; - roles: Role_id.t list; - joined_at: string; - deaf: bool; - mute: bool; -} [@@deriving sexp, yojson { strict = false}] - -type member = { - nick: string option [@default None]; - roles: Role_id.t list; - joined_at: string; - deaf: bool; - mute: bool; - user: User_t.t; -} [@@deriving sexp, yojson { strict = false}] - -type member_wrapper = { - guild_id: Guild_id_t.t; - user: User_t.t; -} [@@deriving sexp, yojson { strict = false }] - -type member_update = { - guild_id: Guild_id_t.t; - roles: Role_id.t list [@default []]; - user: User_t.t; - nick: string option [@default None]; -} [@@deriving sexp, yojson { strict = false}] - -type t = { - nick: string option [@default None]; - roles: Role_id.t list; - joined_at: string; - deaf: bool; - mute: bool; - user: User_t.t; - guild_id: Guild_id_t.t; -} [@@deriving sexp, yojson { strict = false}] - -let wrap ~guild_id ({nick;roles;joined_at;deaf;mute;user}:member) = +open Core
+
+type partial_member = {
+ nick: string option [@default None];
+ roles: Role_id.t list;
+ joined_at: string;
+ deaf: bool;
+ mute: bool;
+} [@@deriving sexp, yojson { strict = false}]
+
+type member = {
+ nick: string option [@default None];
+ roles: Role_id.t list;
+ joined_at: string;
+ deaf: bool;
+ mute: bool;
+ user: User_t.t;
+} [@@deriving sexp, yojson { strict = false}]
+
+type member_wrapper = {
+ guild_id: Guild_id_t.t;
+ user: User_t.t;
+} [@@deriving sexp, yojson { strict = false }]
+
+type member_update = {
+ guild_id: Guild_id_t.t;
+ roles: Role_id.t list [@default []];
+ user: User_t.t;
+ nick: string option [@default None];
+} [@@deriving sexp, yojson { strict = false}]
+
+type t = {
+ nick: string option [@default None];
+ roles: Role_id.t list;
+ joined_at: string;
+ deaf: bool;
+ mute: bool;
+ user: User_t.t;
+ guild_id: Guild_id_t.t;
+} [@@deriving sexp, yojson { strict = false}]
+
+let wrap ~guild_id ({nick;roles;joined_at;deaf;mute;user}:member) =
{nick;roles;joined_at;deaf;mute;user;guild_id = `Guild_id guild_id}
\ No newline at end of file diff --git a/lib/models/guild/member_t.mli b/lib/models/guild/member_t.mli index 918885e..170504f 100644 --- a/lib/models/guild/member_t.mli +++ b/lib/models/guild/member_t.mli @@ -1,41 +1,41 @@ -type partial_member = { - nick: string option; - roles: Role_id.t list; - joined_at: string; - deaf: bool; - mute: bool; -} [@@deriving sexp, yojson] - -type member = { - nick: string option; - roles: Role_id.t list; - joined_at: string; - deaf: bool; - mute: bool; - user: User_t.t; -} [@@deriving sexp, yojson] - -type member_wrapper = { - guild_id: Guild_id_t.t; - user: User_t.t; -} [@@deriving sexp, yojson] - -type member_update = { - guild_id: Guild_id_t.t; - roles: Role_id.t list; - user: User_t.t; - nick: string option; -} [@@deriving sexp, yojson] - -(** A member object. *) -type 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] - +type partial_member = {
+ nick: string option;
+ roles: Role_id.t list;
+ joined_at: string;
+ deaf: bool;
+ mute: bool;
+} [@@deriving sexp, yojson]
+
+type member = {
+ nick: string option;
+ roles: Role_id.t list;
+ joined_at: string;
+ deaf: bool;
+ mute: bool;
+ user: User_t.t;
+} [@@deriving sexp, yojson]
+
+type member_wrapper = {
+ guild_id: Guild_id_t.t;
+ user: User_t.t;
+} [@@deriving sexp, yojson]
+
+type member_update = {
+ guild_id: Guild_id_t.t;
+ roles: Role_id.t list;
+ user: User_t.t;
+ nick: string option;
+} [@@deriving sexp, yojson]
+
+(** A member object. *)
+type 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.ml b/lib/models/guild/role.ml index 46f908b..55e5813 100644 --- a/lib/models/guild/role.ml +++ b/lib/models/guild/role.ml @@ -1,29 +1,29 @@ -include Role_t - -let edit_role ~body (role:t) = - let `Role_id id = role.id in - let `Guild_id guild_id = role.guild_id in - Http.guild_role_edit guild_id id body - -let allow_mention role = - edit_role ~body:(`Assoc [("mentionable", `Bool true)]) role - -let delete (role:t) = - let `Role_id id = role.id in - let `Guild_id guild_id = role.guild_id in - Http.guild_role_remove guild_id 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 = +include Role_t
+
+let edit_role ~body (role:t) =
+ let `Role_id id = role.id in
+ let `Guild_id guild_id = role.guild_id in
+ Http.guild_role_edit guild_id id body
+
+let allow_mention role =
+ edit_role ~body:(`Assoc [("mentionable", `Bool true)]) role
+
+let delete (role:t) =
+ let `Role_id id = role.id in
+ let `Guild_id guild_id = role.guild_id in
+ Http.guild_role_remove guild_id 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
\ No newline at end of file diff --git a/lib/models/guild/role_t.ml b/lib/models/guild/role_t.ml index f012a15..cc461f3 100644 --- a/lib/models/guild/role_t.ml +++ b/lib/models/guild/role_t.ml @@ -1,27 +1,27 @@ -open Core - -type role = { - id: Role_id.t; - name: string; - colour: int [@key "color"]; - hoist: bool; - position: int; - permissions: int; - managed: bool; - mentionable: bool; -} [@@deriving sexp, yojson { strict = false}] - -type t = { - id: Role_id.t; - name: string; - colour: int [@key "color"]; - hoist: bool; - position: int; - permissions: int; - managed: bool; - mentionable: bool; - guild_id: Guild_id_t.t; -} [@@deriving sexp, yojson { strict = false}] - -let wrap ~guild_id ({id;name;colour;hoist;position;permissions;managed;mentionable}:role) = +open Core
+
+type role = {
+ id: Role_id.t;
+ name: string;
+ colour: int [@key "color"];
+ hoist: bool;
+ position: int;
+ permissions: int;
+ managed: bool;
+ mentionable: bool;
+} [@@deriving sexp, yojson { strict = false}]
+
+type t = {
+ id: Role_id.t;
+ name: string;
+ colour: int [@key "color"];
+ hoist: bool;
+ position: int;
+ permissions: int;
+ managed: bool;
+ mentionable: bool;
+ guild_id: Guild_id_t.t;
+} [@@deriving sexp, yojson { strict = false}]
+
+let wrap ~guild_id ({id;name;colour;hoist;position;permissions;managed;mentionable}:role) =
{id;name;colour;hoist;position;permissions;managed;mentionable;guild_id = `Guild_id guild_id}
\ No newline at end of file diff --git a/lib/models/guild/role_t.mli b/lib/models/guild/role_t.mli index 6fd023f..1b69e25 100644 --- a/lib/models/guild/role_t.mli +++ b/lib/models/guild/role_t.mli @@ -1,27 +1,27 @@ -(** 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; - colour: int; - hoist: bool; - position: int; - permissions: int; - managed: bool; - mentionable: bool; -} [@@deriving sexp, yojson] - -(** A role object. *) -type 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. *) +(** 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;
+ colour: int;
+ hoist: bool;
+ position: int;
+ permissions: int;
+ managed: bool;
+ mentionable: bool;
+} [@@deriving sexp, yojson]
+
+(** A role object. *)
+type 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 |