From 164203b44dce278f0b55b2458503097cc0f86757 Mon Sep 17 00:00:00 2001 From: Luca Kellermann Date: Mon, 2 Sep 2024 18:55:24 +0200 Subject: [PATCH] Remove deprecated functions They seem to be here by accident, I already removed them for good in #944. --- buildSrc/src/main/kotlin/Compiler.kt | 2 +- rest/api/rest.api | 5 - rest/api/rest.klib.api | 12 +- .../message/create/MessageCreateBuilder.kt | 115 +++--------------- 4 files changed, 23 insertions(+), 111 deletions(-) diff --git a/buildSrc/src/main/kotlin/Compiler.kt b/buildSrc/src/main/kotlin/Compiler.kt index e137103d598..00b3f31b5b6 100644 --- a/buildSrc/src/main/kotlin/Compiler.kt +++ b/buildSrc/src/main/kotlin/Compiler.kt @@ -19,7 +19,7 @@ object Jvm { fun KotlinCommonCompilerOptions.applyKordCompilerOptions() { allWarningsAsErrors = true progressiveMode = true - freeCompilerArgs.addAll("-Xexpect-actual-classes", "-Xdont-warn-on-error-suppression") + freeCompilerArgs.add("-Xexpect-actual-classes") } internal fun NamedDomainObjectSet.applyKordTestOptIns() { diff --git a/rest/api/rest.api b/rest/api/rest.api index 72ea1af4624..856f852bb19 100644 --- a/rest/api/rest.api +++ b/rest/api/rest.api @@ -2253,11 +2253,6 @@ public final class dev/kord/rest/builder/message/create/MessageCreateBuilder$Def } public final class dev/kord/rest/builder/message/create/MessageCreateBuilderKt { - public static final synthetic fun actionRow (Ldev/kord/rest/builder/message/create/MessageCreateBuilder;Lkotlin/jvm/functions/Function1;)V - public static final synthetic fun allowedMentions (Ldev/kord/rest/builder/message/create/MessageCreateBuilder;Lkotlin/jvm/functions/Function1;)V - public static synthetic fun allowedMentions$default (Ldev/kord/rest/builder/message/create/MessageCreateBuilder;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V - public static final synthetic fun embed (Ldev/kord/rest/builder/message/create/MessageCreateBuilder;Lkotlin/jvm/functions/Function1;)V - public static final synthetic fun messageFlags (Ldev/kord/rest/builder/message/create/MessageCreateBuilder;Lkotlin/jvm/functions/Function1;)V public static final fun poll (Ldev/kord/rest/builder/message/create/MessageCreateBuilder;Lkotlin/jvm/functions/Function1;)V } diff --git a/rest/api/rest.klib.api b/rest/api/rest.klib.api index f7d47d6cbe4..eb63884e3ce 100644 --- a/rest/api/rest.klib.api +++ b/rest/api/rest.klib.api @@ -3546,14 +3546,14 @@ final class dev.kord.rest.json.request/ChannelPositionSwapRequest { // dev.kord. } final class dev.kord.rest.json.request/CreatablePoll { // dev.kord.rest.json.request/CreatablePoll|null[0] - constructor (dev.kord.common.entity/DiscordPoll.Media, kotlin.collections/List, kotlinx.datetime/Instant, dev.kord.common.entity.optional/Optional = ..., dev.kord.common.entity/PollLayoutType) // dev.kord.rest.json.request/CreatablePoll.|(dev.kord.common.entity.DiscordPoll.Media;kotlin.collections.List;kotlinx.datetime.Instant;dev.kord.common.entity.optional.Optional;dev.kord.common.entity.PollLayoutType){}[0] + constructor (dev.kord.common.entity/DiscordPoll.Media, kotlin.collections/List, kotlinx.datetime/Instant?, dev.kord.common.entity.optional/Optional = ..., dev.kord.common.entity/PollLayoutType) // dev.kord.rest.json.request/CreatablePoll.|(dev.kord.common.entity.DiscordPoll.Media;kotlin.collections.List;kotlinx.datetime.Instant?;dev.kord.common.entity.optional.Optional;dev.kord.common.entity.PollLayoutType){}[0] final val allowMultiselect // dev.kord.rest.json.request/CreatablePoll.allowMultiselect|{}allowMultiselect[0] final fun (): dev.kord.common.entity.optional/Optional // dev.kord.rest.json.request/CreatablePoll.allowMultiselect.|(){}[0] final val answers // dev.kord.rest.json.request/CreatablePoll.answers|{}answers[0] final fun (): kotlin.collections/List // dev.kord.rest.json.request/CreatablePoll.answers.|(){}[0] final val expiry // dev.kord.rest.json.request/CreatablePoll.expiry|{}expiry[0] - final fun (): kotlinx.datetime/Instant // dev.kord.rest.json.request/CreatablePoll.expiry.|(){}[0] + final fun (): kotlinx.datetime/Instant? // dev.kord.rest.json.request/CreatablePoll.expiry.|(){}[0] final val layoutType // dev.kord.rest.json.request/CreatablePoll.layoutType|{}layoutType[0] final fun (): dev.kord.common.entity/PollLayoutType // dev.kord.rest.json.request/CreatablePoll.layoutType.|(){}[0] final val question // dev.kord.rest.json.request/CreatablePoll.question|{}question[0] @@ -3561,10 +3561,10 @@ final class dev.kord.rest.json.request/CreatablePoll { // dev.kord.rest.json.req final fun component1(): dev.kord.common.entity/DiscordPoll.Media // dev.kord.rest.json.request/CreatablePoll.component1|component1(){}[0] final fun component2(): kotlin.collections/List // dev.kord.rest.json.request/CreatablePoll.component2|component2(){}[0] - final fun component3(): kotlinx.datetime/Instant // dev.kord.rest.json.request/CreatablePoll.component3|component3(){}[0] + final fun component3(): kotlinx.datetime/Instant? // dev.kord.rest.json.request/CreatablePoll.component3|component3(){}[0] final fun component4(): dev.kord.common.entity.optional/Optional // dev.kord.rest.json.request/CreatablePoll.component4|component4(){}[0] final fun component5(): dev.kord.common.entity/PollLayoutType // dev.kord.rest.json.request/CreatablePoll.component5|component5(){}[0] - final fun copy(dev.kord.common.entity/DiscordPoll.Media = ..., kotlin.collections/List = ..., kotlinx.datetime/Instant = ..., dev.kord.common.entity.optional/Optional = ..., dev.kord.common.entity/PollLayoutType = ...): dev.kord.rest.json.request/CreatablePoll // dev.kord.rest.json.request/CreatablePoll.copy|copy(dev.kord.common.entity.DiscordPoll.Media;kotlin.collections.List;kotlinx.datetime.Instant;dev.kord.common.entity.optional.Optional;dev.kord.common.entity.PollLayoutType){}[0] + final fun copy(dev.kord.common.entity/DiscordPoll.Media = ..., kotlin.collections/List = ..., kotlinx.datetime/Instant? = ..., dev.kord.common.entity.optional/Optional = ..., dev.kord.common.entity/PollLayoutType = ...): dev.kord.rest.json.request/CreatablePoll // dev.kord.rest.json.request/CreatablePoll.copy|copy(dev.kord.common.entity.DiscordPoll.Media;kotlin.collections.List;kotlinx.datetime.Instant?;dev.kord.common.entity.optional.Optional;dev.kord.common.entity.PollLayoutType){}[0] final fun equals(kotlin/Any?): kotlin/Boolean // dev.kord.rest.json.request/CreatablePoll.equals|equals(kotlin.Any?){}[0] final fun hashCode(): kotlin/Int // dev.kord.rest.json.request/CreatablePoll.hashCode|hashCode(){}[0] final fun toString(): kotlin/String // dev.kord.rest.json.request/CreatablePoll.toString|toString(){}[0] @@ -7996,10 +7996,6 @@ final inline fun (dev.kord.rest.builder.interaction/MultiApplicationCommandBuild final inline fun (dev.kord.rest.builder.interaction/MultiApplicationCommandBuilder).dev.kord.rest.builder.interaction/user(kotlin/String, kotlin/Function1 = ...) // dev.kord.rest.builder.interaction/user|user@dev.kord.rest.builder.interaction.MultiApplicationCommandBuilder(kotlin.String;kotlin.Function1){}[0] final inline fun (dev.kord.rest.builder.interaction/RootInputChatBuilder).dev.kord.rest.builder.interaction/group(kotlin/String, kotlin/String, kotlin/Function1 = ...) // dev.kord.rest.builder.interaction/group|group@dev.kord.rest.builder.interaction.RootInputChatBuilder(kotlin.String;kotlin.String;kotlin.Function1){}[0] final inline fun (dev.kord.rest.builder.interaction/RootInputChatBuilder).dev.kord.rest.builder.interaction/subCommand(kotlin/String, kotlin/String, kotlin/Function1 = ...) // dev.kord.rest.builder.interaction/subCommand|subCommand@dev.kord.rest.builder.interaction.RootInputChatBuilder(kotlin.String;kotlin.String;kotlin.Function1){}[0] -final inline fun (dev.kord.rest.builder.message.create/MessageCreateBuilder).dev.kord.rest.builder.message.create/actionRow(kotlin/Function1) // dev.kord.rest.builder.message.create/actionRow|actionRow@dev.kord.rest.builder.message.create.MessageCreateBuilder(kotlin.Function1){}[0] -final inline fun (dev.kord.rest.builder.message.create/MessageCreateBuilder).dev.kord.rest.builder.message.create/allowedMentions(kotlin/Function1 = ...) // dev.kord.rest.builder.message.create/allowedMentions|allowedMentions@dev.kord.rest.builder.message.create.MessageCreateBuilder(kotlin.Function1){}[0] -final inline fun (dev.kord.rest.builder.message.create/MessageCreateBuilder).dev.kord.rest.builder.message.create/embed(kotlin/Function1) // dev.kord.rest.builder.message.create/embed|embed@dev.kord.rest.builder.message.create.MessageCreateBuilder(kotlin.Function1){}[0] -final inline fun (dev.kord.rest.builder.message.create/MessageCreateBuilder).dev.kord.rest.builder.message.create/messageFlags(kotlin/Function1) // dev.kord.rest.builder.message.create/messageFlags|messageFlags@dev.kord.rest.builder.message.create.MessageCreateBuilder(kotlin.Function1){}[0] final inline fun (dev.kord.rest.builder.message.create/MessageCreateBuilder).dev.kord.rest.builder.message.create/poll(kotlin/Function1) // dev.kord.rest.builder.message.create/poll|poll@dev.kord.rest.builder.message.create.MessageCreateBuilder(kotlin.Function1){}[0] final inline fun (dev.kord.rest.builder.message.modify/MessageModifyBuilder).dev.kord.rest.builder.message.modify/keepAttachment(dev.kord.common.entity/Snowflake, kotlin/Function1 = ...) // dev.kord.rest.builder.message.modify/keepAttachment|keepAttachment@dev.kord.rest.builder.message.modify.MessageModifyBuilder(dev.kord.common.entity.Snowflake;kotlin.Function1){}[0] final inline fun (dev.kord.rest.builder.message/MessageBuilder).dev.kord.rest.builder.message/actionRow(kotlin/Function1) // dev.kord.rest.builder.message/actionRow|actionRow@dev.kord.rest.builder.message.MessageBuilder(kotlin.Function1){}[0] diff --git a/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt index b24b916db10..b4c4b932108 100644 --- a/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt @@ -2,27 +2,17 @@ package dev.kord.rest.builder.message.create import dev.kord.common.annotation.KordDsl import dev.kord.common.annotation.KordUnsafe -import dev.kord.rest.json.request.CreatablePoll -import dev.kord.common.entity.DiscordPoll -import dev.kord.common.entity.MessageFlag +import dev.kord.common.entity.DiscordMessage 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 dev.kord.rest.builder.message.MessageBuilder -import dev.kord.rest.builder.message.PollBuilder +import dev.kord.rest.builder.message.* +import dev.kord.rest.json.request.CreatablePoll 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. @@ -51,6 +41,21 @@ public sealed interface MessageCreateBuilder : MessageBuilder { public var suppressNotifications: Boolean? } +/** + * Set's the [poll][DiscordMessage.poll] of this message. + * + * **Please note that if poll is set, you currently cannot set [MessageBuilder.content], + * [MessageBuilder.attachments], [MessageBuilder.embeds] or [MessageBuilder.components]** + */ +@KordUnsafe +public inline fun MessageCreateBuilder.poll(builder: PollBuilder.() -> Unit) { + contract { + callsInPlace(builder, InvocationKind.EXACTLY_ONCE) + } + + poll = PollBuilder().apply(builder).toRequest() +} + // 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 @@ -86,87 +91,3 @@ public sealed class AbstractMessageCreateBuilder : MessageCreateBuilder { @KordUnsafe final override var poll: CreatablePoll? by ::_poll.delegate() } - - -/** - * 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.HIDDEN, -) -public inline fun MessageCreateBuilder.embed(block: EmbedBuilder.() -> Unit) { - contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } - embedExtensionOnNewSupertype(block) -} - -/** - * Configures the mentions that should trigger a mention (aka ping). Not calling this function will result in the default behavior - * (ping everything), calling this function but not configuring it before the request is build will result in all - * pings being ignored. - */ -@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.HIDDEN, -) -public inline fun MessageCreateBuilder.allowedMentions(block: AllowedMentionsBuilder.() -> Unit = {}) { - contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } - 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.HIDDEN, -) -public inline fun MessageCreateBuilder.actionRow(builder: ActionRowBuilder.() -> Unit) { - contract { - callsInPlace(builder, InvocationKind.EXACTLY_ONCE) - } - actionRowExtensionOnNewSupertype(builder) -} - -/** - * Sets the [MessageFlags] for the created message. - * - * **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.HIDDEN, -) -public inline fun MessageCreateBuilder.messageFlags(builder: MessageFlags.Builder.() -> Unit) { - contract { - callsInPlace(builder, InvocationKind.EXACTLY_ONCE) - } - messageFlagsExtensionOnNewSupertype(builder) -} - -/** - * Set's the [poll][dev.kord.common.entity.DiscordMessage.poll] of this message. - * - * **Please note that if poll is set, you currently cannot set [MessageBuilder.content], - * [MessageBuilder.attachments], [MessageBuilder.embeds] or [MessageBuilder.components]** - */ -@KordUnsafe -public inline fun MessageCreateBuilder.poll(builder: PollBuilder.() -> Unit) { - contract { - callsInPlace(builder, InvocationKind.EXACTLY_ONCE) - } - - poll = PollBuilder().apply(builder).toRequest() -}