diff options
| author | Matias Goldfeld <[email protected]> | 2021-01-27 17:15:05 -0500 |
|---|---|---|
| committer | Matias Goldfeld <[email protected]> | 2021-01-27 17:15:05 -0500 |
| commit | 8fc7e259c365c6a84b216b7548b87bc2a96d6868 (patch) | |
| tree | 5ea4f7d6ff82727d62b01fb2d234a4f8ab66aa2b /lib/models | |
| parent | Fixed sending file attachments by adding multiform support (diff) | |
| download | disml-8fc7e259c365c6a84b216b7548b87bc2a96d6868.tar.xz disml-8fc7e259c365c6a84b216b7548b87bc2a96d6868.zip | |
Added message_reference functionality
Diffstat (limited to 'lib/models')
| -rw-r--r-- | lib/models/channel/message/message.ml | 5 | ||||
| -rw-r--r-- | lib/models/channel/message/message.mli | 3 | ||||
| -rw-r--r-- | lib/models/id/channel_id.ml | 6 | ||||
| -rw-r--r-- | lib/models/id/channel_id.mli | 1 |
4 files changed, 11 insertions, 4 deletions
diff --git a/lib/models/channel/message/message.ml b/lib/models/channel/message/message.ml index 38c9242..7f03638 100644 --- a/lib/models/channel/message/message.ml +++ b/lib/models/channel/message/message.ml @@ -50,8 +50,9 @@ let unpin msg = let reply msg content =
Channel_id.say content msg.channel_id
-let reply_with ?embed ?content ?files ?tts msg =
- Channel_id.send_message ?embed ?content ?files ?tts msg.channel_id
+let reply_with ?embed ?content ?files ?tts ?(reply_mention=false) msg =
+ let reply = if reply_mention then Some msg.id else None in
+ Channel_id.send_message ?embed ?content ?files ?tts ?reply msg.channel_id
let set_content msg cont =
let `Message_id id = msg.id in
diff --git a/lib/models/channel/message/message.mli b/lib/models/channel/message/message.mli index e0a789a..3046492 100644 --- a/lib/models/channel/message/message.mli +++ b/lib/models/channel/message/message.mli @@ -23,12 +23,13 @@ val unpin : t -> unit Deferred.Or_error.t (** Sugar for [Channel_id.say msg.channel_id content]. *)
val reply : t -> string -> t Deferred.Or_error.t
-(** Sugar for [Channel_id.send_message ?embed ?content ?files ?tts msg.channel_id]. *)
+(** Sugar for [Channel_id.send_message ?embed ?content ?files ?tts ?reply_mention msg]. *)
val reply_with :
?embed:Embed.t ->
?content:string ->
?files:(string * string) list ->
?tts:bool ->
+ ?reply_mention:bool ->
t ->
Message_t.t Deferred.Or_error.t
diff --git a/lib/models/id/channel_id.ml b/lib/models/id/channel_id.ml index 1aa3fbb..1ea7a46 100644 --- a/lib/models/id/channel_id.ml +++ b/lib/models/id/channel_id.ml @@ -4,7 +4,7 @@ include Channel_id_t exception Invalid_message
exception No_message_found
-let send_message ?embed ?content ?files ?(tts=false) ch =
+let send_message ?embed ?content ?files ?(tts=false) ?reply ch =
let embed = match embed with
| Some e -> Embed.to_yojson e
| None -> `Null in
@@ -14,10 +14,14 @@ let send_message ?embed ?content ?files ?(tts=false) ch = let () = match embed, content with
| `Null, `Null -> raise Invalid_message
| _ -> () in
+ let message_reference = match reply with
+ | Some m -> `Assoc [("message_id", Message_id.to_yojson m)]
+ | None -> `Null in
Http.create_message ?files (get_id ch) (`Assoc [
("embed", embed);
("content", content);
("tts", `Bool tts);
+ ("message_reference", message_reference);
])
let say content ch =
diff --git a/lib/models/id/channel_id.mli b/lib/models/id/channel_id.mli index a05d282..2dfff8f 100644 --- a/lib/models/id/channel_id.mli +++ b/lib/models/id/channel_id.mli @@ -26,6 +26,7 @@ val send_message : ?content:string ->
?files:(string * string) list ->
?tts:bool ->
+ ?reply:Message_id.t ->
t ->
Message_t.t Deferred.Or_error.t
|