From 1b4fcaaa793403510742abf8889622b186b5f8ec Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Sun, 21 Jun 2020 00:13:54 -0500 Subject: [PATCH] Allow editing of message's embeds --- src/message.nim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/message.nim b/src/message.nim index b28c1fd..c94cd79 100644 --- a/src/message.nim +++ b/src/message.nim @@ -271,10 +271,14 @@ proc removeAllReactions*(message: Message, emoji: Emoji) {.async.} = "/reactions/" & emoji.toUrlEncoding()), HttpDelete, defaultHeaders(), message.channelID, RateLimitBucketType.channel) -#TODO: Embeds and maybe flags? -proc editMessage*(message: Message, content: string): Future[Message] {.async.} = +#TODO: Maybe allow editing of message flags? +proc editMessage*(message: Message, content: string, embed: Embed = nil): Future[Message] {.async.} = ## Edit a previously sent message. - let jsonBody = %*{"content": content} + var jsonBody = %*{"content": content} + + if (not embed.isNil()): + jsonBody.add("embed", embed.embedJson) + return newMessage(sendRequest(endpoint("/channels/" & $message.channelID & "/messages/" & $message.id), HttpPatch, defaultHeaders(newHttpHeaders({"Content-Type": "application/json"})), message.channelID, RateLimitBucketType.channel, jsonBody))