diff --git a/BotCommands-app-emojis/src/main/kotlin/io/github/freya022/botcommands/internal/emojis/AppEmojisLoader.kt b/BotCommands-app-emojis/src/main/kotlin/io/github/freya022/botcommands/internal/emojis/AppEmojisLoader.kt index a42ca58a5..cda410350 100644 --- a/BotCommands-app-emojis/src/main/kotlin/io/github/freya022/botcommands/internal/emojis/AppEmojisLoader.kt +++ b/BotCommands-app-emojis/src/main/kotlin/io/github/freya022/botcommands/internal/emojis/AppEmojisLoader.kt @@ -89,7 +89,7 @@ internal class AppEmojisLoader internal constructor( } val oldCount = toLoad.size - clazz.objectInstance // Force initialization (and thus registration) + val _ = clazz.objectInstance // Force initialization (and thus registration) if (oldCount == toLoad.size) { logger.info { "No emojis were registered by ${clazz.simpleNestedName}" } } diff --git a/BotCommands-autocomplete-caffeine/build.gradle.kts b/BotCommands-autocomplete-caffeine/build.gradle.kts index 30544bddb..0cbcb1957 100644 --- a/BotCommands-autocomplete-caffeine/build.gradle.kts +++ b/BotCommands-autocomplete-caffeine/build.gradle.kts @@ -24,14 +24,6 @@ dependencies { configureTests(libs.bytebuddy.agent) -kotlin { - compilerOptions { - freeCompilerArgs.addAll( - "-Xcontext-parameters", - ) - } -} - publishedProjectEnvironment { configureJarArtifact( artifactId = "BotCommands-autocomplete-caffeine", diff --git a/BotCommands-commands/app/build.gradle.kts b/BotCommands-commands/app/build.gradle.kts index 14ca2f62d..1ab1dbcbf 100644 --- a/BotCommands-commands/app/build.gradle.kts +++ b/BotCommands-commands/app/build.gradle.kts @@ -64,14 +64,6 @@ dependencies { configureTests(libs.bytebuddy.agent) -kotlin { - compilerOptions { - freeCompilerArgs.addAll( - "-Xcontext-parameters", - ) - } -} - publishedProjectEnvironment { configureJarArtifact( artifactId = "BotCommands-commands-app", diff --git a/BotCommands-commands/app/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/ratelimit/ApplicationCommandRateLimitHandler.kt b/BotCommands-commands/app/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/ratelimit/ApplicationCommandRateLimitHandler.kt index bc6cae180..ebc55812b 100644 --- a/BotCommands-commands/app/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/ratelimit/ApplicationCommandRateLimitHandler.kt +++ b/BotCommands-commands/app/src/main/kotlin/io/github/freya022/botcommands/internal/commands/application/ratelimit/ApplicationCommandRateLimitHandler.kt @@ -23,12 +23,12 @@ internal class ApplicationCommandRateLimitHandler internal constructor( internal suspend fun tryRun(commandInfo: ApplicationCommandInfoImpl, event: GenericCommandInteractionEvent, block: suspend (CancellableRateLimit) -> Boolean) { val rateLimitInfo = commandInfo.rateLimitInfo if (rateLimitInfo == null) { - block(NullCancellableRateLimit) + val _ = block(NullCancellableRateLimit) return } if (enableOwnerBypass && event.user in botOwners) { - block(NullCancellableRateLimit) + val _ = block(NullCancellableRateLimit) return } diff --git a/BotCommands-commands/core/build.gradle.kts b/BotCommands-commands/core/build.gradle.kts index febbb111f..2d32fbf0a 100644 --- a/BotCommands-commands/core/build.gradle.kts +++ b/BotCommands-commands/core/build.gradle.kts @@ -38,14 +38,6 @@ dependencies { configureTests(libs.bytebuddy.agent) -kotlin { - compilerOptions { - freeCompilerArgs.addAll( - "-Xcontext-parameters", - ) - } -} - publishedProjectEnvironment { configureJarArtifact( artifactId = "BotCommands-commands-core", diff --git a/BotCommands-commands/text/build.gradle.kts b/BotCommands-commands/text/build.gradle.kts index c81345f8c..3f015a991 100644 --- a/BotCommands-commands/text/build.gradle.kts +++ b/BotCommands-commands/text/build.gradle.kts @@ -56,14 +56,6 @@ dependencies { configureTests(libs.bytebuddy.agent) -kotlin { - compilerOptions { - freeCompilerArgs.addAll( - "-Xcontext-parameters", - ) - } -} - publishedProjectEnvironment { configureJarArtifact( artifactId = "BotCommands-commands-text", diff --git a/BotCommands-commands/text/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/TextCommandVariationImpl.kt b/BotCommands-commands/text/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/TextCommandVariationImpl.kt index c569be471..6ffc305ee 100644 --- a/BotCommands-commands/text/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/TextCommandVariationImpl.kt +++ b/BotCommands-commands/text/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/TextCommandVariationImpl.kt @@ -84,7 +84,7 @@ internal class TextCommandVariationImpl internal constructor( internal suspend fun tryParseOptionValues(event: BaseCommandEvent, matchResult: MatchResult?): Map? { val groupsIterator = matchResult?.groups?.iterator() - groupsIterator?.next() //Skip the entire match + val _ = groupsIterator?.next() //Skip the entire match return parameters.mapOptions { option -> if (tryInsertOption(event, this, option, groupsIterator) == InsertOptionResult.ABORT) diff --git a/BotCommands-commands/text/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/ratelimit/TextCommandRateLimitHandler.kt b/BotCommands-commands/text/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/ratelimit/TextCommandRateLimitHandler.kt index a6ddc3e76..402b643ee 100644 --- a/BotCommands-commands/text/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/ratelimit/TextCommandRateLimitHandler.kt +++ b/BotCommands-commands/text/src/main/kotlin/io/github/freya022/botcommands/internal/commands/text/ratelimit/TextCommandRateLimitHandler.kt @@ -23,12 +23,12 @@ internal class TextCommandRateLimitHandler internal constructor( internal suspend fun tryRun(commandInfo: TextCommandInfoImpl, event: MessageReceivedEvent, block: suspend (CancellableRateLimit) -> Boolean) { val rateLimitInfo = commandInfo.rateLimitInfo if (rateLimitInfo == null) { - block(NullCancellableRateLimit) + val _ = block(NullCancellableRateLimit) return } if (enableOwnerBypass && event.author in botOwners) { - block(NullCancellableRateLimit) + val _ = block(NullCancellableRateLimit) return } diff --git a/BotCommands-components/build.gradle.kts b/BotCommands-components/build.gradle.kts index 135c7e2a4..7abdc6f35 100644 --- a/BotCommands-components/build.gradle.kts +++ b/BotCommands-components/build.gradle.kts @@ -67,14 +67,6 @@ dependencies { configureTests(libs.bytebuddy.agent) -kotlin { - compilerOptions { - freeCompilerArgs.addAll( - "-Xcontext-parameters", - ) - } -} - publishedProjectEnvironment { configureJarArtifact( artifactId = "BotCommands-components", diff --git a/BotCommands-components/src/main/kotlin/io/github/freya022/botcommands/internal/components/controller/ComponentController.kt b/BotCommands-components/src/main/kotlin/io/github/freya022/botcommands/internal/components/controller/ComponentController.kt index b8f9a8808..247c897d5 100644 --- a/BotCommands-components/src/main/kotlin/io/github/freya022/botcommands/internal/components/controller/ComponentController.kt +++ b/BotCommands-components/src/main/kotlin/io/github/freya022/botcommands/internal/components/controller/ComponentController.kt @@ -77,7 +77,7 @@ internal class ComponentController( } } - builder.filters.onEach { filter -> + builder.filters.forEach { filter -> val filterClass = filter.javaClass require(!filter.global) { "Global filter ${filterClass.simpleNestedName} cannot be used explicitly, see ${Filter::global.reference}" diff --git a/BotCommands-components/src/main/kotlin/io/github/freya022/botcommands/internal/components/controller/ComponentsListener.kt b/BotCommands-components/src/main/kotlin/io/github/freya022/botcommands/internal/components/controller/ComponentsListener.kt index 21101def4..743f7d3e7 100644 --- a/BotCommands-components/src/main/kotlin/io/github/freya022/botcommands/internal/components/controller/ComponentsListener.kt +++ b/BotCommands-components/src/main/kotlin/io/github/freya022/botcommands/internal/components/controller/ComponentsListener.kt @@ -79,7 +79,7 @@ internal class ComponentsListener( return event.reply(messagesFactory.get(event).componentNotAllowed(event)).setEphemeral(true).queue() } - component.filters.onEach { filter -> + component.filters.forEach { filter -> require(!filter.global) { "Global filter ${filter.javaClass.simpleNestedName} cannot be used explicitly, see ${Filter::global.reference}" } diff --git a/BotCommands-components/src/main/kotlin/io/github/freya022/botcommands/internal/components/ratelimit/ComponentRateLimitHandler.kt b/BotCommands-components/src/main/kotlin/io/github/freya022/botcommands/internal/components/ratelimit/ComponentRateLimitHandler.kt index 8e4353849..3b497f77c 100644 --- a/BotCommands-components/src/main/kotlin/io/github/freya022/botcommands/internal/components/ratelimit/ComponentRateLimitHandler.kt +++ b/BotCommands-components/src/main/kotlin/io/github/freya022/botcommands/internal/components/ratelimit/ComponentRateLimitHandler.kt @@ -33,12 +33,12 @@ internal class ComponentRateLimitHandler internal constructor( internal suspend fun tryRun(component: ActionComponentData, event: GenericComponentInteractionCreateEvent, block: suspend (CancellableRateLimit) -> Boolean) { val rateLimitReference = component.rateLimitReference if (rateLimitReference == null) { - block(NullCancellableRateLimit) + val _ = block(NullCancellableRateLimit) return } if (enableOwnerBypass && event.user in botOwners) { - block(NullCancellableRateLimit) + val _ = block(NullCancellableRateLimit) return } diff --git a/BotCommands-core/build.gradle.kts b/BotCommands-core/build.gradle.kts index 60bebb8ab..1d3d84fde 100644 --- a/BotCommands-core/build.gradle.kts +++ b/BotCommands-core/build.gradle.kts @@ -136,10 +136,6 @@ dokka { kotlin { compilerOptions { - freeCompilerArgs.addAll( - "-Xcontext-parameters", - ) - optIn.addAll( "io.github.freya022.botcommands.api.core.annotations.ExperimentalCoreApi" ) diff --git a/BotCommands-modals/build.gradle.kts b/BotCommands-modals/build.gradle.kts index 09dd87c2b..5bb4538c7 100644 --- a/BotCommands-modals/build.gradle.kts +++ b/BotCommands-modals/build.gradle.kts @@ -52,14 +52,6 @@ dependencies { configureTests(libs.bytebuddy.agent) -kotlin { - compilerOptions { - freeCompilerArgs.addAll( - "-Xcontext-parameters", - ) - } -} - publishedProjectEnvironment { configureJarArtifact( artifactId = "BotCommands-modals", diff --git a/BotCommands-restarter/src/main/kotlin/dev/freya02/botcommands/restarter/internal/watcher/ClasspathWatcher.kt b/BotCommands-restarter/src/main/kotlin/dev/freya02/botcommands/restarter/internal/watcher/ClasspathWatcher.kt index 800c150e5..00321582f 100644 --- a/BotCommands-restarter/src/main/kotlin/dev/freya02/botcommands/restarter/internal/watcher/ClasspathWatcher.kt +++ b/BotCommands-restarter/src/main/kotlin/dev/freya02/botcommands/restarter/internal/watcher/ClasspathWatcher.kt @@ -46,7 +46,7 @@ internal class ClasspathWatcher private constructor() { registerDirectories(classRoot) } - thread(name = "Classpath watcher", isDaemon = true) { + val _ = thread(name = "Classpath watcher", isDaemon = true) { while (true) { val key = try { watchService.take() // Wait for a change diff --git a/BotCommands-typesafe-messages/core/build.gradle.kts b/BotCommands-typesafe-messages/core/build.gradle.kts index 872105ec2..bc2d11590 100644 --- a/BotCommands-typesafe-messages/core/build.gradle.kts +++ b/BotCommands-typesafe-messages/core/build.gradle.kts @@ -35,9 +35,6 @@ setMainJvmTarget(target = 24) kotlin { compilerOptions { optIn.add("dev.freya02.botcommands.typesafe.messages.api.annotations.ExperimentalTypesafeMessagesApi") - freeCompilerArgs.addAll( - "-Xcontext-parameters", - ) } } diff --git a/build.gradle.kts b/build.gradle.kts index 50d4e6d59..71529c3ed 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -62,14 +62,6 @@ tasks.withType { useJUnitPlatform() } -kotlin { - compilerOptions { - freeCompilerArgs.addAll( - "-Xcontext-parameters", - ) - } -} - publishedProjectEnvironment { configureArtifact( artifactId = "BotCommands", diff --git a/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts b/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts index 90b2598ba..82e321e41 100644 --- a/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts @@ -14,7 +14,8 @@ kotlin { freeCompilerArgs.addAll( "-Xjsr305=strict", "-Xconsistent-data-class-copy-visibility", - "-Xwarning-level=PLATFORM_CLASS_MAPPED_TO_KOTLIN:disabled" + "-Xwarning-level=PLATFORM_CLASS_MAPPED_TO_KOTLIN:disabled", + "-Xreturn-value-checker=check", ) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e12f7da06..a0be4ec8a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,7 +16,7 @@ jetbrains-annotations = "26.0.2" jsr305 = "3.0.2" junit = "6.0.1" konsist = "0.17.3" -kotlin = "2.3.20" +kotlin = "2.4.0" kotlin-logging = "7.0.3" kotlinx-coroutines = "1.11.0" kotlinx-serialization = "1.11.0" diff --git a/src/test/kotlin/io/github/freya022/botcommands/arch/JavaInteropTest.kt b/src/test/kotlin/io/github/freya022/botcommands/arch/JavaInteropTest.kt index 1472779c9..b47ae2e75 100644 --- a/src/test/kotlin/io/github/freya022/botcommands/arch/JavaInteropTest.kt +++ b/src/test/kotlin/io/github/freya022/botcommands/arch/JavaInteropTest.kt @@ -202,7 +202,7 @@ class JavaInteropTest { private val KType.jvmErasureOrNull: KClass<*>? get() { - classifier ?: return null + if (classifier == null) return null return jvmErasure } diff --git a/test-bot/build.gradle.kts b/test-bot/build.gradle.kts index 885537204..579c3b1db 100644 --- a/test-bot/build.gradle.kts +++ b/test-bot/build.gradle.kts @@ -63,7 +63,7 @@ tasks.withType { kotlin { compilerOptions { freeCompilerArgs.addAll( - "-Xcontext-parameters", + "-Xcollection-literals", ) } } diff --git a/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/message/MessageContextGetJson.kt b/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/message/MessageContextGetJson.kt index e217a477a..5da9ecd7d 100644 --- a/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/message/MessageContextGetJson.kt +++ b/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/message/MessageContextGetJson.kt @@ -32,6 +32,6 @@ class MessageContextGetJson { val messageObject = DataPath.getObject(dataObject, "d.data.resolved.messages").getObject(message.id) val upload = FileUpload.fromData(messageObject.toPrettyString().encodeToByteArray(), "message-${message.id}.json") - event.reply_(files = listOf(upload), ephemeral = true).await() + event.reply_(files = [upload], ephemeral = true).await() } } diff --git a/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashAggregate.kt b/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashAggregate.kt index ecc594d11..a7a5cbd45 100644 --- a/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashAggregate.kt +++ b/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashAggregate.kt @@ -63,7 +63,7 @@ class SlashAggregate : GlobalApplicationCommandProvider, AutocompleteHandlerProv this.showUserInput = false caffeineCache { - compositeKeys = listOf("string", "nested_double") + compositeKeys = ["string", "nested_double"] } } } diff --git a/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashComponentsV2.kt b/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashComponentsV2.kt index 28bf89eeb..4c427c81f 100644 --- a/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashComponentsV2.kt +++ b/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashComponentsV2.kt @@ -54,7 +54,7 @@ class SlashComponentsV2( accessory = buttons.success("Button in a section").ephemeral { bindTo { buttonEvent -> buttonEvent.reply_( - components = listOf(TextDisplay("My reference ID is ${buttonEvent.component.uniqueId}")), + components = [TextDisplay("My reference ID is ${buttonEvent.component.uniqueId}")], useComponentsV2 = true, ephemeral = true, ).await() diff --git a/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashInteractionMetadata.kt b/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashInteractionMetadata.kt index 745264829..47c968d4a 100644 --- a/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashInteractionMetadata.kt +++ b/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashInteractionMetadata.kt @@ -35,7 +35,7 @@ class SlashInteractionMetadata( it.hook.sendMessage("Followup from button").queue() } } - event.reply_("Message from slash command", components = listOf(row(modalButton, messageButton)), ephemeral = true).queue() + event.reply_("Message from slash command", components = [row(modalButton, messageButton)], ephemeral = true).queue() val buttonEvent = modalButton.await() val modal = modals.create("Interaction metadata") { diff --git a/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashModal.kt b/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashModal.kt index 0449d8a84..b1ee3fca9 100644 --- a/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashModal.kt +++ b/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashModal.kt @@ -120,9 +120,9 @@ class SlashModal(private val buttons: Buttons) : GlobalApplicationCommandProvide definitelyNull: $definitelyNull customObject: $customObject """.trimIndent(), - components = listOf(row(buttons.primary("Test button").ephemeral { + components = [row(buttons.primary("Test button").ephemeral { bindTo(::handleButton) - })), + })], ephemeral = true ).queue() } diff --git a/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashMyCommand.kt b/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashMyCommand.kt index f257b6a0c..2fb0a5fc7 100644 --- a/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashMyCommand.kt +++ b/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashMyCommand.kt @@ -99,7 +99,7 @@ class SlashMyCommand : GlobalApplicationCommandProvider, SlashOptionChoiceProvid option("stringOption", "string") { description = "Option description" - choices = listOf(Choice("a", "a"), Choice("b", "b"), Choice("c", "c")) + choices = [Choice("a", "a"), Choice("b", "b"), Choice("c", "c")] } option("intOption", "int") { @@ -107,7 +107,7 @@ class SlashMyCommand : GlobalApplicationCommandProvider, SlashOptionChoiceProvid valueRange = 1 range 2 - choices = listOf(Choice("1", 1L), Choice("2", 2L)) + choices = [Choice("1", 1L), Choice("2", 2L)] } option("doubleOption", "double") { diff --git a/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashPagination.kt b/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashPagination.kt index b25b3f42e..b81609c07 100644 --- a/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashPagination.kt +++ b/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashPagination.kt @@ -35,7 +35,7 @@ private val logger = KotlinLogging.logger { } @Command @RequiresComponents class SlashPagination(private val paginators: Paginators, private val buttons: Buttons) { - private val menuEntries = listOf("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve") + private val menuEntries = ["One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve"] init { Paginator.Defaults.firstPageButtonContent = ButtonContent.fromLabel(ButtonStyle.SECONDARY, "[Default] First") diff --git a/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashResolveMentions.kt b/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashResolveMentions.kt index 7022c4c64..b0a2dfad5 100644 --- a/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashResolveMentions.kt +++ b/test-bot/src/test/kotlin/dev/freya02/botcommands/bot/commands/slash/SlashResolveMentions.kt @@ -36,7 +36,7 @@ class SlashResolveMentions(private val buttons: Buttons) { } event.reply_( "${forumChannel.asMention} ${threadChannel.asMention} ${archivedThreadChannel.asMention}", - components = listOf(row(button1, button2)), + components = [row(button1, button2)], ephemeral = true ).await() } diff --git a/test-commons/src/main/kotlin/dev/freya02/botcommands/helpers/AbstractMessagesTests.kt b/test-commons/src/main/kotlin/dev/freya02/botcommands/helpers/AbstractMessagesTests.kt index ed3b77d22..6ce0033e4 100644 --- a/test-commons/src/main/kotlin/dev/freya02/botcommands/helpers/AbstractMessagesTests.kt +++ b/test-commons/src/main/kotlin/dev/freya02/botcommands/helpers/AbstractMessagesTests.kt @@ -35,8 +35,8 @@ abstract class AbstractMessagesTests : AbstractIntegrationTest() { protected fun > methodCall( callableRef: F, - executor: F.() -> Unit, + executor: F.() -> MessageCreateData, ): Pair Unit> { - return callableRef.name to { executor(callableRef) } + return callableRef.name to { val _ = executor(callableRef) } } }