From 7ac384bfe531347001cd3704268be5727ac9eec4 Mon Sep 17 00:00:00 2001 From: BartArys Date: Wed, 8 Jul 2020 09:41:33 +0200 Subject: [PATCH] Re-add allowedMentions DSL --- CHANGELOG.md | 3 ++- .../kordlib/rest/builder/message/MessageCreateBuilder.kt | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20c8afec5c1..0eab6e3dcd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ## Additions -* Added `BanAddEvent#getBan` to get the full ban object. +* Added `BanAddEvent#getBan` to get the full ban object. +* Re-added `MessageCreateBuilder#allowedMentions` after removal in 0.5.0. # 0.5.6 diff --git a/rest/src/main/kotlin/com/gitlab/kordlib/rest/builder/message/MessageCreateBuilder.kt b/rest/src/main/kotlin/com/gitlab/kordlib/rest/builder/message/MessageCreateBuilder.kt index b7074c37892..226ead7aa9e 100644 --- a/rest/src/main/kotlin/com/gitlab/kordlib/rest/builder/message/MessageCreateBuilder.kt +++ b/rest/src/main/kotlin/com/gitlab/kordlib/rest/builder/message/MessageCreateBuilder.kt @@ -33,6 +33,15 @@ class MessageCreateBuilder : RequestBuilder { addFile(path.fileName.toString(), Files.newInputStream(path)) } + /** + * Configures the mentions that should trigger a ping. Not calling this function will result in the default behavior + * (ping everything), calling this function but not configuring it before the request is build will result in all + * pings being ignored. + */ + inline fun allowedMentions(block: AllowedMentionsBuilder.() -> Unit = {}) { + allowedMentions = (allowedMentions ?: AllowedMentionsBuilder()).apply(block) + } + override fun toRequest(): MultipartMessageCreateRequest = MultipartMessageCreateRequest( MessageCreateRequest(content, nonce, tts, embed?.toRequest(), allowedMentions?.build()), files