From 6c690609d2862417f3d006cc04bf5e1196fb788f Mon Sep 17 00:00:00 2001 From: lukellmann Date: Mon, 20 Nov 2023 22:04:07 +0100 Subject: [PATCH] Add common MessageBuilder supertype MessageBuilder is the new common supertype of MessageCreateBuilder and MessageModifyBuilder. The support for attachments was improved by adding AttachmentBuilder, which can be configured when adding files to messages. The way multipart requests are sent is now also more closely aligned with the documentation [1]. [1] https://discord.com/developers/docs/reference#uploading-files --- common/api/common.api | 1 + .../kotlin/entity/optional/Optional.kt | 7 + .../channel/MessageChannelBehavior.kt | 2 +- rest/api/rest.api | 471 ++++++++---------- .../builder/message/AttachmentBuilder.kt | 28 ++ .../kotlin/builder/message/MessageBuilder.kt | 147 ++++++ .../create/FollowupMessageCreateBuilder.kt | 56 +-- .../create/ForumMessageCreateBuilder.kt | 61 +-- .../InteractionResponseCreateBuilder.kt | 64 +-- .../message/create/MessageCreateBuilder.kt | 150 +++--- ...MessageInteractionResponseCreateBuilder.kt | 67 ++- .../create/UserMessageCreateBuilder.kt | 101 ++-- .../create/WebhookMessageCreateBuilder.kt | 67 +-- .../modify/FollowupMessageModifyBuilder.kt | 53 +- .../InteractionResponseModifyBuilder.kt | 54 +- .../message/modify/MessageModifyBuilder.kt | 129 +++-- .../modify/MessageModifyStateHolder.kt | 27 - .../modify/UserMessageModifyBuilder.kt | 49 +- .../modify/WebhookMessageModifyBuilder.kt | 54 +- .../json/request/InteractionsRequests.kt | 21 +- .../kotlin/json/request/MessageRequests.kt | 18 +- .../kotlin/json/request/WebhookRequests.kt | 14 +- rest/src/commonMain/kotlin/request/Request.kt | 14 +- .../kotlin/service/InteractionService.kt | 7 +- .../rest/builder/message/MessageBuilderJvm.kt | 22 + .../message/create/MessageCreateBuilderJvm.kt | 12 +- .../message/modify/MessageModifyBuilderJvm.kt | 12 +- 27 files changed, 856 insertions(+), 852 deletions(-) create mode 100644 rest/src/commonMain/kotlin/builder/message/AttachmentBuilder.kt create mode 100644 rest/src/commonMain/kotlin/builder/message/MessageBuilder.kt delete mode 100644 rest/src/commonMain/kotlin/builder/message/modify/MessageModifyStateHolder.kt create mode 100644 rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/MessageBuilderJvm.kt diff --git a/common/api/common.api b/common/api/common.api index 10e1b42fbc1..c675a20e3ae 100644 --- a/common/api/common.api +++ b/common/api/common.api @@ -9182,6 +9182,7 @@ public final class dev/kord/common/entity/optional/OptionalKt { public static final fun mapList (Ldev/kord/common/entity/optional/Optional;Lkotlin/jvm/functions/Function1;)Ldev/kord/common/entity/optional/Optional; public static final fun mapNotNull (Ldev/kord/common/entity/optional/Optional;Lkotlin/jvm/functions/Function1;)Ldev/kord/common/entity/optional/Optional; public static final fun mapNullable (Ldev/kord/common/entity/optional/Optional;Lkotlin/jvm/functions/Function1;)Ldev/kord/common/entity/optional/Optional; + public static final fun mapNullableList (Ldev/kord/common/entity/optional/Optional;Lkotlin/jvm/functions/Function1;)Ldev/kord/common/entity/optional/Optional; public static final fun mapNullableOptional (Ldev/kord/common/entity/optional/Optional;Lkotlin/jvm/functions/Function1;)Ldev/kord/common/entity/optional/Optional; public static final fun mapNullableSnowflake (Ldev/kord/common/entity/optional/Optional;Lkotlin/jvm/functions/Function1;)Ldev/kord/common/entity/optional/OptionalSnowflake; public static final fun mapSnowflake (Ldev/kord/common/entity/optional/Optional;Lkotlin/jvm/functions/Function1;)Ldev/kord/common/entity/optional/OptionalSnowflake; diff --git a/common/src/commonMain/kotlin/entity/optional/Optional.kt b/common/src/commonMain/kotlin/entity/optional/Optional.kt index 743631bf49e..561a6bd85e7 100644 --- a/common/src/commonMain/kotlin/entity/optional/Optional.kt +++ b/common/src/commonMain/kotlin/entity/optional/Optional.kt @@ -216,6 +216,13 @@ public inline fun Optional>.mapList(mapper: (E) -> T): Optional Value(value.map(mapper)) } +@JvmName("mapNullableList") +public inline fun Optional?>.mapList(mapper: (E) -> T): Optional?> = when (this) { + is Missing -> Missing() + is Null -> Null() + is Value -> Value(value!!.map(mapper)) +} + public fun Optional>.mapCopy(): Optional> = map { mutable -> mutable.toList() } @JvmName("mapCopyOfMap") diff --git a/core/src/commonMain/kotlin/behavior/channel/MessageChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/MessageChannelBehavior.kt index 76702092614..99d36695c8f 100644 --- a/core/src/commonMain/kotlin/behavior/channel/MessageChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/MessageChannelBehavior.kt @@ -14,7 +14,7 @@ import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.rest.builder.message.EmbedBuilder import dev.kord.rest.builder.message.create.MessageCreateBuilder import dev.kord.rest.builder.message.create.UserMessageCreateBuilder -import dev.kord.rest.builder.message.create.embed +import dev.kord.rest.builder.message.embed import dev.kord.rest.request.RestRequestException import dev.kord.rest.service.RestClient import kotlinx.coroutines.coroutineScope diff --git a/rest/api/rest.api b/rest/api/rest.api index d0d2009ab61..bbf3e21893a 100644 --- a/rest/api/rest.api +++ b/rest/api/rest.api @@ -2004,6 +2004,16 @@ public final class dev/kord/rest/builder/message/AllowedMentionsBuilder { public final fun unaryPlus (Ldev/kord/common/entity/AllowedMentionType;)V } +public final class dev/kord/rest/builder/message/AttachmentBuilder : dev/kord/rest/builder/RequestBuilder { + public fun (Ldev/kord/common/entity/Snowflake;)V + public final fun getDescription ()Ljava/lang/String; + public final fun getFilename ()Ljava/lang/String; + public final fun setDescription (Ljava/lang/String;)V + public final fun setFilename (Ljava/lang/String;)V + public fun toRequest ()Ldev/kord/rest/json/request/AttachmentRequest; + public synthetic fun toRequest ()Ljava/lang/Object; +} + public final class dev/kord/rest/builder/message/EmbedBuilder : dev/kord/rest/builder/RequestBuilder { public static final field Companion Ldev/kord/rest/builder/message/EmbedBuilder$Companion; public static final field ZERO_WIDTH_SPACE Ljava/lang/String; @@ -2109,92 +2119,99 @@ public final class dev/kord/rest/builder/message/EmbedBuilder$Thumbnail : dev/ko public synthetic fun toRequest ()Ljava/lang/Object; } -public final class dev/kord/rest/builder/message/create/FollowupMessageCreateBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/create/MessageCreateBuilder { - public fun (Z)V +public abstract interface class dev/kord/rest/builder/message/MessageBuilder { + public abstract fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; + public abstract fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; + public abstract fun getAttachments ()Ljava/util/List; + public abstract fun getComponents ()Ljava/util/List; + public abstract fun getContent ()Ljava/lang/String; + public abstract fun getEmbeds ()Ljava/util/List; + public abstract fun getFiles ()Ljava/util/List; + public abstract fun getFlags ()Ldev/kord/common/entity/MessageFlags; + public abstract fun getSuppressEmbeds ()Ljava/lang/Boolean; + public abstract fun setAllowedMentions (Ldev/kord/rest/builder/message/AllowedMentionsBuilder;)V + public abstract fun setAttachments (Ljava/util/List;)V + public abstract fun setComponents (Ljava/util/List;)V + public abstract fun setContent (Ljava/lang/String;)V + public abstract fun setEmbeds (Ljava/util/List;)V + public abstract fun setFlags (Ldev/kord/common/entity/MessageFlags;)V + public abstract fun setSuppressEmbeds (Ljava/lang/Boolean;)V +} + +public final class dev/kord/rest/builder/message/MessageBuilder$DefaultImpls { + public static fun addFile (Ldev/kord/rest/builder/message/MessageBuilder;Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; +} + +public final class dev/kord/rest/builder/message/MessageBuilderJvmKt { + public static final fun addFile (Ldev/kord/rest/builder/message/MessageBuilder;Ljava/nio/file/Path;)Ldev/kord/rest/NamedFile; + public static final fun addFile (Ldev/kord/rest/builder/message/MessageBuilder;Ljava/nio/file/Path;Lkotlin/jvm/functions/Function1;)Ldev/kord/rest/NamedFile; +} + +public final class dev/kord/rest/builder/message/MessageBuilderKt { + public static final fun actionRow (Ldev/kord/rest/builder/message/MessageBuilder;Lkotlin/jvm/functions/Function1;)V + public static final fun addFile (Ldev/kord/rest/builder/message/MessageBuilder;Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;Lkotlin/jvm/functions/Function1;)Ldev/kord/rest/NamedFile; + public static final fun allowedMentions (Ldev/kord/rest/builder/message/MessageBuilder;Lkotlin/jvm/functions/Function1;)V + public static synthetic fun allowedMentions$default (Ldev/kord/rest/builder/message/MessageBuilder;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V + public static final fun embed (Ldev/kord/rest/builder/message/MessageBuilder;Lkotlin/jvm/functions/Function1;)V + public static final fun messageFlags (Ldev/kord/rest/builder/message/MessageBuilder;Lkotlin/jvm/functions/Function1;)V +} + +public abstract class dev/kord/rest/builder/message/create/AbstractMessageCreateBuilder : dev/kord/rest/builder/message/create/MessageCreateBuilder { public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; - public fun getComponents ()Ljava/util/List; - public fun getContent ()Ljava/lang/String; - public fun getEmbeds ()Ljava/util/List; - public final fun getEphemeral ()Z + public final fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; + public final fun getAttachments ()Ljava/util/List; + public final fun getComponents ()Ljava/util/List; + public final fun getContent ()Ljava/lang/String; + public final fun getEmbeds ()Ljava/util/List; public fun getFiles ()Ljava/util/List; - public fun getFlags ()Ldev/kord/common/entity/MessageFlags; - public fun getSuppressEmbeds ()Ljava/lang/Boolean; - public fun getSuppressNotifications ()Ljava/lang/Boolean; - public fun getTts ()Ljava/lang/Boolean; - public fun setAllowedMentions (Ldev/kord/rest/builder/message/AllowedMentionsBuilder;)V - public fun setContent (Ljava/lang/String;)V - public fun setFlags (Ldev/kord/common/entity/MessageFlags;)V - public fun setSuppressEmbeds (Ljava/lang/Boolean;)V - public fun setSuppressNotifications (Ljava/lang/Boolean;)V - public fun setTts (Ljava/lang/Boolean;)V + public final fun getFlags ()Ldev/kord/common/entity/MessageFlags; + public final fun getSuppressEmbeds ()Ljava/lang/Boolean; + public final fun getSuppressNotifications ()Ljava/lang/Boolean; + public final fun getTts ()Ljava/lang/Boolean; + public final fun setAllowedMentions (Ldev/kord/rest/builder/message/AllowedMentionsBuilder;)V + public final fun setAttachments (Ljava/util/List;)V + public final fun setComponents (Ljava/util/List;)V + public final fun setContent (Ljava/lang/String;)V + public final fun setEmbeds (Ljava/util/List;)V + public final fun setFlags (Ldev/kord/common/entity/MessageFlags;)V + public final fun setSuppressEmbeds (Ljava/lang/Boolean;)V + public final fun setSuppressNotifications (Ljava/lang/Boolean;)V + public final fun setTts (Ljava/lang/Boolean;)V +} + +public final class dev/kord/rest/builder/message/create/FollowupMessageCreateBuilder : dev/kord/rest/builder/message/create/AbstractMessageCreateBuilder, dev/kord/rest/builder/RequestBuilder { + public fun (Z)V + public final fun getEphemeral ()Z public fun toRequest ()Ldev/kord/rest/json/request/MultipartFollowupMessageCreateRequest; public synthetic fun toRequest ()Ljava/lang/Object; } -public final class dev/kord/rest/builder/message/create/ForumMessageCreateBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/create/MessageCreateBuilder { +public final class dev/kord/rest/builder/message/create/ForumMessageCreateBuilder : dev/kord/rest/builder/message/create/AbstractMessageCreateBuilder, dev/kord/rest/builder/RequestBuilder { public fun ()V - public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; - public fun getComponents ()Ljava/util/List; - public fun getContent ()Ljava/lang/String; - public fun getEmbeds ()Ljava/util/List; - public fun getFiles ()Ljava/util/List; - public fun getFlags ()Ldev/kord/common/entity/MessageFlags; public final fun getStickerIds ()Ljava/util/List; - public fun getSuppressEmbeds ()Ljava/lang/Boolean; - public fun getSuppressNotifications ()Ljava/lang/Boolean; - public fun getTts ()Ljava/lang/Boolean; - public fun setAllowedMentions (Ldev/kord/rest/builder/message/AllowedMentionsBuilder;)V - public fun setContent (Ljava/lang/String;)V - public fun setFlags (Ldev/kord/common/entity/MessageFlags;)V - public fun setSuppressEmbeds (Ljava/lang/Boolean;)V - public fun setSuppressNotifications (Ljava/lang/Boolean;)V - public fun setTts (Ljava/lang/Boolean;)V + public final fun setStickerIds (Ljava/util/List;)V public fun toRequest ()Ldev/kord/rest/json/request/MultipartForumThreadMessageCreateRequest; public synthetic fun toRequest ()Ljava/lang/Object; } -public final class dev/kord/rest/builder/message/create/InteractionResponseCreateBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/create/MessageCreateBuilder { +public final class dev/kord/rest/builder/message/create/ForumMessageCreateBuilderKt { + public static final fun stickerId (Ldev/kord/rest/builder/message/create/ForumMessageCreateBuilder;Ldev/kord/common/entity/Snowflake;)V +} + +public final class dev/kord/rest/builder/message/create/InteractionResponseCreateBuilder : dev/kord/rest/builder/message/create/AbstractMessageCreateBuilder, dev/kord/rest/builder/RequestBuilder { public fun ()V public fun (Z)V public synthetic fun (ZILkotlin/jvm/internal/DefaultConstructorMarker;)V - public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; - public fun getComponents ()Ljava/util/List; - public fun getContent ()Ljava/lang/String; - public fun getEmbeds ()Ljava/util/List; public final fun getEphemeral ()Z - public fun getFiles ()Ljava/util/List; - public fun getFlags ()Ldev/kord/common/entity/MessageFlags; - public fun getSuppressEmbeds ()Ljava/lang/Boolean; - public fun getSuppressNotifications ()Ljava/lang/Boolean; - public fun getTts ()Ljava/lang/Boolean; - public fun setAllowedMentions (Ldev/kord/rest/builder/message/AllowedMentionsBuilder;)V - public fun setContent (Ljava/lang/String;)V - public fun setFlags (Ldev/kord/common/entity/MessageFlags;)V - public fun setSuppressEmbeds (Ljava/lang/Boolean;)V - public fun setSuppressNotifications (Ljava/lang/Boolean;)V - public fun setTts (Ljava/lang/Boolean;)V public fun toRequest ()Ldev/kord/rest/json/request/MultipartInteractionResponseCreateRequest; public synthetic fun toRequest ()Ljava/lang/Object; } -public abstract interface class dev/kord/rest/builder/message/create/MessageCreateBuilder { - public abstract fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public abstract fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; - public abstract fun getComponents ()Ljava/util/List; - public abstract fun getContent ()Ljava/lang/String; - public abstract fun getEmbeds ()Ljava/util/List; - public abstract fun getFiles ()Ljava/util/List; +public abstract interface class dev/kord/rest/builder/message/create/MessageCreateBuilder : dev/kord/rest/builder/message/MessageBuilder { public abstract fun getFlags ()Ldev/kord/common/entity/MessageFlags; - public abstract fun getSuppressEmbeds ()Ljava/lang/Boolean; public abstract fun getSuppressNotifications ()Ljava/lang/Boolean; public abstract fun getTts ()Ljava/lang/Boolean; - public abstract fun setAllowedMentions (Ldev/kord/rest/builder/message/AllowedMentionsBuilder;)V - public abstract fun setContent (Ljava/lang/String;)V public abstract fun setFlags (Ldev/kord/common/entity/MessageFlags;)V - public abstract fun setSuppressEmbeds (Ljava/lang/Boolean;)V public abstract fun setSuppressNotifications (Ljava/lang/Boolean;)V public abstract fun setTts (Ljava/lang/Boolean;)V } @@ -2215,151 +2232,79 @@ public final class dev/kord/rest/builder/message/create/MessageCreateBuilderKt { public static final fun messageFlags (Ldev/kord/rest/builder/message/create/MessageCreateBuilder;Lkotlin/jvm/functions/Function1;)V } -public final class dev/kord/rest/builder/message/create/UpdateMessageInteractionResponseCreateBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/create/MessageCreateBuilder { +public final class dev/kord/rest/builder/message/create/UpdateMessageInteractionResponseCreateBuilder : dev/kord/rest/builder/message/create/AbstractMessageCreateBuilder, dev/kord/rest/builder/RequestBuilder { public fun ()V - public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; - public fun getComponents ()Ljava/util/List; - public fun getContent ()Ljava/lang/String; - public fun getEmbeds ()Ljava/util/List; public fun getFiles ()Ljava/util/List; - public fun getFlags ()Ldev/kord/common/entity/MessageFlags; - public fun getSuppressEmbeds ()Ljava/lang/Boolean; - public fun getSuppressNotifications ()Ljava/lang/Boolean; - public fun getTts ()Ljava/lang/Boolean; - public fun setAllowedMentions (Ldev/kord/rest/builder/message/AllowedMentionsBuilder;)V - public fun setComponents (Ljava/util/List;)V - public fun setContent (Ljava/lang/String;)V - public fun setEmbeds (Ljava/util/List;)V public fun setFiles (Ljava/util/List;)V - public fun setFlags (Ldev/kord/common/entity/MessageFlags;)V - public fun setSuppressEmbeds (Ljava/lang/Boolean;)V - public fun setSuppressNotifications (Ljava/lang/Boolean;)V - public fun setTts (Ljava/lang/Boolean;)V public fun toRequest ()Ldev/kord/rest/json/request/MultipartInteractionResponseCreateRequest; public synthetic fun toRequest ()Ljava/lang/Object; } -public final class dev/kord/rest/builder/message/create/UserMessageCreateBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/create/MessageCreateBuilder { +public final class dev/kord/rest/builder/message/create/UserMessageCreateBuilder : dev/kord/rest/builder/message/create/AbstractMessageCreateBuilder, dev/kord/rest/builder/RequestBuilder { public fun ()V - public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; - public fun getComponents ()Ljava/util/List; - public fun getContent ()Ljava/lang/String; - public fun getEmbeds ()Ljava/util/List; public final fun getFailIfNotExists ()Ljava/lang/Boolean; - public fun getFiles ()Ljava/util/List; - public fun getFlags ()Ldev/kord/common/entity/MessageFlags; public final fun getMessageReference ()Ldev/kord/common/entity/Snowflake; public final fun getNonce ()Ljava/lang/String; - public fun getSuppressEmbeds ()Ljava/lang/Boolean; - public fun getSuppressNotifications ()Ljava/lang/Boolean; - public fun getTts ()Ljava/lang/Boolean; - public fun setAllowedMentions (Ldev/kord/rest/builder/message/AllowedMentionsBuilder;)V - public fun setContent (Ljava/lang/String;)V + public final fun getStickerIds ()Ljava/util/List; public final fun setFailIfNotExists (Ljava/lang/Boolean;)V - public fun setFlags (Ldev/kord/common/entity/MessageFlags;)V public final fun setMessageReference (Ldev/kord/common/entity/Snowflake;)V public final fun setNonce (Ljava/lang/String;)V - public fun setSuppressEmbeds (Ljava/lang/Boolean;)V - public fun setSuppressNotifications (Ljava/lang/Boolean;)V - public fun setTts (Ljava/lang/Boolean;)V + public final fun setStickerIds (Ljava/util/List;)V public fun toRequest ()Ldev/kord/rest/json/request/MultipartMessageCreateRequest; public synthetic fun toRequest ()Ljava/lang/Object; } -public final class dev/kord/rest/builder/message/create/WebhookMessageCreateBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/create/MessageCreateBuilder { +public final class dev/kord/rest/builder/message/create/UserMessageCreateBuilderKt { + public static final fun stickerId (Ldev/kord/rest/builder/message/create/UserMessageCreateBuilder;Ldev/kord/common/entity/Snowflake;)V +} + +public final class dev/kord/rest/builder/message/create/WebhookMessageCreateBuilder : dev/kord/rest/builder/message/create/AbstractMessageCreateBuilder, dev/kord/rest/builder/RequestBuilder { public fun ()V - public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; public final fun getAvatarUrl ()Ljava/lang/String; - public fun getComponents ()Ljava/util/List; - public fun getContent ()Ljava/lang/String; - public fun getEmbeds ()Ljava/util/List; - public fun getFiles ()Ljava/util/List; - public fun getFlags ()Ldev/kord/common/entity/MessageFlags; - public fun getSuppressEmbeds ()Ljava/lang/Boolean; - public fun getSuppressNotifications ()Ljava/lang/Boolean; public final fun getThreadName ()Ljava/lang/String; - public fun getTts ()Ljava/lang/Boolean; public final fun getUsername ()Ljava/lang/String; - public fun setAllowedMentions (Ldev/kord/rest/builder/message/AllowedMentionsBuilder;)V public final fun setAvatarUrl (Ljava/lang/String;)V - public fun setContent (Ljava/lang/String;)V - public fun setFlags (Ldev/kord/common/entity/MessageFlags;)V - public fun setSuppressEmbeds (Ljava/lang/Boolean;)V - public fun setSuppressNotifications (Ljava/lang/Boolean;)V public final fun setThreadName (Ljava/lang/String;)V - public fun setTts (Ljava/lang/Boolean;)V public final fun setUsername (Ljava/lang/String;)V public fun toRequest ()Ldev/kord/rest/json/request/MultiPartWebhookExecuteRequest; public synthetic fun toRequest ()Ljava/lang/Object; } -public final class dev/kord/rest/builder/message/modify/FollowupMessageModifyBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/modify/MessageModifyBuilder { - public fun ()V +public abstract class dev/kord/rest/builder/message/modify/AbstractMessageModifyBuilder : dev/kord/rest/builder/message/modify/MessageModifyBuilder { public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; - public fun getAttachments ()Ljava/util/List; - public fun getComponents ()Ljava/util/List; - public fun getContent ()Ljava/lang/String; - public fun getEmbeds ()Ljava/util/List; - public fun getFiles ()Ljava/util/List; - public fun getFlags ()Ldev/kord/common/entity/MessageFlags; - public fun getSuppressEmbeds ()Ljava/lang/Boolean; - public fun setAllowedMentions (Ldev/kord/rest/builder/message/AllowedMentionsBuilder;)V - public fun setAttachments (Ljava/util/List;)V - public fun setComponents (Ljava/util/List;)V - public fun setContent (Ljava/lang/String;)V - public fun setEmbeds (Ljava/util/List;)V - public fun setFiles (Ljava/util/List;)V - public fun setFlags (Ldev/kord/common/entity/MessageFlags;)V - public fun setSuppressEmbeds (Ljava/lang/Boolean;)V + public final fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; + public final fun getAttachments ()Ljava/util/List; + public final fun getComponents ()Ljava/util/List; + public final fun getContent ()Ljava/lang/String; + public final fun getEmbeds ()Ljava/util/List; + public final fun getFiles ()Ljava/util/List; + public final fun getFlags ()Ldev/kord/common/entity/MessageFlags; + public final fun getSuppressEmbeds ()Ljava/lang/Boolean; + public final fun setAllowedMentions (Ldev/kord/rest/builder/message/AllowedMentionsBuilder;)V + public final fun setAttachments (Ljava/util/List;)V + public final fun setComponents (Ljava/util/List;)V + public final fun setContent (Ljava/lang/String;)V + public final fun setEmbeds (Ljava/util/List;)V + public final fun setFiles (Ljava/util/List;)V + public final fun setFlags (Ldev/kord/common/entity/MessageFlags;)V + public final fun setSuppressEmbeds (Ljava/lang/Boolean;)V +} + +public final class dev/kord/rest/builder/message/modify/FollowupMessageModifyBuilder : dev/kord/rest/builder/message/modify/AbstractMessageModifyBuilder, dev/kord/rest/builder/RequestBuilder { + public fun ()V public fun toRequest ()Ldev/kord/rest/json/request/MultipartFollowupMessageModifyRequest; public synthetic fun toRequest ()Ljava/lang/Object; } -public final class dev/kord/rest/builder/message/modify/InteractionResponseModifyBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/modify/MessageModifyBuilder { +public final class dev/kord/rest/builder/message/modify/InteractionResponseModifyBuilder : dev/kord/rest/builder/message/modify/AbstractMessageModifyBuilder, dev/kord/rest/builder/RequestBuilder { public fun ()V - public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; - public fun getAttachments ()Ljava/util/List; - public fun getComponents ()Ljava/util/List; - public fun getContent ()Ljava/lang/String; - public fun getEmbeds ()Ljava/util/List; - public fun getFiles ()Ljava/util/List; - public fun getFlags ()Ldev/kord/common/entity/MessageFlags; - public fun getSuppressEmbeds ()Ljava/lang/Boolean; - public fun setAllowedMentions (Ldev/kord/rest/builder/message/AllowedMentionsBuilder;)V - public fun setAttachments (Ljava/util/List;)V - public fun setComponents (Ljava/util/List;)V - public fun setContent (Ljava/lang/String;)V - public fun setEmbeds (Ljava/util/List;)V - public fun setFiles (Ljava/util/List;)V - public fun setFlags (Ldev/kord/common/entity/MessageFlags;)V - public fun setSuppressEmbeds (Ljava/lang/Boolean;)V public fun toRequest ()Ldev/kord/rest/json/request/MultipartInteractionResponseModifyRequest; public synthetic fun toRequest ()Ljava/lang/Object; } -public abstract interface class dev/kord/rest/builder/message/modify/MessageModifyBuilder { - public abstract fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public abstract fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; - public abstract fun getAttachments ()Ljava/util/List; - public abstract fun getComponents ()Ljava/util/List; - public abstract fun getContent ()Ljava/lang/String; - public abstract fun getEmbeds ()Ljava/util/List; +public abstract interface class dev/kord/rest/builder/message/modify/MessageModifyBuilder : dev/kord/rest/builder/message/MessageBuilder { public abstract fun getFiles ()Ljava/util/List; - public abstract fun getFlags ()Ldev/kord/common/entity/MessageFlags; - public abstract fun getSuppressEmbeds ()Ljava/lang/Boolean; - public abstract fun setAllowedMentions (Ldev/kord/rest/builder/message/AllowedMentionsBuilder;)V - public abstract fun setAttachments (Ljava/util/List;)V - public abstract fun setComponents (Ljava/util/List;)V - public abstract fun setContent (Ljava/lang/String;)V - public abstract fun setEmbeds (Ljava/util/List;)V public abstract fun setFiles (Ljava/util/List;)V - public abstract fun setFlags (Ldev/kord/common/entity/MessageFlags;)V - public abstract fun setSuppressEmbeds (Ljava/lang/Boolean;)V } public final class dev/kord/rest/builder/message/modify/MessageModifyBuilder$DefaultImpls { @@ -2375,51 +2320,19 @@ public final class dev/kord/rest/builder/message/modify/MessageModifyBuilderKt { public static final fun allowedMentions (Ldev/kord/rest/builder/message/modify/MessageModifyBuilder;Lkotlin/jvm/functions/Function1;)V public static synthetic fun allowedMentions$default (Ldev/kord/rest/builder/message/modify/MessageModifyBuilder;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V public static final fun embed (Ldev/kord/rest/builder/message/modify/MessageModifyBuilder;Lkotlin/jvm/functions/Function1;)V + public static final fun keepAttachment (Ldev/kord/rest/builder/message/modify/MessageModifyBuilder;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;)V + public static synthetic fun keepAttachment$default (Ldev/kord/rest/builder/message/modify/MessageModifyBuilder;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V public static final fun messageFlags (Ldev/kord/rest/builder/message/modify/MessageModifyBuilder;Lkotlin/jvm/functions/Function1;)V } -public final class dev/kord/rest/builder/message/modify/UserMessageModifyBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/modify/MessageModifyBuilder { +public final class dev/kord/rest/builder/message/modify/UserMessageModifyBuilder : dev/kord/rest/builder/message/modify/AbstractMessageModifyBuilder, dev/kord/rest/builder/RequestBuilder { public fun ()V - public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; - public fun getAttachments ()Ljava/util/List; - public fun getComponents ()Ljava/util/List; - public fun getContent ()Ljava/lang/String; - public fun getEmbeds ()Ljava/util/List; - public fun getFiles ()Ljava/util/List; - public fun getFlags ()Ldev/kord/common/entity/MessageFlags; - public fun getSuppressEmbeds ()Ljava/lang/Boolean; - public fun setAllowedMentions (Ldev/kord/rest/builder/message/AllowedMentionsBuilder;)V - public fun setAttachments (Ljava/util/List;)V - public fun setComponents (Ljava/util/List;)V - public fun setContent (Ljava/lang/String;)V - public fun setEmbeds (Ljava/util/List;)V - public fun setFiles (Ljava/util/List;)V - public fun setFlags (Ldev/kord/common/entity/MessageFlags;)V - public fun setSuppressEmbeds (Ljava/lang/Boolean;)V public fun toRequest ()Ldev/kord/rest/json/request/MultipartMessagePatchRequest; public synthetic fun toRequest ()Ljava/lang/Object; } -public final class dev/kord/rest/builder/message/modify/WebhookMessageModifyBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/modify/MessageModifyBuilder { +public final class dev/kord/rest/builder/message/modify/WebhookMessageModifyBuilder : dev/kord/rest/builder/message/modify/AbstractMessageModifyBuilder, dev/kord/rest/builder/RequestBuilder { public fun ()V - public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; - public fun getAttachments ()Ljava/util/List; - public fun getComponents ()Ljava/util/List; - public fun getContent ()Ljava/lang/String; - public fun getEmbeds ()Ljava/util/List; - public fun getFiles ()Ljava/util/List; - public fun getFlags ()Ldev/kord/common/entity/MessageFlags; - public fun getSuppressEmbeds ()Ljava/lang/Boolean; - public fun setAllowedMentions (Ldev/kord/rest/builder/message/AllowedMentionsBuilder;)V - public fun setAttachments (Ljava/util/List;)V - public fun setComponents (Ljava/util/List;)V - public fun setContent (Ljava/lang/String;)V - public fun setEmbeds (Ljava/util/List;)V - public fun setFiles (Ljava/util/List;)V - public fun setFlags (Ldev/kord/common/entity/MessageFlags;)V - public fun setSuppressEmbeds (Ljava/lang/Boolean;)V public fun toRequest ()Ldev/kord/rest/json/request/MultipartWebhookEditMessageRequest; public synthetic fun toRequest ()Ljava/lang/Object; } @@ -2912,6 +2825,38 @@ public final class dev/kord/rest/json/request/ApplicationCommandModifyRequest$Co public final fun serializer ()Lkotlinx/serialization/KSerializer; } +public final class dev/kord/rest/json/request/AttachmentRequest { + public static final field Companion Ldev/kord/rest/json/request/AttachmentRequest$Companion; + public fun (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V + public synthetic fun (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun component1 ()Ldev/kord/common/entity/Snowflake; + public final fun component2 ()Ldev/kord/common/entity/optional/Optional; + public final fun component3 ()Ldev/kord/common/entity/optional/Optional; + public final fun copy (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/AttachmentRequest; + public static synthetic fun copy$default (Ldev/kord/rest/json/request/AttachmentRequest;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/AttachmentRequest; + public fun equals (Ljava/lang/Object;)Z + public final fun getDescription ()Ldev/kord/common/entity/optional/Optional; + public final fun getFilename ()Ldev/kord/common/entity/optional/Optional; + public final fun getId ()Ldev/kord/common/entity/Snowflake; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class dev/kord/rest/json/request/AttachmentRequest$$serializer : kotlinx/serialization/internal/GeneratedSerializer { + public static final field INSTANCE Ldev/kord/rest/json/request/AttachmentRequest$$serializer; + public fun childSerializers ()[Lkotlinx/serialization/KSerializer; + public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/kord/rest/json/request/AttachmentRequest; + public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object; + public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor; + public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/kord/rest/json/request/AttachmentRequest;)V + public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V + public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer; +} + +public final class dev/kord/rest/json/request/AttachmentRequest$Companion { + public final fun serializer ()Lkotlinx/serialization/KSerializer; +} + public final class dev/kord/rest/json/request/AuditLogGetRequest { public fun ()V public fun (Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/AuditLogEvent;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Ljava/lang/Integer;)V @@ -3665,27 +3610,25 @@ public final class dev/kord/rest/json/request/EmojiModifyRequest$Companion { public final class dev/kord/rest/json/request/FollowupMessageCreateRequest { public static final field Companion Ldev/kord/rest/json/request/FollowupMessageCreateRequest$Companion; public fun ()V - public fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V - public synthetic fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V + public synthetic fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/common/entity/optional/Optional; - public final fun component2 ()Ldev/kord/common/entity/optional/Optional; + public final fun component2 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component3 ()Ldev/kord/common/entity/optional/Optional; - public final fun component4 ()Ldev/kord/common/entity/optional/OptionalBoolean; + public final fun component4 ()Ldev/kord/common/entity/optional/Optional; public final fun component5 ()Ldev/kord/common/entity/optional/Optional; public final fun component6 ()Ldev/kord/common/entity/optional/Optional; public final fun component7 ()Ldev/kord/common/entity/optional/Optional; - public final fun component8 ()Ldev/kord/common/entity/optional/Optional; - public final fun copy (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/FollowupMessageCreateRequest; - public static synthetic fun copy$default (Ldev/kord/rest/json/request/FollowupMessageCreateRequest;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/FollowupMessageCreateRequest; + public final fun copy (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/FollowupMessageCreateRequest; + public static synthetic fun copy$default (Ldev/kord/rest/json/request/FollowupMessageCreateRequest;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/FollowupMessageCreateRequest; public fun equals (Ljava/lang/Object;)Z public final fun getAllowedMentions ()Ldev/kord/common/entity/optional/Optional; - public final fun getAvatar ()Ldev/kord/common/entity/optional/Optional; + public final fun getAttachments ()Ldev/kord/common/entity/optional/Optional; public final fun getComponents ()Ldev/kord/common/entity/optional/Optional; public final fun getContent ()Ldev/kord/common/entity/optional/Optional; public final fun getEmbeds ()Ldev/kord/common/entity/optional/Optional; public final fun getFlags ()Ldev/kord/common/entity/optional/Optional; public final fun getTts ()Ldev/kord/common/entity/optional/OptionalBoolean; - public final fun getUsername ()Ldev/kord/common/entity/optional/Optional; public fun hashCode ()I public fun toString ()Ljava/lang/String; } @@ -3781,23 +3724,27 @@ public final class dev/kord/rest/json/request/ForumTagRequest$Companion { public final class dev/kord/rest/json/request/ForumThreadMessageRequest { public static final field Companion Ldev/kord/rest/json/request/ForumThreadMessageRequest$Companion; public fun ()V - public fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V - public synthetic fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V + public synthetic fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/common/entity/optional/Optional; - public final fun component2 ()Ldev/kord/common/entity/optional/Optional; + public final fun component2 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component3 ()Ldev/kord/common/entity/optional/Optional; public final fun component4 ()Ldev/kord/common/entity/optional/Optional; public final fun component5 ()Ldev/kord/common/entity/optional/Optional; public final fun component6 ()Ldev/kord/common/entity/optional/Optional; - public final fun copy (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/ForumThreadMessageRequest; - public static synthetic fun copy$default (Ldev/kord/rest/json/request/ForumThreadMessageRequest;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/ForumThreadMessageRequest; + public final fun component7 ()Ldev/kord/common/entity/optional/Optional; + public final fun component8 ()Ldev/kord/common/entity/optional/Optional; + public final fun copy (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/ForumThreadMessageRequest; + public static synthetic fun copy$default (Ldev/kord/rest/json/request/ForumThreadMessageRequest;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/ForumThreadMessageRequest; public fun equals (Ljava/lang/Object;)Z public final fun getAllowedMentions ()Ldev/kord/common/entity/optional/Optional; + public final fun getAttachments ()Ldev/kord/common/entity/optional/Optional; public final fun getComponents ()Ldev/kord/common/entity/optional/Optional; public final fun getContent ()Ldev/kord/common/entity/optional/Optional; public final fun getEmbeds ()Ldev/kord/common/entity/optional/Optional; public final fun getFlags ()Ldev/kord/common/entity/optional/Optional; public final fun getStickerIds ()Ldev/kord/common/entity/optional/Optional; + public final fun getTts ()Ldev/kord/common/entity/optional/OptionalBoolean; public fun hashCode ()I public fun toString ()Ljava/lang/String; } @@ -4663,18 +4610,20 @@ public final class dev/kord/rest/json/request/GuildWidgetModifyRequest$Companion public final class dev/kord/rest/json/request/InteractionApplicationCommandCallbackData { public static final field Companion Ldev/kord/rest/json/request/InteractionApplicationCommandCallbackData$Companion; public fun ()V - public fun (Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V - public synthetic fun (Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V + public synthetic fun (Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component2 ()Ldev/kord/common/entity/optional/Optional; public final fun component3 ()Ldev/kord/common/entity/optional/Optional; public final fun component4 ()Ldev/kord/common/entity/optional/Optional; public final fun component5 ()Ldev/kord/common/entity/optional/Optional; public final fun component6 ()Ldev/kord/common/entity/optional/Optional; - public final fun copy (Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/InteractionApplicationCommandCallbackData; - public static synthetic fun copy$default (Ldev/kord/rest/json/request/InteractionApplicationCommandCallbackData;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/InteractionApplicationCommandCallbackData; + public final fun component7 ()Ldev/kord/common/entity/optional/Optional; + public final fun copy (Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/InteractionApplicationCommandCallbackData; + public static synthetic fun copy$default (Ldev/kord/rest/json/request/InteractionApplicationCommandCallbackData;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/InteractionApplicationCommandCallbackData; public fun equals (Ljava/lang/Object;)Z public final fun getAllowedMentions ()Ldev/kord/common/entity/optional/Optional; + public final fun getAttachments ()Ldev/kord/common/entity/optional/Optional; public final fun getComponents ()Ldev/kord/common/entity/optional/Optional; public final fun getContent ()Ldev/kord/common/entity/optional/Optional; public final fun getEmbeds ()Ldev/kord/common/entity/optional/Optional; @@ -4842,9 +4791,10 @@ public final class dev/kord/rest/json/request/ListThreadsByTimestampRequest { public final class dev/kord/rest/json/request/MessageCreateRequest { public static final field Companion Ldev/kord/rest/json/request/MessageCreateRequest$Companion; public fun ()V - public fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V - public synthetic fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V + public synthetic fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/common/entity/optional/Optional; + public final fun component10 ()Ldev/kord/common/entity/optional/Optional; public final fun component2 ()Ldev/kord/common/entity/optional/Optional; public final fun component3 ()Ldev/kord/common/entity/optional/OptionalBoolean; public final fun component4 ()Ldev/kord/common/entity/optional/Optional; @@ -4852,16 +4802,19 @@ public final class dev/kord/rest/json/request/MessageCreateRequest { public final fun component6 ()Ldev/kord/common/entity/optional/Optional; public final fun component7 ()Ldev/kord/common/entity/optional/Optional; public final fun component8 ()Ldev/kord/common/entity/optional/Optional; - public final fun copy (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/MessageCreateRequest; - public static synthetic fun copy$default (Ldev/kord/rest/json/request/MessageCreateRequest;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/MessageCreateRequest; + public final fun component9 ()Ldev/kord/common/entity/optional/Optional; + public final fun copy (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/MessageCreateRequest; + public static synthetic fun copy$default (Ldev/kord/rest/json/request/MessageCreateRequest;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/MessageCreateRequest; public fun equals (Ljava/lang/Object;)Z public final fun getAllowedMentions ()Ldev/kord/common/entity/optional/Optional; + public final fun getAttachments ()Ldev/kord/common/entity/optional/Optional; public final fun getComponents ()Ldev/kord/common/entity/optional/Optional; public final fun getContent ()Ldev/kord/common/entity/optional/Optional; public final fun getEmbeds ()Ldev/kord/common/entity/optional/Optional; public final fun getFlags ()Ldev/kord/common/entity/optional/Optional; public final fun getMessageReference ()Ldev/kord/common/entity/optional/Optional; public final fun getNonce ()Ldev/kord/common/entity/optional/Optional; + public final fun getStickerIds ()Ldev/kord/common/entity/optional/Optional; public final fun getTts ()Ldev/kord/common/entity/optional/OptionalBoolean; public fun hashCode ()I public fun toString ()Ljava/lang/String; @@ -4979,14 +4932,14 @@ public final class dev/kord/rest/json/request/MultipartFollowupMessageCreateRequ } public final class dev/kord/rest/json/request/MultipartFollowupMessageModifyRequest { - public fun (Ldev/kord/rest/json/request/FollowupMessageModifyRequest;Ldev/kord/common/entity/optional/Optional;)V - public synthetic fun (Ldev/kord/rest/json/request/FollowupMessageModifyRequest;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ldev/kord/rest/json/request/FollowupMessageModifyRequest;Ljava/util/List;)V + public synthetic fun (Ldev/kord/rest/json/request/FollowupMessageModifyRequest;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/rest/json/request/FollowupMessageModifyRequest; - public final fun component2 ()Ldev/kord/common/entity/optional/Optional; - public final fun copy (Ldev/kord/rest/json/request/FollowupMessageModifyRequest;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/MultipartFollowupMessageModifyRequest; - public static synthetic fun copy$default (Ldev/kord/rest/json/request/MultipartFollowupMessageModifyRequest;Ldev/kord/rest/json/request/FollowupMessageModifyRequest;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/MultipartFollowupMessageModifyRequest; + public final fun component2 ()Ljava/util/List; + public final fun copy (Ldev/kord/rest/json/request/FollowupMessageModifyRequest;Ljava/util/List;)Ldev/kord/rest/json/request/MultipartFollowupMessageModifyRequest; + public static synthetic fun copy$default (Ldev/kord/rest/json/request/MultipartFollowupMessageModifyRequest;Ldev/kord/rest/json/request/FollowupMessageModifyRequest;Ljava/util/List;ILjava/lang/Object;)Ldev/kord/rest/json/request/MultipartFollowupMessageModifyRequest; public fun equals (Ljava/lang/Object;)Z - public final fun getFiles ()Ldev/kord/common/entity/optional/Optional; + public final fun getFiles ()Ljava/util/List; public final fun getRequest ()Ldev/kord/rest/json/request/FollowupMessageModifyRequest; public fun hashCode ()I public fun toString ()Ljava/lang/String; @@ -5020,28 +4973,28 @@ public final class dev/kord/rest/json/request/MultipartGuildStickerCreateRequest } public final class dev/kord/rest/json/request/MultipartInteractionResponseCreateRequest { - public fun (Ldev/kord/rest/json/request/InteractionResponseCreateRequest;Ldev/kord/common/entity/optional/Optional;)V - public synthetic fun (Ldev/kord/rest/json/request/InteractionResponseCreateRequest;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ldev/kord/rest/json/request/InteractionResponseCreateRequest;Ljava/util/List;)V + public synthetic fun (Ldev/kord/rest/json/request/InteractionResponseCreateRequest;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/rest/json/request/InteractionResponseCreateRequest; - public final fun component2 ()Ldev/kord/common/entity/optional/Optional; - public final fun copy (Ldev/kord/rest/json/request/InteractionResponseCreateRequest;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/MultipartInteractionResponseCreateRequest; - public static synthetic fun copy$default (Ldev/kord/rest/json/request/MultipartInteractionResponseCreateRequest;Ldev/kord/rest/json/request/InteractionResponseCreateRequest;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/MultipartInteractionResponseCreateRequest; + public final fun component2 ()Ljava/util/List; + public final fun copy (Ldev/kord/rest/json/request/InteractionResponseCreateRequest;Ljava/util/List;)Ldev/kord/rest/json/request/MultipartInteractionResponseCreateRequest; + public static synthetic fun copy$default (Ldev/kord/rest/json/request/MultipartInteractionResponseCreateRequest;Ldev/kord/rest/json/request/InteractionResponseCreateRequest;Ljava/util/List;ILjava/lang/Object;)Ldev/kord/rest/json/request/MultipartInteractionResponseCreateRequest; public fun equals (Ljava/lang/Object;)Z - public final fun getFiles ()Ldev/kord/common/entity/optional/Optional; + public final fun getFiles ()Ljava/util/List; public final fun getRequest ()Ldev/kord/rest/json/request/InteractionResponseCreateRequest; public fun hashCode ()I public fun toString ()Ljava/lang/String; } public final class dev/kord/rest/json/request/MultipartInteractionResponseModifyRequest { - public fun (Ldev/kord/rest/json/request/InteractionResponseModifyRequest;Ldev/kord/common/entity/optional/Optional;)V - public synthetic fun (Ldev/kord/rest/json/request/InteractionResponseModifyRequest;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ldev/kord/rest/json/request/InteractionResponseModifyRequest;Ljava/util/List;)V + public synthetic fun (Ldev/kord/rest/json/request/InteractionResponseModifyRequest;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/rest/json/request/InteractionResponseModifyRequest; - public final fun component2 ()Ldev/kord/common/entity/optional/Optional; - public final fun copy (Ldev/kord/rest/json/request/InteractionResponseModifyRequest;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/MultipartInteractionResponseModifyRequest; - public static synthetic fun copy$default (Ldev/kord/rest/json/request/MultipartInteractionResponseModifyRequest;Ldev/kord/rest/json/request/InteractionResponseModifyRequest;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/MultipartInteractionResponseModifyRequest; + public final fun component2 ()Ljava/util/List; + public final fun copy (Ldev/kord/rest/json/request/InteractionResponseModifyRequest;Ljava/util/List;)Ldev/kord/rest/json/request/MultipartInteractionResponseModifyRequest; + public static synthetic fun copy$default (Ldev/kord/rest/json/request/MultipartInteractionResponseModifyRequest;Ldev/kord/rest/json/request/InteractionResponseModifyRequest;Ljava/util/List;ILjava/lang/Object;)Ldev/kord/rest/json/request/MultipartInteractionResponseModifyRequest; public fun equals (Ljava/lang/Object;)Z - public final fun getFiles ()Ldev/kord/common/entity/optional/Optional; + public final fun getFiles ()Ljava/util/List; public final fun getRequest ()Ldev/kord/rest/json/request/InteractionResponseModifyRequest; public fun hashCode ()I public fun toString ()Ljava/lang/String; @@ -5062,14 +5015,14 @@ public final class dev/kord/rest/json/request/MultipartMessageCreateRequest { } public final class dev/kord/rest/json/request/MultipartMessagePatchRequest { - public fun (Ldev/kord/rest/json/request/MessageEditPatchRequest;Ldev/kord/common/entity/optional/Optional;)V - public synthetic fun (Ldev/kord/rest/json/request/MessageEditPatchRequest;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ldev/kord/rest/json/request/MessageEditPatchRequest;Ljava/util/List;)V + public synthetic fun (Ldev/kord/rest/json/request/MessageEditPatchRequest;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/rest/json/request/MessageEditPatchRequest; - public final fun component2 ()Ldev/kord/common/entity/optional/Optional; - public final fun copy (Ldev/kord/rest/json/request/MessageEditPatchRequest;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/MultipartMessagePatchRequest; - public static synthetic fun copy$default (Ldev/kord/rest/json/request/MultipartMessagePatchRequest;Ldev/kord/rest/json/request/MessageEditPatchRequest;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/MultipartMessagePatchRequest; + public final fun component2 ()Ljava/util/List; + public final fun copy (Ldev/kord/rest/json/request/MessageEditPatchRequest;Ljava/util/List;)Ldev/kord/rest/json/request/MultipartMessagePatchRequest; + public static synthetic fun copy$default (Ldev/kord/rest/json/request/MultipartMessagePatchRequest;Ldev/kord/rest/json/request/MessageEditPatchRequest;Ljava/util/List;ILjava/lang/Object;)Ldev/kord/rest/json/request/MultipartMessagePatchRequest; public fun equals (Ljava/lang/Object;)Z - public final fun getFiles ()Ldev/kord/common/entity/optional/Optional; + public final fun getFiles ()Ljava/util/List; public final fun getRequests ()Ldev/kord/rest/json/request/MessageEditPatchRequest; public fun hashCode ()I public fun toString ()Ljava/lang/String; @@ -5090,14 +5043,14 @@ public final class dev/kord/rest/json/request/MultipartStartThreadRequest { } public final class dev/kord/rest/json/request/MultipartWebhookEditMessageRequest { - public fun (Ldev/kord/rest/json/request/WebhookEditMessageRequest;Ldev/kord/common/entity/optional/Optional;)V - public synthetic fun (Ldev/kord/rest/json/request/WebhookEditMessageRequest;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ldev/kord/rest/json/request/WebhookEditMessageRequest;Ljava/util/List;)V + public synthetic fun (Ldev/kord/rest/json/request/WebhookEditMessageRequest;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/rest/json/request/WebhookEditMessageRequest; - public final fun component2 ()Ldev/kord/common/entity/optional/Optional; - public final fun copy (Ldev/kord/rest/json/request/WebhookEditMessageRequest;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/MultipartWebhookEditMessageRequest; - public static synthetic fun copy$default (Ldev/kord/rest/json/request/MultipartWebhookEditMessageRequest;Ldev/kord/rest/json/request/WebhookEditMessageRequest;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/MultipartWebhookEditMessageRequest; + public final fun component2 ()Ljava/util/List; + public final fun copy (Ldev/kord/rest/json/request/WebhookEditMessageRequest;Ljava/util/List;)Ldev/kord/rest/json/request/MultipartWebhookEditMessageRequest; + public static synthetic fun copy$default (Ldev/kord/rest/json/request/MultipartWebhookEditMessageRequest;Ldev/kord/rest/json/request/WebhookEditMessageRequest;Ljava/util/List;ILjava/lang/Object;)Ldev/kord/rest/json/request/MultipartWebhookEditMessageRequest; public fun equals (Ljava/lang/Object;)Z - public final fun getFiles ()Ldev/kord/common/entity/optional/Optional; + public final fun getFiles ()Ljava/util/List; public final fun getRequest ()Ldev/kord/rest/json/request/WebhookEditMessageRequest; public fun hashCode ()I public fun toString ()Ljava/lang/String; @@ -5458,9 +5411,10 @@ public final class dev/kord/rest/json/request/WebhookEditMessageRequest$Companio public final class dev/kord/rest/json/request/WebhookExecuteRequest { public static final field Companion Ldev/kord/rest/json/request/WebhookExecuteRequest$Companion; public fun ()V - public fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V - public synthetic fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)V + public synthetic fun (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ldev/kord/common/entity/optional/Optional; + public final fun component10 ()Ldev/kord/common/entity/optional/Optional; public final fun component2 ()Ldev/kord/common/entity/optional/Optional; public final fun component3 ()Ldev/kord/common/entity/optional/Optional; public final fun component4 ()Ldev/kord/common/entity/optional/OptionalBoolean; @@ -5469,10 +5423,11 @@ public final class dev/kord/rest/json/request/WebhookExecuteRequest { public final fun component7 ()Ldev/kord/common/entity/optional/Optional; public final fun component8 ()Ldev/kord/common/entity/optional/Optional; public final fun component9 ()Ldev/kord/common/entity/optional/Optional; - public final fun copy (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/WebhookExecuteRequest; - public static synthetic fun copy$default (Ldev/kord/rest/json/request/WebhookExecuteRequest;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/WebhookExecuteRequest; + public final fun copy (Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;)Ldev/kord/rest/json/request/WebhookExecuteRequest; + public static synthetic fun copy$default (Ldev/kord/rest/json/request/WebhookExecuteRequest;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalBoolean;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/WebhookExecuteRequest; public fun equals (Ljava/lang/Object;)Z public final fun getAllowedMentions ()Ldev/kord/common/entity/optional/Optional; + public final fun getAttachments ()Ldev/kord/common/entity/optional/Optional; public final fun getAvatar ()Ldev/kord/common/entity/optional/Optional; public final fun getComponents ()Ldev/kord/common/entity/optional/Optional; public final fun getContent ()Ldev/kord/common/entity/optional/Optional; diff --git a/rest/src/commonMain/kotlin/builder/message/AttachmentBuilder.kt b/rest/src/commonMain/kotlin/builder/message/AttachmentBuilder.kt new file mode 100644 index 00000000000..2d06065ad4f --- /dev/null +++ b/rest/src/commonMain/kotlin/builder/message/AttachmentBuilder.kt @@ -0,0 +1,28 @@ +package dev.kord.rest.builder.message + +import dev.kord.common.annotation.KordDsl +import dev.kord.common.entity.Snowflake +import dev.kord.common.entity.optional.Optional +import dev.kord.common.entity.optional.delegate.delegate +import dev.kord.rest.builder.RequestBuilder +import dev.kord.rest.json.request.AttachmentRequest + +@KordDsl +public class AttachmentBuilder(private val id: Snowflake) : RequestBuilder { + + private var _filename: Optional = Optional.Missing() + + /** The name of the attached file. */ + public var filename: String? by ::_filename.delegate() + + private var _description: Optional = Optional.Missing() + + /** The description for the file (max 1024 characters). */ + public var description: String? by ::_description.delegate() + + override fun toRequest(): AttachmentRequest = AttachmentRequest( + id = id, + filename = _filename, + description = _description, + ) +} diff --git a/rest/src/commonMain/kotlin/builder/message/MessageBuilder.kt b/rest/src/commonMain/kotlin/builder/message/MessageBuilder.kt new file mode 100644 index 00000000000..b861fb4ec22 --- /dev/null +++ b/rest/src/commonMain/kotlin/builder/message/MessageBuilder.kt @@ -0,0 +1,147 @@ +package dev.kord.rest.builder.message + +import dev.kord.common.annotation.KordDsl +import dev.kord.common.entity.MessageFlag +import dev.kord.common.entity.MessageFlags +import dev.kord.common.entity.Snowflake +import dev.kord.common.entity.optional.Optional +import dev.kord.rest.NamedFile +import dev.kord.rest.builder.component.ActionRowBuilder +import dev.kord.rest.builder.component.MessageComponentBuilder +import dev.kord.rest.request.MultipartRequest +import io.ktor.client.request.forms.* +import kotlin.contracts.InvocationKind.EXACTLY_ONCE +import kotlin.contracts.contract + +@KordDsl +public interface MessageBuilder { + + /** The message contents (up to 2000 characters). */ + public var content: String? + + /** Up to 10 embeds (up to 6000 characters). */ + public var embeds: MutableList? + + /** + * The mentions in the message that are allowed to trigger a ping. + * + * Setting this to `null` will default to triggering pings for all mentions. + */ + public var allowedMentions: AllowedMentionsBuilder? + + /** The components to include with the message.*/ + public var components: MutableList? + + /** The files to include as attachments. */ + public val files: MutableList + + /** + * The attachment objects with [filename][AttachmentBuilder.filename] and + * [description][AttachmentBuilder.description]. + */ + public var attachments: MutableList? + + /** + * Optional custom [MessageFlags]. + * + * @see suppressEmbeds + */ + public var flags: MessageFlags? + + /** Do not include any embeds when serializing this message. */ + public var suppressEmbeds: Boolean? + + /** Adds a [file][NamedFile] with [name] and [contentProvider] to [files]. */ + public fun addFile(name: String, contentProvider: ChannelProvider): NamedFile { + val file = NamedFile(name, contentProvider) + files.add(file) + return file + } +} + +/** + * Adds an [embed][EmbedBuilder] configured by [builder] to the [embeds][MessageBuilder.embeds] of the message. + * + * A message can have up to 10 embeds. + */ +public inline fun MessageBuilder.embed(builder: EmbedBuilder.() -> Unit) { + contract { callsInPlace(builder, EXACTLY_ONCE) } + val embed = EmbedBuilder().apply(builder) + embeds?.add(embed) ?: run { embeds = mutableListOf(embed) } +} + +/** + * Configures the mentions in the message that are allowed to trigger a ping. + * + * Not calling this function will result in the default behavior (ping for all mentions), calling this function but not + * configuring it before the request is build will result in all mentions being ignored. + */ +public inline fun MessageBuilder.allowedMentions(builder: AllowedMentionsBuilder.() -> Unit = {}) { + contract { callsInPlace(builder, EXACTLY_ONCE) } + val mentions = allowedMentions ?: (AllowedMentionsBuilder().also { allowedMentions = it }) + mentions.builder() +} + +/** + * Adds an [action row][ActionRowBuilder] configured by the [builder] to the [components][MessageBuilder.components] of + * the message. + * + * A message can have up to five action rows. + */ +public inline fun MessageBuilder.actionRow(builder: ActionRowBuilder.() -> Unit) { + contract { callsInPlace(builder, EXACTLY_ONCE) } + val actionRow = ActionRowBuilder().apply(builder) + components?.add(actionRow) ?: run { components = mutableListOf(actionRow) } +} + +/** + * Adds a [file][NamedFile] with [name] and [contentProvider] to [files][MessageBuilder.files]. + * + * The corresponding attachment object can be configured with [builder]. + */ +public inline fun MessageBuilder.addFile( + name: String, + contentProvider: ChannelProvider, + builder: AttachmentBuilder.() -> Unit, +): NamedFile { + contract { callsInPlace(builder, EXACTLY_ONCE) } + // see https://discord.com/developers/docs/reference#uploading-files: + // we use the index of a file in the `files` list as `n` in `files[n]`, as implemented in `MultipartRequest.data` + /** (clickable link: [MultipartRequest.data]) */ + val file = NamedFile(name, contentProvider) + files.add(file) + val index = files.lastIndex + val attachment = AttachmentBuilder(id = Snowflake(index.toLong())).apply(builder) + attachments?.add(attachment) ?: run { attachments = mutableListOf(attachment) } + return file +} + +/** Sets the [flags][MessageBuilder.flags] for the message. */ +public inline fun MessageBuilder.messageFlags(builder: MessageFlags.Builder.() -> Unit) { + contract { callsInPlace(builder, EXACTLY_ONCE) } + flags = MessageFlags(builder) +} + + +internal fun buildMessageFlags( + base: MessageFlags?, + suppressEmbeds: Boolean?, + suppressNotifications: Boolean? = null, + ephemeral: Boolean? = null, +): Optional = + if (base == null && suppressEmbeds == null && suppressNotifications == null && ephemeral == null) { + Optional.Missing() + } else { + val flags = MessageFlags { + if (base != null) +base + fun apply(add: Boolean?, flag: MessageFlag) = when (add) { + true -> +flag + false -> -flag + null -> {} + } + apply(suppressEmbeds, MessageFlag.SuppressEmbeds) + apply(suppressNotifications, MessageFlag.SuppressNotifications) + apply(ephemeral, MessageFlag.Ephemeral) + } + Optional.Value(flags) + } diff --git a/rest/src/commonMain/kotlin/builder/message/create/FollowupMessageCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/FollowupMessageCreateBuilder.kt index 4fa1cb08436..a0e1e0df0bf 100644 --- a/rest/src/commonMain/kotlin/builder/message/create/FollowupMessageCreateBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/create/FollowupMessageCreateBuilder.kt @@ -1,13 +1,10 @@ package dev.kord.rest.builder.message.create import dev.kord.common.annotation.KordDsl -import dev.kord.common.entity.MessageFlags -import dev.kord.common.entity.optional.* -import dev.kord.rest.NamedFile +import dev.kord.common.entity.optional.map +import dev.kord.common.entity.optional.mapList import dev.kord.rest.builder.RequestBuilder -import dev.kord.rest.builder.component.MessageComponentBuilder -import dev.kord.rest.builder.message.AllowedMentionsBuilder -import dev.kord.rest.builder.message.EmbedBuilder +import dev.kord.rest.builder.message.buildMessageFlags import dev.kord.rest.json.request.FollowupMessageCreateRequest import dev.kord.rest.json.request.MultipartFollowupMessageCreateRequest @@ -16,38 +13,19 @@ import dev.kord.rest.json.request.MultipartFollowupMessageCreateRequest */ @KordDsl public class FollowupMessageCreateBuilder(public val ephemeral: Boolean) : - MessageCreateBuilder, + AbstractMessageCreateBuilder(), RequestBuilder { - - override var content: String? = null - - override var tts: Boolean? = null - - override val embeds: MutableList = mutableListOf() - - override var allowedMentions: AllowedMentionsBuilder? = null - - - override val components: MutableList = mutableListOf() - - override val files: MutableList = mutableListOf() - - override var flags: MessageFlags? = null - override var suppressEmbeds: Boolean? = null - override var suppressNotifications: Boolean? = null - - override fun toRequest(): MultipartFollowupMessageCreateRequest { - return MultipartFollowupMessageCreateRequest( - FollowupMessageCreateRequest( - content = Optional(content).coerceToMissing(), - tts = Optional(tts).coerceToMissing().toPrimitive(), - embeds = Optional(embeds).mapList { it.toRequest() }, - allowedMentions = Optional(allowedMentions).coerceToMissing().map { it.build() }, - components = Optional(components).coerceToMissing().mapList { it.build() }, - flags = buildMessageFlags(flags, suppressEmbeds, suppressNotifications, ephemeral) - ), - files - ) - } - + // see https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message + override fun toRequest(): MultipartFollowupMessageCreateRequest = MultipartFollowupMessageCreateRequest( + request = FollowupMessageCreateRequest( + content = _content, + tts = _tts, + embeds = _embeds.mapList { it.toRequest() }, + allowedMentions = _allowedMentions.map { it.build() }, + components = _components.mapList { it.build() }, + attachments = _attachments.mapList { it.toRequest() }, + flags = buildMessageFlags(flags, suppressEmbeds, suppressNotifications, ephemeral), + ), + files = files.toList(), + ) } diff --git a/rest/src/commonMain/kotlin/builder/message/create/ForumMessageCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/ForumMessageCreateBuilder.kt index e7950745659..fc2ac568bb9 100644 --- a/rest/src/commonMain/kotlin/builder/message/create/ForumMessageCreateBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/create/ForumMessageCreateBuilder.kt @@ -1,55 +1,44 @@ package dev.kord.rest.builder.message.create import dev.kord.common.annotation.KordDsl -import dev.kord.common.entity.MessageFlags import dev.kord.common.entity.Snowflake import dev.kord.common.entity.optional.Optional -import dev.kord.common.entity.optional.coerceToMissing import dev.kord.common.entity.optional.delegate.delegate import dev.kord.common.entity.optional.map +import dev.kord.common.entity.optional.mapCopy import dev.kord.common.entity.optional.mapList -import dev.kord.rest.NamedFile import dev.kord.rest.builder.RequestBuilder -import dev.kord.rest.builder.component.MessageComponentBuilder -import dev.kord.rest.builder.message.AllowedMentionsBuilder -import dev.kord.rest.builder.message.EmbedBuilder +import dev.kord.rest.builder.message.buildMessageFlags import dev.kord.rest.json.request.ForumThreadMessageRequest import dev.kord.rest.json.request.MultipartForumThreadMessageCreateRequest @KordDsl -public class ForumMessageCreateBuilder : MessageCreateBuilder, +public class ForumMessageCreateBuilder : + AbstractMessageCreateBuilder(), RequestBuilder { - - override var content: String? = null - - override var tts: Boolean? = null - - override val embeds: MutableList = mutableListOf() - - override var allowedMentions: AllowedMentionsBuilder? = null - - override val components: MutableList = mutableListOf() - - override val files: MutableList = mutableListOf() + // see https://discord.com/developers/docs/resources/channel#start-thread-in-forum-or-media-channel private var _stickerIds: Optional> = Optional.Missing() - public val stickerIds: MutableList? by ::_stickerIds.delegate() - override var flags: MessageFlags? = null - override var suppressEmbeds: Boolean? = null - override var suppressNotifications: Boolean? = null + /** The IDs of up to three stickers to send in the message. */ + public var stickerIds: MutableList? by ::_stickerIds.delegate() + + override fun toRequest(): MultipartForumThreadMessageCreateRequest = MultipartForumThreadMessageCreateRequest( + request = ForumThreadMessageRequest( + content = _content, + tts = _tts, + embeds = _embeds.mapList { it.toRequest() }, + allowedMentions = _allowedMentions.map { it.build() }, + components = _components.mapList { it.build() }, + stickerIds = _stickerIds.mapCopy(), + attachments = _attachments.mapList { it.toRequest() }, + flags = buildMessageFlags(flags, suppressEmbeds, suppressNotifications), + ), + files = files.toList(), + ) +} - override fun toRequest(): MultipartForumThreadMessageCreateRequest { - return MultipartForumThreadMessageCreateRequest( - ForumThreadMessageRequest( - content = Optional(content).coerceToMissing(), - embeds = Optional(embeds).mapList { it.toRequest() }, - allowedMentions = Optional(allowedMentions).coerceToMissing().map { it.build() }, - components = Optional(components).coerceToMissing().mapList { it.build() }, - stickerIds = _stickerIds, - flags = buildMessageFlags(flags, suppressEmbeds, suppressNotifications), - ), - files - ) - } +/** Add a [stickerId] to [stickerIds][ForumMessageCreateBuilder.stickerIds]. */ +public fun ForumMessageCreateBuilder.stickerId(stickerId: Snowflake) { + stickerIds?.add(stickerId) ?: run { stickerIds = mutableListOf(stickerId) } } diff --git a/rest/src/commonMain/kotlin/builder/message/create/InteractionResponseCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/InteractionResponseCreateBuilder.kt index 1633f4197da..73894826536 100644 --- a/rest/src/commonMain/kotlin/builder/message/create/InteractionResponseCreateBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/create/InteractionResponseCreateBuilder.kt @@ -2,13 +2,11 @@ package dev.kord.rest.builder.message.create import dev.kord.common.annotation.KordDsl import dev.kord.common.entity.InteractionResponseType -import dev.kord.common.entity.MessageFlags -import dev.kord.common.entity.optional.* -import dev.kord.rest.NamedFile +import dev.kord.common.entity.optional.map +import dev.kord.common.entity.optional.mapList +import dev.kord.common.entity.optional.optional import dev.kord.rest.builder.RequestBuilder -import dev.kord.rest.builder.component.MessageComponentBuilder -import dev.kord.rest.builder.message.AllowedMentionsBuilder -import dev.kord.rest.builder.message.EmbedBuilder +import dev.kord.rest.builder.message.buildMessageFlags import dev.kord.rest.json.request.InteractionApplicationCommandCallbackData import dev.kord.rest.json.request.InteractionResponseCreateRequest import dev.kord.rest.json.request.MultipartInteractionResponseCreateRequest @@ -18,42 +16,22 @@ import dev.kord.rest.json.request.MultipartInteractionResponseCreateRequest */ @KordDsl public class InteractionResponseCreateBuilder(public val ephemeral: Boolean = false) : - MessageCreateBuilder, + AbstractMessageCreateBuilder(), RequestBuilder { - - override var content: String? = null - - override var tts: Boolean? = null - - override val embeds: MutableList = mutableListOf() - - override var allowedMentions: AllowedMentionsBuilder? = null - - override val components: MutableList = mutableListOf() - - override val files: MutableList = mutableListOf() - - override var flags: MessageFlags? = null - override var suppressEmbeds: Boolean? = null - override var suppressNotifications: Boolean? = null - - override fun toRequest(): MultipartInteractionResponseCreateRequest { - return MultipartInteractionResponseCreateRequest( - InteractionResponseCreateRequest( - type = InteractionResponseType.ChannelMessageWithSource, - data = Optional( - InteractionApplicationCommandCallbackData( - content = Optional(content).coerceToMissing(), - tts = Optional(tts).coerceToMissing().toPrimitive(), - embeds = Optional(embeds).mapList { it.toRequest() }, - allowedMentions = Optional(allowedMentions).coerceToMissing().map { it.build() }, - components = Optional(components).coerceToMissing().mapList { it.build() }, - flags = buildMessageFlags(flags, suppressEmbeds, suppressNotifications, ephemeral) - ) - ) - ), - Optional(files) - ) - } - + // see https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response + override fun toRequest(): MultipartInteractionResponseCreateRequest = MultipartInteractionResponseCreateRequest( + request = InteractionResponseCreateRequest( + type = InteractionResponseType.ChannelMessageWithSource, + data = InteractionApplicationCommandCallbackData( + tts = _tts, + content = _content, + embeds = _embeds.mapList { it.toRequest() }, + allowedMentions = _allowedMentions.map { it.build() }, + flags = buildMessageFlags(flags, suppressEmbeds, suppressNotifications, ephemeral), + components = _components.mapList { it.build() }, + attachments = _attachments.mapList { it.toRequest() }, + ).optional(), + ), + files = files.toList(), + ) } diff --git a/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt index d7b28c95dab..dbb0cb0110a 100644 --- a/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt @@ -4,115 +4,89 @@ import dev.kord.common.annotation.KordDsl import dev.kord.common.entity.MessageFlag import dev.kord.common.entity.MessageFlags import dev.kord.common.entity.optional.Optional +import dev.kord.common.entity.optional.OptionalBoolean +import dev.kord.common.entity.optional.delegate.delegate import dev.kord.rest.NamedFile import dev.kord.rest.builder.component.ActionRowBuilder import dev.kord.rest.builder.component.MessageComponentBuilder import dev.kord.rest.builder.message.AllowedMentionsBuilder +import dev.kord.rest.builder.message.AttachmentBuilder import dev.kord.rest.builder.message.EmbedBuilder -import io.ktor.client.request.forms.* +import dev.kord.rest.builder.message.MessageBuilder import kotlin.contracts.InvocationKind import kotlin.contracts.contract +import dev.kord.rest.builder.message.actionRow as actionRowExtensionOnNewSupertype +import dev.kord.rest.builder.message.allowedMentions as allowedMentionsExtensionOnNewSupertype +import dev.kord.rest.builder.message.embed as embedExtensionOnNewSupertype +import dev.kord.rest.builder.message.messageFlags as messageFlagsExtensionOnNewSupertype /** * The base builder for creating a new message. */ @KordDsl -public sealed interface MessageCreateBuilder { +public sealed interface MessageCreateBuilder : MessageBuilder { - /** - * The text content of the message. - */ - public var content: String? - - /** - * Whether this message should be played as a text-to-speech message. - */ + /** Whether this message should be played as a text-to-speech message. */ public var tts: Boolean? - /** - * The embedded content of the message. - */ - public val embeds: MutableList - - /** - * The mentions in this message that are allowed to raise a notification. - * Setting this to null will default to creating notifications for all mentions. - */ - public var allowedMentions: AllowedMentionsBuilder? - - /** - * The message components to include in this message. - */ - - public val components: MutableList - - /** - * The files to include as attachments. - */ - public val files: MutableList - /** * Optional custom [MessageFlags] to add to the message created. * * @see suppressEmbeds * @see suppressNotifications */ - public var flags: MessageFlags? + override var flags: MessageFlags? - /** - * Do not include any embeds when serializing this message. - */ - public var suppressEmbeds: Boolean? - - /** - * This message will not trigger push and desktop notifications. - */ + /** This message will not trigger push and desktop notifications. */ public var suppressNotifications: Boolean? - - /** - * Adds a file with the [name] and [contentProvider] to the attachments. - */ - public fun addFile(name: String, contentProvider: ChannelProvider): NamedFile { - val namedFile = NamedFile(name, contentProvider) - files += namedFile - return namedFile - } } -internal fun buildMessageFlags( - base: MessageFlags?, - suppressEmbeds: Boolean?, - suppressNotifications: Boolean? = null, - ephemeral: Boolean? = null -): Optional { - fun MessageFlags.Builder.add(add: Boolean?, flag: MessageFlag) { - when (add) { - true -> +flag - false -> -flag - null -> {} - } - } - if (base == null && suppressEmbeds == null && suppressNotifications == null && ephemeral == null) { - return Optional.Missing() - } +// this could have been combined with MessageCreateBuilder into a single sealed class, but it would have broken binary +// compatibility, because MessageCreateBuilder would have changed from interface to class +@Suppress("PropertyName") +@KordDsl +public sealed class AbstractMessageCreateBuilder : MessageCreateBuilder { - val flags = MessageFlags { - if (base != null) +base - add(suppressEmbeds, MessageFlag.SuppressEmbeds) - add(suppressNotifications, MessageFlag.SuppressNotifications) - add(ephemeral, MessageFlag.Ephemeral) - } + internal var _content: Optional = Optional.Missing() + final override var content: String? by ::_content.delegate() + + internal var _tts: OptionalBoolean = OptionalBoolean.Missing + final override var tts: Boolean? by ::_tts.delegate() + + internal var _embeds: Optional> = Optional.Missing() + final override var embeds: MutableList? by ::_embeds.delegate() + + internal var _allowedMentions: Optional = Optional.Missing() + final override var allowedMentions: AllowedMentionsBuilder? by ::_allowedMentions.delegate() + + internal var _components: Optional> = Optional.Missing() + final override var components: MutableList? by ::_components.delegate() - return Optional.Value(flags) + override val files: MutableList = mutableListOf() + + internal var _attachments: Optional> = Optional.Missing() + final override var attachments: MutableList? by ::_attachments.delegate() + + final override var flags: MessageFlags? = null + final override var suppressEmbeds: Boolean? = null + final override var suppressNotifications: Boolean? = null } + /** * Adds an embed to the message, configured by the [block]. A message can have up to 10 embeds. */ +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@kotlin.internal.LowPriorityInOverloadResolution +@Deprecated( + "Replaced by extension on 'MessageBuilder'. Change import to 'dev.kord.rest.builder.message.embed'.", + ReplaceWith("this.embed(block)", imports = ["dev.kord.rest.builder.message.embed"]), + DeprecationLevel.WARNING, +) public inline fun MessageCreateBuilder.embed(block: EmbedBuilder.() -> Unit) { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } - embeds.add(EmbedBuilder().apply(block)) + embedExtensionOnNewSupertype(block) } /** @@ -120,20 +94,33 @@ public inline fun MessageCreateBuilder.embed(block: EmbedBuilder.() -> Unit) { * (ping everything), calling this function but not configuring it before the request is build will result in all * pings being ignored. */ +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@kotlin.internal.LowPriorityInOverloadResolution +@Deprecated( + "Replaced by extension on 'MessageBuilder'. Change import to 'dev.kord.rest.builder.message.allowedMentions'.", + ReplaceWith("this.allowedMentions(block)", imports = ["dev.kord.rest.builder.message.allowedMentions"]), + DeprecationLevel.WARNING, +) public inline fun MessageCreateBuilder.allowedMentions(block: AllowedMentionsBuilder.() -> Unit = {}) { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } - allowedMentions = (allowedMentions ?: AllowedMentionsBuilder()).apply(block) + allowedMentionsExtensionOnNewSupertype(block) } /** * Adds an Action Row to the message, configured by the [builder]. A message can have up to 5 action rows. */ +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@kotlin.internal.LowPriorityInOverloadResolution +@Deprecated( + "Replaced by extension on 'MessageBuilder'. Change import to 'dev.kord.rest.builder.message.actionRow'.", + ReplaceWith("this.actionRow(builder)", imports = ["dev.kord.rest.builder.message.actionRow"]), + DeprecationLevel.WARNING, +) public inline fun MessageCreateBuilder.actionRow(builder: ActionRowBuilder.() -> Unit) { contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) } - - components.add(ActionRowBuilder().apply(builder)) + actionRowExtensionOnNewSupertype(builder) } /** @@ -141,9 +128,16 @@ public inline fun MessageCreateBuilder.actionRow(builder: ActionRowBuilder.() -> * * **Only supports [MessageFlag.SuppressEmbeds] and [MessageFlag.SuppressNotifications]** */ +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@kotlin.internal.LowPriorityInOverloadResolution +@Deprecated( + "Replaced by extension on 'MessageBuilder'. Change import to 'dev.kord.rest.builder.message.messageFlags'.", + ReplaceWith("this.messageFlags(builder)", imports = ["dev.kord.rest.builder.message.messageFlags"]), + DeprecationLevel.WARNING, +) public inline fun MessageCreateBuilder.messageFlags(builder: MessageFlags.Builder.() -> Unit) { contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) } - flags = MessageFlags(builder) + messageFlagsExtensionOnNewSupertype(builder) } diff --git a/rest/src/commonMain/kotlin/builder/message/create/UpdateMessageInteractionResponseCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/UpdateMessageInteractionResponseCreateBuilder.kt index 9cec48258cd..acd243389c4 100644 --- a/rest/src/commonMain/kotlin/builder/message/create/UpdateMessageInteractionResponseCreateBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/create/UpdateMessageInteractionResponseCreateBuilder.kt @@ -2,54 +2,43 @@ package dev.kord.rest.builder.message.create import dev.kord.common.annotation.KordDsl import dev.kord.common.entity.InteractionResponseType -import dev.kord.common.entity.MessageFlags -import dev.kord.common.entity.optional.* +import dev.kord.common.entity.optional.map +import dev.kord.common.entity.optional.mapList +import dev.kord.common.entity.optional.optional import dev.kord.rest.NamedFile import dev.kord.rest.builder.RequestBuilder -import dev.kord.rest.builder.component.MessageComponentBuilder -import dev.kord.rest.builder.message.AllowedMentionsBuilder -import dev.kord.rest.builder.message.EmbedBuilder +import dev.kord.rest.builder.message.buildMessageFlags import dev.kord.rest.json.request.InteractionApplicationCommandCallbackData import dev.kord.rest.json.request.InteractionResponseCreateRequest import dev.kord.rest.json.request.MultipartInteractionResponseCreateRequest @KordDsl public class UpdateMessageInteractionResponseCreateBuilder : - MessageCreateBuilder, + AbstractMessageCreateBuilder(), RequestBuilder { - - + // see https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response + + // TODO make override final in AbstractMessageCreateBuilder when this is removed + @set:Deprecated( + "This setter will be removed in the future, replace with files.clear() followed by files.addAll(...).", + ReplaceWith("this.files.clear()\nthis.files.addAll(value)"), + DeprecationLevel.WARNING, + ) override var files: MutableList = mutableListOf() - override var content: String? = null - - override var tts: Boolean? = null - - override var embeds: MutableList = mutableListOf() - - override var allowedMentions: AllowedMentionsBuilder? = null - - override var components: MutableList = mutableListOf() - - override var flags: MessageFlags? = null - override var suppressEmbeds: Boolean? = null - override var suppressNotifications: Boolean? = null - - override fun toRequest(): MultipartInteractionResponseCreateRequest { - return MultipartInteractionResponseCreateRequest( - InteractionResponseCreateRequest( - InteractionResponseType.UpdateMessage, - InteractionApplicationCommandCallbackData( - content = Optional(content).coerceToMissing(), - embeds = Optional(embeds).mapList { it.toRequest() }, - allowedMentions = Optional(allowedMentions).map { it.build() }, - components = Optional(components).mapList { it.build() }, - tts = Optional(tts).coerceToMissing().toPrimitive(), - flags = buildMessageFlags(flags, suppressEmbeds, suppressNotifications) - ).optional() - ), - Optional(files) - ) - - } + override fun toRequest(): MultipartInteractionResponseCreateRequest = MultipartInteractionResponseCreateRequest( + request = InteractionResponseCreateRequest( + type = InteractionResponseType.UpdateMessage, + data = InteractionApplicationCommandCallbackData( + tts = _tts, + content = _content, + embeds = _embeds.mapList { it.toRequest() }, + allowedMentions = _allowedMentions.map { it.build() }, + flags = buildMessageFlags(flags, suppressEmbeds, suppressNotifications), + components = _components.mapList { it.build() }, + attachments = _attachments.mapList { it.toRequest() }, + ).optional(), + ), + files = files.toList(), + ) } diff --git a/rest/src/commonMain/kotlin/builder/message/create/UserMessageCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/UserMessageCreateBuilder.kt index a53d01f2477..bd13c9ebf97 100644 --- a/rest/src/commonMain/kotlin/builder/message/create/UserMessageCreateBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/create/UserMessageCreateBuilder.kt @@ -2,14 +2,14 @@ package dev.kord.rest.builder.message.create import dev.kord.common.annotation.KordDsl import dev.kord.common.entity.DiscordMessageReference -import dev.kord.common.entity.MessageFlags +import dev.kord.common.entity.Permission.ReadMessageHistory import dev.kord.common.entity.Snowflake import dev.kord.common.entity.optional.* -import dev.kord.rest.NamedFile +import dev.kord.common.entity.optional.delegate.delegate import dev.kord.rest.builder.RequestBuilder -import dev.kord.rest.builder.component.MessageComponentBuilder import dev.kord.rest.builder.message.AllowedMentionsBuilder -import dev.kord.rest.builder.message.EmbedBuilder +import dev.kord.rest.builder.message.allowedMentions +import dev.kord.rest.builder.message.buildMessageFlags import dev.kord.rest.json.request.MessageCreateRequest import dev.kord.rest.json.request.MultipartMessageCreateRequest @@ -17,68 +17,63 @@ import dev.kord.rest.json.request.MultipartMessageCreateRequest * Message builder for creating messages as a bot user. */ @KordDsl -public class UserMessageCreateBuilder - : MessageCreateBuilder, - RequestBuilder { +public class UserMessageCreateBuilder : AbstractMessageCreateBuilder(), RequestBuilder { + // see https://discord.com/developers/docs/resources/channel#create-message - override var content: String? = null + private var _nonce: Optional = Optional.Missing() - /** - * An identifier that can be used to validate the message was sent. - */ - public var nonce: String? = null - - override var tts: Boolean? = null - - override val embeds: MutableList = mutableListOf() - - override var allowedMentions: AllowedMentionsBuilder? = null + /** A value that can be used to verify a message was sent (up to 25 characters). */ + public var nonce: String? by ::_nonce.delegate() - - override val components: MutableList = mutableListOf() + private var _messageReference: OptionalSnowflake = OptionalSnowflake.Missing /** * The id of the message being replied to. - * Requires the [ReadMessageHistory][dev.kord.common.entity.Permission.ReadMessageHistory] permission. * - * Replying will not mention the author by default, - * set [AllowedMentionsBuilder.repliedUser] to `true` via [allowedMentions] to mention the author. + * Requires the [ReadMessageHistory] permission. + * + * Replying will not mention the author by default, set [AllowedMentionsBuilder.repliedUser] to `true` via + * [allowedMentions] to mention the author. */ - public var messageReference: Snowflake? = null + public var messageReference: Snowflake? by ::_messageReference.delegate() + + private var _failIfNotExists: OptionalBoolean = OptionalBoolean.Missing /** - * whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message, - * defaults to true. + * Whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message, + * defaults to `true`. + * + * This is only useful if combined with [messageReference]. */ - public var failIfNotExists: Boolean? = null + public var failIfNotExists: Boolean? by ::_failIfNotExists.delegate() - override val files: MutableList = mutableListOf() + private var _stickerIds: Optional> = Optional.Missing() - override var flags: MessageFlags? = null - override var suppressEmbeds: Boolean? = null - override var suppressNotifications: Boolean? = null + /** The IDs of up to three stickers to send in the message. */ + public var stickerIds: MutableList? by ::_stickerIds.delegate() - override fun toRequest(): MultipartMessageCreateRequest { - return MultipartMessageCreateRequest( - MessageCreateRequest( - content = Optional(content).coerceToMissing(), - nonce = Optional(nonce).coerceToMissing(), - tts = Optional(tts).coerceToMissing().toPrimitive(), - embeds = Optional(embeds).mapList { it.toRequest() }, - allowedMentions = Optional(allowedMentions).coerceToMissing().map { it.build() }, - messageReference = messageReference?.let { - Optional( - DiscordMessageReference( - OptionalSnowflake.Value(it), - failIfNotExists = Optional(failIfNotExists).coerceToMissing().toPrimitive() - ) - ) - } ?: Optional.Missing(), - components = Optional(components).coerceToMissing().mapList { it.build() }, - flags = buildMessageFlags(flags, suppressEmbeds, suppressNotifications) - ), - files - ) - } + override fun toRequest(): MultipartMessageCreateRequest = MultipartMessageCreateRequest( + request = MessageCreateRequest( + content = _content, + nonce = _nonce, + tts = _tts, + embeds = _embeds.mapList { it.toRequest() }, + allowedMentions = _allowedMentions.map { it.build() }, + messageReference = when (val id = _messageReference) { + is OptionalSnowflake.Value -> + Optional.Value(DiscordMessageReference(id = id, failIfNotExists = _failIfNotExists)) + is OptionalSnowflake.Missing -> Optional.Missing() + }, + components = _components.mapList { it.build() }, + stickerIds = _stickerIds.mapCopy(), + attachments = _attachments.mapList { it.toRequest() }, + flags = buildMessageFlags(flags, suppressEmbeds, suppressNotifications), + ), + files = files.toList(), + ) +} +/** Add a [stickerId] to [stickerIds][UserMessageCreateBuilder.stickerIds]. */ +public fun UserMessageCreateBuilder.stickerId(stickerId: Snowflake) { + stickerIds?.add(stickerId) ?: run { stickerIds = mutableListOf(stickerId) } } diff --git a/rest/src/commonMain/kotlin/builder/message/create/WebhookMessageCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/WebhookMessageCreateBuilder.kt index 9cce3823106..881178553f0 100644 --- a/rest/src/commonMain/kotlin/builder/message/create/WebhookMessageCreateBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/create/WebhookMessageCreateBuilder.kt @@ -3,14 +3,12 @@ package dev.kord.rest.builder.message.create import dev.kord.common.annotation.KordDsl import dev.kord.common.entity.ChannelType.GuildForum import dev.kord.common.entity.ChannelType.GuildMedia -import dev.kord.common.entity.MessageFlags -import dev.kord.common.entity.optional.* +import dev.kord.common.entity.optional.Optional import dev.kord.common.entity.optional.delegate.delegate -import dev.kord.rest.NamedFile +import dev.kord.common.entity.optional.map +import dev.kord.common.entity.optional.mapList import dev.kord.rest.builder.RequestBuilder -import dev.kord.rest.builder.component.MessageComponentBuilder -import dev.kord.rest.builder.message.AllowedMentionsBuilder -import dev.kord.rest.builder.message.EmbedBuilder +import dev.kord.rest.builder.message.buildMessageFlags import dev.kord.rest.json.request.MultiPartWebhookExecuteRequest import dev.kord.rest.json.request.WebhookExecuteRequest @@ -19,49 +17,38 @@ import dev.kord.rest.json.request.WebhookExecuteRequest */ @KordDsl public class WebhookMessageCreateBuilder : - MessageCreateBuilder, + AbstractMessageCreateBuilder(), RequestBuilder { + // see https://discord.com/developers/docs/resources/webhook#execute-webhook - override var content: String? = null + private var _username: Optional = Optional.Missing() - public var username: String? = null + /** Overrides the default username of the webhook. */ + public var username: String? by ::_username.delegate() - public var avatarUrl: String? = null + private var _avatarUrl: Optional = Optional.Missing() - override var tts: Boolean? = null - - override val embeds: MutableList = mutableListOf() - - override var allowedMentions: AllowedMentionsBuilder? = null - - - override val components: MutableList = mutableListOf() - - override val files: MutableList = mutableListOf() - - override var flags: MessageFlags? = null - override var suppressEmbeds: Boolean? = null - override var suppressNotifications: Boolean? = null + /** Overrides the default avatar of the webhook. */ + public var avatarUrl: String? by ::_avatarUrl.delegate() private var _threadName: Optional = Optional.Missing() /** Name of the thread to create (requires the webhook channel to be a [GuildForum] or [GuildMedia] channel). */ public var threadName: String? by ::_threadName.delegate() - override fun toRequest(): MultiPartWebhookExecuteRequest { - return MultiPartWebhookExecuteRequest( - WebhookExecuteRequest( - content = Optional(content).coerceToMissing(), - username = Optional(username).coerceToMissing(), - avatar = Optional(avatarUrl).coerceToMissing(), - tts = Optional(tts).coerceToMissing().toPrimitive(), - embeds = Optional(embeds).mapList { it.toRequest() }, - allowedMentions = Optional(allowedMentions).coerceToMissing().map { it.build() }, - components = Optional(components).coerceToMissing().mapList { it.build() }, - flags = buildMessageFlags(flags, suppressEmbeds, suppressNotifications), - threadName = _threadName, - ), - files - ) - } + override fun toRequest(): MultiPartWebhookExecuteRequest = MultiPartWebhookExecuteRequest( + request = WebhookExecuteRequest( + content = _content, + username = _username, + avatar = _avatarUrl, + tts = _tts, + embeds = _embeds.mapList { it.toRequest() }, + allowedMentions = _allowedMentions.map { it.build() }, + components = _components.mapList { it.build() }, + attachments = _attachments.mapList { it.toRequest() }, + flags = buildMessageFlags(flags, suppressEmbeds, suppressNotifications), + threadName = _threadName, + ), + files = files.toList(), + ) } diff --git a/rest/src/commonMain/kotlin/builder/message/modify/FollowupMessageModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/message/modify/FollowupMessageModifyBuilder.kt index ccf8240f49e..9aa8d39dae2 100644 --- a/rest/src/commonMain/kotlin/builder/message/modify/FollowupMessageModifyBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/modify/FollowupMessageModifyBuilder.kt @@ -1,53 +1,26 @@ package dev.kord.rest.builder.message.modify import dev.kord.common.annotation.KordDsl -import dev.kord.common.entity.DiscordAttachment -import dev.kord.common.entity.MessageFlags -import dev.kord.common.entity.optional.delegate.delegate import dev.kord.common.entity.optional.map import dev.kord.common.entity.optional.mapList -import dev.kord.rest.NamedFile import dev.kord.rest.builder.RequestBuilder -import dev.kord.rest.builder.component.MessageComponentBuilder -import dev.kord.rest.builder.message.AllowedMentionsBuilder -import dev.kord.rest.builder.message.EmbedBuilder -import dev.kord.rest.builder.message.create.buildMessageFlags import dev.kord.rest.json.request.FollowupMessageModifyRequest import dev.kord.rest.json.request.MultipartFollowupMessageModifyRequest @KordDsl public class FollowupMessageModifyBuilder : - MessageModifyBuilder, + AbstractMessageModifyBuilder(), RequestBuilder { - - private var state = MessageModifyStateHolder() - - override var files: MutableList? by state::files.delegate() - - override var attachments: MutableList? by state::attachments.delegate() - - override var content: String? by state::content.delegate() - - override var embeds: MutableList? by state::embeds.delegate() - - override var allowedMentions: AllowedMentionsBuilder? by state::allowedMentions.delegate() - - override var flags: MessageFlags? = null - override var suppressEmbeds: Boolean? = null - - override var components: MutableList? by state::components.delegate() - - override fun toRequest(): MultipartFollowupMessageModifyRequest { - return MultipartFollowupMessageModifyRequest( - FollowupMessageModifyRequest( - content = state.content, - embeds = state.embeds.mapList { it.toRequest() }, - allowedMentions = state.allowedMentions.map { it.build() }, - components = state.components.mapList { it.build() }, - attachments = state.attachments, - flags = buildMessageFlags(flags, suppressEmbeds) - ), - state.files - ) - } + // see https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message + override fun toRequest(): MultipartFollowupMessageModifyRequest = MultipartFollowupMessageModifyRequest( + request = FollowupMessageModifyRequest( + content = _content, + embeds = _embeds.mapList { it.toRequest() }, + flags = buildFlags(), + allowedMentions = _allowedMentions.map { it.build() }, + components = _components.mapList { it.build() }, + attachments = _attachments.mapList { it.toRequest() }, + ), + files = files.toList(), + ) } diff --git a/rest/src/commonMain/kotlin/builder/message/modify/InteractionResponseModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/message/modify/InteractionResponseModifyBuilder.kt index 36f2b9ed00b..3b24359ed66 100644 --- a/rest/src/commonMain/kotlin/builder/message/modify/InteractionResponseModifyBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/modify/InteractionResponseModifyBuilder.kt @@ -1,52 +1,26 @@ package dev.kord.rest.builder.message.modify import dev.kord.common.annotation.KordDsl -import dev.kord.common.entity.DiscordAttachment -import dev.kord.common.entity.MessageFlags -import dev.kord.common.entity.optional.delegate.delegate import dev.kord.common.entity.optional.map import dev.kord.common.entity.optional.mapList -import dev.kord.rest.NamedFile import dev.kord.rest.builder.RequestBuilder -import dev.kord.rest.builder.component.MessageComponentBuilder -import dev.kord.rest.builder.message.AllowedMentionsBuilder -import dev.kord.rest.builder.message.EmbedBuilder -import dev.kord.rest.builder.message.create.buildMessageFlags import dev.kord.rest.json.request.InteractionResponseModifyRequest import dev.kord.rest.json.request.MultipartInteractionResponseModifyRequest @KordDsl -public class InteractionResponseModifyBuilder : MessageModifyBuilder, +public class InteractionResponseModifyBuilder : + AbstractMessageModifyBuilder(), RequestBuilder { - - private var state = MessageModifyStateHolder() - - override var files: MutableList? by state::files.delegate() - - override var attachments: MutableList? by state::attachments.delegate() - - override var content: String? by state::content.delegate() - - override var embeds: MutableList? by state::embeds.delegate() - - override var allowedMentions: AllowedMentionsBuilder? by state::allowedMentions.delegate() - - override var flags: MessageFlags? = null - override var suppressEmbeds: Boolean? = null - - override var components: MutableList? by state::components.delegate() - - override fun toRequest(): MultipartInteractionResponseModifyRequest { - return MultipartInteractionResponseModifyRequest( - InteractionResponseModifyRequest( - content = state.content, - embeds = state.embeds.mapList { it.toRequest() }, - allowedMentions = state.allowedMentions.map { it.build() }, - components = state.components.mapList { it.build() }, - attachments = state.attachments, - flags = buildMessageFlags(flags, suppressEmbeds) - ), state.files - ) - } - + // see https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response + override fun toRequest(): MultipartInteractionResponseModifyRequest = MultipartInteractionResponseModifyRequest( + request = InteractionResponseModifyRequest( + content = _content, + embeds = _embeds.mapList { it.toRequest() }, + flags = buildFlags(), + allowedMentions = _allowedMentions.map { it.build() }, + components = _components.mapList { it.build() }, + attachments = _attachments.mapList { it.toRequest() }, + ), + files = files.toList(), + ) } diff --git a/rest/src/commonMain/kotlin/builder/message/modify/MessageModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/message/modify/MessageModifyBuilder.kt index 1fa4ce0b615..e64022f7a38 100644 --- a/rest/src/commonMain/kotlin/builder/message/modify/MessageModifyBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/modify/MessageModifyBuilder.kt @@ -1,67 +1,94 @@ package dev.kord.rest.builder.message.modify import dev.kord.common.annotation.KordDsl -import dev.kord.common.entity.DiscordAttachment import dev.kord.common.entity.MessageFlag import dev.kord.common.entity.MessageFlags +import dev.kord.common.entity.Snowflake +import dev.kord.common.entity.optional.Optional +import dev.kord.common.entity.optional.delegate.delegate import dev.kord.rest.NamedFile import dev.kord.rest.builder.component.ActionRowBuilder import dev.kord.rest.builder.component.MessageComponentBuilder -import dev.kord.rest.builder.message.AllowedMentionsBuilder -import dev.kord.rest.builder.message.EmbedBuilder -import io.ktor.client.request.forms.* +import dev.kord.rest.builder.message.* import kotlin.contracts.InvocationKind +import kotlin.contracts.InvocationKind.EXACTLY_ONCE import kotlin.contracts.contract +import dev.kord.rest.builder.message.actionRow as actionRowExtensionOnNewSupertype +import dev.kord.rest.builder.message.allowedMentions as allowedMentionsExtensionOnNewSupertype +import dev.kord.rest.builder.message.embed as embedExtensionOnNewSupertype +import dev.kord.rest.builder.message.messageFlags as messageFlagsExtensionOnNewSupertype @KordDsl -public sealed interface MessageModifyBuilder { +public sealed interface MessageModifyBuilder : MessageBuilder { + + @set:Deprecated( + "This setter will be removed in the future, replace with files.clear() followed by files.addAll(...).", + ReplaceWith("this.files.clear()\nthis.files.addAll(value)"), + DeprecationLevel.WARNING, + ) + override var files: MutableList +} - public var content: String? +/** + * Keeps the attachment with the given [id], so it will be present after editing the message. + * + * The attachment object can optionally be edited with [builder]. + */ +public inline fun MessageModifyBuilder.keepAttachment(id: Snowflake, builder: AttachmentBuilder.() -> Unit = {}) { + contract { callsInPlace(builder, EXACTLY_ONCE) } + val attachment = AttachmentBuilder(id).apply(builder) + attachments?.add(attachment) ?: run { attachments = mutableListOf(attachment) } +} - public var embeds: MutableList? - public var allowedMentions: AllowedMentionsBuilder? +// this could have been combined with MessageModifyBuilder into a single sealed class, but it would have broken binary +// compatibility, because MessageModifyBuilder would have changed from interface to class +@Suppress("PropertyName") +@KordDsl +public sealed class AbstractMessageModifyBuilder : MessageModifyBuilder { - public var components: MutableList? + internal var _content: Optional = Optional.Missing() + final override var content: String? by ::_content.delegate() + internal var _embeds: Optional?> = Optional.Missing() + final override var embeds: MutableList? by ::_embeds.delegate() - /** - * The files to include as attachments - */ - public var files: MutableList? + private var _flags: Optional = Optional.Missing() + final override var flags: MessageFlags? by ::_flags.delegate() + final override var suppressEmbeds: Boolean? = null + internal fun buildFlags(): Optional = + suppressEmbeds?.let { buildMessageFlags(flags, suppressEmbeds = it) } ?: _flags - public var attachments: MutableList? + internal var _allowedMentions: Optional = Optional.Missing() + final override var allowedMentions: AllowedMentionsBuilder? by ::_allowedMentions.delegate() - /** - * Optional custom [MessageFlags] to update in this message. - * - * @see suppressEmbeds - */ - public var flags: MessageFlags? + internal var _components: Optional?> = Optional.Missing() + final override var components: MutableList? by ::_components.delegate() - /** - * Do not include any embeds when serializing this message. - */ - public var suppressEmbeds: Boolean? + @set:Deprecated( + "This setter will be removed in the future, replace with files.clear() followed by files.addAll(...).", + ReplaceWith("this.files.clear()\nthis.files.addAll(value)"), + DeprecationLevel.WARNING, + ) + final override var files: MutableList = mutableListOf() - /** - * Adds a file with the [name] and [contentProvider] to the attachments. - */ - public fun addFile(name: String, contentProvider: ChannelProvider): NamedFile = - NamedFile(name, contentProvider).also { file -> - files = (files ?: mutableListOf()).also { - it.add(file) - } - } + internal var _attachments: Optional?> = Optional.Missing() + final override var attachments: MutableList? by ::_attachments.delegate() } + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "RemoveRedundantQualifierName") +@kotlin.internal.LowPriorityInOverloadResolution +@Deprecated( + "Replaced by extension on 'MessageBuilder'. Change import to 'dev.kord.rest.builder.message.embed'.", + ReplaceWith("this.embed(block)", imports = ["dev.kord.rest.builder.message.embed"]), + DeprecationLevel.WARNING, +) public inline fun MessageModifyBuilder.embed(block: EmbedBuilder.() -> Unit) { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } - embeds = (embeds ?: mutableListOf()).also { - it.add(EmbedBuilder().apply(block)) - } + embedExtensionOnNewSupertype(block) } /** @@ -69,21 +96,32 @@ public inline fun MessageModifyBuilder.embed(block: EmbedBuilder.() -> Unit) { * (ping everything), calling this function but not configuring it before the request is build will result in all * pings being ignored. */ +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "RemoveRedundantQualifierName") +@kotlin.internal.LowPriorityInOverloadResolution +@Deprecated( + "Replaced by extension on 'MessageBuilder'. Change import to 'dev.kord.rest.builder.message.allowedMentions'.", + ReplaceWith("this.allowedMentions(block)", imports = ["dev.kord.rest.builder.message.allowedMentions"]), + DeprecationLevel.WARNING, +) public inline fun MessageModifyBuilder.allowedMentions(block: AllowedMentionsBuilder.() -> Unit = {}) { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } - allowedMentions = (allowedMentions ?: AllowedMentionsBuilder()).apply(block) + allowedMentionsExtensionOnNewSupertype(block) } - +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "RemoveRedundantQualifierName") +@kotlin.internal.LowPriorityInOverloadResolution +@Deprecated( + "Replaced by extension on 'MessageBuilder'. Change import to 'dev.kord.rest.builder.message.actionRow'.", + ReplaceWith("this.actionRow(builder)", imports = ["dev.kord.rest.builder.message.actionRow"]), + DeprecationLevel.WARNING, +) public inline fun MessageModifyBuilder.actionRow(builder: ActionRowBuilder.() -> Unit) { contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) } - components = (components ?: mutableListOf()).also { - it.add(ActionRowBuilder().apply(builder)) - } + actionRowExtensionOnNewSupertype(builder) } /** @@ -91,9 +129,16 @@ public inline fun MessageModifyBuilder.actionRow(builder: ActionRowBuilder.() -> * * **Only supports [MessageFlag.SuppressEmbeds]** */ +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "RemoveRedundantQualifierName") +@kotlin.internal.LowPriorityInOverloadResolution +@Deprecated( + "Replaced by extension on 'MessageBuilder'. Change import to 'dev.kord.rest.builder.message.messageFlags'.", + ReplaceWith("this.messageFlags(builder)", imports = ["dev.kord.rest.builder.message.messageFlags"]), + DeprecationLevel.WARNING, +) public inline fun MessageModifyBuilder.messageFlags(builder: MessageFlags.Builder.() -> Unit) { contract { callsInPlace(builder, InvocationKind.EXACTLY_ONCE) } - flags = MessageFlags(builder) + messageFlagsExtensionOnNewSupertype(builder) } diff --git a/rest/src/commonMain/kotlin/builder/message/modify/MessageModifyStateHolder.kt b/rest/src/commonMain/kotlin/builder/message/modify/MessageModifyStateHolder.kt deleted file mode 100644 index a5a249c5d9e..00000000000 --- a/rest/src/commonMain/kotlin/builder/message/modify/MessageModifyStateHolder.kt +++ /dev/null @@ -1,27 +0,0 @@ -package dev.kord.rest.builder.message.modify - -import dev.kord.common.entity.DiscordAttachment -import dev.kord.common.entity.optional.Optional -import dev.kord.rest.NamedFile -import dev.kord.rest.builder.component.MessageComponentBuilder -import dev.kord.rest.builder.message.AllowedMentionsBuilder -import dev.kord.rest.builder.message.EmbedBuilder - -/** - * Utility container for message modify builder. This class contains - * all possible fields as optionals. - */ -internal class MessageModifyStateHolder { - - var files: Optional> = Optional.Missing() - - var content: Optional = Optional.Missing() - - var embeds: Optional> = Optional.Missing() - - var allowedMentions: Optional = Optional.Missing() - - var attachments: Optional> = Optional.Missing() - - var components: Optional> = Optional.Missing() -} diff --git a/rest/src/commonMain/kotlin/builder/message/modify/UserMessageModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/message/modify/UserMessageModifyBuilder.kt index 3506e8f13b5..bd0c6f79168 100644 --- a/rest/src/commonMain/kotlin/builder/message/modify/UserMessageModifyBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/modify/UserMessageModifyBuilder.kt @@ -1,53 +1,24 @@ package dev.kord.rest.builder.message.modify import dev.kord.common.annotation.KordDsl -import dev.kord.common.entity.DiscordAttachment -import dev.kord.common.entity.MessageFlags -import dev.kord.common.entity.optional.delegate.delegate import dev.kord.common.entity.optional.map import dev.kord.common.entity.optional.mapList -import dev.kord.rest.NamedFile import dev.kord.rest.builder.RequestBuilder -import dev.kord.rest.builder.component.MessageComponentBuilder -import dev.kord.rest.builder.message.AllowedMentionsBuilder -import dev.kord.rest.builder.message.EmbedBuilder -import dev.kord.rest.builder.message.create.buildMessageFlags import dev.kord.rest.json.request.MessageEditPatchRequest import dev.kord.rest.json.request.MultipartMessagePatchRequest @KordDsl -public class UserMessageModifyBuilder - : MessageModifyBuilder, - RequestBuilder { - - private var state = MessageModifyStateHolder() - - override var files: MutableList? by state::files.delegate() - - override var attachments: MutableList? by state::attachments.delegate() - - override var content: String? by state::content.delegate() - - override var embeds: MutableList? by state::embeds.delegate() - - override var flags: MessageFlags? = null - override var suppressEmbeds: Boolean? = null - - override var allowedMentions: AllowedMentionsBuilder? by state::allowedMentions.delegate() - - - override var components: MutableList? by state::components.delegate() - +public class UserMessageModifyBuilder : AbstractMessageModifyBuilder(), RequestBuilder { + // see https://discord.com/developers/docs/resources/channel#edit-message override fun toRequest(): MultipartMessagePatchRequest = MultipartMessagePatchRequest( - MessageEditPatchRequest( - content = state.content, - embeds = state.embeds.mapList { it.toRequest() }, - flags = buildMessageFlags(flags, suppressEmbeds), - allowedMentions = state.allowedMentions.map { it.build() }, - components = state.components.mapList { it.build() }, - attachments = state.attachments, + requests = MessageEditPatchRequest( + content = _content, + embeds = _embeds.mapList { it.toRequest() }, + flags = buildFlags(), + allowedMentions = _allowedMentions.map { it.build() }, + components = _components.mapList { it.build() }, + attachments = _attachments.mapList { it.toRequest() }, ), - state.files, + files = files.toList(), ) - } diff --git a/rest/src/commonMain/kotlin/builder/message/modify/WebhookMessageModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/message/modify/WebhookMessageModifyBuilder.kt index a85604ce3be..aa34e13367e 100644 --- a/rest/src/commonMain/kotlin/builder/message/modify/WebhookMessageModifyBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/modify/WebhookMessageModifyBuilder.kt @@ -1,54 +1,26 @@ package dev.kord.rest.builder.message.modify import dev.kord.common.annotation.KordDsl -import dev.kord.common.entity.DiscordAttachment -import dev.kord.common.entity.MessageFlags -import dev.kord.common.entity.optional.delegate.delegate import dev.kord.common.entity.optional.map import dev.kord.common.entity.optional.mapList -import dev.kord.rest.NamedFile import dev.kord.rest.builder.RequestBuilder -import dev.kord.rest.builder.component.MessageComponentBuilder -import dev.kord.rest.builder.message.AllowedMentionsBuilder -import dev.kord.rest.builder.message.EmbedBuilder -import dev.kord.rest.builder.message.create.buildMessageFlags import dev.kord.rest.json.request.MultipartWebhookEditMessageRequest import dev.kord.rest.json.request.WebhookEditMessageRequest @KordDsl public class WebhookMessageModifyBuilder : - MessageModifyBuilder, + AbstractMessageModifyBuilder(), RequestBuilder { - - private var state = MessageModifyStateHolder() - - override var files: MutableList? by state::files.delegate() - - override var attachments: MutableList? by state::attachments.delegate() - - override var content: String? by state::content.delegate() - - override var embeds: MutableList? by state::embeds.delegate() - - override var allowedMentions: AllowedMentionsBuilder? by state::allowedMentions.delegate() - - override var flags: MessageFlags? = null - override var suppressEmbeds: Boolean? = null - - override var components: MutableList? by state::components.delegate() - - override fun toRequest(): MultipartWebhookEditMessageRequest { - return MultipartWebhookEditMessageRequest( - WebhookEditMessageRequest( - content = state.content, - embeds = state.embeds.mapList { it.toRequest() }, - allowedMentions = state.allowedMentions.map { it.build() }, - components = state.components.mapList { it.build() }, - attachments = state.attachments, - flags = buildMessageFlags(flags, suppressEmbeds) - ), - files = state.files - ) - } - + // see https://discord.com/developers/docs/resources/webhook#edit-webhook-message + override fun toRequest(): MultipartWebhookEditMessageRequest = MultipartWebhookEditMessageRequest( + request = WebhookEditMessageRequest( + content = _content, + embeds = _embeds.mapList { it.toRequest() }, + flags = buildFlags(), + allowedMentions = _allowedMentions.map { it.build() }, + components = _components.mapList { it.build() }, + attachments = _attachments.mapList { it.toRequest() }, + ), + files = files.toList(), + ) } diff --git a/rest/src/commonMain/kotlin/json/request/InteractionsRequests.kt b/rest/src/commonMain/kotlin/json/request/InteractionsRequests.kt index 7ad774cb0ae..725c99ef4d3 100644 --- a/rest/src/commonMain/kotlin/json/request/InteractionsRequests.kt +++ b/rest/src/commonMain/kotlin/json/request/InteractionsRequests.kt @@ -56,12 +56,12 @@ public data class InteractionResponseModifyRequest( val allowedMentions: Optional = Optional.Missing(), val flags: Optional = Optional.Missing(), val components: Optional?> = Optional.Missing(), - val attachments: Optional?> = Optional.Missing() + val attachments: Optional?> = Optional.Missing(), ) public data class MultipartInteractionResponseModifyRequest( val request: InteractionResponseModifyRequest, - val files: Optional> = Optional.Missing(), + val files: List = emptyList(), ) @Serializable @@ -95,18 +95,19 @@ public data class ModalResponseCreateRequest( public data class MultipartInteractionResponseCreateRequest( val request: InteractionResponseCreateRequest, - val files: Optional> = Optional.Missing() + val files: List = emptyList(), ) @Serializable public data class InteractionApplicationCommandCallbackData( val tts: OptionalBoolean = OptionalBoolean.Missing, - val content: Optional = Optional.Missing(), + val content: Optional = Optional.Missing(), val embeds: Optional> = Optional.Missing(), @SerialName("allowed_mentions") - val allowedMentions: Optional = Optional.Missing(), + val allowedMentions: Optional = Optional.Missing(), val flags: Optional = Optional.Missing(), val components: Optional> = Optional.Missing(), + val attachments: Optional> = Optional.Missing(), ) public data class MultipartFollowupMessageCreateRequest( @@ -117,14 +118,12 @@ public data class MultipartFollowupMessageCreateRequest( @Serializable public data class FollowupMessageCreateRequest( val content: Optional = Optional.Missing(), - val username: Optional = Optional.Missing(), - @SerialName("avatar_url") - val avatar: Optional = Optional.Missing(), val tts: OptionalBoolean = OptionalBoolean.Missing, val embeds: Optional> = Optional.Missing(), @SerialName("allowed_mentions") val allowedMentions: Optional = Optional.Missing(), val components: Optional> = Optional.Missing(), + val attachments: Optional> = Optional.Missing(), val flags: Optional = Optional.Missing(), ) @@ -135,11 +134,11 @@ public data class FollowupMessageModifyRequest( @SerialName("allowed_mentions") val allowedMentions: Optional = Optional.Missing(), val components: Optional?> = Optional.Missing(), - val attachments: Optional?> = Optional.Missing(), - val flags: Optional = Optional.Missing() + val attachments: Optional?> = Optional.Missing(), + val flags: Optional = Optional.Missing(), ) public data class MultipartFollowupMessageModifyRequest( val request: FollowupMessageModifyRequest, - val files: Optional> = Optional.Missing() + val files: List = emptyList(), ) diff --git a/rest/src/commonMain/kotlin/json/request/MessageRequests.kt b/rest/src/commonMain/kotlin/json/request/MessageRequests.kt index 011f12cd683..f451d6da3b3 100644 --- a/rest/src/commonMain/kotlin/json/request/MessageRequests.kt +++ b/rest/src/commonMain/kotlin/json/request/MessageRequests.kt @@ -20,6 +20,9 @@ public data class MessageCreateRequest( @SerialName("message_reference") val messageReference: Optional = Optional.Missing(), val components: Optional> = Optional.Missing(), + @SerialName("sticker_ids") + val stickerIds: Optional> = Optional.Missing(), + val attachments: Optional> = Optional.Missing(), val flags: Optional = Optional.Missing() ) @@ -71,6 +74,13 @@ public data class EmbedFieldRequest( val inline: OptionalBoolean = OptionalBoolean.Missing, ) +@Serializable +public data class AttachmentRequest( + val id: Snowflake, + val filename: Optional = Optional.Missing(), + val description: Optional = Optional.Missing(), +) + @Serializable public data class MessageEditPatchRequest( val content: Optional = Optional.Missing(), @@ -78,13 +88,13 @@ public data class MessageEditPatchRequest( val flags: Optional = Optional.Missing(), @SerialName("allowed_mentions") val allowedMentions: Optional = Optional.Missing(), - val components: Optional> = Optional.Missing(), - val attachments: Optional> = Optional.Missing(), + val components: Optional?> = Optional.Missing(), + val attachments: Optional?> = Optional.Missing(), ) public data class MultipartMessagePatchRequest( val requests: MessageEditPatchRequest, - val files: Optional> = Optional.Missing() + val files: List = emptyList(), ) @Serializable @@ -93,12 +103,14 @@ public data class BulkDeleteRequest(val messages: List) @Serializable public data class ForumThreadMessageRequest( val content: Optional = Optional.Missing(), + val tts: OptionalBoolean = OptionalBoolean.Missing, val embeds: Optional> = Optional.Missing(), @SerialName("allowed_mentions") val allowedMentions: Optional = Optional.Missing(), val components: Optional> = Optional.Missing(), @SerialName("sticker_ids") val stickerIds: Optional> = Optional.Missing(), + val attachments: Optional> = Optional.Missing(), val flags: Optional = Optional.Missing() ) diff --git a/rest/src/commonMain/kotlin/json/request/WebhookRequests.kt b/rest/src/commonMain/kotlin/json/request/WebhookRequests.kt index b594b5003ad..699b7a29ce5 100644 --- a/rest/src/commonMain/kotlin/json/request/WebhookRequests.kt +++ b/rest/src/commonMain/kotlin/json/request/WebhookRequests.kt @@ -1,7 +1,6 @@ package dev.kord.rest.json.request import dev.kord.common.entity.AllowedMentions -import dev.kord.common.entity.DiscordAttachment import dev.kord.common.entity.DiscordComponent import dev.kord.common.entity.MessageFlags import dev.kord.common.entity.optional.Optional @@ -33,6 +32,7 @@ public data class WebhookExecuteRequest( @SerialName("allowed_mentions") val allowedMentions: Optional = Optional.Missing(), val components: Optional> = Optional.Missing(), + val attachments: Optional> = Optional.Missing(), val flags: Optional = Optional.Missing(), @SerialName("thread_name") val threadName: Optional = Optional.Missing(), @@ -46,15 +46,15 @@ public data class MultiPartWebhookExecuteRequest( @Serializable public data class WebhookEditMessageRequest( val content: Optional = Optional.Missing(), - val embeds: Optional> = Optional.Missing(), + val embeds: Optional?> = Optional.Missing(), @SerialName("allowed_mentions") - val allowedMentions: Optional = Optional.Missing(), - val components: Optional> = Optional.Missing(), - val attachments: Optional> = Optional.Missing(), - val flags: Optional = Optional.Missing() + val allowedMentions: Optional = Optional.Missing(), + val components: Optional?> = Optional.Missing(), + val attachments: Optional?> = Optional.Missing(), + val flags: Optional = Optional.Missing(), ) public data class MultipartWebhookEditMessageRequest( val request: WebhookEditMessageRequest, - val files: Optional> = Optional.Missing() + val files: List = emptyList(), ) diff --git a/rest/src/commonMain/kotlin/request/Request.kt b/rest/src/commonMain/kotlin/request/Request.kt index 8bbd55b048c..e78351daa27 100644 --- a/rest/src/commonMain/kotlin/request/Request.kt +++ b/rest/src/commonMain/kotlin/request/Request.kt @@ -87,13 +87,17 @@ public class MultipartRequest( public val data: List = formData { body?.let { - append("payload_json", Json.encodeToString(it.strategy, it.body)) + append( + key = "payload_json", + value = Json.encodeToString(it.strategy, it.body), + headersOf(HttpHeaders.ContentType, ContentType.Application.Json.toString()), + ) } - files.forEachIndexed { index, (fileName, contentProvider) -> + files.forEachIndexed { index, (filename, contentProvider) -> append( - "file$index", - contentProvider, - headersOf(HttpHeaders.ContentDisposition, "filename=$fileName") + key = "files[$index]", + value = contentProvider, + headersOf(HttpHeaders.ContentDisposition, "filename=${filename.escapeIfNeeded()}"), ) } } diff --git a/rest/src/commonMain/kotlin/service/InteractionService.kt b/rest/src/commonMain/kotlin/service/InteractionService.kt index ef943b80f0a..977ca65ea3a 100644 --- a/rest/src/commonMain/kotlin/service/InteractionService.kt +++ b/rest/src/commonMain/kotlin/service/InteractionService.kt @@ -4,7 +4,6 @@ import dev.kord.common.entity.* import dev.kord.common.entity.MessageFlag.Ephemeral import dev.kord.common.entity.optional.Optional import dev.kord.common.entity.optional.coerceToMissing -import dev.kord.common.entity.optional.orEmpty import dev.kord.rest.builder.interaction.* import dev.kord.rest.builder.message.create.FollowupMessageCreateBuilder import dev.kord.rest.builder.message.create.InteractionResponseCreateBuilder @@ -111,7 +110,7 @@ public class InteractionService(requestHandler: RequestHandler) : RestService(re ): Unit = call(Route.InteractionResponseCreate) { interactionIdInteractionToken(interactionId, interactionToken) body(InteractionResponseCreateRequest.serializer(), request.request) - request.files.orEmpty().onEach { file(it) } + request.files.onEach { file(it) } } public suspend fun createInteractionResponse( @@ -259,7 +258,7 @@ public class InteractionService(requestHandler: RequestHandler) : RestService(re ): DiscordMessage = call(Route.OriginalInteractionResponseModify) { applicationIdInteractionToken(applicationId, interactionToken) body(InteractionResponseModifyRequest.serializer(), multipartRequest.request) - multipartRequest.files.orEmpty().forEach { file(it) } + multipartRequest.files.forEach { file(it) } } public suspend fun modifyInteractionResponse( @@ -310,7 +309,7 @@ public class InteractionService(requestHandler: RequestHandler) : RestService(re ): DiscordMessage = call(Route.FollowupMessageModify) { applicationIdInteractionTokenMessageId(applicationId, interactionToken, messageId) body(FollowupMessageModifyRequest.serializer(), request.request) - request.files.orEmpty().forEach { file(it) } + request.files.forEach { file(it) } } public suspend fun modifyFollowupMessage( diff --git a/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/MessageBuilderJvm.kt b/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/MessageBuilderJvm.kt new file mode 100644 index 00000000000..ca48c82b873 --- /dev/null +++ b/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/MessageBuilderJvm.kt @@ -0,0 +1,22 @@ +package dev.kord.rest.builder.message + +import dev.kord.rest.NamedFile +import io.ktor.client.request.forms.* +import io.ktor.util.cio.* +import java.nio.file.Path +import kotlin.contracts.InvocationKind.EXACTLY_ONCE +import kotlin.contracts.contract + +/** Adds a [file][NamedFile] with the given [path] to [files][MessageBuilder.files]. */ +public fun MessageBuilder.addFile(path: Path): NamedFile = + addFile(path.fileName.toString(), ChannelProvider { path.readChannel() }) + +/** + * Adds a [file][NamedFile] with the given [path] to [files][MessageBuilder.files]. + * + * The corresponding attachment object can be configured with [builder]. + */ +public inline fun MessageBuilder.addFile(path: Path, builder: AttachmentBuilder.() -> Unit): NamedFile { + contract { callsInPlace(builder, EXACTLY_ONCE) } + return addFile(path.fileName.toString(), ChannelProvider { path.readChannel() }, builder) +} diff --git a/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/MessageCreateBuilderJvm.kt b/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/MessageCreateBuilderJvm.kt index 4ac22022c30..68095de5161 100644 --- a/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/MessageCreateBuilderJvm.kt +++ b/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/MessageCreateBuilderJvm.kt @@ -1,12 +1,18 @@ package dev.kord.rest.builder.message.create import dev.kord.rest.NamedFile -import io.ktor.client.request.forms.* -import io.ktor.util.cio.* import java.nio.file.Path +import dev.kord.rest.builder.message.addFile as addFileExtensionOnNewSupertype /** * Adds a file with the given [path] to the attachments. */ +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@kotlin.internal.LowPriorityInOverloadResolution +@Deprecated( + "Replaced by extension on 'MessageBuilder'. Change import to 'dev.kord.rest.builder.message.addFile'.", + ReplaceWith("this.addFile(path)", imports = ["dev.kord.rest.builder.message.addFile"]), + DeprecationLevel.WARNING, +) public fun MessageCreateBuilder.addFile(path: Path): NamedFile = - addFile(path.fileName.toString(), ChannelProvider { path.readChannel() }) + addFileExtensionOnNewSupertype(path) diff --git a/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/MessageModifyBuilderJvm.kt b/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/MessageModifyBuilderJvm.kt index ea279a11431..c33219f9238 100644 --- a/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/MessageModifyBuilderJvm.kt +++ b/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/MessageModifyBuilderJvm.kt @@ -1,12 +1,18 @@ package dev.kord.rest.builder.message.modify import dev.kord.rest.NamedFile -import io.ktor.client.request.forms.* -import io.ktor.util.cio.* import java.nio.file.Path +import dev.kord.rest.builder.message.addFile as addFileExtensionOnNewSupertype /** * Adds a file with the given [path] to the attachments. */ +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@kotlin.internal.LowPriorityInOverloadResolution +@Deprecated( + "Replaced by extension on 'MessageBuilder'. Change import to 'dev.kord.rest.builder.message.addFile'.", + ReplaceWith("this.addFile(path)", imports = ["dev.kord.rest.builder.message.addFile"]), + DeprecationLevel.WARNING, +) public fun MessageModifyBuilder.addFile(path: Path): NamedFile = - addFile(path.fileName.toString(), ChannelProvider { path.readChannel() }) + addFileExtensionOnNewSupertype(path)