From 7e9ae30de3b5643a2ba364e9e80c34c95c8053cd Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Fri, 24 Feb 2023 16:50:33 +0100 Subject: [PATCH 001/136] A lot of MPP --- buildSrc/src/main/kotlin/Compiler.kt | 25 ++- .../kord-multiplatform-module.gradle.kts | 42 +++++ common/build.gradle.kts | 67 ++++++-- .../src/{main => commonMain}/kotlin/Color.kt | 1 - .../kotlin/DiscordBitSet.kt | 18 ++- .../kotlin/DiscordTimestamp.kt | 0 .../kotlin/KordConfiguration.kt | 0 .../kotlin/KordConstants.kt | 0 .../src/{main => commonMain}/kotlin/Locale.kt | 12 -- .../kotlin/annotation/Annotations.kt | 13 +- .../kotlin/entity/AuditLog.kt | 147 ++++++++++-------- .../kotlin/entity/AutoModeration.kt | 0 .../kotlin/entity/Data.kt | 0 .../kotlin/entity/DiscordActivity.kt | 5 +- .../kotlin/entity/DiscordApplication.kt | 1 + .../kotlin/entity/DiscordChannel.kt | 0 .../kotlin/entity/DiscordComponent.kt | 0 .../kotlin/entity/DiscordConnection.kt | 0 .../kotlin/entity/DiscordEmoji.kt | 0 .../kotlin/entity/DiscordGuild.kt | 0 .../kotlin/entity/DiscordGuildPreview.kt | 0 .../entity/DiscordGuildScheduledEvent.kt | 0 .../kotlin/entity/DiscordGuildWidget.kt | 0 .../kotlin/entity/DiscordIntegration.kt | 0 .../kotlin/entity/DiscordInvite.kt | 0 .../kotlin/entity/DiscordMessage.kt | 1 + .../kotlin/entity/DiscordNull.kt | 0 .../kotlin/entity/DiscordRole.kt | 0 .../kotlin/entity/DiscordSelectOption.kt | 0 .../kotlin/entity/DiscordShard.kt | 0 .../kotlin/entity/DiscordStageInstance.kt | 0 .../kotlin/entity/DiscordTemplate.kt | 0 .../kotlin/entity/DiscordUser.kt | 0 .../kotlin/entity/DiscordWebhook.kt | 0 .../kotlin/entity/Interactions.kt | 1 + .../kotlin/entity/Member.kt | 0 .../kotlin/entity/Permission.kt | 1 + .../kotlin/entity/Presence.kt | 0 .../kotlin/entity/Snowflake.kt | 0 .../kotlin/entity/Team.kt | 0 .../kotlin/entity/optional/Optional.kt | 5 + .../kotlin/entity/optional/OptionalBoolean.kt | 0 .../kotlin/entity/optional/OptionalInt.kt | 0 .../kotlin/entity/optional/OptionalLong.kt | 0 .../entity/optional/OptionalSnowflake.kt | 2 + .../delegate/OptionalBooleanDelegate.kt | 1 + .../optional/delegate/OptionalDelegate.kt | 3 + .../optional/delegate/OptionalIntDelegate.kt | 3 + .../optional/delegate/OptionalLongDelegate.kt | 1 + .../delegate/OptionalSnowflakeDelegate.kt | 1 + .../kotlin/exception/RequestException.kt | 0 .../ratelimit/AbstractIntervalRateLimiter.kt | 0 .../ratelimit/ClockIntervalRateLimiter.kt | 0 .../kotlin/ratelimit/RateLimiter.kt | 0 .../TimeSourceIntervalRateLimiter.kt | 0 .../serialization/DurationSerializers.kt | 0 .../serialization/InstantSerializers.kt | 1 - .../serialization/LongOrStringSerializer.kt | 0 .../kotlin/BitSetTests.kt | 10 ++ .../{test => commonTest}/kotlin/ColorTests.kt | 23 ++- .../{test => commonTest}/kotlin/FixedClock.kt | 2 + .../{test => commonTest}/kotlin/LocaleTest.kt | 5 + .../kotlin/entity/SnowflakeTest.kt | 12 ++ .../entity/optional/OptionalBooleanTest.kt | 25 +-- .../kotlin/entity/optional/OptionalIntTest.kt | 22 +-- .../entity/optional/OptionalLongTest.kt | 22 +-- .../entity/optional/OptionalSnowflakeTest.kt | 29 ++-- .../kotlin/entity/optional/OptionalTest.kt | 39 +++-- common/src/commonTest/kotlin/file.kt | 3 + .../kotlin/json/ChannelTest.kt | 28 ++-- .../kotlin/json/EmojiTest.kt | 20 +-- .../kotlin/json/GuildTest.kt | 23 +-- .../kotlin/json/InteractionTest.kt | 37 +++-- .../kotlin/json/MessageTest.kt | 17 +- .../kotlin/json/PermissionsTest.kt | 15 +- .../kotlin/json/UserTest.kt | 13 +- common/src/commonTest/kotlin/json/Util.kt | 53 +++++++ .../kotlin/json/VoiceStateTest.kt | 13 +- .../AbstractIntervalRateLimiterTest.kt | 6 +- .../ratelimit/ClockIntervalRateLimiterTest.kt | 6 +- .../TimeSourceIntervalRateLimiterTest.kt | 4 +- .../serialization/DurationSerializersTests.kt | 14 ++ .../serialization/InstantSerializersTests.kt | 13 ++ .../json/channel/channelcategory.json | 0 .../resources/json/channel/dmchannel.json | 0 .../json/channel/groupdmchannel.json | 0 .../json/channel/guildnewschannel.json | 0 .../json/channel/guildtextchannel.json | 0 .../json/channel/guildvoicechannel.json | 0 .../resources/json/emoji/customemoji.json | 0 .../resources/json/emoji/emoji.json | 0 .../resources/json/emoji/standardemoji.json | 0 .../resources/json/guild/guild.json | 0 .../resources/json/guild/guildmember.json | 0 .../resources/json/guild/partialguild.json | 0 .../json/guild/unavailableguild.json | 0 .../json/interaction/groupsubcommand.json | 0 .../json/interaction/rootcommand.json | 0 .../json/interaction/selectmenu.json | 0 .../slash_command_permissions_update.json | 0 .../json/interaction/subcommand.json | 0 .../resources/json/message/crossposted.json | 0 .../resources/json/message/message.json | 0 .../resources/json/user/user.json | 0 .../resources/json/voice/voicestate.json | 0 common/src/jsTest/kotlin/file.kt | 7 + common/src/jvmMain/kotlin/Color.kt | 7 + common/src/jvmMain/kotlin/Locale.kt | 15 ++ common/src/jvmTest/kotlin/ColorTests.kt | 15 ++ common/src/jvmTest/kotlin/file.kt | 4 + common/src/test/kotlin/json/Util.kt | 69 -------- gradle/libs.versions.toml | 11 +- ksp-annotations/build.gradle.kts | 2 +- .../kotlin/GenerateKordEnum.kt | 0 ksp-processors/src/main/kotlin/KSPUtils.kt | 17 +- .../src/main/kotlin/kordenum/KordEnum.kt | 47 +++--- 116 files changed, 637 insertions(+), 362 deletions(-) create mode 100644 buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts rename common/src/{main => commonMain}/kotlin/Color.kt (97%) rename common/src/{main => commonMain}/kotlin/DiscordBitSet.kt (90%) rename common/src/{main => commonMain}/kotlin/DiscordTimestamp.kt (100%) rename common/src/{main => commonMain}/kotlin/KordConfiguration.kt (100%) rename common/src/{main => commonMain}/kotlin/KordConstants.kt (100%) rename common/src/{main => commonMain}/kotlin/Locale.kt (95%) rename common/src/{main => commonMain}/kotlin/annotation/Annotations.kt (94%) rename common/src/{main => commonMain}/kotlin/entity/AuditLog.kt (83%) rename common/src/{main => commonMain}/kotlin/entity/AutoModeration.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/Data.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordActivity.kt (98%) rename common/src/{main => commonMain}/kotlin/entity/DiscordApplication.kt (99%) rename common/src/{main => commonMain}/kotlin/entity/DiscordChannel.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordComponent.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordConnection.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordEmoji.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordGuild.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordGuildPreview.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordGuildScheduledEvent.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordGuildWidget.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordIntegration.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordInvite.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordMessage.kt (99%) rename common/src/{main => commonMain}/kotlin/entity/DiscordNull.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordRole.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordSelectOption.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordShard.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordStageInstance.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordTemplate.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordUser.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/DiscordWebhook.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/Interactions.kt (99%) rename common/src/{main => commonMain}/kotlin/entity/Member.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/Permission.kt (99%) rename common/src/{main => commonMain}/kotlin/entity/Presence.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/Snowflake.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/Team.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/optional/Optional.kt (98%) rename common/src/{main => commonMain}/kotlin/entity/optional/OptionalBoolean.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/optional/OptionalInt.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/optional/OptionalLong.kt (100%) rename common/src/{main => commonMain}/kotlin/entity/optional/OptionalSnowflake.kt (98%) rename common/src/{main => commonMain}/kotlin/entity/optional/delegate/OptionalBooleanDelegate.kt (98%) rename common/src/{main => commonMain}/kotlin/entity/optional/delegate/OptionalDelegate.kt (95%) rename common/src/{main => commonMain}/kotlin/entity/optional/delegate/OptionalIntDelegate.kt (94%) rename common/src/{main => commonMain}/kotlin/entity/optional/delegate/OptionalLongDelegate.kt (98%) rename common/src/{main => commonMain}/kotlin/entity/optional/delegate/OptionalSnowflakeDelegate.kt (98%) rename common/src/{main => commonMain}/kotlin/exception/RequestException.kt (100%) rename common/src/{main => commonMain}/kotlin/ratelimit/AbstractIntervalRateLimiter.kt (100%) rename common/src/{main => commonMain}/kotlin/ratelimit/ClockIntervalRateLimiter.kt (100%) rename common/src/{main => commonMain}/kotlin/ratelimit/RateLimiter.kt (100%) rename common/src/{main => commonMain}/kotlin/ratelimit/TimeSourceIntervalRateLimiter.kt (100%) rename common/src/{main => commonMain}/kotlin/serialization/DurationSerializers.kt (100%) rename common/src/{main => commonMain}/kotlin/serialization/InstantSerializers.kt (98%) rename common/src/{main => commonMain}/kotlin/serialization/LongOrStringSerializer.kt (100%) rename common/src/{test => commonTest}/kotlin/BitSetTests.kt (91%) rename common/src/{test => commonTest}/kotlin/ColorTests.kt (61%) rename common/src/{test => commonTest}/kotlin/FixedClock.kt (90%) rename common/src/{test => commonTest}/kotlin/LocaleTest.kt (95%) rename common/src/{test => commonTest}/kotlin/entity/SnowflakeTest.kt (94%) rename common/src/{test => commonTest}/kotlin/entity/optional/OptionalBooleanTest.kt (71%) rename common/src/{test => commonTest}/kotlin/entity/optional/OptionalIntTest.kt (73%) rename common/src/{test => commonTest}/kotlin/entity/optional/OptionalLongTest.kt (73%) rename common/src/{test => commonTest}/kotlin/entity/optional/OptionalSnowflakeTest.kt (65%) rename common/src/{test => commonTest}/kotlin/entity/optional/OptionalTest.kt (71%) create mode 100644 common/src/commonTest/kotlin/file.kt rename common/src/{test => commonTest}/kotlin/json/ChannelTest.kt (87%) rename common/src/{test => commonTest}/kotlin/json/EmojiTest.kt (75%) rename common/src/{test => commonTest}/kotlin/json/GuildTest.kt (87%) rename common/src/{test => commonTest}/kotlin/json/InteractionTest.kt (84%) rename common/src/{test => commonTest}/kotlin/json/MessageTest.kt (90%) rename common/src/{test => commonTest}/kotlin/json/PermissionsTest.kt (82%) rename common/src/{test => commonTest}/kotlin/json/UserTest.kt (72%) create mode 100644 common/src/commonTest/kotlin/json/Util.kt rename common/src/{test => commonTest}/kotlin/json/VoiceStateTest.kt (74%) rename common/src/{test => commonTest}/kotlin/ratelimit/AbstractIntervalRateLimiterTest.kt (94%) rename common/src/{test => commonTest}/kotlin/ratelimit/ClockIntervalRateLimiterTest.kt (70%) rename common/src/{test => commonTest}/kotlin/ratelimit/TimeSourceIntervalRateLimiterTest.kt (72%) rename common/src/{test => commonTest}/kotlin/serialization/DurationSerializersTests.kt (95%) rename common/src/{test => commonTest}/kotlin/serialization/InstantSerializersTests.kt (92%) rename common/src/{test => commonTest}/resources/json/channel/channelcategory.json (100%) rename common/src/{test => commonTest}/resources/json/channel/dmchannel.json (100%) rename common/src/{test => commonTest}/resources/json/channel/groupdmchannel.json (100%) rename common/src/{test => commonTest}/resources/json/channel/guildnewschannel.json (100%) rename common/src/{test => commonTest}/resources/json/channel/guildtextchannel.json (100%) rename common/src/{test => commonTest}/resources/json/channel/guildvoicechannel.json (100%) rename common/src/{test => commonTest}/resources/json/emoji/customemoji.json (100%) rename common/src/{test => commonTest}/resources/json/emoji/emoji.json (100%) rename common/src/{test => commonTest}/resources/json/emoji/standardemoji.json (100%) rename common/src/{test => commonTest}/resources/json/guild/guild.json (100%) rename common/src/{test => commonTest}/resources/json/guild/guildmember.json (100%) rename common/src/{test => commonTest}/resources/json/guild/partialguild.json (100%) rename common/src/{test => commonTest}/resources/json/guild/unavailableguild.json (100%) rename common/src/{test => commonTest}/resources/json/interaction/groupsubcommand.json (100%) rename common/src/{test => commonTest}/resources/json/interaction/rootcommand.json (100%) rename common/src/{test => commonTest}/resources/json/interaction/selectmenu.json (100%) rename common/src/{test => commonTest}/resources/json/interaction/slash_command_permissions_update.json (100%) rename common/src/{test => commonTest}/resources/json/interaction/subcommand.json (100%) rename common/src/{test => commonTest}/resources/json/message/crossposted.json (100%) rename common/src/{test => commonTest}/resources/json/message/message.json (100%) rename common/src/{test => commonTest}/resources/json/user/user.json (100%) rename common/src/{test => commonTest}/resources/json/voice/voicestate.json (100%) create mode 100644 common/src/jsTest/kotlin/file.kt create mode 100644 common/src/jvmMain/kotlin/Color.kt create mode 100644 common/src/jvmMain/kotlin/Locale.kt create mode 100644 common/src/jvmTest/kotlin/ColorTests.kt create mode 100644 common/src/jvmTest/kotlin/file.kt delete mode 100644 common/src/test/kotlin/json/Util.kt rename ksp-annotations/src/{main => commonMain}/kotlin/GenerateKordEnum.kt (100%) diff --git a/buildSrc/src/main/kotlin/Compiler.kt b/buildSrc/src/main/kotlin/Compiler.kt index 382763bca8c7..5d33eff77e01 100644 --- a/buildSrc/src/main/kotlin/Compiler.kt +++ b/buildSrc/src/main/kotlin/Compiler.kt @@ -1,21 +1,32 @@ -import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions +import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions + +object OptIns { + const val time = "kotlin.time.ExperimentalTime" + const val contracts = "kotlin.contracts.ExperimentalContracts" + + const val kordPreview = "dev.kord.common.annotation.KordPreview" + const val kordExperimental = "dev.kord.common.annotation.KordExperimental" + const val kordVoice = "dev.kord.common.annotation.KordVoice" +} object CompilerArguments { - const val time = "-opt-in=kotlin.time.ExperimentalTime" - const val contracts = "-opt-in=kotlin.contracts.ExperimentalContracts" + val time = OptIns.time.asOptIn() + val contracts = OptIns.contracts.asOptIn() - const val kordPreview = "-opt-in=dev.kord.common.annotation.KordPreview" - const val kordExperimental = "-opt-in=dev.kord.common.annotation.KordExperimental" - const val kordVoice = "-opt-in=dev.kord.common.annotation.KordVoice" + val kordPreview = OptIns.kordPreview.asOptIn() + val kordExperimental = OptIns.kordExperimental.asOptIn() + val kordVoice = OptIns.kordVoice.asOptIn() const val progressive = "-progressive" } +private fun String.asOptIn() = "-opt-in=$this" + object Jvm { const val target = 8 } -fun KotlinJvmCompilerOptions.applyKordCompilerOptions() { +fun KotlinCommonCompilerOptions.applyKordCompilerOptions() { allWarningsAsErrors.set(true) freeCompilerArgs.add(CompilerArguments.progressive) } diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts new file mode 100644 index 000000000000..9f5403e42328 --- /dev/null +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -0,0 +1,42 @@ +import gradle.kotlin.dsl.accessors._e5121a5856746b077c6819bbe5a86a2f.main + +plugins { + org.jetbrains.kotlin.multiplatform + org.jetbrains.kotlin.plugin.serialization + org.jetbrains.dokka + `kotlinx-atomicfu` + org.jetbrains.kotlinx.`binary-compatibility-validator` + com.google.devtools.ksp +} + +repositories { + mavenCentral() +} + +kotlin { + jvm() + js(IR) { + nodejs() + } + jvmToolchain(Jvm.target) + + targets { + all { + compilations.all { + compilerOptions.options.applyKordCompilerOptions() + } + } + } + + sourceSets { + all { + if ("Test" in name) { + languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") + } + } + commonMain { + // mark ksp src dir + kotlin.srcDir("build/generated/ksp/main/kotlin") + } + } +} diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 270b4b897d91..b21bf6c93922 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,22 +1,65 @@ @Suppress("DSL_SCOPE_VIOLATION") // false positive for `libs` in IntelliJ plugins { - `kord-module` - `kord-sampled-module` - `kord-publishing` + `kord-multiplatform-module` + `kotlinx-atomicfu` + `kotlinx-serialization` alias(libs.plugins.buildconfig) } -dependencies { - api(libs.kotlinx.coroutines.core) - api(libs.kotlinx.serialization.json) - api(libs.kotlinx.datetime) - api(libs.kotlin.logging) +kotlin { + explicitApi() + + sourceSets { + all { + languageSettings { + listOf( + OptIns.time, + OptIns.contracts, + OptIns.kordPreview, + OptIns.kordExperimental, + OptIns.kordVoice, + ).forEach(::optIn) + } + } + commonMain { + dependencies { + api(libs.kotlinx.coroutines.core) + api(libs.kotlinx.serialization.json) + api(libs.kotlinx.datetime) + api(libs.kotlin.logging) + api(libs.bignum) + // Replacement for java.io + api(libs.ktor.utils) + + compileOnly(projects.kspAnnotations) + // The plugin should add this automatically, but it doesn't + compileOnly(libs.kotlinx.atomicfu) + } + } - compileOnly(projects.kspAnnotations) - ksp(projects.kspProcessors) + commonTest { + dependencies { + implementation(libs.bundles.test.common) + } + } + jvmTest { + dependencies { + runtimeOnly(libs.bundles.test.runtime) + implementation(libs.bundles.test.implementation) + implementation(libs.bundles.test.common) + } + } + jsTest { + dependencies { + implementation(libs.kotlin.test.js) + implementation(libs.kotlinx.nodejs) + } + } + } +} - testImplementation(libs.bundles.test.implementation) - testRuntimeOnly(libs.bundles.test.runtime) +dependencies { + kspCommonMainMetadata(projects.kspProcessors) } /* diff --git a/common/src/main/kotlin/Color.kt b/common/src/commonMain/kotlin/Color.kt similarity index 97% rename from common/src/main/kotlin/Color.kt rename to common/src/commonMain/kotlin/Color.kt index c45381954b26..fbc6fa790919 100644 --- a/common/src/main/kotlin/Color.kt +++ b/common/src/commonMain/kotlin/Color.kt @@ -61,4 +61,3 @@ private fun rgb(red: Int, green: Int, blue: Int): Int { (blue and 0xFF) shl 0 } -public val java.awt.Color.kColor: Color get() = Color(rgb) diff --git a/common/src/main/kotlin/DiscordBitSet.kt b/common/src/commonMain/kotlin/DiscordBitSet.kt similarity index 90% rename from common/src/main/kotlin/DiscordBitSet.kt rename to common/src/commonMain/kotlin/DiscordBitSet.kt index 17ebcffb2c44..594ecafb76f5 100644 --- a/common/src/main/kotlin/DiscordBitSet.kt +++ b/common/src/commonMain/kotlin/DiscordBitSet.kt @@ -1,5 +1,11 @@ package dev.kord.common +import com.ionspin.kotlin.bignum.integer.BigInteger +import com.ionspin.kotlin.bignum.integer.Sign +import io.ktor.utils.io.bits.* +import io.ktor.utils.io.core.* +import io.ktor.utils.io.core.internal.* +import io.ktor.utils.io.pool.* import kotlinx.serialization.KSerializer import kotlinx.serialization.Serializable import kotlinx.serialization.descriptors.PrimitiveKind @@ -7,8 +13,6 @@ import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -import java.math.BigInteger -import java.nio.ByteBuffer import kotlin.math.max import kotlin.math.min @@ -27,9 +31,11 @@ public class DiscordBitSet(internal var data: LongArray) { // data is in little- public val value: String get() { // need to convert from little-endian data to big-endian expected by BigInteger - val buffer = ByteBuffer.allocate(data.size * Long.SIZE_BYTES) - buffer.asLongBuffer().put(data.reversedArray()) - return BigInteger(buffer.array()).toString() + val buffer = withBuffer(data.size * Long.SIZE_BYTES) { + writeFully(data.reversedArray()) + this.readBytes() + } + return BigInteger.fromByteArray(buffer, Sign.POSITIVE).toString() } public val size: Int @@ -128,7 +134,7 @@ public fun DiscordBitSet(value: String): DiscordBitSet { return DiscordBitSet(longArrayOf(value.toULong().toLong())) } - val bytes = BigInteger(value).toByteArray() + val bytes = BigInteger.parseString(value, 10).toByteArray() val longSize = (bytes.size / Long.SIZE_BYTES) + 1 val destination = LongArray(longSize) diff --git a/common/src/main/kotlin/DiscordTimestamp.kt b/common/src/commonMain/kotlin/DiscordTimestamp.kt similarity index 100% rename from common/src/main/kotlin/DiscordTimestamp.kt rename to common/src/commonMain/kotlin/DiscordTimestamp.kt diff --git a/common/src/main/kotlin/KordConfiguration.kt b/common/src/commonMain/kotlin/KordConfiguration.kt similarity index 100% rename from common/src/main/kotlin/KordConfiguration.kt rename to common/src/commonMain/kotlin/KordConfiguration.kt diff --git a/common/src/main/kotlin/KordConstants.kt b/common/src/commonMain/kotlin/KordConstants.kt similarity index 100% rename from common/src/main/kotlin/KordConstants.kt rename to common/src/commonMain/kotlin/KordConstants.kt diff --git a/common/src/main/kotlin/Locale.kt b/common/src/commonMain/kotlin/Locale.kt similarity index 95% rename from common/src/main/kotlin/Locale.kt rename to common/src/commonMain/kotlin/Locale.kt index 63e922ddb2ed..9b45e530cdd8 100644 --- a/common/src/main/kotlin/Locale.kt +++ b/common/src/commonMain/kotlin/Locale.kt @@ -7,7 +7,6 @@ import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -import java.util.Locale as JLocale /** * Representation of a locale [supported by Discord](https://discord.com/developers/docs/reference#locales). @@ -17,11 +16,6 @@ import java.util.Locale as JLocale */ @Serializable(with = Locale.Serializer::class) public data class Locale(val language: String, val country: String? = null) { - /** - * Converts this into a [JLocale]. - */ - public fun asJavaLocale(): JLocale = JLocale(language, country ?: "") - public companion object { /** @@ -247,9 +241,3 @@ public data class Locale(val language: String, val country: String? = null) { override fun deserialize(decoder: Decoder): Locale = fromString(decoder.decodeString()) } } - -/** - * Converts this into a [Locale]. - */ -public val JLocale.kLocale: Locale - get() = Locale(language, country.ifBlank { null }) diff --git a/common/src/main/kotlin/annotation/Annotations.kt b/common/src/commonMain/kotlin/annotation/Annotations.kt similarity index 94% rename from common/src/main/kotlin/annotation/Annotations.kt rename to common/src/commonMain/kotlin/annotation/Annotations.kt index ee5107389a4b..202fb4cb5edd 100644 --- a/common/src/main/kotlin/annotation/Annotations.kt +++ b/common/src/commonMain/kotlin/annotation/Annotations.kt @@ -1,12 +1,13 @@ package dev.kord.common.annotation import kotlin.RequiresOptIn.Level.WARNING +import kotlin.annotation.AnnotationRetention.BINARY import kotlin.annotation.AnnotationRetention.RUNTIME import kotlin.annotation.AnnotationTarget.* /** [DslMarker] for Kord DSLs. */ @DslMarker -@Retention(RUNTIME) +@Retention(BINARY) @Target(CLASS) public annotation class KordDsl @@ -20,7 +21,7 @@ public annotation class KordDsl */ @MustBeDocumented @RequiresOptIn(level = WARNING) -@Retention(RUNTIME) +@Retention(BINARY) @Target(CLASS, PROPERTY, CONSTRUCTOR, FUNCTION, TYPEALIAS) public annotation class KordPreview @@ -35,7 +36,7 @@ public annotation class KordPreview */ @MustBeDocumented @RequiresOptIn(level = WARNING) -@Retention(RUNTIME) +@Retention(BINARY) @Target(CLASS, PROPERTY, FUNCTION, TYPEALIAS) public annotation class KordExperimental @@ -50,7 +51,7 @@ public annotation class KordExperimental */ @MustBeDocumented @RequiresOptIn(level = WARNING) -@Retention(RUNTIME) +@Retention(BINARY) @Target(CLASS, PROPERTY, FUNCTION, TYPEALIAS) public annotation class KordVoice @@ -66,7 +67,7 @@ public annotation class KordVoice */ @MustBeDocumented @RequiresOptIn("This API is potentially unsafe.", level = WARNING) -@Retention(RUNTIME) +@Retention(BINARY) @Target(CLASS, PROPERTY, FUNCTION, PROPERTY_SETTER, TYPEALIAS) public annotation class KordUnsafe @@ -76,6 +77,6 @@ public annotation class KordUnsafe * These declarations must also be annotated with [Deprecated]. */ @MustBeDocumented -@Retention(RUNTIME) +@Retention(BINARY) @Target(CLASS, ANNOTATION_CLASS, PROPERTY, CONSTRUCTOR, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER, TYPEALIAS) public annotation class DeprecatedSinceKord(val version: String) diff --git a/common/src/main/kotlin/entity/AuditLog.kt b/common/src/commonMain/kotlin/entity/AuditLog.kt similarity index 83% rename from common/src/main/kotlin/entity/AuditLog.kt rename to common/src/commonMain/kotlin/entity/AuditLog.kt index 5dc4b4365161..50b1c8561be6 100644 --- a/common/src/main/kotlin/entity/AuditLog.kt +++ b/common/src/commonMain/kotlin/entity/AuditLog.kt @@ -39,7 +39,11 @@ Entry("IntegrationDelete", intValue = 82, kDoc = "App was removed from server."), Entry("StageInstanceCreate", intValue = 83, kDoc = "Stage instance was created (stage channel becomes live)."), Entry("StageInstanceUpdate", intValue = 84, kDoc = "Stage instance details were updated."), - Entry("StageInstanceDelete", intValue = 85, kDoc = "Stage instance was deleted (stage channel no longer live)."), + Entry( + "StageInstanceDelete", + intValue = 85, + kDoc = "Stage instance was deleted (stage channel no longer live)." + ), Entry("StickerCreate", intValue = 90, kDoc = "Sticker was created."), Entry("StickerUpdate", intValue = 91, kDoc = "Sticker details were updated."), Entry("StickerDelete", intValue = 92, kDoc = "Sticker was deleted."), @@ -55,7 +59,11 @@ Entry("AutoModerationRuleDelete", intValue = 142, kDoc = "Auto Moderation rule was deleted."), Entry("AutoModerationBlockMessage", intValue = 143, kDoc = "Message was blocked by Auto Moderation."), Entry("AutoModerationFlagToChannel", intValue = 144, kDoc = "Message was flagged by Auto Moderation."), - Entry("AutoModerationUserCommunicationDisabled", intValue = 145, kDoc = "Member was timed out by Auto Moderation."), + Entry( + "AutoModerationUserCommunicationDisabled", + intValue = 145, + kDoc = "Member was timed out by Auto Moderation." + ), ], ) @@ -72,6 +80,7 @@ import dev.kord.ksp.GenerateKordEnum.Entry import dev.kord.ksp.GenerateKordEnum.ValueType.INT import kotlinx.datetime.Instant import kotlinx.serialization.* +import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.builtins.serializer import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* @@ -201,6 +210,7 @@ public data class AuditLogChange( index, AuditLogChangeKey.Serializer(Unit.serializer()) ) + CompositeDecoder.DECODE_DONE -> break else -> throw SerializationException("unknown index: $index") } @@ -237,147 +247,156 @@ public sealed class AuditLogChangeKey(public val name: String, public val ser public class Unknown(name: String) : AuditLogChangeKey(name, JsonElement.serializer()) @SerialName("name") - public object Name : AuditLogChangeKey("name", serializer()) + public object Name : AuditLogChangeKey("name", String.serializer()) @SerialName("icon_hash") - public object IconHash : AuditLogChangeKey("icon_hash", serializer()) + public object IconHash : AuditLogChangeKey("icon_hash", String.serializer()) @SerialName("image_hash") - public object ImageHash : AuditLogChangeKey("image_hash", serializer()) + public object ImageHash : AuditLogChangeKey("image_hash", String.serializer()) @SerialName("splash_hash") - public object SplashHash : AuditLogChangeKey("splash_hash", serializer()) + public object SplashHash : AuditLogChangeKey("splash_hash", String.serializer()) @SerialName("owner_id") - public object OwnerId : AuditLogChangeKey("owner_id", serializer()) + public object OwnerId : AuditLogChangeKey("owner_id", Snowflake.serializer()) @SerialName("region") - public object Region : AuditLogChangeKey("region", serializer()) + public object Region : AuditLogChangeKey("region", String.serializer()) @SerialName("afk_channel_id") - public object AfkChannelId : AuditLogChangeKey("afk_channel_id", serializer()) + public object AfkChannelId : AuditLogChangeKey("afk_channel_id", Snowflake.serializer()) @SerialName("afk_timeout") public object AfkTimeout : AuditLogChangeKey("afk_timeout", DurationInSecondsSerializer) @SerialName("mfa_level") - public object MFALevel : AuditLogChangeKey("mfa_level", serializer()) + public object MFALevel : AuditLogChangeKey("mfa_level", CommonMFALevel.serializer()) @SerialName("verification_level") - public object VerificationLevel : AuditLogChangeKey("verification_level", serializer()) + public object VerificationLevel : + AuditLogChangeKey("verification_level", CommonVerificationLevel.serializer()) @SerialName("explicit_content_filter") - public object ExplicitContentFilter : - AuditLogChangeKey("explicit_content_filter", serializer()) + public object ExplicitContentFilter : AuditLogChangeKey( + "explicit_content_filter", + CommonExplicitContentFilter.serializer() + ) @SerialName("default_message_notifications") - public object DefaultMessageNotificationLevel : - AuditLogChangeKey("default_message_notifications", serializer()) + public object DefaultMessageNotificationLevel : AuditLogChangeKey( + "default_message_notifications", + CommonDefaultMessageNotificationLevel.serializer() + ) @SerialName("vanity_url_code") - public object VanityUrlCode : AuditLogChangeKey("vanity_url_code", serializer()) + public object VanityUrlCode : AuditLogChangeKey("vanity_url_code", String.serializer()) @SerialName("\$add") - public object Add : AuditLogChangeKey>("\$add", serializer()) + public object Add : + AuditLogChangeKey>("\$add", ListSerializer(DiscordPartialRole.serializer())) @SerialName("\$remove") - public object Remove : AuditLogChangeKey>("\$remove", serializer()) + public object Remove : + AuditLogChangeKey>("\$remove", ListSerializer(DiscordPartialRole.serializer())) @SerialName("prune_delete_days") - public object PruneDeleteDays : AuditLogChangeKey("prune_delete_days", serializer()) + public object PruneDeleteDays : AuditLogChangeKey("prune_delete_days", Int.serializer()) @SerialName("widget_enabled") - public object WidgetEnabled : AuditLogChangeKey("widget_enabled", serializer()) + public object WidgetEnabled : AuditLogChangeKey("widget_enabled", Boolean.serializer()) @SerialName("widget_channel_id") - public object WidgetChannelId : AuditLogChangeKey("widget_channel_id", serializer()) + public object WidgetChannelId : AuditLogChangeKey("widget_channel_id", Snowflake.serializer()) @SerialName("system_channel_id") - public object SystemChannelId : AuditLogChangeKey("system_channel_id", serializer()) + public object SystemChannelId : AuditLogChangeKey("system_channel_id", Snowflake.serializer()) @SerialName("position") - public object Position : AuditLogChangeKey("position", serializer()) + public object Position : AuditLogChangeKey("position", Int.serializer()) @SerialName("topic") - public object Topic : AuditLogChangeKey("topic", serializer()) + public object Topic : AuditLogChangeKey("topic", String.serializer()) @SerialName("bitrate") - public object Bitrate : AuditLogChangeKey("bitrate", serializer()) + public object Bitrate : AuditLogChangeKey("bitrate", Int.serializer()) @SerialName("permission_overwrites") - public object PermissionOverwrites : AuditLogChangeKey>("permission_overwrites", serializer()) + public object PermissionOverwrites : + AuditLogChangeKey>("permission_overwrites", ListSerializer(Overwrite.serializer())) @SerialName("nsfw") - public object Nsfw : AuditLogChangeKey("nsfw", serializer()) + public object Nsfw : AuditLogChangeKey("nsfw", Boolean.serializer()) @SerialName("application_id") - public object ApplicationId : AuditLogChangeKey("application_id", serializer()) + public object ApplicationId : AuditLogChangeKey("application_id", Snowflake.serializer()) @SerialName("rate_limit_per_user") public object RateLimitPerUser : AuditLogChangeKey("rate_limit_per_user", DurationInSecondsSerializer) @SerialName("permissions") - public object Permissions : AuditLogChangeKey("permissions", serializer()) + public object Permissions : AuditLogChangeKey("permissions", CommonPermissions.serializer()) @SerialName("color") - public object Color : AuditLogChangeKey("color", serializer()) + public object Color : AuditLogChangeKey("color", CommonColor.serializer()) @SerialName("command_id") - public object CommandId : AuditLogChangeKey("command_id", serializer()) + public object CommandId : AuditLogChangeKey("command_id", Snowflake.serializer()) @SerialName("communication_disabled_until") - public object CommunicationDisabledUntil : AuditLogChangeKey("communication_disabled_until", serializer()) + public object CommunicationDisabledUntil : + AuditLogChangeKey("communication_disabled_until", Instant.serializer()) @SerialName("hoist") - public object Hoist : AuditLogChangeKey("hoist", serializer()) + public object Hoist : AuditLogChangeKey("hoist", Boolean.serializer()) @SerialName("mentionable") - public object Mentionable : AuditLogChangeKey("mentionable", serializer()) + public object Mentionable : AuditLogChangeKey("mentionable", Boolean.serializer()) @SerialName("allow") - public object Allow : AuditLogChangeKey("allow", serializer()) + public object Allow : AuditLogChangeKey("allow", CommonPermissions.serializer()) @SerialName("deny") - public object Deny : AuditLogChangeKey("deny", serializer()) + public object Deny : AuditLogChangeKey("deny", CommonPermissions.serializer()) @SerialName("code") - public object Code : AuditLogChangeKey("code", serializer()) + public object Code : AuditLogChangeKey("code", String.serializer()) @SerialName("channel_id") - public object ChannelId : AuditLogChangeKey("channel_id", serializer()) + public object ChannelId : AuditLogChangeKey("channel_id", Snowflake.serializer()) @SerialName("inviter_id") - public object InviterId : AuditLogChangeKey("inviter_id", serializer()) + public object InviterId : AuditLogChangeKey("inviter_id", Snowflake.serializer()) @SerialName("location") - public object Location : AuditLogChangeKey("location", serializer()) + public object Location : AuditLogChangeKey("location", String.serializer()) @SerialName("max_uses") - public object MaxUses : AuditLogChangeKey("max_uses", serializer()) + public object MaxUses : AuditLogChangeKey("max_uses", Int.serializer()) @SerialName("uses") - public object Uses : AuditLogChangeKey("uses", serializer()) + public object Uses : AuditLogChangeKey("uses", Int.serializer()) @SerialName("max_age") public object MaxAges : AuditLogChangeKey("max_age", DurationInSecondsSerializer) @SerialName("temporary") - public object Temporary : AuditLogChangeKey("temporary", serializer()) + public object Temporary : AuditLogChangeKey("temporary", Boolean.serializer()) @SerialName("deaf") - public object Deaf : AuditLogChangeKey("deaf", serializer()) + public object Deaf : AuditLogChangeKey("deaf", Boolean.serializer()) @SerialName("mute") - public object Mute : AuditLogChangeKey("mute", serializer()) + public object Mute : AuditLogChangeKey("mute", Boolean.serializer()) @SerialName("nick") - public object Nick : AuditLogChangeKey("nick", serializer()) + public object Nick : AuditLogChangeKey("nick", String.serializer()) @SerialName("avatar_hash") - public object AvatarHash : AuditLogChangeKey("avatar_hash", serializer()) + public object AvatarHash : AuditLogChangeKey("avatar_hash", String.serializer()) @SerialName("id") - public object Id : AuditLogChangeKey("id", serializer()) + public object Id : AuditLogChangeKey("id", Snowflake.serializer()) /** * The actual supertype is [AuditLogChangeKey][AuditLogChangeKey] but Kotlin does not support union @@ -390,47 +409,41 @@ public sealed class AuditLogChangeKey(public val name: String, public val ser public object Type : AuditLogChangeKey("type", LongOrStringSerializer) @SerialName("enable_emoticons") - public object EnableEmoticons : AuditLogChangeKey("enable_emoticons", serializer()) + public object EnableEmoticons : AuditLogChangeKey("enable_emoticons", Boolean.serializer()) @SerialName("expire_behavior") - public object ExpireBehavior : AuditLogChangeKey("expire_behavior", serializer()) + public object ExpireBehavior : + AuditLogChangeKey("expire_behavior", IntegrationExpireBehavior.serializer()) @SerialName("expire_grace_period") public object ExpireGracePeriod : AuditLogChangeKey("expire_grace_period", DurationInDaysSerializer) @SerialName("user_limit") - public object UserLimit : AuditLogChangeKey("user_limit", serializer()) + public object UserLimit : AuditLogChangeKey("user_limit", Int.serializer()) @SerialName("archived") - public object Archived : AuditLogChangeKey("archived", serializer()) + public object Archived : AuditLogChangeKey("archived", Boolean.serializer()) @SerialName("locked") - public object Locked : AuditLogChangeKey("locked", serializer()) + public object Locked : AuditLogChangeKey("locked", Boolean.serializer()) @SerialName("auto_archive_duration") - public object AutoArchiveDuration : AuditLogChangeKey("auto_archive_duration", serializer()) + public object AutoArchiveDuration : + AuditLogChangeKey("auto_archive_duration", ArchiveDuration.serializer()) @SerialName("default_auto_archive_duration") public object DefaultAutoArchiveDuration : - AuditLogChangeKey("default_auto_archive_duration", serializer()) + AuditLogChangeKey("default_auto_archive_duration", ArchiveDuration.serializer()) @SerialName("entity_type") - public object EntityType : AuditLogChangeKey( - "entity_type", - serializer() - ) + public object EntityType : AuditLogChangeKey("entity_type", ScheduledEntityType.serializer()) @SerialName("status") - public object Status : AuditLogChangeKey( - "status", - serializer() - ) + public object Status : + AuditLogChangeKey("status", GuildScheduledEventStatus.serializer()) @SerialName("sku_ids") - public object SkuIds : AuditLogChangeKey>( - "sku_ids", - serializer() - ) + public object SkuIds : AuditLogChangeKey>("sku_ids", ListSerializer(Snowflake.serializer())) internal class Serializer(val type: KSerializer) : KSerializer> { override val descriptor: SerialDescriptor diff --git a/common/src/main/kotlin/entity/AutoModeration.kt b/common/src/commonMain/kotlin/entity/AutoModeration.kt similarity index 100% rename from common/src/main/kotlin/entity/AutoModeration.kt rename to common/src/commonMain/kotlin/entity/AutoModeration.kt diff --git a/common/src/main/kotlin/entity/Data.kt b/common/src/commonMain/kotlin/entity/Data.kt similarity index 100% rename from common/src/main/kotlin/entity/Data.kt rename to common/src/commonMain/kotlin/entity/Data.kt diff --git a/common/src/main/kotlin/entity/DiscordActivity.kt b/common/src/commonMain/kotlin/entity/DiscordActivity.kt similarity index 98% rename from common/src/main/kotlin/entity/DiscordActivity.kt rename to common/src/commonMain/kotlin/entity/DiscordActivity.kt index 9b1fd74dcd43..407ad6f9ed0e 100644 --- a/common/src/main/kotlin/entity/DiscordActivity.kt +++ b/common/src/commonMain/kotlin/entity/DiscordActivity.kt @@ -13,6 +13,8 @@ import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import kotlin.DeprecationLevel.HIDDEN import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.jvm.JvmField +import kotlin.jvm.JvmStatic @Serializable public data class DiscordBotActivity( @@ -195,7 +197,8 @@ public sealed class ActivityType(public val code: Int) { @Deprecated("Binary compatibility", level = HIDDEN) @JvmField public val Listening: ActivityType = Listening @Deprecated("Binary compatibility", level = HIDDEN) @JvmField public val Watching: ActivityType = Watching @Deprecated("Binary compatibility", level = HIDDEN) @JvmField public val Custom: ActivityType = Custom - @Deprecated("Binary compatibility", level = HIDDEN) @JvmField public val Competing: ActivityType = Competing + @Deprecated("Binary compatibility", level = HIDDEN) @JvmField + public val Competing: ActivityType = Competing // @formatter:on /** @suppress */ diff --git a/common/src/main/kotlin/entity/DiscordApplication.kt b/common/src/commonMain/kotlin/entity/DiscordApplication.kt similarity index 99% rename from common/src/main/kotlin/entity/DiscordApplication.kt rename to common/src/commonMain/kotlin/entity/DiscordApplication.kt index 1da4363971c8..203b12e60895 100644 --- a/common/src/main/kotlin/entity/DiscordApplication.kt +++ b/common/src/commonMain/kotlin/entity/DiscordApplication.kt @@ -12,6 +12,7 @@ import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import kotlin.contracts.InvocationKind import kotlin.contracts.contract +import kotlin.jvm.JvmName public sealed interface BaseDiscordApplication { public val id: Snowflake diff --git a/common/src/main/kotlin/entity/DiscordChannel.kt b/common/src/commonMain/kotlin/entity/DiscordChannel.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordChannel.kt rename to common/src/commonMain/kotlin/entity/DiscordChannel.kt diff --git a/common/src/main/kotlin/entity/DiscordComponent.kt b/common/src/commonMain/kotlin/entity/DiscordComponent.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordComponent.kt rename to common/src/commonMain/kotlin/entity/DiscordComponent.kt diff --git a/common/src/main/kotlin/entity/DiscordConnection.kt b/common/src/commonMain/kotlin/entity/DiscordConnection.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordConnection.kt rename to common/src/commonMain/kotlin/entity/DiscordConnection.kt diff --git a/common/src/main/kotlin/entity/DiscordEmoji.kt b/common/src/commonMain/kotlin/entity/DiscordEmoji.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordEmoji.kt rename to common/src/commonMain/kotlin/entity/DiscordEmoji.kt diff --git a/common/src/main/kotlin/entity/DiscordGuild.kt b/common/src/commonMain/kotlin/entity/DiscordGuild.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordGuild.kt rename to common/src/commonMain/kotlin/entity/DiscordGuild.kt diff --git a/common/src/main/kotlin/entity/DiscordGuildPreview.kt b/common/src/commonMain/kotlin/entity/DiscordGuildPreview.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordGuildPreview.kt rename to common/src/commonMain/kotlin/entity/DiscordGuildPreview.kt diff --git a/common/src/main/kotlin/entity/DiscordGuildScheduledEvent.kt b/common/src/commonMain/kotlin/entity/DiscordGuildScheduledEvent.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordGuildScheduledEvent.kt rename to common/src/commonMain/kotlin/entity/DiscordGuildScheduledEvent.kt diff --git a/common/src/main/kotlin/entity/DiscordGuildWidget.kt b/common/src/commonMain/kotlin/entity/DiscordGuildWidget.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordGuildWidget.kt rename to common/src/commonMain/kotlin/entity/DiscordGuildWidget.kt diff --git a/common/src/main/kotlin/entity/DiscordIntegration.kt b/common/src/commonMain/kotlin/entity/DiscordIntegration.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordIntegration.kt rename to common/src/commonMain/kotlin/entity/DiscordIntegration.kt diff --git a/common/src/main/kotlin/entity/DiscordInvite.kt b/common/src/commonMain/kotlin/entity/DiscordInvite.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordInvite.kt rename to common/src/commonMain/kotlin/entity/DiscordInvite.kt diff --git a/common/src/main/kotlin/entity/DiscordMessage.kt b/common/src/commonMain/kotlin/entity/DiscordMessage.kt similarity index 99% rename from common/src/main/kotlin/entity/DiscordMessage.kt rename to common/src/commonMain/kotlin/entity/DiscordMessage.kt index 37b4904e030e..263a79c080ab 100644 --- a/common/src/main/kotlin/entity/DiscordMessage.kt +++ b/common/src/commonMain/kotlin/entity/DiscordMessage.kt @@ -108,6 +108,7 @@ import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import kotlin.contracts.InvocationKind import kotlin.contracts.contract +import kotlin.jvm.JvmName /** * Represents [a message sent in a channel within Discord](https://discord.com/developers/docs/resources/channel#message-object). diff --git a/common/src/main/kotlin/entity/DiscordNull.kt b/common/src/commonMain/kotlin/entity/DiscordNull.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordNull.kt rename to common/src/commonMain/kotlin/entity/DiscordNull.kt diff --git a/common/src/main/kotlin/entity/DiscordRole.kt b/common/src/commonMain/kotlin/entity/DiscordRole.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordRole.kt rename to common/src/commonMain/kotlin/entity/DiscordRole.kt diff --git a/common/src/main/kotlin/entity/DiscordSelectOption.kt b/common/src/commonMain/kotlin/entity/DiscordSelectOption.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordSelectOption.kt rename to common/src/commonMain/kotlin/entity/DiscordSelectOption.kt diff --git a/common/src/main/kotlin/entity/DiscordShard.kt b/common/src/commonMain/kotlin/entity/DiscordShard.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordShard.kt rename to common/src/commonMain/kotlin/entity/DiscordShard.kt diff --git a/common/src/main/kotlin/entity/DiscordStageInstance.kt b/common/src/commonMain/kotlin/entity/DiscordStageInstance.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordStageInstance.kt rename to common/src/commonMain/kotlin/entity/DiscordStageInstance.kt diff --git a/common/src/main/kotlin/entity/DiscordTemplate.kt b/common/src/commonMain/kotlin/entity/DiscordTemplate.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordTemplate.kt rename to common/src/commonMain/kotlin/entity/DiscordTemplate.kt diff --git a/common/src/main/kotlin/entity/DiscordUser.kt b/common/src/commonMain/kotlin/entity/DiscordUser.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordUser.kt rename to common/src/commonMain/kotlin/entity/DiscordUser.kt diff --git a/common/src/main/kotlin/entity/DiscordWebhook.kt b/common/src/commonMain/kotlin/entity/DiscordWebhook.kt similarity index 100% rename from common/src/main/kotlin/entity/DiscordWebhook.kt rename to common/src/commonMain/kotlin/entity/DiscordWebhook.kt diff --git a/common/src/main/kotlin/entity/Interactions.kt b/common/src/commonMain/kotlin/entity/Interactions.kt similarity index 99% rename from common/src/main/kotlin/entity/Interactions.kt rename to common/src/commonMain/kotlin/entity/Interactions.kt index 21fab94936ee..37bce30a1c6f 100644 --- a/common/src/main/kotlin/entity/Interactions.kt +++ b/common/src/commonMain/kotlin/entity/Interactions.kt @@ -92,6 +92,7 @@ import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* import kotlin.DeprecationLevel.ERROR +import kotlin.jvm.JvmName @Serializable public data class DiscordApplicationCommand( diff --git a/common/src/main/kotlin/entity/Member.kt b/common/src/commonMain/kotlin/entity/Member.kt similarity index 100% rename from common/src/main/kotlin/entity/Member.kt rename to common/src/commonMain/kotlin/entity/Member.kt diff --git a/common/src/main/kotlin/entity/Permission.kt b/common/src/commonMain/kotlin/entity/Permission.kt similarity index 99% rename from common/src/main/kotlin/entity/Permission.kt rename to common/src/commonMain/kotlin/entity/Permission.kt index f23643336844..0e0c23be0709 100644 --- a/common/src/main/kotlin/entity/Permission.kt +++ b/common/src/commonMain/kotlin/entity/Permission.kt @@ -11,6 +11,7 @@ import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import kotlin.contracts.InvocationKind import kotlin.contracts.contract +import kotlin.jvm.JvmName @Serializable(with = Permissions.Companion::class) diff --git a/common/src/main/kotlin/entity/Presence.kt b/common/src/commonMain/kotlin/entity/Presence.kt similarity index 100% rename from common/src/main/kotlin/entity/Presence.kt rename to common/src/commonMain/kotlin/entity/Presence.kt diff --git a/common/src/main/kotlin/entity/Snowflake.kt b/common/src/commonMain/kotlin/entity/Snowflake.kt similarity index 100% rename from common/src/main/kotlin/entity/Snowflake.kt rename to common/src/commonMain/kotlin/entity/Snowflake.kt diff --git a/common/src/main/kotlin/entity/Team.kt b/common/src/commonMain/kotlin/entity/Team.kt similarity index 100% rename from common/src/main/kotlin/entity/Team.kt rename to common/src/commonMain/kotlin/entity/Team.kt diff --git a/common/src/main/kotlin/entity/optional/Optional.kt b/common/src/commonMain/kotlin/entity/optional/Optional.kt similarity index 98% rename from common/src/main/kotlin/entity/optional/Optional.kt rename to common/src/commonMain/kotlin/entity/optional/Optional.kt index c67a8cbebe7d..96b157dfe696 100644 --- a/common/src/main/kotlin/entity/optional/Optional.kt +++ b/common/src/commonMain/kotlin/entity/optional/Optional.kt @@ -9,6 +9,8 @@ import kotlinx.serialization.SerializationException import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder +import kotlin.js.JsName +import kotlin.jvm.JvmName /** * Represents a value that encapsulates all [three possible states of a value in the Discord API](https://discord.com/developers/docs/reference#nullable-and-optional-resource-fields). @@ -143,6 +145,7 @@ public sealed class Optional { * Returns an [Optional] that is either [value] on a non-null [value], or [Null] on `null`. */ @JvmName("invokeNullable") + @JsName("invokeNullable") public operator fun invoke(value: T?): Optional = when (value) { null -> Null() else -> Value(value) @@ -252,6 +255,7 @@ public inline fun Optional.flatMap(mapper: (E) -> Optional @Suppress("UNCHECKED_CAST") @JvmName("mapNullableOptional") +@JsName("mapNullableOptional") public inline fun Optional.map(mapper: (E) -> T): Optional = when (this) { is Missing, is Null<*> -> this as Optional is Value -> Value(mapper(value!!)) @@ -285,6 +289,7 @@ public inline fun Optional.mapSnowflake(mapper: (E) -> Snowflake): } @JvmName("mapNullableSnowflake") +@JsName("mapNullableSnowflake") public inline fun Optional.mapSnowflake(mapper: (E) -> Snowflake): OptionalSnowflake = when (this) { is Missing, is Null<*> -> OptionalSnowflake.Missing is Value -> OptionalSnowflake.Value(mapper(value!!)) diff --git a/common/src/main/kotlin/entity/optional/OptionalBoolean.kt b/common/src/commonMain/kotlin/entity/optional/OptionalBoolean.kt similarity index 100% rename from common/src/main/kotlin/entity/optional/OptionalBoolean.kt rename to common/src/commonMain/kotlin/entity/optional/OptionalBoolean.kt diff --git a/common/src/main/kotlin/entity/optional/OptionalInt.kt b/common/src/commonMain/kotlin/entity/optional/OptionalInt.kt similarity index 100% rename from common/src/main/kotlin/entity/optional/OptionalInt.kt rename to common/src/commonMain/kotlin/entity/optional/OptionalInt.kt diff --git a/common/src/main/kotlin/entity/optional/OptionalLong.kt b/common/src/commonMain/kotlin/entity/optional/OptionalLong.kt similarity index 100% rename from common/src/main/kotlin/entity/optional/OptionalLong.kt rename to common/src/commonMain/kotlin/entity/optional/OptionalLong.kt diff --git a/common/src/main/kotlin/entity/optional/OptionalSnowflake.kt b/common/src/commonMain/kotlin/entity/optional/OptionalSnowflake.kt similarity index 98% rename from common/src/main/kotlin/entity/optional/OptionalSnowflake.kt rename to common/src/commonMain/kotlin/entity/optional/OptionalSnowflake.kt index cd304db75048..9baaba7b41d0 100644 --- a/common/src/main/kotlin/entity/optional/OptionalSnowflake.kt +++ b/common/src/commonMain/kotlin/entity/optional/OptionalSnowflake.kt @@ -7,6 +7,8 @@ import kotlinx.serialization.builtins.serializer import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder +import kotlin.js.JsName +import kotlin.jvm.JvmName /** * Represents a value that encapsulate a [Snowflake]'s diff --git a/common/src/main/kotlin/entity/optional/delegate/OptionalBooleanDelegate.kt b/common/src/commonMain/kotlin/entity/optional/delegate/OptionalBooleanDelegate.kt similarity index 98% rename from common/src/main/kotlin/entity/optional/delegate/OptionalBooleanDelegate.kt rename to common/src/commonMain/kotlin/entity/optional/delegate/OptionalBooleanDelegate.kt index 698e198fa821..dfb602cad61e 100644 --- a/common/src/main/kotlin/entity/optional/delegate/OptionalBooleanDelegate.kt +++ b/common/src/commonMain/kotlin/entity/optional/delegate/OptionalBooleanDelegate.kt @@ -3,6 +3,7 @@ package dev.kord.common.entity.optional.delegate import dev.kord.common.entity.optional.OptionalBoolean import dev.kord.common.entity.optional.optional import dev.kord.common.entity.optional.value +import kotlin.jvm.JvmName import kotlin.properties.ReadWriteProperty import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty diff --git a/common/src/main/kotlin/entity/optional/delegate/OptionalDelegate.kt b/common/src/commonMain/kotlin/entity/optional/delegate/OptionalDelegate.kt similarity index 95% rename from common/src/main/kotlin/entity/optional/delegate/OptionalDelegate.kt rename to common/src/commonMain/kotlin/entity/optional/delegate/OptionalDelegate.kt index e2b498760f03..cf5f6517d4b7 100644 --- a/common/src/main/kotlin/entity/optional/delegate/OptionalDelegate.kt +++ b/common/src/commonMain/kotlin/entity/optional/delegate/OptionalDelegate.kt @@ -1,6 +1,8 @@ package dev.kord.common.entity.optional.delegate import dev.kord.common.entity.optional.Optional +import kotlin.js.JsName +import kotlin.jvm.JvmName import kotlin.properties.ReadWriteProperty import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty @@ -42,6 +44,7 @@ public fun KMutableProperty0>>.delegateList(): ReadWr } @JvmName("provideNullableDelegate") +@JsName("provideNullableDelegate") public fun KMutableProperty0>.delegate(): ReadWriteProperty = object : ReadWriteProperty { diff --git a/common/src/main/kotlin/entity/optional/delegate/OptionalIntDelegate.kt b/common/src/commonMain/kotlin/entity/optional/delegate/OptionalIntDelegate.kt similarity index 94% rename from common/src/main/kotlin/entity/optional/delegate/OptionalIntDelegate.kt rename to common/src/commonMain/kotlin/entity/optional/delegate/OptionalIntDelegate.kt index e938aab84a6d..239c8e844109 100644 --- a/common/src/main/kotlin/entity/optional/delegate/OptionalIntDelegate.kt +++ b/common/src/commonMain/kotlin/entity/optional/delegate/OptionalIntDelegate.kt @@ -3,10 +3,13 @@ package dev.kord.common.entity.optional.delegate import dev.kord.common.entity.optional.OptionalInt import dev.kord.common.entity.optional.optionalInt import dev.kord.common.entity.optional.value +import kotlin.js.JsName +import kotlin.jvm.JvmName import kotlin.properties.ReadWriteProperty import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty +@JsName("intDelegate") public fun KMutableProperty0.delegate(): ReadWriteProperty = object : ReadWriteProperty { override fun getValue(thisRef: Any?, property: KProperty<*>): Int? { diff --git a/common/src/main/kotlin/entity/optional/delegate/OptionalLongDelegate.kt b/common/src/commonMain/kotlin/entity/optional/delegate/OptionalLongDelegate.kt similarity index 98% rename from common/src/main/kotlin/entity/optional/delegate/OptionalLongDelegate.kt rename to common/src/commonMain/kotlin/entity/optional/delegate/OptionalLongDelegate.kt index 1f3e674d5574..8e67e2ecfef3 100644 --- a/common/src/main/kotlin/entity/optional/delegate/OptionalLongDelegate.kt +++ b/common/src/commonMain/kotlin/entity/optional/delegate/OptionalLongDelegate.kt @@ -3,6 +3,7 @@ package dev.kord.common.entity.optional.delegate import dev.kord.common.entity.optional.OptionalLong import dev.kord.common.entity.optional.optional import dev.kord.common.entity.optional.value +import kotlin.jvm.JvmName import kotlin.properties.ReadWriteProperty import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty diff --git a/common/src/main/kotlin/entity/optional/delegate/OptionalSnowflakeDelegate.kt b/common/src/commonMain/kotlin/entity/optional/delegate/OptionalSnowflakeDelegate.kt similarity index 98% rename from common/src/main/kotlin/entity/optional/delegate/OptionalSnowflakeDelegate.kt rename to common/src/commonMain/kotlin/entity/optional/delegate/OptionalSnowflakeDelegate.kt index 975f299eb4ec..756689e8972e 100644 --- a/common/src/main/kotlin/entity/optional/delegate/OptionalSnowflakeDelegate.kt +++ b/common/src/commonMain/kotlin/entity/optional/delegate/OptionalSnowflakeDelegate.kt @@ -4,6 +4,7 @@ import dev.kord.common.entity.Snowflake import dev.kord.common.entity.optional.OptionalSnowflake import dev.kord.common.entity.optional.optionalSnowflake import dev.kord.common.entity.optional.value +import kotlin.jvm.JvmName import kotlin.properties.ReadWriteProperty import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty diff --git a/common/src/main/kotlin/exception/RequestException.kt b/common/src/commonMain/kotlin/exception/RequestException.kt similarity index 100% rename from common/src/main/kotlin/exception/RequestException.kt rename to common/src/commonMain/kotlin/exception/RequestException.kt diff --git a/common/src/main/kotlin/ratelimit/AbstractIntervalRateLimiter.kt b/common/src/commonMain/kotlin/ratelimit/AbstractIntervalRateLimiter.kt similarity index 100% rename from common/src/main/kotlin/ratelimit/AbstractIntervalRateLimiter.kt rename to common/src/commonMain/kotlin/ratelimit/AbstractIntervalRateLimiter.kt diff --git a/common/src/main/kotlin/ratelimit/ClockIntervalRateLimiter.kt b/common/src/commonMain/kotlin/ratelimit/ClockIntervalRateLimiter.kt similarity index 100% rename from common/src/main/kotlin/ratelimit/ClockIntervalRateLimiter.kt rename to common/src/commonMain/kotlin/ratelimit/ClockIntervalRateLimiter.kt diff --git a/common/src/main/kotlin/ratelimit/RateLimiter.kt b/common/src/commonMain/kotlin/ratelimit/RateLimiter.kt similarity index 100% rename from common/src/main/kotlin/ratelimit/RateLimiter.kt rename to common/src/commonMain/kotlin/ratelimit/RateLimiter.kt diff --git a/common/src/main/kotlin/ratelimit/TimeSourceIntervalRateLimiter.kt b/common/src/commonMain/kotlin/ratelimit/TimeSourceIntervalRateLimiter.kt similarity index 100% rename from common/src/main/kotlin/ratelimit/TimeSourceIntervalRateLimiter.kt rename to common/src/commonMain/kotlin/ratelimit/TimeSourceIntervalRateLimiter.kt diff --git a/common/src/main/kotlin/serialization/DurationSerializers.kt b/common/src/commonMain/kotlin/serialization/DurationSerializers.kt similarity index 100% rename from common/src/main/kotlin/serialization/DurationSerializers.kt rename to common/src/commonMain/kotlin/serialization/DurationSerializers.kt diff --git a/common/src/main/kotlin/serialization/InstantSerializers.kt b/common/src/commonMain/kotlin/serialization/InstantSerializers.kt similarity index 98% rename from common/src/main/kotlin/serialization/InstantSerializers.kt rename to common/src/commonMain/kotlin/serialization/InstantSerializers.kt index 12fe03a99238..31b1213e8860 100644 --- a/common/src/main/kotlin/serialization/InstantSerializers.kt +++ b/common/src/commonMain/kotlin/serialization/InstantSerializers.kt @@ -2,7 +2,6 @@ package dev.kord.common.serialization import kotlinx.datetime.Instant import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable import kotlinx.serialization.SerializationException import kotlinx.serialization.descriptors.PrimitiveKind import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor diff --git a/common/src/main/kotlin/serialization/LongOrStringSerializer.kt b/common/src/commonMain/kotlin/serialization/LongOrStringSerializer.kt similarity index 100% rename from common/src/main/kotlin/serialization/LongOrStringSerializer.kt rename to common/src/commonMain/kotlin/serialization/LongOrStringSerializer.kt diff --git a/common/src/test/kotlin/BitSetTests.kt b/common/src/commonTest/kotlin/BitSetTests.kt similarity index 91% rename from common/src/test/kotlin/BitSetTests.kt rename to common/src/commonTest/kotlin/BitSetTests.kt index c4fe11871bbf..1c70bfc2c33b 100644 --- a/common/src/test/kotlin/BitSetTests.kt +++ b/common/src/commonTest/kotlin/BitSetTests.kt @@ -1,9 +1,11 @@ import dev.kord.common.DiscordBitSet import dev.kord.common.EmptyBitSet +import kotlin.js.JsName import kotlin.test.* class BitSetTests { @Test + @JsName("test1") fun `a contains b and c`() { val a = DiscordBitSet(0b111) val b = DiscordBitSet(0b101) @@ -13,6 +15,7 @@ class BitSetTests { } @Test + @JsName("test2") fun `a and b are equal and have the same hashCode`() { val a = DiscordBitSet(0b111, 0) val b = DiscordBitSet(0b111) @@ -21,6 +24,7 @@ class BitSetTests { } @Test + @JsName("test3") fun `a does not equal b`() { val a = DiscordBitSet(0b111, 0) val b = DiscordBitSet(0b111, 0b1) @@ -28,6 +32,7 @@ class BitSetTests { } @Test + @JsName("test4") fun `get bits`() { val a = DiscordBitSet(0b101, 0) assertTrue(a[0]) @@ -41,6 +46,7 @@ class BitSetTests { } @Test + @JsName("test5") fun `set bits`() { val a = EmptyBitSet() for (i in 0..64) a[i] = true @@ -56,12 +62,14 @@ class BitSetTests { } @Test + @JsName("test6") fun `get a bit out of range`() { val a = DiscordBitSet(0b101, 0) assert(!a[10000]) } @Test + @JsName("test7") fun `add and remove a bit`() { val a = DiscordBitSet(0b101, 0) a.add(DiscordBitSet(0b111)) @@ -71,6 +79,7 @@ class BitSetTests { } @Test + @JsName("test8") fun `remove a bit`() { val a = DiscordBitSet(0b101, 0) a.remove(DiscordBitSet(0b111)) @@ -78,6 +87,7 @@ class BitSetTests { } @Test + @JsName("test9") fun `binary works`() { assertEquals("0", DiscordBitSet().binary) assertEquals("0", DiscordBitSet(0).binary) diff --git a/common/src/test/kotlin/ColorTests.kt b/common/src/commonTest/kotlin/ColorTests.kt similarity index 61% rename from common/src/test/kotlin/ColorTests.kt rename to common/src/commonTest/kotlin/ColorTests.kt index bff3b9261913..5dfd63076ae1 100644 --- a/common/src/test/kotlin/ColorTests.kt +++ b/common/src/commonTest/kotlin/ColorTests.kt @@ -1,16 +1,19 @@ -import dev.kord.common.Color -import dev.kord.common.kColor -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows +package dev.kord.common + +import kotlin.js.JsName +import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith class ColorTests { @Test + @JsName("test1") fun `Color throws if invalid rgb value is provided`() { - assertThrows { Color(256, 256, 300) } + assertFailsWith { Color(256, 256, 300) } } @Test + @JsName("test2") fun `Color provides a correct value`() { val red = Color(0xFF0000) assertEquals(255, red.red) @@ -25,15 +28,7 @@ class ColorTests { } @Test - fun `java to kColor conversion`() { - val color = java.awt.Color.decode("#DBD0B4").kColor - - assertEquals(219, color.red) - assertEquals(208, color.green) - assertEquals(180, color.blue) - } - - @Test + @JsName("test3") fun `Color implementation should drop alpha values if given`() { val color = Color(0x1E1F2E3D) assertEquals(0x1F2E3D, color.rgb) diff --git a/common/src/test/kotlin/FixedClock.kt b/common/src/commonTest/kotlin/FixedClock.kt similarity index 90% rename from common/src/test/kotlin/FixedClock.kt rename to common/src/commonTest/kotlin/FixedClock.kt index 9268573652a9..b34fdb8dcf78 100644 --- a/common/src/test/kotlin/FixedClock.kt +++ b/common/src/commonTest/kotlin/FixedClock.kt @@ -1,3 +1,5 @@ +package dev.kord.common + import kotlinx.datetime.Clock import kotlinx.datetime.Instant diff --git a/common/src/test/kotlin/LocaleTest.kt b/common/src/commonTest/kotlin/LocaleTest.kt similarity index 95% rename from common/src/test/kotlin/LocaleTest.kt rename to common/src/commonTest/kotlin/LocaleTest.kt index e8f29c8b4ba3..f5a779a521dc 100644 --- a/common/src/test/kotlin/LocaleTest.kt +++ b/common/src/commonTest/kotlin/LocaleTest.kt @@ -1,7 +1,10 @@ +package dev.kord.common + import dev.kord.common.Locale import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json +import kotlin.js.JsName import kotlin.test.Test import kotlin.test.assertEquals @@ -49,6 +52,7 @@ class LocaleTest { @Test + @JsName("test1") fun `all documented Locales can be deserialized`() { all.forEach { (string, locale) -> assertEquals(expected = locale, actual = Json.decodeFromString("\"$string\"")) @@ -56,6 +60,7 @@ class LocaleTest { } @Test + @JsName("test2") fun `all documented Locales can be serialized`() { all.forEach { (string, locale) -> assertEquals(expected = "\"$string\"", actual = Json.encodeToString(locale)) diff --git a/common/src/test/kotlin/entity/SnowflakeTest.kt b/common/src/commonTest/kotlin/entity/SnowflakeTest.kt similarity index 94% rename from common/src/test/kotlin/entity/SnowflakeTest.kt rename to common/src/commonTest/kotlin/entity/SnowflakeTest.kt index 23832a7985a4..19ca2fbc02ec 100644 --- a/common/src/test/kotlin/entity/SnowflakeTest.kt +++ b/common/src/commonTest/kotlin/entity/SnowflakeTest.kt @@ -3,6 +3,7 @@ package entity import dev.kord.common.entity.Snowflake import kotlinx.datetime.Clock import kotlinx.datetime.Instant +import kotlin.js.JsName import kotlin.test.* import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.nanoseconds @@ -10,46 +11,54 @@ import kotlin.time.Duration.Companion.nanoseconds class SnowflakeTest { @Test + @JsName("test1") fun `min Snowflake's timestamp is equal to discordEpoch`() { assertEquals(Snowflake.discordEpoch, Snowflake.min.timestamp) } @Test + @JsName("test2") fun `max Snowflake's timestamp is equal to endOfTime`() { assertEquals(Snowflake.endOfTime, Snowflake.max.timestamp) } @Test + @JsName("test3") fun `Snowflake created from ULong MIN_VALUE has timestamp equal to discordEpoch`() { val snowflake = Snowflake(ULong.MIN_VALUE) assertEquals(Snowflake.discordEpoch, snowflake.timestamp) } @Test + @JsName("test4") fun `Snowflake created from ULong MAX_VALUE has timestamp equal to endOfTime`() { val snowflake = Snowflake(ULong.MAX_VALUE) assertEquals(Snowflake.endOfTime, snowflake.timestamp) } @Test + @JsName("test5") fun `Snowflake created from Long MIN_VALUE has timestamp equal to discordEpoch`() { val snowflake = Snowflake(Long.MIN_VALUE) assertEquals(Snowflake.discordEpoch, snowflake.timestamp) } @Test + @JsName("test6") fun `Snowflake created from instant far in the past has timestamp equal to discordEpoch`() { val snowflake = Snowflake(Instant.DISTANT_PAST) assertEquals(Snowflake.discordEpoch, snowflake.timestamp) } @Test + @JsName("test7") fun `Snowflake created from instant far in the future has timestamp equal to endOfTime`() { val snowflake = Snowflake(Instant.DISTANT_FUTURE) assertEquals(Snowflake.endOfTime, snowflake.timestamp) } @Test + @JsName("test8") fun `Snowflake's timestamp calculates an Instant close to the Instant the Snowflake was created from`() { val instant = Clock.System.now() val snowflake = Snowflake(instant) @@ -62,16 +71,19 @@ class SnowflakeTest { } @Test + @JsName("test9") fun `min Snowflake's timeMark has passed`() { assertTrue(Snowflake.min.timeMark.hasPassedNow()) } @Test + @JsName("test10") fun `max Snowflake's timeMark has not passed`() { assertFalse(Snowflake.max.timeMark.hasPassedNow()) } @Test + @JsName("test11") fun `Snowflake can be destructured`() { val snowflake = Snowflake(0b110010110111_10111_01101_101100111101_u) val (timestamp, worker, process, increment) = snowflake diff --git a/common/src/test/kotlin/entity/optional/OptionalBooleanTest.kt b/common/src/commonTest/kotlin/entity/optional/OptionalBooleanTest.kt similarity index 71% rename from common/src/test/kotlin/entity/optional/OptionalBooleanTest.kt rename to common/src/commonTest/kotlin/entity/optional/OptionalBooleanTest.kt index 14b32bf1d2b6..74142b875b27 100644 --- a/common/src/test/kotlin/entity/optional/OptionalBooleanTest.kt +++ b/common/src/commonTest/kotlin/entity/optional/OptionalBooleanTest.kt @@ -4,9 +4,11 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.SerializationException import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json -import org.intellij.lang.annotations.Language -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.Test +import kotlin.test.assertFailsWith +import kotlin.test.assertIs +import kotlin.test.assertTrue internal class OptionalBooleanTest { @@ -14,24 +16,26 @@ internal class OptionalBooleanTest { private class EmptyOptionalEntity(val value: OptionalBoolean = OptionalBoolean.Missing) @Test + @JsName("test1") fun `deserializing nothing in optional assigns Missing`(){ - @Language("json") + //language=json val json = """{}""" val entity = Json.decodeFromString(json) - assert(entity.value is OptionalBoolean.Missing) + assertIs(entity.value) } @Serializable private class NullOptionalEntity(@Suppress("unused") val value: OptionalBoolean = OptionalBoolean.Missing) @Test + @JsName("test2") fun `deserializing null in optional throws SerializationException`(){ - @Language("json") + //language=json val json = """{ "value":null }""" - org.junit.jupiter.api.assertThrows { + assertFailsWith { Json.decodeFromString(json) } } @@ -40,15 +44,16 @@ internal class OptionalBooleanTest { private class ValueOptionalEntity(@Suppress("unused") val value: OptionalBoolean = OptionalBoolean.Missing) @Test + @JsName("test3") fun `deserializing value in optional assigns Value`(){ - @Language("json") + //language=json val json = """{ "value":true }""" val entity = Json.decodeFromString(json) - require(entity.value is OptionalBoolean.Value) + assertIs(entity.value) - Assertions.assertEquals(true, entity.value.value) + assertTrue(entity.value.value) } } diff --git a/common/src/test/kotlin/entity/optional/OptionalIntTest.kt b/common/src/commonTest/kotlin/entity/optional/OptionalIntTest.kt similarity index 73% rename from common/src/test/kotlin/entity/optional/OptionalIntTest.kt rename to common/src/commonTest/kotlin/entity/optional/OptionalIntTest.kt index a6f497e26be5..cda9d356eb19 100644 --- a/common/src/test/kotlin/entity/optional/OptionalIntTest.kt +++ b/common/src/commonTest/kotlin/entity/optional/OptionalIntTest.kt @@ -4,9 +4,8 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.SerializationException import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json -import org.intellij.lang.annotations.Language -import org.junit.jupiter.api.Assertions.* -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.* internal class OptionalIntTest { @@ -14,13 +13,14 @@ internal class OptionalIntTest { private class EmptyOptionalEntity(val value: OptionalInt = OptionalInt.Missing) @Test + @JsName("test1") fun `deserializing nothing in optional assigns Missing`(){ - @Language("json") + //language=json val json = """{}""" val entity = Json.decodeFromString(json) - assert(entity.value is OptionalInt.Missing) + assertIs(entity.value) } @@ -28,12 +28,13 @@ internal class OptionalIntTest { private class NullOptionalEntity(@Suppress("unused") val value: OptionalInt = OptionalInt.Missing) @Test + @JsName("test2") fun `deserializing null in optional throws SerializationException`(){ - @Language("json") + //language=json val json = """{ "value":null }""" - org.junit.jupiter.api.assertThrows { + assertFailsWith { Json.decodeFromString(json) } } @@ -42,14 +43,15 @@ internal class OptionalIntTest { class ValueOptionalEntity(@Suppress("unused") val value: OptionalInt = OptionalInt.Missing) @Test + @JsName("test3") fun `deserializing value in optional assigns Value`(){ - @Language("json") + //language=json val json = """{ "value":5 }""" val entity = Json.decodeFromString(json) - require(entity.value is OptionalInt.Value) + assertIs(entity.value) - assertEquals(5, entity.value.value) + assertSame(5, entity.value.value) } } diff --git a/common/src/test/kotlin/entity/optional/OptionalLongTest.kt b/common/src/commonTest/kotlin/entity/optional/OptionalLongTest.kt similarity index 73% rename from common/src/test/kotlin/entity/optional/OptionalLongTest.kt rename to common/src/commonTest/kotlin/entity/optional/OptionalLongTest.kt index 9ec0618be62b..6f29e2985cfe 100644 --- a/common/src/test/kotlin/entity/optional/OptionalLongTest.kt +++ b/common/src/commonTest/kotlin/entity/optional/OptionalLongTest.kt @@ -4,9 +4,8 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.SerializationException import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json -import org.intellij.lang.annotations.Language -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.* internal class OptionalLongTest { @@ -14,14 +13,15 @@ internal class OptionalLongTest { class EmptyOptionalEntity(val value: OptionalLong = OptionalLong.Missing) @Test + @JsName("test1") fun `deserializing nothing in optional assigns Missing`() { - @Language("json") + //language=json val json = """{}""" val entity = Json.decodeFromString(json) - assert(entity.value is OptionalLong.Missing) + assertIs(entity.value) } @@ -29,12 +29,13 @@ internal class OptionalLongTest { class NullOptionalEntity(@Suppress("unused") val value: OptionalLong = OptionalLong.Missing) @Test + @JsName("test2") fun `deserializing null in optional throws SerializationException`() { - @Language("json") + //language=json val json = """{ "value":null }""" - org.junit.jupiter.api.assertThrows { + assertFailsWith { Json.decodeFromString(json) } } @@ -44,14 +45,15 @@ internal class OptionalLongTest { class ValueOptionalEntity(@Suppress("unused") val value: OptionalLong = OptionalLong.Missing) @Test + @JsName("test3") fun `deserializing value in optional assigns Value`() { - @Language("json") + //language=json val json = """{ "value":5 }""" val entity = Json.decodeFromString(json) - require(entity.value is OptionalLong.Value) + assertIs(entity.value) - Assertions.assertEquals(5, entity.value.value) + assertSame(5, entity.value.value) } } diff --git a/common/src/test/kotlin/entity/optional/OptionalSnowflakeTest.kt b/common/src/commonTest/kotlin/entity/optional/OptionalSnowflakeTest.kt similarity index 65% rename from common/src/test/kotlin/entity/optional/OptionalSnowflakeTest.kt rename to common/src/commonTest/kotlin/entity/optional/OptionalSnowflakeTest.kt index 3bdc8cb69fa2..d7f4b05a391a 100644 --- a/common/src/test/kotlin/entity/optional/OptionalSnowflakeTest.kt +++ b/common/src/commonTest/kotlin/entity/optional/OptionalSnowflakeTest.kt @@ -5,9 +5,8 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.SerializationException import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json -import org.intellij.lang.annotations.Language -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.* internal class OptionalSnowflakeTest { @@ -16,14 +15,15 @@ internal class OptionalSnowflakeTest { class EmptyOptionalEntity(val value: OptionalSnowflake = OptionalSnowflake.Missing) @Test - fun `deserializing nothing in optional assigns Missing`(){ - @Language("json") + @JsName("test1") + fun `deserializing nothing in optional assigns Missing`() { + //language=json val json = """{}""" val entity = Json.decodeFromString(json) - assert(entity.value is OptionalSnowflake.Missing) + assertIs(entity.value) } @@ -31,11 +31,12 @@ internal class OptionalSnowflakeTest { class NullOptionalEntity(@Suppress("unused") val value: OptionalSnowflake = OptionalSnowflake.Missing) @Test - fun `deserializing null in optional throws SerializationException`(){ - @Language("json") + @JsName("test2") + fun `deserializing null in optional throws SerializationException`() { + //language=json val json = """{ "value":null }""" - org.junit.jupiter.api.assertThrows { + assertFailsWith { Json.decodeFromString(json) } } @@ -45,14 +46,14 @@ internal class OptionalSnowflakeTest { class ValueOptionalEntity(@Suppress("unused") val value: OptionalSnowflake = OptionalSnowflake.Missing) @Test - fun `deserializing value in optional assigns Value`(){ - @Language("json") + @JsName("test3") + fun `deserializing value in optional assigns Value`() { + //language=test val json = """{ "value":5 }""" val entity = Json.decodeFromString(json) - require(entity.value is OptionalSnowflake.Value) - - Assertions.assertEquals(Snowflake(5u), entity.value.value) + assertIs(entity.value) + assertEquals(Snowflake(5u), entity.value.value) } } diff --git a/common/src/test/kotlin/entity/optional/OptionalTest.kt b/common/src/commonTest/kotlin/entity/optional/OptionalTest.kt similarity index 71% rename from common/src/test/kotlin/entity/optional/OptionalTest.kt rename to common/src/commonTest/kotlin/entity/optional/OptionalTest.kt index 144a03872889..2cea77ee8e5e 100644 --- a/common/src/test/kotlin/entity/optional/OptionalTest.kt +++ b/common/src/commonTest/kotlin/entity/optional/OptionalTest.kt @@ -4,26 +4,31 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.SerializationException import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json -import org.intellij.lang.annotations.Language -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.test.assertIs internal class OptionalTest { @Test + @JsName("test1") fun `creating optional from nullable value returns Value on non-null value`() { - val value: Int? = 5 + val value = 5 val optional = Optional(value) - assert(optional is Optional.Value) - assert((optional as Optional.Value).value == value) + assertIs>(optional) + assertEquals(optional.value, value) } @Test + @JsName("test2") fun `creating optional from nullable value returns Null on null value`() { val value: Int? = null val optional = Optional(value) - assert(optional is Optional.Null) + assertIs>(optional) } @@ -31,13 +36,14 @@ internal class OptionalTest { private class NullOptionalEntity(val value: Optional) @Test + @JsName("test3") fun `deserializing null in nullable optional assigns Null`() { - @Language("json") + //language=json val json = """{ "value":null }""" val entity = Json.decodeFromString(json) - assert(entity.value is Optional.Null) + assertIs>(entity.value) } @@ -45,13 +51,14 @@ internal class OptionalTest { class EmptyOptionalEntity(val value: Optional = Optional.Missing()) @Test + @JsName("test4") fun `deserializing nothing in nullable optional assigns Missing`() { - @Language("json") + //language=json val json = """{}""" val entity = Json.decodeFromString(json) - assert(entity.value is Optional.Missing) + assertIs>(entity.value) } @@ -59,13 +66,14 @@ internal class OptionalTest { class UnexpectedEmptyOptionalEntity(val value: Optional = Optional.Missing()) @Test + @JsName("test5") fun `deserializing nothing in non-nullable optional assigns Missing`() { - @Language("json") + //language=json val json = """{}""" val entity = Json.decodeFromString(json) - assert(entity.value is Optional.Missing) + assertIs>(entity.value) } @@ -73,13 +81,14 @@ internal class OptionalTest { private class UnexpectedNullOptionalEntity(@Suppress("unused") val value: Optional = Optional.Missing()) @Test + @JsName("test6") fun `deserializing null in non-nullable optional throws SerializationException`() { - @Language("json") + //language=json val json = """{ "value":null }""" - org.junit.jupiter.api.assertThrows { + assertFailsWith { Json.decodeFromString(json) } } -} \ No newline at end of file +} diff --git a/common/src/commonTest/kotlin/file.kt b/common/src/commonTest/kotlin/file.kt new file mode 100644 index 000000000000..fc61460974ff --- /dev/null +++ b/common/src/commonTest/kotlin/file.kt @@ -0,0 +1,3 @@ +package dev.kord.common + +expect suspend fun readFile(prefix: String, name: String): String diff --git a/common/src/test/kotlin/json/ChannelTest.kt b/common/src/commonTest/kotlin/json/ChannelTest.kt similarity index 87% rename from common/src/test/kotlin/json/ChannelTest.kt rename to common/src/commonTest/kotlin/json/ChannelTest.kt index 9b87b0d9619b..9d031cda1d17 100644 --- a/common/src/test/kotlin/json/ChannelTest.kt +++ b/common/src/commonTest/kotlin/json/ChannelTest.kt @@ -2,19 +2,20 @@ package json import dev.kord.common.entity.DiscordChannel import dev.kord.common.entity.optional.value +import dev.kord.common.readFile +import kotlinx.coroutines.test.runTest import kotlinx.serialization.json.Json -import org.junit.jupiter.api.Test +import kotlin.js.JsName import kotlin.time.Duration.Companion.seconds +import kotlin.test.Test -private fun file(name: String): String { - val loader = ChannelTest::class.java.classLoader - return loader.getResource("json/channel/$name.json")!!.readText() -} +private suspend fun file(name: String): String = readFile("channel", name) class ChannelTest { @Test - fun `DMChannel serialization`() { + @JsName("test1") + fun `DMChannel serialization`() = runTest { val channel = Json.decodeFromString(DiscordChannel.serializer(), file("dmchannel")) with(channel) { @@ -34,7 +35,8 @@ class ChannelTest { @Test - fun `ChannelCategory serialization`() { + @JsName("test2") + fun `ChannelCategory serialization`() = runTest { val channel = Json.decodeFromString(DiscordChannel.serializer(), file("channelcategory")) with(channel) { @@ -50,7 +52,8 @@ class ChannelTest { @Test - fun `GroupDMChannel serialization`() { + @JsName("test3") + fun `GroupDMChannel serialization`() = runTest { val channel = Json.decodeFromString(DiscordChannel.serializer(), file("groupdmchannel")) with(channel) { @@ -78,7 +81,8 @@ class ChannelTest { @Test - fun `GuildNewChannel serialization`() { + @JsName("test4") + fun `GuildNewChannel serialization`() = runTest { val channel = Json.decodeFromString(DiscordChannel.serializer(), file("guildnewschannel")) with(channel) { @@ -97,7 +101,8 @@ class ChannelTest { @Test - fun `GuildTextChannel serialization`() { + @JsName("test5") + fun `GuildTextChannel serialization`() = runTest { val channel = Json.decodeFromString(DiscordChannel.serializer(), file("guildtextchannel")) with(channel) { @@ -117,7 +122,8 @@ class ChannelTest { @Test - fun `GuildVoiceChannel serialization`() { + @JsName("test6") + fun `GuildVoiceChannel serialization`() = runTest { val channel = Json.decodeFromString(DiscordChannel.serializer(), file("guildvoicechannel")) with(channel) { diff --git a/common/src/test/kotlin/json/EmojiTest.kt b/common/src/commonTest/kotlin/json/EmojiTest.kt similarity index 75% rename from common/src/test/kotlin/json/EmojiTest.kt rename to common/src/commonTest/kotlin/json/EmojiTest.kt index 528b834932e2..879f6b9a63c4 100644 --- a/common/src/test/kotlin/json/EmojiTest.kt +++ b/common/src/commonTest/kotlin/json/EmojiTest.kt @@ -2,19 +2,19 @@ package json import dev.kord.common.entity.DiscordEmoji import dev.kord.common.entity.Snowflake +import dev.kord.common.readFile +import kotlinx.coroutines.test.runTest import kotlinx.serialization.json.Json -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.Test - -private fun file(name: String): String { - val loader = ChannelTest::class.java.classLoader - return loader.getResource("json/emoji/$name.json").readText() -} +private suspend fun file(name: String): String = readFile("emoji", name) class EmojiTest { @Test - fun `Custom Emoji serialization`() { + @JsName("test1") + fun `Custom Emoji serialization`() = runTest { val emoji = Json.decodeFromString(DiscordEmoji.serializer(), file("customemoji")) with(emoji) { @@ -24,7 +24,8 @@ class EmojiTest { } @Test - fun `Standard Emoji serialization`() { + @JsName("test2") + fun `Standard Emoji serialization`() = runTest { val emoji = Json.decodeFromString(DiscordEmoji.serializer(), file("standardemoji")) with(emoji) { @@ -34,7 +35,8 @@ class EmojiTest { } @Test - fun `Emoji serialization`() { + @JsName("test3") + fun `Emoji serialization`() = runTest { val emoji = Json.decodeFromString(DiscordEmoji.serializer(), file("emoji")) with(emoji) { diff --git a/common/src/test/kotlin/json/GuildTest.kt b/common/src/commonTest/kotlin/json/GuildTest.kt similarity index 87% rename from common/src/test/kotlin/json/GuildTest.kt rename to common/src/commonTest/kotlin/json/GuildTest.kt index a0570b56da2f..d2eedc02004d 100644 --- a/common/src/test/kotlin/json/GuildTest.kt +++ b/common/src/commonTest/kotlin/json/GuildTest.kt @@ -1,21 +1,21 @@ package json import dev.kord.common.entity.* +import dev.kord.common.readFile +import kotlinx.coroutines.test.runTest import kotlinx.datetime.Instant import kotlinx.serialization.json.Json -import org.junit.jupiter.api.Test +import kotlin.js.JsName import kotlin.time.Duration.Companion.seconds +import kotlin.test.Test - -private fun file(name: String): String { - val loader = ChannelTest::class.java.classLoader - return loader.getResource("json/guild/$name.json")!!.readText() -} +private suspend fun file(name: String): String = readFile("guild", name) class GuildTest { @Test - fun `Guild serialization`() { + @JsName("test1") + fun `Guild serialization`() = runTest { val guild = Json.decodeFromString(DiscordGuild.serializer(), file("guild")) with(guild) { @@ -65,7 +65,8 @@ class GuildTest { } @Test - fun `UnavailableGuild serialization`() { + @JsName("test2") + fun `UnavailableGuild serialization`() = runTest { val guild = Json.decodeFromString(DiscordUnavailableGuild.serializer(), file("unavailableguild")) with(guild) { @@ -76,7 +77,8 @@ class GuildTest { } @Test - fun `GuildMember serialization`() { + @JsName("test3") + fun `GuildMember serialization`() = runTest { val member = Json.decodeFromString(DiscordGuildMember.serializer(), file("guildmember")) with(member) { @@ -90,7 +92,8 @@ class GuildTest { } @Test - fun `PartialGuild serialization`() { + @JsName("test4") + fun `PartialGuild serialization`() = runTest { val guild = Json.decodeFromString(DiscordPartialGuild.serializer(), file("partialguild")) with(guild) { diff --git a/common/src/test/kotlin/json/InteractionTest.kt b/common/src/commonTest/kotlin/json/InteractionTest.kt similarity index 84% rename from common/src/test/kotlin/json/InteractionTest.kt rename to common/src/commonTest/kotlin/json/InteractionTest.kt index c962e75d18ac..c345d736c5a6 100644 --- a/common/src/test/kotlin/json/InteractionTest.kt +++ b/common/src/commonTest/kotlin/json/InteractionTest.kt @@ -2,13 +2,14 @@ package json import dev.kord.common.entity.* import dev.kord.common.entity.optional.orEmpty +import dev.kord.common.readFile +import kotlinx.coroutines.test.runTest import kotlinx.serialization.json.Json -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.Test +import kotlin.test.assertIs -private fun file(name: String): String { - val loader = InteractionTest::class.java.classLoader - return loader.getResource("json/interaction/$name.json")!!.readText() -} +private suspend fun file(name: String): String = readFile("interaction", name) class InteractionTest { @@ -17,7 +18,8 @@ class InteractionTest { } @Test - fun `group command can be deserialized`() { + @JsName("test1") + fun `group command can be deserialized`() = runTest { val text = file("groupsubcommand") val interaction = json.decodeFromString(DiscordInteraction.serializer(), text) @@ -31,8 +33,7 @@ class InteractionTest { data.name shouldBe "testsubcommands" data.id shouldBe "792107855418490901" val group = data.options.orEmpty().first() - assert(group is CommandGroup) - group as CommandGroup + assertIs(group) group.name shouldBe "group" val subCommand = group.options.orEmpty().first() subCommand.name shouldBe "groupsubcommand" @@ -45,7 +46,8 @@ class InteractionTest { } @Test - fun `subcommand can be deserialized`() { + @JsName("test2") + fun `subcommand can be deserialized`() = runTest { val text = file("subcommand") val interaction = json.decodeFromString(DiscordInteraction.serializer(), text) @@ -59,8 +61,7 @@ class InteractionTest { data.name shouldBe "testsubcommands" data.id shouldBe "792107855418490901" val subCommand = data.options.orEmpty().first() - assert(subCommand is SubCommand) - subCommand as SubCommand + assertIs(subCommand) subCommand.name shouldBe "subcommand" val arg = subCommand.options.orEmpty().first() arg.type shouldBe ApplicationCommandOptionType.Integer @@ -72,7 +73,8 @@ class InteractionTest { @Test - fun `root can be deserialized`() { + @JsName("test3") + fun `root can be deserialized`() = runTest { val text = file("rootcommand") val interaction = json.decodeFromString(DiscordInteraction.serializer(), text) @@ -86,8 +88,7 @@ class InteractionTest { data.name shouldBe "testsubcommands" data.id shouldBe "792107855418490901" val arg = data.options.orEmpty().first() - assert(arg is CommandArgument<*>) - arg as CommandArgument<*> + assertIs>(arg) arg.type shouldBe ApplicationCommandOptionType.Integer arg.name shouldBe "testint" arg.value shouldBe 1L @@ -96,7 +97,8 @@ class InteractionTest { } @Test - fun `slash command permissions can be serialized`() { + @JsName("test4") + fun `slash command permissions can be serialized`() = runTest { val text = file("slash_command_permissions_update") val interaction = json.decodeFromString(DiscordGuildApplicationCommandPermissions.serializer(), text) @@ -115,14 +117,15 @@ class InteractionTest { } @Test - fun `select menu can be deserialized`() { + @JsName("test5") + fun `select menu can be deserialized`() = runTest { val text = file("selectmenu") val interaction = json.decodeFromString(DiscordInteraction.serializer(), text) with(interaction) { applicationId shouldBe "845027738276462632" channelId shouldBe "772908445358620702" - with(data){ + with(data) { componentType shouldBe ComponentType.StringSelect customId shouldBe "class_select_1" values shouldBe listOf("mage", "rogue") diff --git a/common/src/test/kotlin/json/MessageTest.kt b/common/src/commonTest/kotlin/json/MessageTest.kt similarity index 90% rename from common/src/test/kotlin/json/MessageTest.kt rename to common/src/commonTest/kotlin/json/MessageTest.kt index 5f6bfabd3d13..c4376382af00 100644 --- a/common/src/test/kotlin/json/MessageTest.kt +++ b/common/src/commonTest/kotlin/json/MessageTest.kt @@ -1,20 +1,20 @@ package json import dev.kord.common.entity.* +import dev.kord.common.readFile +import kotlinx.coroutines.test.runTest import kotlinx.datetime.Instant import kotlinx.serialization.json.Json -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.Test - -private fun file(name: String): String { - val loader = ChannelTest::class.java.classLoader - return loader.getResource("json/message/$name.json")!!.readText() -} +private suspend fun file(name: String): String = readFile("message", name) class MessageTest { @Test - fun `Message serialization`() { + @JsName("test1") + fun `Message serialization`() = runTest { val message: DiscordMessage = Json.decodeFromString(DiscordMessage.serializer(), file("message")) with(message) { @@ -51,7 +51,8 @@ class MessageTest { } @Test - fun `User serialization`() { + @JsName("test2") + fun `User serialization`() = runTest { val message = Json.decodeFromString(DiscordMessage.serializer(), file("crossposted")) with(message) { diff --git a/common/src/test/kotlin/json/PermissionsTest.kt b/common/src/commonTest/kotlin/json/PermissionsTest.kt similarity index 82% rename from common/src/test/kotlin/json/PermissionsTest.kt rename to common/src/commonTest/kotlin/json/PermissionsTest.kt index 63a7c8405d3b..7d6eafe681de 100644 --- a/common/src/test/kotlin/json/PermissionsTest.kt +++ b/common/src/commonTest/kotlin/json/PermissionsTest.kt @@ -1,16 +1,18 @@ package json import dev.kord.common.DiscordBitSet -import dev.kord.common.EmptyBitSet import dev.kord.common.entity.* import kotlinx.serialization.json.Json import kotlinx.serialization.json.buildJsonObject import kotlinx.serialization.json.put -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.Test +import kotlin.test.assertEquals class PermissionsTest { @Test + @JsName("test1") fun `adding permissions together does not swallow the universe`() { Permission.values.fold(Permissions(DiscordBitSet(0))) { acc, permission -> acc + permission @@ -18,11 +20,13 @@ class PermissionsTest { } @Test + @JsName("test2") fun `Permission All does not swallow the universe`() { Permission.All //oh yeah, this is worthy of a test } @Test + @JsName("test3") fun `permissions serialization test`() { val expected = buildJsonObject { put("id", "12323232") @@ -35,10 +39,11 @@ class PermissionsTest { put("mentionable", false) } val actual = Json.decodeFromJsonElement(DiscordRole.serializer(), expected) - assert(actual.permissions.code.value == "123456789876543000000000000") { + assertEquals( + actual.permissions.code.value, "123456789876543000000000000", "1234567898765430000000000 was expected but ${actual.permissions.code.value} was found" - } + ) } -} \ No newline at end of file +} diff --git a/common/src/test/kotlin/json/UserTest.kt b/common/src/commonTest/kotlin/json/UserTest.kt similarity index 72% rename from common/src/test/kotlin/json/UserTest.kt rename to common/src/commonTest/kotlin/json/UserTest.kt index f25a129cc107..b10bfeba9bab 100644 --- a/common/src/test/kotlin/json/UserTest.kt +++ b/common/src/commonTest/kotlin/json/UserTest.kt @@ -2,18 +2,19 @@ package json import dev.kord.common.entity.DiscordUser import dev.kord.common.entity.UserFlags +import dev.kord.common.readFile +import kotlinx.coroutines.test.runTest import kotlinx.serialization.json.Json -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.Test -private fun file(name: String): String { - val loader = ChannelTest::class.java.classLoader - return loader.getResource("json/user/$name.json").readText() -} +private suspend fun file(name: String): String = readFile("user", name) class UserTest { @Test - fun `User serialization`() { + @JsName("test1") + fun `User serialization`() = runTest{ val user = Json.decodeFromString(DiscordUser.serializer(), file("user")) with(user) { diff --git a/common/src/commonTest/kotlin/json/Util.kt b/common/src/commonTest/kotlin/json/Util.kt new file mode 100644 index 000000000000..24f8df2c6c34 --- /dev/null +++ b/common/src/commonTest/kotlin/json/Util.kt @@ -0,0 +1,53 @@ +package json + +import dev.kord.common.entity.* +import dev.kord.common.entity.optional.* +import kotlin.test.assertEquals + +infix fun String?.shouldBe(value: String?) = + assertEquals(value, this) + +infix fun Optional.shouldBe(value: String?) = + assertEquals(value, this.value) + +infix fun OptionalBoolean.shouldBe(value: Boolean) = + assertEquals(value, this.value) + +infix fun Snowflake?.shouldBe(value: String?) = + assertEquals(value, this?.toString()) + +infix fun OptionalSnowflake?.shouldBe(value: String?) = + assertEquals(value, this?.value?.toString()) + +infix fun VerificationLevel?.shouldBe(value: VerificationLevel?) = + assertEquals(value, this) + +infix fun DefaultMessageNotificationLevel?.shouldBe(value: DefaultMessageNotificationLevel?) = + assertEquals(value, this) + +infix fun MFALevel?.shouldBe(value: MFALevel?) = + assertEquals(value, this) + +infix fun ExplicitContentFilter?.shouldBe(value: ExplicitContentFilter?) = + assertEquals(value, this) + +infix fun PremiumTier?.shouldBe(value: PremiumTier?) = + assertEquals(value, this) + +infix fun SystemChannelFlags?.shouldBe(value: SystemChannelFlags?) = + assertEquals(value, this) + +infix fun List?.shouldBe(value: List?) = + assertEquals(value, this) + +infix fun Int?.shouldBe(value: Int?) = + assertEquals(value, this) + +infix fun OptionalInt?.shouldBe(value: Int?) = + assertEquals(value, this.value) + +infix fun Optional.shouldBe(that: T?) = + assertEquals(that, this.value) + +infix fun T.shouldBe(that: T) = + assertEquals(that, this) diff --git a/common/src/test/kotlin/json/VoiceStateTest.kt b/common/src/commonTest/kotlin/json/VoiceStateTest.kt similarity index 74% rename from common/src/test/kotlin/json/VoiceStateTest.kt rename to common/src/commonTest/kotlin/json/VoiceStateTest.kt index 0aa78e4062b8..b7a917c53095 100644 --- a/common/src/test/kotlin/json/VoiceStateTest.kt +++ b/common/src/commonTest/kotlin/json/VoiceStateTest.kt @@ -1,19 +1,20 @@ package json import dev.kord.common.entity.DiscordVoiceState +import dev.kord.common.readFile +import kotlinx.coroutines.test.runTest import kotlinx.datetime.Instant import kotlinx.serialization.json.Json -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.Test -private fun file(name: String): String { - val loader = ChannelTest::class.java.classLoader - return loader.getResource("json/voice/$name.json")!!.readText() -} +private suspend fun file(name: String): String = readFile("voice", name) class VoiceStateTest { @Test - fun `VoiceState serialization`() { + @JsName("test1") + fun `VoiceState serialization`() = runTest { val state = Json.decodeFromString(DiscordVoiceState.serializer(), file("voicestate")) with(state) { diff --git a/common/src/test/kotlin/ratelimit/AbstractIntervalRateLimiterTest.kt b/common/src/commonTest/kotlin/ratelimit/AbstractIntervalRateLimiterTest.kt similarity index 94% rename from common/src/test/kotlin/ratelimit/AbstractIntervalRateLimiterTest.kt rename to common/src/commonTest/kotlin/ratelimit/AbstractIntervalRateLimiterTest.kt index 5abebfbbb03c..7038bd99a919 100644 --- a/common/src/test/kotlin/ratelimit/AbstractIntervalRateLimiterTest.kt +++ b/common/src/commonTest/kotlin/ratelimit/AbstractIntervalRateLimiterTest.kt @@ -1,8 +1,9 @@ -package ratelimit +package dev.kord.common.ratelimit import dev.kord.common.ratelimit.IntervalRateLimiter import kotlinx.coroutines.test.currentTime import kotlinx.coroutines.test.runTest +import kotlin.js.JsName import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertEquals @@ -27,6 +28,7 @@ abstract class AbstractIntervalRateLimiterTest { } @Test + @JsName("test1") fun `an interval rate limiter does not accept illegal arguments`() { fun assertIAE(limit: Int, interval: Duration) { @@ -41,6 +43,7 @@ abstract class AbstractIntervalRateLimiterTest { } @Test + @JsName("test2") fun `an interval rate limiter does not ratelimit when under limit`() = runTest { repeat(limit) { rateLimiter.consume() } @@ -48,6 +51,7 @@ abstract class AbstractIntervalRateLimiterTest { } @Test + @JsName("test3") fun `an interval rate limiter does ratelimit when over limit`() = runTest { repeat(limit + 1) { rateLimiter.consume() } diff --git a/common/src/test/kotlin/ratelimit/ClockIntervalRateLimiterTest.kt b/common/src/commonTest/kotlin/ratelimit/ClockIntervalRateLimiterTest.kt similarity index 70% rename from common/src/test/kotlin/ratelimit/ClockIntervalRateLimiterTest.kt rename to common/src/commonTest/kotlin/ratelimit/ClockIntervalRateLimiterTest.kt index c6a3533ca10e..f88681bc4f13 100644 --- a/common/src/test/kotlin/ratelimit/ClockIntervalRateLimiterTest.kt +++ b/common/src/commonTest/kotlin/ratelimit/ClockIntervalRateLimiterTest.kt @@ -1,8 +1,6 @@ -package ratelimit +package dev.kord.common.ratelimit -import dev.kord.common.ratelimit.ClockIntervalRateLimiter -import dev.kord.common.ratelimit.IntervalRateLimiter -import fixed +import dev.kord.common.fixed import kotlinx.datetime.Clock import kotlin.time.Duration diff --git a/common/src/test/kotlin/ratelimit/TimeSourceIntervalRateLimiterTest.kt b/common/src/commonTest/kotlin/ratelimit/TimeSourceIntervalRateLimiterTest.kt similarity index 72% rename from common/src/test/kotlin/ratelimit/TimeSourceIntervalRateLimiterTest.kt rename to common/src/commonTest/kotlin/ratelimit/TimeSourceIntervalRateLimiterTest.kt index 694196d78a6c..2f519e8d2100 100644 --- a/common/src/test/kotlin/ratelimit/TimeSourceIntervalRateLimiterTest.kt +++ b/common/src/commonTest/kotlin/ratelimit/TimeSourceIntervalRateLimiterTest.kt @@ -1,7 +1,5 @@ -package ratelimit +package dev.kord.common.ratelimit -import dev.kord.common.ratelimit.IntervalRateLimiter -import dev.kord.common.ratelimit.TimeSourceIntervalRateLimiter import kotlin.time.Duration import kotlin.time.TestTimeSource diff --git a/common/src/test/kotlin/serialization/DurationSerializersTests.kt b/common/src/commonTest/kotlin/serialization/DurationSerializersTests.kt similarity index 95% rename from common/src/test/kotlin/serialization/DurationSerializersTests.kt rename to common/src/commonTest/kotlin/serialization/DurationSerializersTests.kt index be071f4a8dbb..31d673a79401 100644 --- a/common/src/test/kotlin/serialization/DurationSerializersTests.kt +++ b/common/src/commonTest/kotlin/serialization/DurationSerializersTests.kt @@ -3,6 +3,7 @@ package serialization import dev.kord.common.serialization.* import kotlinx.serialization.SerializationException import kotlinx.serialization.json.Json +import kotlin.js.JsName import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith @@ -43,17 +44,20 @@ abstract class DurationSerializerTest( @Test + @JsName("test1") fun `zero Duration can be serialized`() { assertEquals(expected = "0", actual = serialize(Duration.ZERO)) } @Test + @JsName("test2") fun `zero Duration can be deserialized`() { assertEquals(expected = Duration.ZERO, actual = deserialize("0")) } @Test + @JsName("test3") fun `infinite Durations cannot be serialized`() { assertFailsWith { serialize(Duration.INFINITE) } assertFailsWith { serialize(-Duration.INFINITE) } @@ -61,38 +65,45 @@ abstract class DurationSerializerTest( @Test + @JsName("test4") fun `positive Duration can be serialized`() { assertEquals(expected = json, actual = serialize(duration)) } @Test + @JsName("test5") fun `positive Duration can be rounded and serialized`() { assertEquals(expected = json, actual = serialize(durationToRound)) } @Test + @JsName("test6") fun `positive Duration can be deserialized`() { assertEquals(expected = duration, actual = deserialize(json)) } @Test + @JsName("test7") fun `negative Duration can be serialized`() { assertEquals(expected = "-$json", actual = serialize(-duration)) } @Test + @JsName("test8") fun `negative Duration can be rounded and serialized`() { assertEquals(expected = "-$json", actual = serialize(-durationToRound)) } @Test + @JsName("test9") fun `negative Duration can be deserialized`() { assertEquals(expected = -duration, actual = deserialize("-$json")) } @Test + @JsName("test10") fun `positive Duration that would overflow in target unit cannot be serialized`() { if (durationThatWouldOverflowInTargetUnit != null) assertFailsWith { serialize(durationThatWouldOverflowInTargetUnit) @@ -100,6 +111,7 @@ abstract class DurationSerializerTest( } @Test + @JsName("test11") fun `negative Duration that would overflow in target unit cannot be serialized`() { if (durationThatWouldOverflowInTargetUnit != null) assertFailsWith { serialize(-durationThatWouldOverflowInTargetUnit) @@ -108,11 +120,13 @@ abstract class DurationSerializerTest( @Test + @JsName("test12") fun `large positive Duration gets deserialized as Infinity`() { if (largeJson != null) assertEquals(expected = Duration.INFINITE, deserialize(largeJson)) } @Test + @JsName("test13") fun `large negative Duration gets deserialized as -Infinity`() { if (largeJson != null) assertEquals(expected = -Duration.INFINITE, deserialize("-$largeJson")) } diff --git a/common/src/test/kotlin/serialization/InstantSerializersTests.kt b/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt similarity index 92% rename from common/src/test/kotlin/serialization/InstantSerializersTests.kt rename to common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt index ebbe87a3abfa..d9ee9f05152e 100644 --- a/common/src/test/kotlin/serialization/InstantSerializersTests.kt +++ b/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt @@ -6,6 +6,7 @@ import kotlinx.datetime.Instant import kotlinx.serialization.KSerializer import kotlinx.serialization.SerializationException import kotlinx.serialization.json.Json +import kotlin.js.JsName import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith @@ -29,33 +30,39 @@ abstract class InstantSerializerTest( @Test + @JsName("test1") fun `epoch Instant can be serialized`() { assertEquals(expected = "0", actual = serialize(EPOCH)) } @Test + @JsName("test2") fun `epoch Instant can be deserialized`() { assertEquals(expected = EPOCH, actual = deserialize("0")) } @Test + @JsName("test3") fun `future Instant can be serialized`() { assertEquals(expected = json, actual = serialize(instant)) } @Test + @JsName("test4") fun `future Instant can be deserialized`() { assertEquals(expected = instant, actual = deserialize(json)) } @Test + @JsName("test5") fun `past Instant can be serialized`() { assertEquals(expected = "-$json", actual = serialize(mirroredInstant)) } @Test + @JsName("testtest6") fun `past Instant can be deserialized`() { assertEquals(expected = mirroredInstant, actual = deserialize("-$json")) } @@ -71,6 +78,7 @@ class InstantInEpochMillisecondsSerializerTest : InstantSerializerTest( private val pastInstantExactlyAtLimit = Instant.fromEpochMilliseconds(Long.MIN_VALUE) @Test + @JsName("test7") fun `future Instant under limit can be serialized`() { assertEquals( expected = (Long.MAX_VALUE - 1).toString(), @@ -79,6 +87,7 @@ class InstantInEpochMillisecondsSerializerTest : InstantSerializerTest( } @Test + @JsName("test8") fun `past Instant under limit can be serialized`() { assertEquals( expected = Long.MIN_VALUE.toString(), @@ -88,22 +97,26 @@ class InstantInEpochMillisecondsSerializerTest : InstantSerializerTest( @Test + @JsName("test9") fun `future Instant exactly at limit can be serialized`() { assertEquals(expected = Long.MAX_VALUE.toString(), actual = serialize(futureInstantExactlyAtLimit)) } @Test + @JsName("test10") fun `past Instant exactly at limit can be serialized`() { assertEquals(expected = Long.MIN_VALUE.toString(), actual = serialize(pastInstantExactlyAtLimit)) } @Test + @JsName("test11") fun `future Instant over limit cannot be serialized`() { assertFailsWith { serialize(futureInstantExactlyAtLimit + 1.nanoseconds) } } @Test + @JsName("test12") fun `past Instant over limit cannot be serialized`() { assertFailsWith { serialize(pastInstantExactlyAtLimit - 1.nanoseconds) } } diff --git a/common/src/test/resources/json/channel/channelcategory.json b/common/src/commonTest/resources/json/channel/channelcategory.json similarity index 100% rename from common/src/test/resources/json/channel/channelcategory.json rename to common/src/commonTest/resources/json/channel/channelcategory.json diff --git a/common/src/test/resources/json/channel/dmchannel.json b/common/src/commonTest/resources/json/channel/dmchannel.json similarity index 100% rename from common/src/test/resources/json/channel/dmchannel.json rename to common/src/commonTest/resources/json/channel/dmchannel.json diff --git a/common/src/test/resources/json/channel/groupdmchannel.json b/common/src/commonTest/resources/json/channel/groupdmchannel.json similarity index 100% rename from common/src/test/resources/json/channel/groupdmchannel.json rename to common/src/commonTest/resources/json/channel/groupdmchannel.json diff --git a/common/src/test/resources/json/channel/guildnewschannel.json b/common/src/commonTest/resources/json/channel/guildnewschannel.json similarity index 100% rename from common/src/test/resources/json/channel/guildnewschannel.json rename to common/src/commonTest/resources/json/channel/guildnewschannel.json diff --git a/common/src/test/resources/json/channel/guildtextchannel.json b/common/src/commonTest/resources/json/channel/guildtextchannel.json similarity index 100% rename from common/src/test/resources/json/channel/guildtextchannel.json rename to common/src/commonTest/resources/json/channel/guildtextchannel.json diff --git a/common/src/test/resources/json/channel/guildvoicechannel.json b/common/src/commonTest/resources/json/channel/guildvoicechannel.json similarity index 100% rename from common/src/test/resources/json/channel/guildvoicechannel.json rename to common/src/commonTest/resources/json/channel/guildvoicechannel.json diff --git a/common/src/test/resources/json/emoji/customemoji.json b/common/src/commonTest/resources/json/emoji/customemoji.json similarity index 100% rename from common/src/test/resources/json/emoji/customemoji.json rename to common/src/commonTest/resources/json/emoji/customemoji.json diff --git a/common/src/test/resources/json/emoji/emoji.json b/common/src/commonTest/resources/json/emoji/emoji.json similarity index 100% rename from common/src/test/resources/json/emoji/emoji.json rename to common/src/commonTest/resources/json/emoji/emoji.json diff --git a/common/src/test/resources/json/emoji/standardemoji.json b/common/src/commonTest/resources/json/emoji/standardemoji.json similarity index 100% rename from common/src/test/resources/json/emoji/standardemoji.json rename to common/src/commonTest/resources/json/emoji/standardemoji.json diff --git a/common/src/test/resources/json/guild/guild.json b/common/src/commonTest/resources/json/guild/guild.json similarity index 100% rename from common/src/test/resources/json/guild/guild.json rename to common/src/commonTest/resources/json/guild/guild.json diff --git a/common/src/test/resources/json/guild/guildmember.json b/common/src/commonTest/resources/json/guild/guildmember.json similarity index 100% rename from common/src/test/resources/json/guild/guildmember.json rename to common/src/commonTest/resources/json/guild/guildmember.json diff --git a/common/src/test/resources/json/guild/partialguild.json b/common/src/commonTest/resources/json/guild/partialguild.json similarity index 100% rename from common/src/test/resources/json/guild/partialguild.json rename to common/src/commonTest/resources/json/guild/partialguild.json diff --git a/common/src/test/resources/json/guild/unavailableguild.json b/common/src/commonTest/resources/json/guild/unavailableguild.json similarity index 100% rename from common/src/test/resources/json/guild/unavailableguild.json rename to common/src/commonTest/resources/json/guild/unavailableguild.json diff --git a/common/src/test/resources/json/interaction/groupsubcommand.json b/common/src/commonTest/resources/json/interaction/groupsubcommand.json similarity index 100% rename from common/src/test/resources/json/interaction/groupsubcommand.json rename to common/src/commonTest/resources/json/interaction/groupsubcommand.json diff --git a/common/src/test/resources/json/interaction/rootcommand.json b/common/src/commonTest/resources/json/interaction/rootcommand.json similarity index 100% rename from common/src/test/resources/json/interaction/rootcommand.json rename to common/src/commonTest/resources/json/interaction/rootcommand.json diff --git a/common/src/test/resources/json/interaction/selectmenu.json b/common/src/commonTest/resources/json/interaction/selectmenu.json similarity index 100% rename from common/src/test/resources/json/interaction/selectmenu.json rename to common/src/commonTest/resources/json/interaction/selectmenu.json diff --git a/common/src/test/resources/json/interaction/slash_command_permissions_update.json b/common/src/commonTest/resources/json/interaction/slash_command_permissions_update.json similarity index 100% rename from common/src/test/resources/json/interaction/slash_command_permissions_update.json rename to common/src/commonTest/resources/json/interaction/slash_command_permissions_update.json diff --git a/common/src/test/resources/json/interaction/subcommand.json b/common/src/commonTest/resources/json/interaction/subcommand.json similarity index 100% rename from common/src/test/resources/json/interaction/subcommand.json rename to common/src/commonTest/resources/json/interaction/subcommand.json diff --git a/common/src/test/resources/json/message/crossposted.json b/common/src/commonTest/resources/json/message/crossposted.json similarity index 100% rename from common/src/test/resources/json/message/crossposted.json rename to common/src/commonTest/resources/json/message/crossposted.json diff --git a/common/src/test/resources/json/message/message.json b/common/src/commonTest/resources/json/message/message.json similarity index 100% rename from common/src/test/resources/json/message/message.json rename to common/src/commonTest/resources/json/message/message.json diff --git a/common/src/test/resources/json/user/user.json b/common/src/commonTest/resources/json/user/user.json similarity index 100% rename from common/src/test/resources/json/user/user.json rename to common/src/commonTest/resources/json/user/user.json diff --git a/common/src/test/resources/json/voice/voicestate.json b/common/src/commonTest/resources/json/voice/voicestate.json similarity index 100% rename from common/src/test/resources/json/voice/voicestate.json rename to common/src/commonTest/resources/json/voice/voicestate.json diff --git a/common/src/jsTest/kotlin/file.kt b/common/src/jsTest/kotlin/file.kt new file mode 100644 index 000000000000..a39d74575d0c --- /dev/null +++ b/common/src/jsTest/kotlin/file.kt @@ -0,0 +1,7 @@ +package dev.kord.common + +import node.fs.readFile as nodeReadFile + +actual suspend fun readFile(prefix: String, name: String): String = + nodeReadFile("common/commonTest/resources/json/$prefix/$name.json") + .toString() diff --git a/common/src/jvmMain/kotlin/Color.kt b/common/src/jvmMain/kotlin/Color.kt new file mode 100644 index 000000000000..735306d43732 --- /dev/null +++ b/common/src/jvmMain/kotlin/Color.kt @@ -0,0 +1,7 @@ +@file:JvmName("ColorJvm" +) +package dev.kord.common + +import java.awt.Color as AwtColor + +public val AwtColor.kColor: Color get() = Color(rgb) diff --git a/common/src/jvmMain/kotlin/Locale.kt b/common/src/jvmMain/kotlin/Locale.kt new file mode 100644 index 000000000000..fae8d46c84a1 --- /dev/null +++ b/common/src/jvmMain/kotlin/Locale.kt @@ -0,0 +1,15 @@ +package dev.kord.common + +import java.util.Locale as JLocale + + +/** + * Converts this into a [JLocale]. + */ +public fun Locale.asJavaLocale(): JLocale = JLocale(language, country ?: "") + +/** + * Converts this into a [Locale]. + */ +public val JLocale.kLocale: Locale + get() = Locale(language, country.ifBlank { null }) diff --git a/common/src/jvmTest/kotlin/ColorTests.kt b/common/src/jvmTest/kotlin/ColorTests.kt new file mode 100644 index 000000000000..387bb1e338a9 --- /dev/null +++ b/common/src/jvmTest/kotlin/ColorTests.kt @@ -0,0 +1,15 @@ +import dev.kord.common.kColor +import kotlin.test.assertEquals + +import kotlin.test.Test + +class ColorTests { + @Test + fun `java to kColor conversion`() { + val color = java.awt.Color.decode("#DBD0B4").kColor + + assertEquals(219, color.red) + assertEquals(208, color.green) + assertEquals(180, color.blue) + } +} diff --git a/common/src/jvmTest/kotlin/file.kt b/common/src/jvmTest/kotlin/file.kt new file mode 100644 index 000000000000..3bee4f5efbf6 --- /dev/null +++ b/common/src/jvmTest/kotlin/file.kt @@ -0,0 +1,4 @@ +package dev.kord.common + +actual suspend inline fun readFile(prefix: String, name: String): String = + ClassLoader.getSystemResource("json/$prefix/$name.json")!!.readText() diff --git a/common/src/test/kotlin/json/Util.kt b/common/src/test/kotlin/json/Util.kt deleted file mode 100644 index 8f952f310b82..000000000000 --- a/common/src/test/kotlin/json/Util.kt +++ /dev/null @@ -1,69 +0,0 @@ -package json - -import dev.kord.common.entity.* -import dev.kord.common.entity.optional.* -import org.junit.jupiter.api.Assertions - -infix fun String?.shouldBe(value: String?){ - Assertions.assertEquals(value, this) -} - -infix fun Optional.shouldBe(value: String?){ - Assertions.assertEquals(value, this.value) -} - -infix fun OptionalBoolean.shouldBe(value: Boolean){ - Assertions.assertEquals(value, this.value) -} - -infix fun Snowflake?.shouldBe(value: String?){ - Assertions.assertEquals(value, this?.toString()) -} - -infix fun OptionalSnowflake?.shouldBe(value: String?){ - Assertions.assertEquals(value, this?.value?.toString()) -} - -infix fun VerificationLevel?.shouldBe(value: VerificationLevel?){ - Assertions.assertEquals(value, this) -} - -infix fun DefaultMessageNotificationLevel?.shouldBe(value: DefaultMessageNotificationLevel?){ - Assertions.assertEquals(value, this) -} - -infix fun MFALevel?.shouldBe(value: MFALevel?){ - Assertions.assertEquals(value, this) -} - -infix fun ExplicitContentFilter?.shouldBe(value: ExplicitContentFilter?){ - Assertions.assertEquals(value, this) -} - -infix fun PremiumTier?.shouldBe(value: PremiumTier?){ - Assertions.assertEquals(value, this) -} - -infix fun SystemChannelFlags?.shouldBe(value: SystemChannelFlags?){ - Assertions.assertEquals(value, this) -} - -infix fun List?.shouldBe(value: List?){ - Assertions.assertEquals(value, this) -} - -infix fun Int?.shouldBe(value: Int?){ - Assertions.assertEquals(value, this) -} - -infix fun OptionalInt?.shouldBe(value: Int?){ - Assertions.assertEquals(value, this.value) -} - -infix fun Optional.shouldBe(that: T?) { - Assertions.assertEquals(that, this.value) -} - -infix fun T.shouldBe(that: T) { - Assertions.assertEquals(that, this) -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f2e6f14229b6..7e47eb590ff1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -38,12 +38,15 @@ ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" } ktor-client-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" } ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" } ktor-network = { module = "io.ktor:ktor-network", version.ref = "ktor" } +ktor-utils = { module = "io.ktor:ktor-utils", version.ref = "ktor" } # kotlinx kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" } kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" } kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" } +kotlinx-atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version.ref = "kotlinx-atomicfu" } +kotlinx-nodejs = { module = "org.jetbrains.kotlin-wrappers:kotlin-node", version = "18.14.0-pre.502" } # other kotlin-logging = { module = "io.github.microutils:kotlin-logging", version.ref = "kotlin-logging" } @@ -53,8 +56,13 @@ ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.re kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoet" } kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlinpoet" } +# JDK Replacements +bignum = { module = "com.ionspin.kotlin:bignum", version = "0.3.8" } + # tests -kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } +kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test-common", version.ref = "kotlin" } +kotlin-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref = "kotlin" } +kotlin-test-annotations-common = { module = "org.jetbrains.kotlin:kotlin-test-annotations-common", version.ref = "kotlin" } kotlin-test-junit5 = { module = "org.jetbrains.kotlin:kotlin-test-junit5", version.ref = "kotlin" } junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit5" } junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit5" } @@ -76,6 +84,7 @@ ksp-plugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin ktor-client-serialization = ["ktor-client-content-negotiation", "ktor-serialization-kotlinx-json"] test-implementation = ["kotlinx-coroutines-test", "kotlin-test", "junit-jupiter-api", "mockk"] +test-common = ["kotlinx-coroutines-test", "kotlin-test", "kotlin-test-annotations-common"] test-runtime = ["kotlin-test-junit5", "junit-jupiter-engine", "slf4j-simple"] pluginsForBuildSrc = [ diff --git a/ksp-annotations/build.gradle.kts b/ksp-annotations/build.gradle.kts index e8efcb5ecf8c..4bcb3c72f8b5 100644 --- a/ksp-annotations/build.gradle.kts +++ b/ksp-annotations/build.gradle.kts @@ -1,3 +1,3 @@ plugins { - `kord-internal-module` + `kord-multiplatform-module` } diff --git a/ksp-annotations/src/main/kotlin/GenerateKordEnum.kt b/ksp-annotations/src/commonMain/kotlin/GenerateKordEnum.kt similarity index 100% rename from ksp-annotations/src/main/kotlin/GenerateKordEnum.kt rename to ksp-annotations/src/commonMain/kotlin/GenerateKordEnum.kt diff --git a/ksp-processors/src/main/kotlin/KSPUtils.kt b/ksp-processors/src/main/kotlin/KSPUtils.kt index be0176599880..7b6a516ab49b 100644 --- a/ksp-processors/src/main/kotlin/KSPUtils.kt +++ b/ksp-processors/src/main/kotlin/KSPUtils.kt @@ -10,11 +10,20 @@ internal inline fun Resolver.getSymbolsWithAnnotation(i internal inline fun KSAnnotation.isOfType() = shortName.asString() == A::class.simpleName!! && annotationType.resolve().declaration.qualifiedName?.asString() == A::class.qualifiedName!! -internal class AnnotationArguments private constructor(private val map: Map) { - internal operator fun get(parameter: KProperty1) = map[parameter.name] +internal class AnnotationArguments private constructor(private val map: Map) { + private inline fun get(parameter: KProperty1) = map[parameter.name] as V? + + internal inline fun getSafe(parameter: KProperty1) = get(parameter) ?: error("Missing required parameter: $parameter") + // https://github.com/google/ksp/issues/885 + internal inline fun getOrDefault(parameter: KProperty1, defaultValue: V) = get(parameter) ?: defaultValue + + internal fun getRaw(parameter: KProperty1) = map[parameter.name] internal companion object { - internal val KSAnnotation.annotationArguments - get() = AnnotationArguments(arguments.associate { it.name!!.getShortName() to it.value!! }) + internal val KSAnnotation.annotationArguments: AnnotationArguments + get() { + return AnnotationArguments(arguments + .associate { it.name!!.getShortName() to it.value }) + } } } diff --git a/ksp-processors/src/main/kotlin/kordenum/KordEnum.kt b/ksp-processors/src/main/kotlin/kordenum/KordEnum.kt index 33b8230e8489..fe913ca9a851 100644 --- a/ksp-processors/src/main/kotlin/kordenum/KordEnum.kt +++ b/ksp-processors/src/main/kotlin/kordenum/KordEnum.kt @@ -53,16 +53,18 @@ internal class KordEnum( internal fun KSAnnotation.toKordEnumOrNull(logger: KSPLogger): KordEnum? { val args = annotationArguments - val name = args[GenerateKordEnum::name] as String - val valueType = args[GenerateKordEnum::valueType].toValueType() - val entries = args[GenerateKordEnum::entries] as List<*> - val kDoc = args[GenerateKordEnum::kDoc].toKDoc() - val docUrl = (args[GenerateKordEnum::docUrl] as String).ifBlank { null } - val valueName = args[GenerateKordEnum::valueName] as String - val deprecatedEntries = args[GenerateKordEnum::deprecatedEntries] as List<*> - - val valuesPropertyName = (args[GenerateKordEnum::valuesPropertyName] as String).ifEmpty { null } - val valuesPropertyType = args[GenerateKordEnum::valuesPropertyType].toValuesPropertyType() + val name = args.getSafe(GenerateKordEnum::name) + val valueType = args.getRaw(GenerateKordEnum::valueType).toValueType() + val entries = args.getRaw(GenerateKordEnum::entries) as List<*> + val kDoc = args.getOrDefault(GenerateKordEnum::kDoc, "").toKDoc() + val docUrl = args.getOrDefault(GenerateKordEnum::docUrl, "").ifBlank { null } + val valueName = args.getOrDefault(GenerateKordEnum::valueName, "value") + val deprecatedEntries = args.getRaw(GenerateKordEnum::deprecatedEntries) as List<*>? ?: emptyList() + + val valuesPropertyName = args.getOrDefault(GenerateKordEnum::valuesPropertyName, "") + .ifEmpty { null } + val valuesPropertyType = args.getRaw(GenerateKordEnum::valuesPropertyType)?.toValuesPropertyType() + ?: NONE if (valuesPropertyName != null) { if (valuesPropertyType == NONE) { logger.error("Didn't specify valuesPropertyType", symbol = this) @@ -74,7 +76,7 @@ internal fun KSAnnotation.toKordEnumOrNull(logger: KSPLogger): KordEnum? { return null } } - val deprecatedSerializerName = (args[GenerateKordEnum::deprecatedSerializerName] as String).ifEmpty { null } + val deprecatedSerializerName = args.getOrDefault(GenerateKordEnum::deprecatedSerializerName, "").ifEmpty { null } return KordEnum( name, kDoc, docUrl, valueType, valueName, @@ -109,14 +111,16 @@ private fun Any?.toValuesPropertyType() = when (val name = (this as KSType).decl private fun Any?.toEntryOrNull(valueType: ValueType, isDeprecated: Boolean, logger: KSPLogger): Entry? { val args = (this as KSAnnotation).annotationArguments - val name = args[GenerateKordEnum.Entry::name] as String - val intValue = args[GenerateKordEnum.Entry::intValue] as Int - val stringValue = args[GenerateKordEnum.Entry::stringValue] as String - val kDoc = args[GenerateKordEnum.Entry::kDoc].toKDoc() - val isKordExperimental = args[GenerateKordEnum.Entry::isKordExperimental] as Boolean - val deprecationMessage = args[GenerateKordEnum.Entry::deprecationMessage] as String - val replaceWith = args[GenerateKordEnum.Entry::replaceWith].toReplaceWith() - val deprecationLevel = args[GenerateKordEnum.Entry::deprecationLevel].toDeprecationLevel() + val name = args.getSafe(GenerateKordEnum.Entry::name) + val intValue = args.getOrDefault(GenerateKordEnum.Entry::intValue, GenerateKordEnum.Entry.DEFAULT_INT_VALUE) + val stringValue = args.getOrDefault(GenerateKordEnum.Entry::stringValue, GenerateKordEnum.Entry.DEFAULT_STRING_VALUE) + val kDoc = args.getOrDefault(GenerateKordEnum.Entry::kDoc, "").toKDoc() + val isKordExperimental = args.getOrDefault(GenerateKordEnum.Entry::isKordExperimental, false) + val deprecationMessage = args.getOrDefault(GenerateKordEnum.Entry::deprecationMessage, "") + @Suppress("RemoveRedundantSpreadOperator") // Removing the emptyArray() will cause a compiler error + val replaceWith = args.getRaw(GenerateKordEnum.Entry::replaceWith)?.toReplaceWith() ?: ReplaceWith("", *emptyArray()) + val deprecationLevel = args.getRaw(GenerateKordEnum.Entry::deprecationLevel)?.toDeprecationLevel() + ?: WARNING val value = when (valueType) { INT -> { @@ -131,6 +135,7 @@ private fun Any?.toEntryOrNull(valueType: ValueType, isDeprecated: Boolean, logg intValue } + STRING -> { if (intValue != GenerateKordEnum.Entry.DEFAULT_INT_VALUE) { logger.error("Specified intValue for valueType $valueType", symbol = this) @@ -172,8 +177,8 @@ private fun Any?.toEntryOrNull(valueType: ValueType, isDeprecated: Boolean, logg private fun Any?.toReplaceWith(): ReplaceWith { val args = (this as KSAnnotation).annotationArguments - val expression = args[ReplaceWith::expression] as String - val imports = @Suppress("UNCHECKED_CAST") (args[ReplaceWith::imports] as List) + val expression = args.getSafe(ReplaceWith::expression) + val imports = @Suppress("UNCHECKED_CAST") (args.getRaw(ReplaceWith::imports) as List) return ReplaceWith(expression, *imports.toTypedArray()) } From afdb8acc62ce143ac9c4dadc27aed1944187adcc Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Fri, 24 Feb 2023 16:51:39 +0100 Subject: [PATCH 002/136] Add generated files --- .../kord/common/entity/AllowedMentionType.kt | 95 +++ .../entity/ApplicationCommandOptionType.kt | 128 ++++ .../ApplicationCommandPermissionType.kt | 86 +++ .../common/entity/ApplicationCommandType.kt | 94 +++ .../dev/kord/common/entity/AuditLogEvent.kt | 450 ++++++++++++++ .../common/entity/AutoModerationActionType.kt | 103 ++++ .../entity/AutoModerationRuleEventType.kt | 83 +++ .../AutoModerationRuleKeywordPresetType.kt | 97 +++ .../entity/AutoModerationRuleTriggerType.kt | 104 ++++ .../dev/kord/common/entity/ButtonStyle.kt | 137 ++++ .../dev/kord/common/entity/ChannelType.kt | 156 +++++ .../dev/kord/common/entity/ComponentType.kt | 166 +++++ .../entity/DefaultMessageNotificationLevel.kt | 88 +++ .../entity/DiscordConnectionVisibility.kt | 88 +++ .../dev/kord/common/entity/EmbedType.kt | 115 ++++ .../common/entity/ExplicitContentFilter.kt | 94 +++ .../dev/kord/common/entity/GuildFeature.kt | 287 +++++++++ .../entity/GuildScheduledEventPrivacyLevel.kt | 81 +++ .../entity/GuildScheduledEventStatus.kt | 118 ++++ .../entity/IntegrationExpireBehavior.kt | 110 ++++ .../common/entity/InteractionResponseType.kt | 124 ++++ .../dev/kord/common/entity/InteractionType.kt | 93 +++ .../kord/common/entity/InviteTargetType.kt | 81 +++ .../kotlin/dev/kord/common/entity/MFALevel.kt | 86 +++ .../kord/common/entity/MessageActivityType.kt | 89 +++ .../kord/common/entity/MessageStickerType.kt | 101 +++ .../dev/kord/common/entity/MessageType.kt | 259 ++++++++ .../dev/kord/common/entity/NsfwLevel.kt | 88 +++ .../dev/kord/common/entity/OverwriteType.kt | 80 +++ .../dev/kord/common/entity/PremiumTier.kt | 100 +++ .../dev/kord/common/entity/PresenceStatus.kt | 137 ++++ .../kord/common/entity/ScheduledEntityType.kt | 113 ++++ .../entity/StageInstancePrivacyLevel.kt | 117 ++++ .../kord/common/entity/TeamMembershipState.kt | 110 ++++ .../dev/kord/common/entity/TextInputStyle.kt | 89 +++ .../dev/kord/common/entity/UserPremium.kt | 90 +++ .../kord/common/entity/VerificationLevel.kt | 108 ++++ .../kord/common/entity/VideoQualityMode.kt | 87 +++ .../dev/kord/common/entity/WebhookType.kt | 94 +++ kotlin-js-store/yarn.lock | 583 ++++++++++++++++++ 40 files changed, 5309 insertions(+) create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AllowedMentionType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationCommandOptionType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationCommandPermissionType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationCommandType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AuditLogEvent.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationActionType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleEventType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleKeywordPresetType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleTriggerType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ButtonStyle.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ComponentType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/DefaultMessageNotificationLevel.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/DiscordConnectionVisibility.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/EmbedType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ExplicitContentFilter.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildFeature.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildScheduledEventPrivacyLevel.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildScheduledEventStatus.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/IntegrationExpireBehavior.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/InteractionResponseType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/InteractionType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/InviteTargetType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MFALevel.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageActivityType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageStickerType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/NsfwLevel.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/OverwriteType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/PremiumTier.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/PresenceStatus.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ScheduledEntityType.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/StageInstancePrivacyLevel.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/TeamMembershipState.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/TextInputStyle.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/UserPremium.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/VerificationLevel.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/VideoQualityMode.kt create mode 100644 common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/WebhookType.kt create mode 100644 kotlin-js-store/yarn.lock diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AllowedMentionType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AllowedMentionType.kt new file mode 100644 index 000000000000..7e0809b33c70 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AllowedMentionType.kt @@ -0,0 +1,95 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [AllowedMentionType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types). + */ +@Serializable(with = AllowedMentionType.Serializer::class) +public sealed class AllowedMentionType( + /** + * The raw value used by Discord. + */ + public val `value`: String, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is AllowedMentionType && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "AllowedMentionType.${this::class.simpleName}(value=$value)" + + /** + * An unknown [AllowedMentionType]. + * + * This is used as a fallback for [AllowedMentionType]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: String, + ) : AllowedMentionType(value) + + /** + * Controls role mentions. + */ + public object RoleMentions : AllowedMentionType("roles") + + /** + * Controls user mentions + */ + public object UserMentions : AllowedMentionType("users") + + /** + * Controls @everyone and @here mentions. + */ + public object EveryoneMentions : AllowedMentionType("everyone") + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.AllowedMentionType", + PrimitiveKind.STRING) + + public override fun serialize(encoder: Encoder, `value`: AllowedMentionType) = + encoder.encodeString(value.value) + + public override fun deserialize(decoder: Decoder) = + when (val value = decoder.decodeString()) { + "roles" -> RoleMentions + "users" -> UserMentions + "everyone" -> EveryoneMentions + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [AllowedMentionType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + RoleMentions, + UserMentions, + EveryoneMentions, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationCommandOptionType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationCommandOptionType.kt new file mode 100644 index 000000000000..3009f6405875 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationCommandOptionType.kt @@ -0,0 +1,128 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [ApplicationCommandOptionType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type). + */ +@Serializable(with = ApplicationCommandOptionType.Serializer::class) +public sealed class ApplicationCommandOptionType( + /** + * The raw type used by Discord. + */ + public val type: Int, +) { + public final override fun equals(other: Any?): kotlin.Boolean = this === other || + (other is ApplicationCommandOptionType && this.type == other.type) + + public final override fun hashCode(): Int = type.hashCode() + + public final override fun toString(): kotlin.String = + "ApplicationCommandOptionType.${this::class.simpleName}(type=$type)" + + /** + * An unknown [ApplicationCommandOptionType]. + * + * This is used as a fallback for [ApplicationCommandOptionType]s that haven't been added to + * Kord yet. + */ + public class Unknown( + type: Int, + ) : ApplicationCommandOptionType(type) + + public object SubCommand : ApplicationCommandOptionType(1) + + public object SubCommandGroup : ApplicationCommandOptionType(2) + + public object String : ApplicationCommandOptionType(3) + + /** + * Any integer between `-2^53` and `2^53`. + */ + public object Integer : ApplicationCommandOptionType(4) + + public object Boolean : ApplicationCommandOptionType(5) + + public object User : ApplicationCommandOptionType(6) + + /** + * Includes all channel types + categories. + */ + public object Channel : ApplicationCommandOptionType(7) + + public object Role : ApplicationCommandOptionType(8) + + /** + * Includes users and roles. + */ + public object Mentionable : ApplicationCommandOptionType(9) + + /** + * Any double between `-2^53` and `2^53`. + */ + public object Number : ApplicationCommandOptionType(10) + + public object Attachment : ApplicationCommandOptionType(11) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.ApplicationCommandOptionType", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: ApplicationCommandOptionType) = + encoder.encodeInt(value.type) + + public override fun deserialize(decoder: Decoder) = when (val type = decoder.decodeInt()) { + 1 -> SubCommand + 2 -> SubCommandGroup + 3 -> String + 4 -> Integer + 5 -> Boolean + 6 -> User + 7 -> Channel + 8 -> Role + 9 -> Mentionable + 10 -> Number + 11 -> Attachment + else -> Unknown(type) + } + } + + public companion object { + /** + * A [List] of all known [ApplicationCommandOptionType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + SubCommand, + SubCommandGroup, + String, + Integer, + Boolean, + User, + Channel, + Role, + Mentionable, + Number, + Attachment, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationCommandPermissionType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationCommandPermissionType.kt new file mode 100644 index 000000000000..f98288a8e2de --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationCommandPermissionType.kt @@ -0,0 +1,86 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [ApplicationCommandPermissionType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type). + */ +@Serializable(with = ApplicationCommandPermissionType.Serializer::class) +public sealed class ApplicationCommandPermissionType( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is ApplicationCommandPermissionType && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "ApplicationCommandPermissionType.${this::class.simpleName}(value=$value)" + + /** + * An unknown [ApplicationCommandPermissionType]. + * + * This is used as a fallback for [ApplicationCommandPermissionType]s that haven't been added to + * Kord yet. + */ + public class Unknown( + `value`: Int, + ) : ApplicationCommandPermissionType(value) + + public object Role : ApplicationCommandPermissionType(1) + + public object User : ApplicationCommandPermissionType(2) + + public object Channel : ApplicationCommandPermissionType(3) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.ApplicationCommandPermissionType", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: ApplicationCommandPermissionType) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> Role + 2 -> User + 3 -> Channel + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [ApplicationCommandPermissionType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Role, + User, + Channel, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationCommandType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationCommandType.kt new file mode 100644 index 000000000000..37540d3e6b56 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ApplicationCommandType.kt @@ -0,0 +1,94 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [ApplicationCommandType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types). + */ +@Serializable(with = ApplicationCommandType.Serializer::class) +public sealed class ApplicationCommandType( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is ApplicationCommandType && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "ApplicationCommandType.${this::class.simpleName}(value=$value)" + + /** + * An unknown [ApplicationCommandType]. + * + * This is used as a fallback for [ApplicationCommandType]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : ApplicationCommandType(value) + + /** + * A text-based command that shows up when a user types `/`. + */ + public object ChatInput : ApplicationCommandType(1) + + /** + * A UI-based command that shows up when you right-click or tap on a user. + */ + public object User : ApplicationCommandType(2) + + /** + * A UI-based command that shows up when you right-click or tap on a message. + */ + public object Message : ApplicationCommandType(3) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.ApplicationCommandType", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: ApplicationCommandType) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> ChatInput + 2 -> User + 3 -> Message + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [ApplicationCommandType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + ChatInput, + User, + Message, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AuditLogEvent.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AuditLogEvent.kt new file mode 100644 index 000000000000..81ac1e4e0148 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AuditLogEvent.kt @@ -0,0 +1,450 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [AuditLogEvent]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events). + */ +@Serializable(with = AuditLogEvent.Serializer::class) +public sealed class AuditLogEvent( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is AuditLogEvent && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "AuditLogEvent.${this::class.simpleName}(value=$value)" + + /** + * An unknown [AuditLogEvent]. + * + * This is used as a fallback for [AuditLogEvent]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : AuditLogEvent(value) + + /** + * Server settings were updated. + */ + public object GuildUpdate : AuditLogEvent(1) + + /** + * Channel was created. + */ + public object ChannelCreate : AuditLogEvent(10) + + /** + * Channel settings were updated. + */ + public object ChannelUpdate : AuditLogEvent(11) + + /** + * Channel was deleted. + */ + public object ChannelDelete : AuditLogEvent(12) + + /** + * Permission overwrite was added to a channel. + */ + public object ChannelOverwriteCreate : AuditLogEvent(13) + + /** + * Permission overwrite was updated for a channel. + */ + public object ChannelOverwriteUpdate : AuditLogEvent(14) + + /** + * Permission overwrite was deleted from a channel. + */ + public object ChannelOverwriteDelete : AuditLogEvent(15) + + /** + * Member was removed from server. + */ + public object MemberKick : AuditLogEvent(20) + + /** + * Members were pruned from server. + */ + public object MemberPrune : AuditLogEvent(21) + + /** + * Member was banned from server. + */ + public object MemberBanAdd : AuditLogEvent(22) + + /** + * Server ban was lifted for a member. + */ + public object MemberBanRemove : AuditLogEvent(23) + + /** + * Member was updated in server. + */ + public object MemberUpdate : AuditLogEvent(24) + + /** + * Member was added or removed from a role. + */ + public object MemberRoleUpdate : AuditLogEvent(25) + + /** + * Member was moved to a different voice channel. + */ + public object MemberMove : AuditLogEvent(26) + + /** + * Member was disconnected from a voice channel. + */ + public object MemberDisconnect : AuditLogEvent(27) + + /** + * Bot user was added to server. + */ + public object BotAdd : AuditLogEvent(28) + + /** + * Role was created. + */ + public object RoleCreate : AuditLogEvent(30) + + /** + * Role was edited. + */ + public object RoleUpdate : AuditLogEvent(31) + + /** + * Role was deleted. + */ + public object RoleDelete : AuditLogEvent(32) + + /** + * Server invite was created. + */ + public object InviteCreate : AuditLogEvent(40) + + /** + * Server invite was updated. + */ + public object InviteUpdate : AuditLogEvent(41) + + /** + * Server invite was deleted. + */ + public object InviteDelete : AuditLogEvent(42) + + /** + * Webhook was created. + */ + public object WebhookCreate : AuditLogEvent(50) + + /** + * Webhook properties or channel were updated. + */ + public object WebhookUpdate : AuditLogEvent(51) + + /** + * Webhook was deleted. + */ + public object WebhookDelete : AuditLogEvent(52) + + /** + * Emoji was created. + */ + public object EmojiCreate : AuditLogEvent(60) + + /** + * Emoji name was updated. + */ + public object EmojiUpdate : AuditLogEvent(61) + + /** + * Emoji was deleted. + */ + public object EmojiDelete : AuditLogEvent(62) + + /** + * Single message was deleted. + */ + public object MessageDelete : AuditLogEvent(72) + + /** + * Multiple messages were deleted. + */ + public object MessageBulkDelete : AuditLogEvent(73) + + /** + * Message was pinned to a channel. + */ + public object MessagePin : AuditLogEvent(74) + + /** + * Message was unpinned from a channel. + */ + public object MessageUnpin : AuditLogEvent(75) + + /** + * App was added to server. + */ + public object IntegrationCreate : AuditLogEvent(80) + + /** + * App was updated (as an example, its scopes were updated). + */ + public object IntegrationUpdate : AuditLogEvent(81) + + /** + * App was removed from server. + */ + public object IntegrationDelete : AuditLogEvent(82) + + /** + * Stage instance was created (stage channel becomes live). + */ + public object StageInstanceCreate : AuditLogEvent(83) + + /** + * Stage instance details were updated. + */ + public object StageInstanceUpdate : AuditLogEvent(84) + + /** + * Stage instance was deleted (stage channel no longer live). + */ + public object StageInstanceDelete : AuditLogEvent(85) + + /** + * Sticker was created. + */ + public object StickerCreate : AuditLogEvent(90) + + /** + * Sticker details were updated. + */ + public object StickerUpdate : AuditLogEvent(91) + + /** + * Sticker was deleted. + */ + public object StickerDelete : AuditLogEvent(92) + + /** + * Event was created. + */ + public object GuildScheduledEventCreate : AuditLogEvent(100) + + /** + * Event was updated. + */ + public object GuildScheduledEventUpdate : AuditLogEvent(101) + + /** + * Event was cancelled. + */ + public object GuildScheduledEventDelete : AuditLogEvent(102) + + /** + * Thread was created in a channel. + */ + public object ThreadCreate : AuditLogEvent(110) + + /** + * Thread was updated. + */ + public object ThreadUpdate : AuditLogEvent(111) + + /** + * Thread was deleted. + */ + public object ThreadDelete : AuditLogEvent(112) + + /** + * Permissions were updated for a command. + */ + public object ApplicationCommandPermissionUpdate : AuditLogEvent(121) + + /** + * Auto Moderation rule was created. + */ + public object AutoModerationRuleCreate : AuditLogEvent(140) + + /** + * Auto Moderation rule was updated. + */ + public object AutoModerationRuleUpdate : AuditLogEvent(141) + + /** + * Auto Moderation rule was deleted. + */ + public object AutoModerationRuleDelete : AuditLogEvent(142) + + /** + * Message was blocked by Auto Moderation. + */ + public object AutoModerationBlockMessage : AuditLogEvent(143) + + /** + * Message was flagged by Auto Moderation. + */ + public object AutoModerationFlagToChannel : AuditLogEvent(144) + + /** + * Member was timed out by Auto Moderation. + */ + public object AutoModerationUserCommunicationDisabled : AuditLogEvent(145) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.AuditLogEvent", PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: AuditLogEvent) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> GuildUpdate + 10 -> ChannelCreate + 11 -> ChannelUpdate + 12 -> ChannelDelete + 13 -> ChannelOverwriteCreate + 14 -> ChannelOverwriteUpdate + 15 -> ChannelOverwriteDelete + 20 -> MemberKick + 21 -> MemberPrune + 22 -> MemberBanAdd + 23 -> MemberBanRemove + 24 -> MemberUpdate + 25 -> MemberRoleUpdate + 26 -> MemberMove + 27 -> MemberDisconnect + 28 -> BotAdd + 30 -> RoleCreate + 31 -> RoleUpdate + 32 -> RoleDelete + 40 -> InviteCreate + 41 -> InviteUpdate + 42 -> InviteDelete + 50 -> WebhookCreate + 51 -> WebhookUpdate + 52 -> WebhookDelete + 60 -> EmojiCreate + 61 -> EmojiUpdate + 62 -> EmojiDelete + 72 -> MessageDelete + 73 -> MessageBulkDelete + 74 -> MessagePin + 75 -> MessageUnpin + 80 -> IntegrationCreate + 81 -> IntegrationUpdate + 82 -> IntegrationDelete + 83 -> StageInstanceCreate + 84 -> StageInstanceUpdate + 85 -> StageInstanceDelete + 90 -> StickerCreate + 91 -> StickerUpdate + 92 -> StickerDelete + 100 -> GuildScheduledEventCreate + 101 -> GuildScheduledEventUpdate + 102 -> GuildScheduledEventDelete + 110 -> ThreadCreate + 111 -> ThreadUpdate + 112 -> ThreadDelete + 121 -> ApplicationCommandPermissionUpdate + 140 -> AutoModerationRuleCreate + 141 -> AutoModerationRuleUpdate + 142 -> AutoModerationRuleDelete + 143 -> AutoModerationBlockMessage + 144 -> AutoModerationFlagToChannel + 145 -> AutoModerationUserCommunicationDisabled + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [AuditLogEvent]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + GuildUpdate, + ChannelCreate, + ChannelUpdate, + ChannelDelete, + ChannelOverwriteCreate, + ChannelOverwriteUpdate, + ChannelOverwriteDelete, + MemberKick, + MemberPrune, + MemberBanAdd, + MemberBanRemove, + MemberUpdate, + MemberRoleUpdate, + MemberMove, + MemberDisconnect, + BotAdd, + RoleCreate, + RoleUpdate, + RoleDelete, + InviteCreate, + InviteUpdate, + InviteDelete, + WebhookCreate, + WebhookUpdate, + WebhookDelete, + EmojiCreate, + EmojiUpdate, + EmojiDelete, + MessageDelete, + MessageBulkDelete, + MessagePin, + MessageUnpin, + IntegrationCreate, + IntegrationUpdate, + IntegrationDelete, + StageInstanceCreate, + StageInstanceUpdate, + StageInstanceDelete, + StickerCreate, + StickerUpdate, + StickerDelete, + GuildScheduledEventCreate, + GuildScheduledEventUpdate, + GuildScheduledEventDelete, + ThreadCreate, + ThreadUpdate, + ThreadDelete, + ApplicationCommandPermissionUpdate, + AutoModerationRuleCreate, + AutoModerationRuleUpdate, + AutoModerationRuleDelete, + AutoModerationBlockMessage, + AutoModerationFlagToChannel, + AutoModerationUserCommunicationDisabled, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationActionType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationActionType.kt new file mode 100644 index 000000000000..f3266b09da72 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationActionType.kt @@ -0,0 +1,103 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * The type of action. + * + * See [AutoModerationActionType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-action-types). + */ +@Serializable(with = AutoModerationActionType.Serializer::class) +public sealed class AutoModerationActionType( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is AutoModerationActionType && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "AutoModerationActionType.${this::class.simpleName}(value=$value)" + + /** + * An unknown [AutoModerationActionType]. + * + * This is used as a fallback for [AutoModerationActionType]s that haven't been added to Kord + * yet. + */ + public class Unknown( + `value`: Int, + ) : AutoModerationActionType(value) + + /** + * Blocks the content of a message according to the rule. + */ + public object BlockMessage : AutoModerationActionType(1) + + /** + * Logs user content to a specified channel. + */ + public object SendAlertMessage : AutoModerationActionType(2) + + /** + * Timeout user for a specified duration. + * + * A [Timeout] action can only be set up for + * [Keyword][dev.kord.common.entity.AutoModerationRuleTriggerType.Keyword] and + * [MentionSpam][dev.kord.common.entity.AutoModerationRuleTriggerType.MentionSpam] rules. The + * [ModerateMembers][dev.kord.common.entity.Permission.ModerateMembers] permission is required to + * use the [Timeout] action type. + */ + public object Timeout : AutoModerationActionType(3) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.AutoModerationActionType", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: AutoModerationActionType) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> BlockMessage + 2 -> SendAlertMessage + 3 -> Timeout + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [AutoModerationActionType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + BlockMessage, + SendAlertMessage, + Timeout, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleEventType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleEventType.kt new file mode 100644 index 000000000000..7f285d457160 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleEventType.kt @@ -0,0 +1,83 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * Indicates in what event context a rule should be checked. + * + * See [AutoModerationRuleEventType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types). + */ +@Serializable(with = AutoModerationRuleEventType.Serializer::class) +public sealed class AutoModerationRuleEventType( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is AutoModerationRuleEventType && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "AutoModerationRuleEventType.${this::class.simpleName}(value=$value)" + + /** + * An unknown [AutoModerationRuleEventType]. + * + * This is used as a fallback for [AutoModerationRuleEventType]s that haven't been added to Kord + * yet. + */ + public class Unknown( + `value`: Int, + ) : AutoModerationRuleEventType(value) + + /** + * When a member sends or edits a message in the guild. + */ + public object MessageSend : AutoModerationRuleEventType(1) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.AutoModerationRuleEventType", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: AutoModerationRuleEventType) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> MessageSend + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [AutoModerationRuleEventType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + MessageSend, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleKeywordPresetType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleKeywordPresetType.kt new file mode 100644 index 000000000000..0fd6bd7c1ce8 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleKeywordPresetType.kt @@ -0,0 +1,97 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * An internally pre-defined wordset which will be searched for in content. + * + * See [AutoModerationRuleKeywordPresetType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-preset-types). + */ +@Serializable(with = AutoModerationRuleKeywordPresetType.Serializer::class) +public sealed class AutoModerationRuleKeywordPresetType( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is AutoModerationRuleKeywordPresetType && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "AutoModerationRuleKeywordPresetType.${this::class.simpleName}(value=$value)" + + /** + * An unknown [AutoModerationRuleKeywordPresetType]. + * + * This is used as a fallback for [AutoModerationRuleKeywordPresetType]s that haven't been added + * to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : AutoModerationRuleKeywordPresetType(value) + + /** + * Words that may be considered forms of swearing or cursing. + */ + public object Profanity : AutoModerationRuleKeywordPresetType(1) + + /** + * Words that refer to sexually explicit behavior or activity. + */ + public object SexualContent : AutoModerationRuleKeywordPresetType(2) + + /** + * Personal insults or words that may be considered hate speech. + */ + public object Slurs : AutoModerationRuleKeywordPresetType(3) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.AutoModerationRuleKeywordPresetType", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, + `value`: AutoModerationRuleKeywordPresetType) = encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> Profanity + 2 -> SexualContent + 3 -> Slurs + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [AutoModerationRuleKeywordPresetType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Profanity, + SexualContent, + Slurs, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleTriggerType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleTriggerType.kt new file mode 100644 index 000000000000..38d7f7282d96 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationRuleTriggerType.kt @@ -0,0 +1,104 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * Characterizes the type of content which can trigger the rule. + * + * See [AutoModerationRuleTriggerType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types). + */ +@Serializable(with = AutoModerationRuleTriggerType.Serializer::class) +public sealed class AutoModerationRuleTriggerType( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is AutoModerationRuleTriggerType && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "AutoModerationRuleTriggerType.${this::class.simpleName}(value=$value)" + + /** + * An unknown [AutoModerationRuleTriggerType]. + * + * This is used as a fallback for [AutoModerationRuleTriggerType]s that haven't been added to + * Kord yet. + */ + public class Unknown( + `value`: Int, + ) : AutoModerationRuleTriggerType(value) + + /** + * Check if content contains words from a user defined list of keywords. + */ + public object Keyword : AutoModerationRuleTriggerType(1) + + /** + * Check if content represents generic spam. + */ + public object Spam : AutoModerationRuleTriggerType(3) + + /** + * Check if content contains words from internal pre-defined wordsets. + */ + public object KeywordPreset : AutoModerationRuleTriggerType(4) + + /** + * Check if content contains more unique mentions than allowed. + */ + public object MentionSpam : AutoModerationRuleTriggerType(5) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.AutoModerationRuleTriggerType", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: AutoModerationRuleTriggerType) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> Keyword + 3 -> Spam + 4 -> KeywordPreset + 5 -> MentionSpam + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [AutoModerationRuleTriggerType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Keyword, + Spam, + KeywordPreset, + MentionSpam, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ButtonStyle.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ButtonStyle.kt new file mode 100644 index 000000000000..2af04b4c42b4 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ButtonStyle.kt @@ -0,0 +1,137 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Deprecated +import kotlin.DeprecationLevel +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.ReplaceWith +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlin.jvm.JvmField +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * Style of a [button][dev.kord.common.entity.ComponentType.Button]. + * + * See [ButtonStyle]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/interactions/message-components#button-object-button-styles). + */ +@Serializable(with = ButtonStyle.NewSerializer::class) +public sealed class ButtonStyle( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is ButtonStyle && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "ButtonStyle.${this::class.simpleName}(value=$value)" + + /** + * An unknown [ButtonStyle]. + * + * This is used as a fallback for [ButtonStyle]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : ButtonStyle(value) + + /** + * Blurple. + */ + public object Primary : ButtonStyle(1) + + /** + * Grey. + */ + public object Secondary : ButtonStyle(2) + + /** + * Green. + */ + public object Success : ButtonStyle(3) + + /** + * Red. + */ + public object Danger : ButtonStyle(4) + + /** + * Grey, navigates to a URL. + */ + public object Link : ButtonStyle(5) + + internal object NewSerializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.ButtonStyle", PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: ButtonStyle) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> Primary + 2 -> Secondary + 3 -> Success + 4 -> Danger + 5 -> Link + else -> Unknown(value) + } + } + + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Use 'ButtonStyle.serializer()' instead.", + replaceWith = ReplaceWith(expression = "ButtonStyle.serializer()", imports = + arrayOf("dev.kord.common.entity.ButtonStyle")), + ) + public object Serializer : KSerializer by NewSerializer { + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Use 'ButtonStyle.serializer()' instead.", + replaceWith = ReplaceWith(expression = "ButtonStyle.serializer()", imports = + arrayOf("dev.kord.common.entity.ButtonStyle")), + ) + public fun serializer(): KSerializer = this + } + + public companion object { + /** + * A [List] of all known [ButtonStyle]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Primary, + Secondary, + Success, + Danger, + Link, + ) + } + + + @Suppress(names = arrayOf("DEPRECATION_ERROR")) + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = "Binary compatibility", + ) + @JvmField + public val Serializer: Serializer = Serializer + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelType.kt new file mode 100644 index 000000000000..0e2264191961 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelType.kt @@ -0,0 +1,156 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [ChannelType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/channel#channel-object-channel-types). + */ +@Serializable(with = ChannelType.Serializer::class) +public sealed class ChannelType( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is ChannelType && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "ChannelType.${this::class.simpleName}(value=$value)" + + /** + * An unknown [ChannelType]. + * + * This is used as a fallback for [ChannelType]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : ChannelType(value) + + /** + * A text channel within a server. + */ + public object GuildText : ChannelType(0) + + /** + * A direct message between users. + */ + public object DM : ChannelType(1) + + /** + * A voice channel within a server. + */ + public object GuildVoice : ChannelType(2) + + /** + * A direct message between multiple users. + */ + public object GroupDM : ChannelType(3) + + /** + * An + * [organizational category](https://support.discord.com/hc/en-us/articles/115001580171-Channel-Categories-101) + * that contains up to 50 channels. + */ + public object GuildCategory : ChannelType(4) + + /** + * A channel that + * [users can follow and crosspost into their own server](https://support.discord.com/hc/en-us/articles/360032008192). + */ + public object GuildNews : ChannelType(5) + + /** + * A temporary sub-channel within a [GuildNews] channel. + */ + public object PublicNewsThread : ChannelType(10) + + /** + * A temporary sub-channel within a [GuildText] channel. + */ + public object PublicGuildThread : ChannelType(11) + + /** + * A temporary sub-channel within a [GuildText] channel that is only viewable by those invited + * and those with the [ManageThreads][dev.kord.common.entity.Permission.ManageThreads] permission. + */ + public object PrivateThread : ChannelType(12) + + /** + * A voice channel for + * [hosting events with an audience](https://support.discord.com/hc/en-us/articles/1500005513722). + */ + public object GuildStageVoice : ChannelType(13) + + /** + * The channel in a + * [hub](https://support.discord.com/hc/en-us/articles/4406046651927-Discord-Student-Hubs-FAQ) + * containing the listed servers. + */ + public object GuildDirectory : ChannelType(14) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.ChannelType", PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: ChannelType) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 0 -> GuildText + 1 -> DM + 2 -> GuildVoice + 3 -> GroupDM + 4 -> GuildCategory + 5 -> GuildNews + 10 -> PublicNewsThread + 11 -> PublicGuildThread + 12 -> PrivateThread + 13 -> GuildStageVoice + 14 -> GuildDirectory + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [ChannelType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + GuildText, + DM, + GuildVoice, + GroupDM, + GuildCategory, + GuildNews, + PublicNewsThread, + PublicGuildThread, + PrivateThread, + GuildStageVoice, + GuildDirectory, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ComponentType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ComponentType.kt new file mode 100644 index 000000000000..70be45d6cb37 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ComponentType.kt @@ -0,0 +1,166 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Deprecated +import kotlin.DeprecationLevel +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.ReplaceWith +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlin.jvm.JvmField +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [ComponentType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/interactions/message-components#component-object-component-types). + */ +@Serializable(with = ComponentType.NewSerializer::class) +public sealed class ComponentType( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is ComponentType && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "ComponentType.${this::class.simpleName}(value=$value)" + + /** + * An unknown [ComponentType]. + * + * This is used as a fallback for [ComponentType]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : ComponentType(value) + + /** + * A container for other components. + */ + public object ActionRow : ComponentType(1) + + /** + * A button object. + */ + public object Button : ComponentType(2) + + /** + * A select menu for picking from defined text options. + */ + public object StringSelect : ComponentType(3) + + /** + * A text input object. + */ + public object TextInput : ComponentType(4) + + /** + * Select menu for users. + */ + public object UserSelect : ComponentType(5) + + /** + * Select menu for roles. + */ + public object RoleSelect : ComponentType(6) + + /** + * Select menu for mentionables (users and roles). + */ + public object MentionableSelect : ComponentType(7) + + /** + * Select menu for channels. + */ + public object ChannelSelect : ComponentType(8) + + /** + * A select menu for picking from choices. + */ + @Deprecated( + message = "Renamed by discord", + replaceWith = ReplaceWith(expression = "StringSelect", imports = + arrayOf("dev.kord.common.entity.ComponentType.StringSelect")), + ) + public object SelectMenu : ComponentType(3) + + internal object NewSerializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.ComponentType", PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: ComponentType) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> ActionRow + 2 -> Button + 3 -> StringSelect + 4 -> TextInput + 5 -> UserSelect + 6 -> RoleSelect + 7 -> MentionableSelect + 8 -> ChannelSelect + else -> Unknown(value) + } + } + + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Use 'ComponentType.serializer()' instead.", + replaceWith = ReplaceWith(expression = "ComponentType.serializer()", imports = + arrayOf("dev.kord.common.entity.ComponentType")), + ) + public object Serializer : KSerializer by NewSerializer { + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Use 'ComponentType.serializer()' instead.", + replaceWith = ReplaceWith(expression = "ComponentType.serializer()", imports = + arrayOf("dev.kord.common.entity.ComponentType")), + ) + public fun serializer(): KSerializer = this + } + + public companion object { + /** + * A [List] of all known [ComponentType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + ActionRow, + Button, + StringSelect, + TextInput, + UserSelect, + RoleSelect, + MentionableSelect, + ChannelSelect, + ) + } + + + @Suppress(names = arrayOf("DEPRECATION_ERROR")) + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = "Binary compatibility", + ) + @JvmField + public val Serializer: Serializer = Serializer + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/DefaultMessageNotificationLevel.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/DefaultMessageNotificationLevel.kt new file mode 100644 index 000000000000..2f67ffa23031 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/DefaultMessageNotificationLevel.kt @@ -0,0 +1,88 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [DefaultMessageNotificationLevel]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level). + */ +@Serializable(with = DefaultMessageNotificationLevel.Serializer::class) +public sealed class DefaultMessageNotificationLevel( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is DefaultMessageNotificationLevel && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "DefaultMessageNotificationLevel.${this::class.simpleName}(value=$value)" + + /** + * An unknown [DefaultMessageNotificationLevel]. + * + * This is used as a fallback for [DefaultMessageNotificationLevel]s that haven't been added to + * Kord yet. + */ + public class Unknown( + `value`: Int, + ) : DefaultMessageNotificationLevel(value) + + /** + * Members will receive notifications for all messages by default. + */ + public object AllMessages : DefaultMessageNotificationLevel(0) + + /** + * Members will receive notifications only for messages that @mention them by default. + */ + public object OnlyMentions : DefaultMessageNotificationLevel(1) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.DefaultMessageNotificationLevel", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: DefaultMessageNotificationLevel) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 0 -> AllMessages + 1 -> OnlyMentions + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [DefaultMessageNotificationLevel]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + AllMessages, + OnlyMentions, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/DiscordConnectionVisibility.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/DiscordConnectionVisibility.kt new file mode 100644 index 000000000000..5ac2c352fc18 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/DiscordConnectionVisibility.kt @@ -0,0 +1,88 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [DiscordConnectionVisibility]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/user#connection-object-visibility-types). + */ +@Serializable(with = DiscordConnectionVisibility.Serializer::class) +public sealed class DiscordConnectionVisibility( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is DiscordConnectionVisibility && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "DiscordConnectionVisibility.${this::class.simpleName}(value=$value)" + + /** + * An unknown [DiscordConnectionVisibility]. + * + * This is used as a fallback for [DiscordConnectionVisibility]s that haven't been added to Kord + * yet. + */ + public class Unknown( + `value`: Int, + ) : DiscordConnectionVisibility(value) + + /** + * Invisible to everyone except the user themselves. + */ + public object None : DiscordConnectionVisibility(0) + + /** + * Visible to everyone. + */ + public object Everyone : DiscordConnectionVisibility(1) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.DiscordConnectionVisibility", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: DiscordConnectionVisibility) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 0 -> None + 1 -> Everyone + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [DiscordConnectionVisibility]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + None, + Everyone, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/EmbedType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/EmbedType.kt new file mode 100644 index 000000000000..7922959a0fbc --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/EmbedType.kt @@ -0,0 +1,115 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [EmbedType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/channel#embed-object-embed-types). + */ +@Serializable(with = EmbedType.Serializer::class) +public sealed class EmbedType( + /** + * The raw value used by Discord. + */ + public val `value`: String, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is EmbedType && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "EmbedType.${this::class.simpleName}(value=$value)" + + /** + * An unknown [EmbedType]. + * + * This is used as a fallback for [EmbedType]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: String, + ) : EmbedType(value) + + /** + * Generic embed rendered from embed attributes. + */ + public object Rich : EmbedType("rich") + + /** + * Image embed. + */ + public object Image : EmbedType("image") + + /** + * Video embed. + */ + public object Video : EmbedType("video") + + /** + * Animated gif image embed rendered as a video embed. + */ + public object Gifv : EmbedType("gifv") + + /** + * Article embed. + */ + public object Article : EmbedType("article") + + /** + * Link embed. + */ + public object Link : EmbedType("link") + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.EmbedType", PrimitiveKind.STRING) + + public override fun serialize(encoder: Encoder, `value`: EmbedType) = + encoder.encodeString(value.value) + + public override fun deserialize(decoder: Decoder) = + when (val value = decoder.decodeString()) { + "rich" -> Rich + "image" -> Image + "video" -> Video + "gifv" -> Gifv + "article" -> Article + "link" -> Link + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [EmbedType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Rich, + Image, + Video, + Gifv, + Article, + Link, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ExplicitContentFilter.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ExplicitContentFilter.kt new file mode 100644 index 000000000000..b8f46401e9e6 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ExplicitContentFilter.kt @@ -0,0 +1,94 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [ExplicitContentFilter]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level). + */ +@Serializable(with = ExplicitContentFilter.Serializer::class) +public sealed class ExplicitContentFilter( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is ExplicitContentFilter && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "ExplicitContentFilter.${this::class.simpleName}(value=$value)" + + /** + * An unknown [ExplicitContentFilter]. + * + * This is used as a fallback for [ExplicitContentFilter]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : ExplicitContentFilter(value) + + /** + * Media content will not be scanned. + */ + public object Disabled : ExplicitContentFilter(0) + + /** + * Media content sent by members without roles will be scanned. + */ + public object MembersWithoutRoles : ExplicitContentFilter(1) + + /** + * Media content sent by all members will be scanned. + */ + public object AllMembers : ExplicitContentFilter(2) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.ExplicitContentFilter", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: ExplicitContentFilter) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 0 -> Disabled + 1 -> MembersWithoutRoles + 2 -> AllMembers + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [ExplicitContentFilter]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Disabled, + MembersWithoutRoles, + AllMembers, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildFeature.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildFeature.kt new file mode 100644 index 000000000000..3c48544959e6 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildFeature.kt @@ -0,0 +1,287 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Deprecated +import kotlin.DeprecationLevel +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [GuildFeature]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild#guild-object-guild-features). + */ +@Serializable(with = GuildFeature.Serializer::class) +public sealed class GuildFeature( + /** + * The raw value used by Discord. + */ + public val `value`: String, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is GuildFeature && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "GuildFeature.${this::class.simpleName}(value=$value)" + + /** + * An unknown [GuildFeature]. + * + * This is used as a fallback for [GuildFeature]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: String, + ) : GuildFeature(value) + + /** + * Guild has access to set an animated guild banner image. + */ + public object AnimatedBanner : GuildFeature("ANIMATED_BANNER") + + /** + * Guild has access to set an animated guild icon. + */ + public object AnimatedIcon : GuildFeature("ANIMATED_ICON") + + /** + * Guild is using the old permissions configuration behavior. + */ + public object ApplicationCommandPermissionsV2 : + GuildFeature("APPLICATION_COMMAND_PERMISSIONS_V2") + + /** + * Guild has set up auto moderation rules. + */ + public object AutoModeration : GuildFeature("AUTO_MODERATION") + + /** + * Guild has access to set a guild banner image. + */ + public object Banner : GuildFeature("BANNER") + + /** + * Guild can enable welcome screen, Membership Screening, stage channels and discovery, and + * receives community updates. + */ + public object Community : GuildFeature("COMMUNITY") + + /** + * Guild has been set as a support server on the App Directory. + */ + public object DeveloperSupportServer : GuildFeature("DEVELOPER_SUPPORT_SERVER") + + /** + * Guild is able to be discovered in the directory. + */ + public object Discoverable : GuildFeature("DISCOVERABLE") + + /** + * Guild is able to be featured in the directory. + */ + public object Featurable : GuildFeature("FEATURABLE") + + /** + * Guild has paused invites, preventing new users from joining. + */ + public object InvitesDisabled : GuildFeature("INVITES_DISABLED") + + /** + * Guild has access to set an invite splash background. + */ + public object InviteSplash : GuildFeature("INVITE_SPLASH") + + /** + * Guild has enabled Membership Screening. + */ + public object MemberVerificationGateEnabled : GuildFeature("MEMBER_VERIFICATION_GATE_ENABLED") + + /** + * Guild has enabled monetization. + */ + public object MonetizationEnabled : GuildFeature("MONETIZATION_ENABLED") + + /** + * Guild has increased custom sticker slots. + */ + public object MoreStickers : GuildFeature("MORE_STICKERS") + + /** + * Guild has access to create announcement channels. + */ + public object News : GuildFeature("NEWS") + + /** + * Guild is partnered. + */ + public object Partnered : GuildFeature("PARTNERED") + + /** + * Guild can be previewed before joining via Membership Screening or the directory. + */ + public object PreviewEnabled : GuildFeature("PREVIEW_ENABLED") + + /** + * Guild is able to set role icons. + */ + public object RoleIcons : GuildFeature("ROLE_ICONS") + + /** + * Guild has enabled ticketed events. + */ + public object TicketedEventsEnabled : GuildFeature("TICKETED_EVENTS_ENABLED") + + /** + * Guild has access to set a vanity URL. + */ + public object VanityUrl : GuildFeature("VANITY_URL") + + /** + * Guild is verified. + */ + public object Verified : GuildFeature("VERIFIED") + + /** + * Guild has access to set 384kbps bitrate in voice (previously VIP voice servers). + */ + public object VIPRegions : GuildFeature("VIP_REGIONS") + + /** + * Guild has enabled the welcome screen. + */ + public object WelcomeScreenEnabled : GuildFeature("WELCOME_SCREEN_ENABLED") + + /** + * Guild has access to use commerce features (i.e. create store channels). + * + * @suppress + */ + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = + "Discord no longer offers the ability to purchase a license to sell PC games on Discord and store channels were removed on March 10, 2022. See https://support-dev.discord.com/hc/en-us/articles/6309018858647-Self-serve-Game-Selling-Deprecation for more information.", + ) + public object Commerce : GuildFeature("COMMERCE") + + /** + * Guild has access to create private threads + */ + @Deprecated(message = "Creating a private thread no longer requires the server to be boosted.") + public object PrivateThreads : GuildFeature("PRIVATE_THREADS") + + /** + * Guild has access to the seven day archive time for threads. + * + * @suppress + */ + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = "Thread archive durations are no longer boost locked.", + ) + public object SevenDayThreadArchive : GuildFeature("SEVEN_DAY_THREAD_ARCHIVE") + + /** + * Guild has access to the three-day archive time for threads. + * + * @suppress + */ + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = "Thread archive durations are no longer boost locked.", + ) + public object ThreeDayThreadArchive : GuildFeature("THREE_DAY_THREAD_ARCHIVE") + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.GuildFeature", + PrimitiveKind.STRING) + + public override fun serialize(encoder: Encoder, `value`: GuildFeature) = + encoder.encodeString(value.value) + + public override fun deserialize(decoder: Decoder) = + when (val value = decoder.decodeString()) { + "ANIMATED_BANNER" -> AnimatedBanner + "ANIMATED_ICON" -> AnimatedIcon + "APPLICATION_COMMAND_PERMISSIONS_V2" -> ApplicationCommandPermissionsV2 + "AUTO_MODERATION" -> AutoModeration + "BANNER" -> Banner + "COMMERCE" -> @Suppress("DEPRECATION_ERROR") Commerce + "COMMUNITY" -> Community + "DEVELOPER_SUPPORT_SERVER" -> DeveloperSupportServer + "DISCOVERABLE" -> Discoverable + "FEATURABLE" -> Featurable + "INVITES_DISABLED" -> InvitesDisabled + "INVITE_SPLASH" -> InviteSplash + "MEMBER_VERIFICATION_GATE_ENABLED" -> MemberVerificationGateEnabled + "MONETIZATION_ENABLED" -> MonetizationEnabled + "MORE_STICKERS" -> MoreStickers + "NEWS" -> News + "PARTNERED" -> Partnered + "PREVIEW_ENABLED" -> PreviewEnabled + "PRIVATE_THREADS" -> @Suppress("DEPRECATION") PrivateThreads + "ROLE_ICONS" -> RoleIcons + "SEVEN_DAY_THREAD_ARCHIVE" -> @Suppress("DEPRECATION_ERROR") SevenDayThreadArchive + "THREE_DAY_THREAD_ARCHIVE" -> @Suppress("DEPRECATION_ERROR") ThreeDayThreadArchive + "TICKETED_EVENTS_ENABLED" -> TicketedEventsEnabled + "VANITY_URL" -> VanityUrl + "VERIFIED" -> Verified + "VIP_REGIONS" -> VIPRegions + "WELCOME_SCREEN_ENABLED" -> WelcomeScreenEnabled + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [GuildFeature]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + AnimatedBanner, + AnimatedIcon, + ApplicationCommandPermissionsV2, + AutoModeration, + Banner, + @Suppress("DEPRECATION_ERROR") Commerce, + Community, + DeveloperSupportServer, + Discoverable, + Featurable, + InvitesDisabled, + InviteSplash, + MemberVerificationGateEnabled, + MonetizationEnabled, + MoreStickers, + News, + Partnered, + PreviewEnabled, + @Suppress("DEPRECATION") PrivateThreads, + RoleIcons, + @Suppress("DEPRECATION_ERROR") SevenDayThreadArchive, + @Suppress("DEPRECATION_ERROR") ThreeDayThreadArchive, + TicketedEventsEnabled, + VanityUrl, + Verified, + VIPRegions, + WelcomeScreenEnabled, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildScheduledEventPrivacyLevel.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildScheduledEventPrivacyLevel.kt new file mode 100644 index 000000000000..99cea88ebdc1 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildScheduledEventPrivacyLevel.kt @@ -0,0 +1,81 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [GuildScheduledEventPrivacyLevel]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-privacy-level). + */ +@Serializable(with = GuildScheduledEventPrivacyLevel.Serializer::class) +public sealed class GuildScheduledEventPrivacyLevel( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is GuildScheduledEventPrivacyLevel && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "GuildScheduledEventPrivacyLevel.${this::class.simpleName}(value=$value)" + + /** + * An unknown [GuildScheduledEventPrivacyLevel]. + * + * This is used as a fallback for [GuildScheduledEventPrivacyLevel]s that haven't been added to + * Kord yet. + */ + public class Unknown( + `value`: Int, + ) : GuildScheduledEventPrivacyLevel(value) + + /** + * The scheduled event is only accessible to guild members. + */ + public object GuildOnly : GuildScheduledEventPrivacyLevel(2) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.GuildScheduledEventPrivacyLevel", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: GuildScheduledEventPrivacyLevel) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 2 -> GuildOnly + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [GuildScheduledEventPrivacyLevel]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + GuildOnly, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildScheduledEventStatus.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildScheduledEventStatus.kt new file mode 100644 index 000000000000..73e7473d93bf --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildScheduledEventStatus.kt @@ -0,0 +1,118 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Deprecated +import kotlin.DeprecationLevel +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.ReplaceWith +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlin.jvm.JvmField +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [GuildScheduledEventStatus]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status). + */ +@Serializable(with = GuildScheduledEventStatus.NewSerializer::class) +public sealed class GuildScheduledEventStatus( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is GuildScheduledEventStatus && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "GuildScheduledEventStatus.${this::class.simpleName}(value=$value)" + + /** + * An unknown [GuildScheduledEventStatus]. + * + * This is used as a fallback for [GuildScheduledEventStatus]s that haven't been added to Kord + * yet. + */ + public class Unknown( + `value`: Int, + ) : GuildScheduledEventStatus(value) + + public object Scheduled : GuildScheduledEventStatus(1) + + public object Active : GuildScheduledEventStatus(2) + + public object Completed : GuildScheduledEventStatus(3) + + public object Cancelled : GuildScheduledEventStatus(4) + + internal object NewSerializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.GuildScheduledEventStatus", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: GuildScheduledEventStatus) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> Scheduled + 2 -> Active + 3 -> Completed + 4 -> Cancelled + else -> Unknown(value) + } + } + + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Use 'GuildScheduledEventStatus.serializer()' instead.", + replaceWith = ReplaceWith(expression = "GuildScheduledEventStatus.serializer()", imports = + arrayOf("dev.kord.common.entity.GuildScheduledEventStatus")), + ) + public object Serializer : KSerializer by NewSerializer { + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Use 'GuildScheduledEventStatus.serializer()' instead.", + replaceWith = ReplaceWith(expression = "GuildScheduledEventStatus.serializer()", imports + = arrayOf("dev.kord.common.entity.GuildScheduledEventStatus")), + ) + public fun serializer(): KSerializer = this + } + + public companion object { + /** + * A [List] of all known [GuildScheduledEventStatus]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Scheduled, + Active, + Completed, + Cancelled, + ) + } + + + @Suppress(names = arrayOf("DEPRECATION_ERROR")) + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = "Binary compatibility", + ) + @JvmField + public val Serializer: Serializer = Serializer + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/IntegrationExpireBehavior.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/IntegrationExpireBehavior.kt new file mode 100644 index 000000000000..401753d3b492 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/IntegrationExpireBehavior.kt @@ -0,0 +1,110 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Deprecated +import kotlin.DeprecationLevel +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.ReplaceWith +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlin.jvm.JvmField +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [IntegrationExpireBehavior]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors). + */ +@Serializable(with = IntegrationExpireBehavior.NewSerializer::class) +public sealed class IntegrationExpireBehavior( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is IntegrationExpireBehavior && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "IntegrationExpireBehavior.${this::class.simpleName}(value=$value)" + + /** + * An unknown [IntegrationExpireBehavior]. + * + * This is used as a fallback for [IntegrationExpireBehavior]s that haven't been added to Kord + * yet. + */ + public class Unknown( + `value`: Int, + ) : IntegrationExpireBehavior(value) + + public object RemoveRole : IntegrationExpireBehavior(0) + + public object Kick : IntegrationExpireBehavior(1) + + internal object NewSerializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.IntegrationExpireBehavior", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: IntegrationExpireBehavior) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 0 -> RemoveRole + 1 -> Kick + else -> Unknown(value) + } + } + + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Use 'IntegrationExpireBehavior.serializer()' instead.", + replaceWith = ReplaceWith(expression = "IntegrationExpireBehavior.serializer()", imports = + arrayOf("dev.kord.common.entity.IntegrationExpireBehavior")), + ) + public object Serializer : KSerializer by NewSerializer { + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Use 'IntegrationExpireBehavior.serializer()' instead.", + replaceWith = ReplaceWith(expression = "IntegrationExpireBehavior.serializer()", imports + = arrayOf("dev.kord.common.entity.IntegrationExpireBehavior")), + ) + public fun serializer(): KSerializer = this + } + + public companion object { + /** + * A [List] of all known [IntegrationExpireBehavior]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + RemoveRole, + Kick, + ) + } + + + @Suppress(names = arrayOf("DEPRECATION_ERROR")) + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = "Binary compatibility", + ) + @JvmField + public val Serializer: Serializer = Serializer + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/InteractionResponseType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/InteractionResponseType.kt new file mode 100644 index 000000000000..81062aee2999 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/InteractionResponseType.kt @@ -0,0 +1,124 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [InteractionResponseType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type). + */ +@Serializable(with = InteractionResponseType.Serializer::class) +public sealed class InteractionResponseType( + /** + * The raw type used by Discord. + */ + public val type: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is InteractionResponseType && this.type == other.type) + + public final override fun hashCode(): Int = type.hashCode() + + public final override fun toString(): String = + "InteractionResponseType.${this::class.simpleName}(type=$type)" + + /** + * An unknown [InteractionResponseType]. + * + * This is used as a fallback for [InteractionResponseType]s that haven't been added to Kord + * yet. + */ + public class Unknown( + type: Int, + ) : InteractionResponseType(type) + + /** + * ACK a [Ping][dev.kord.common.entity.InteractionType.Ping]. + */ + public object Pong : InteractionResponseType(1) + + /** + * Respond to an interaction with a message. + */ + public object ChannelMessageWithSource : InteractionResponseType(4) + + /** + * ACK an interaction and edit a response later, the user sees a loading state. + */ + public object DeferredChannelMessageWithSource : InteractionResponseType(5) + + /** + * For components, ACK an interaction and edit the original message later; the user does not see + * a loading state. + */ + public object DeferredUpdateMessage : InteractionResponseType(6) + + /** + * For components, edit the message the component was attached to. + */ + public object UpdateMessage : InteractionResponseType(7) + + /** + * Respond to an autocomplete interaction with suggested choices. + */ + public object ApplicationCommandAutoCompleteResult : InteractionResponseType(8) + + /** + * Respond to an interaction with a popup modal. + */ + public object Modal : InteractionResponseType(9) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.InteractionResponseType", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: InteractionResponseType) = + encoder.encodeInt(value.type) + + public override fun deserialize(decoder: Decoder) = when (val type = decoder.decodeInt()) { + 1 -> Pong + 4 -> ChannelMessageWithSource + 5 -> DeferredChannelMessageWithSource + 6 -> DeferredUpdateMessage + 7 -> UpdateMessage + 8 -> ApplicationCommandAutoCompleteResult + 9 -> Modal + else -> Unknown(type) + } + } + + public companion object { + /** + * A [List] of all known [InteractionResponseType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Pong, + ChannelMessageWithSource, + DeferredChannelMessageWithSource, + DeferredUpdateMessage, + UpdateMessage, + ApplicationCommandAutoCompleteResult, + Modal, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/InteractionType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/InteractionType.kt new file mode 100644 index 000000000000..5cc9105e0a1c --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/InteractionType.kt @@ -0,0 +1,93 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [InteractionType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type). + */ +@Serializable(with = InteractionType.Serializer::class) +public sealed class InteractionType( + /** + * The raw type used by Discord. + */ + public val type: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is InteractionType && this.type == other.type) + + public final override fun hashCode(): Int = type.hashCode() + + public final override fun toString(): String = + "InteractionType.${this::class.simpleName}(type=$type)" + + /** + * An unknown [InteractionType]. + * + * This is used as a fallback for [InteractionType]s that haven't been added to Kord yet. + */ + public class Unknown( + type: Int, + ) : InteractionType(type) + + public object Ping : InteractionType(1) + + public object ApplicationCommand : InteractionType(2) + + public object Component : InteractionType(3) + + public object AutoComplete : InteractionType(4) + + public object ModalSubmit : InteractionType(5) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.InteractionType", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: InteractionType) = + encoder.encodeInt(value.type) + + public override fun deserialize(decoder: Decoder) = when (val type = decoder.decodeInt()) { + 1 -> Ping + 2 -> ApplicationCommand + 3 -> Component + 4 -> AutoComplete + 5 -> ModalSubmit + else -> Unknown(type) + } + } + + public companion object { + /** + * A [List] of all known [InteractionType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Ping, + ApplicationCommand, + Component, + AutoComplete, + ModalSubmit, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/InviteTargetType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/InviteTargetType.kt new file mode 100644 index 000000000000..b2c887f81899 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/InviteTargetType.kt @@ -0,0 +1,81 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [InviteTargetType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types). + */ +@Serializable(with = InviteTargetType.Serializer::class) +public sealed class InviteTargetType( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is InviteTargetType && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "InviteTargetType.${this::class.simpleName}(value=$value)" + + /** + * An unknown [InviteTargetType]. + * + * This is used as a fallback for [InviteTargetType]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : InviteTargetType(value) + + public object Stream : InviteTargetType(1) + + public object EmbeddedApplication : InviteTargetType(2) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.InviteTargetType", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: InviteTargetType) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> Stream + 2 -> EmbeddedApplication + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [InviteTargetType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Stream, + EmbeddedApplication, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MFALevel.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MFALevel.kt new file mode 100644 index 000000000000..522db376f61a --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MFALevel.kt @@ -0,0 +1,86 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [MFALevel]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild#guild-object-mfa-level). + */ +@Serializable(with = MFALevel.Serializer::class) +public sealed class MFALevel( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is MFALevel && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "MFALevel.${this::class.simpleName}(value=$value)" + + /** + * An unknown [MFALevel]. + * + * This is used as a fallback for [MFALevel]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : MFALevel(value) + + /** + * Guild has no MFA/2FA requirement for moderation actions. + */ + public object None : MFALevel(0) + + /** + * Guild has a 2FA requirement for moderation actions. + */ + public object Elevated : MFALevel(1) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.MFALevel", PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: MFALevel) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 0 -> None + 1 -> Elevated + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [MFALevel]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + None, + Elevated, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageActivityType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageActivityType.kt new file mode 100644 index 000000000000..5ff513a4a219 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageActivityType.kt @@ -0,0 +1,89 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [MessageActivityType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-activity-types). + */ +@Serializable(with = MessageActivityType.Serializer::class) +public sealed class MessageActivityType( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is MessageActivityType && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "MessageActivityType.${this::class.simpleName}(value=$value)" + + /** + * An unknown [MessageActivityType]. + * + * This is used as a fallback for [MessageActivityType]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : MessageActivityType(value) + + public object Join : MessageActivityType(1) + + public object Spectate : MessageActivityType(2) + + public object Listen : MessageActivityType(3) + + public object JoinRequest : MessageActivityType(5) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.MessageActivityType", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: MessageActivityType) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> Join + 2 -> Spectate + 3 -> Listen + 5 -> JoinRequest + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [MessageActivityType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Join, + Spectate, + Listen, + JoinRequest, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageStickerType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageStickerType.kt new file mode 100644 index 000000000000..7fe0dfdade5d --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageStickerType.kt @@ -0,0 +1,101 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Deprecated +import kotlin.DeprecationLevel +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.ReplaceWith +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlin.collections.Set +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [MessageStickerType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types). + */ +@Serializable(with = MessageStickerType.Serializer::class) +public sealed class MessageStickerType( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is MessageStickerType && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "MessageStickerType.${this::class.simpleName}(value=$value)" + + /** + * An unknown [MessageStickerType]. + * + * This is used as a fallback for [MessageStickerType]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : MessageStickerType(value) + + public object PNG : MessageStickerType(1) + + public object APNG : MessageStickerType(2) + + public object LOTTIE : MessageStickerType(3) + + public object GIF : MessageStickerType(4) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.MessageStickerType", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: MessageStickerType) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> PNG + 2 -> APNG + 3 -> LOTTIE + 4 -> GIF + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [MessageStickerType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + PNG, + APNG, + LOTTIE, + GIF, + ) + } + + + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Renamed to 'entries'.", + replaceWith = ReplaceWith(expression = "this.entries", imports = arrayOf()), + ) + public val values: Set + get() = entries.toSet() + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageType.kt new file mode 100644 index 000000000000..204caac5b45c --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageType.kt @@ -0,0 +1,259 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Deprecated +import kotlin.DeprecationLevel +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.ReplaceWith +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlin.collections.Set +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [MessageType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-types). + */ +@Serializable(with = MessageType.Serializer::class) +public sealed class MessageType( + /** + * The raw code used by Discord. + */ + public val code: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is MessageType && this.code == other.code) + + public final override fun hashCode(): Int = code.hashCode() + + public final override fun toString(): String = + "MessageType.${this::class.simpleName}(code=$code)" + + /** + * An unknown [MessageType]. + * + * This is used as a fallback for [MessageType]s that haven't been added to Kord yet. + */ + public class Unknown( + code: Int, + ) : MessageType(code) + + public object Default : MessageType(0) + + public object RecipientAdd : MessageType(1) + + public object RecipientRemove : MessageType(2) + + public object Call : MessageType(3) + + public object ChannelNameChange : MessageType(4) + + public object ChannelIconChange : MessageType(5) + + public object ChannelPinnedMessage : MessageType(6) + + public object UserJoin : MessageType(7) + + public object GuildBoost : MessageType(8) + + public object GuildBoostTier1 : MessageType(9) + + public object GuildBoostTier2 : MessageType(10) + + public object GuildBoostTier3 : MessageType(11) + + public object ChannelFollowAdd : MessageType(12) + + public object GuildDiscoveryDisqualified : MessageType(14) + + public object GuildDiscoveryRequalified : MessageType(15) + + public object GuildDiscoveryGracePeriodInitialWarning : MessageType(16) + + public object GuildDiscoveryGracePeriodFinalWarning : MessageType(17) + + public object ThreadCreated : MessageType(18) + + public object Reply : MessageType(19) + + public object ChatInputCommand : MessageType(20) + + public object ThreadStarterMessage : MessageType(21) + + public object GuildInviteReminder : MessageType(22) + + public object ContextMenuCommand : MessageType(23) + + public object AutoModerationAction : MessageType(24) + + public object InteractionPremiumUpsell : MessageType(26) + + public object StageStart : MessageType(27) + + public object StageEnd : MessageType(28) + + public object StageSpeaker : MessageType(29) + + public object StageTopic : MessageType(31) + + public object GuildApplicationPremiumSubscription : MessageType(32) + + /** + * @suppress + */ + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = "Renamed to 'UserJoin'.", + replaceWith = ReplaceWith(expression = "UserJoin", imports = + arrayOf("dev.kord.common.entity.MessageType.UserJoin")), + ) + public object GuildMemberJoin : MessageType(7) + + /** + * @suppress + */ + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = "Renamed to 'GuildBoost'.", + replaceWith = ReplaceWith(expression = "GuildBoost", imports = + arrayOf("dev.kord.common.entity.MessageType.GuildBoost")), + ) + public object UserPremiumGuildSubscription : MessageType(8) + + /** + * @suppress + */ + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = "Renamed to 'GuildBoostTier1'.", + replaceWith = ReplaceWith(expression = "GuildBoostTier1", imports = + arrayOf("dev.kord.common.entity.MessageType.GuildBoostTier1")), + ) + public object UserPremiumGuildSubscriptionTierOne : MessageType(9) + + /** + * @suppress + */ + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = "Renamed to 'GuildBoostTier2'.", + replaceWith = ReplaceWith(expression = "GuildBoostTier2", imports = + arrayOf("dev.kord.common.entity.MessageType.GuildBoostTier2")), + ) + public object UserPremiumGuildSubscriptionTwo : MessageType(10) + + /** + * @suppress + */ + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = "Renamed to 'GuildBoostTier3'.", + replaceWith = ReplaceWith(expression = "GuildBoostTier3", imports = + arrayOf("dev.kord.common.entity.MessageType.GuildBoostTier3")), + ) + public object UserPremiumGuildSubscriptionThree : MessageType(11) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.MessageType", PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: MessageType) = + encoder.encodeInt(value.code) + + public override fun deserialize(decoder: Decoder) = when (val code = decoder.decodeInt()) { + 0 -> Default + 1 -> RecipientAdd + 2 -> RecipientRemove + 3 -> Call + 4 -> ChannelNameChange + 5 -> ChannelIconChange + 6 -> ChannelPinnedMessage + 7 -> UserJoin + 8 -> GuildBoost + 9 -> GuildBoostTier1 + 10 -> GuildBoostTier2 + 11 -> GuildBoostTier3 + 12 -> ChannelFollowAdd + 14 -> GuildDiscoveryDisqualified + 15 -> GuildDiscoveryRequalified + 16 -> GuildDiscoveryGracePeriodInitialWarning + 17 -> GuildDiscoveryGracePeriodFinalWarning + 18 -> ThreadCreated + 19 -> Reply + 20 -> ChatInputCommand + 21 -> ThreadStarterMessage + 22 -> GuildInviteReminder + 23 -> ContextMenuCommand + 24 -> AutoModerationAction + 26 -> InteractionPremiumUpsell + 27 -> StageStart + 28 -> StageEnd + 29 -> StageSpeaker + 31 -> StageTopic + 32 -> GuildApplicationPremiumSubscription + else -> Unknown(code) + } + } + + public companion object { + /** + * A [List] of all known [MessageType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Default, + RecipientAdd, + RecipientRemove, + Call, + ChannelNameChange, + ChannelIconChange, + ChannelPinnedMessage, + UserJoin, + GuildBoost, + GuildBoostTier1, + GuildBoostTier2, + GuildBoostTier3, + ChannelFollowAdd, + GuildDiscoveryDisqualified, + GuildDiscoveryRequalified, + GuildDiscoveryGracePeriodInitialWarning, + GuildDiscoveryGracePeriodFinalWarning, + ThreadCreated, + Reply, + ChatInputCommand, + ThreadStarterMessage, + GuildInviteReminder, + ContextMenuCommand, + AutoModerationAction, + InteractionPremiumUpsell, + StageStart, + StageEnd, + StageSpeaker, + StageTopic, + GuildApplicationPremiumSubscription, + ) + } + + + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Renamed to 'entries'.", + replaceWith = ReplaceWith(expression = "this.entries", imports = arrayOf()), + ) + public val values: Set + get() = entries.toSet() + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/NsfwLevel.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/NsfwLevel.kt new file mode 100644 index 000000000000..ed5b734e8077 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/NsfwLevel.kt @@ -0,0 +1,88 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [NsfwLevel]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild#guild-object-guild-nsfw-level). + */ +@Serializable(with = NsfwLevel.Serializer::class) +public sealed class NsfwLevel( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is NsfwLevel && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "NsfwLevel.${this::class.simpleName}(value=$value)" + + /** + * An unknown [NsfwLevel]. + * + * This is used as a fallback for [NsfwLevel]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : NsfwLevel(value) + + public object Default : NsfwLevel(0) + + public object Explicit : NsfwLevel(1) + + public object Safe : NsfwLevel(2) + + public object AgeRestricted : NsfwLevel(3) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.NsfwLevel", PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: NsfwLevel) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 0 -> Default + 1 -> Explicit + 2 -> Safe + 3 -> AgeRestricted + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [NsfwLevel]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Default, + Explicit, + Safe, + AgeRestricted, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/OverwriteType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/OverwriteType.kt new file mode 100644 index 000000000000..7f1dfff1524c --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/OverwriteType.kt @@ -0,0 +1,80 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [OverwriteType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/channel#overwrite-object-overwrite-structure). + */ +@Serializable(with = OverwriteType.Serializer::class) +public sealed class OverwriteType( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is OverwriteType && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "OverwriteType.${this::class.simpleName}(value=$value)" + + /** + * An unknown [OverwriteType]. + * + * This is used as a fallback for [OverwriteType]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : OverwriteType(value) + + public object Role : OverwriteType(0) + + public object Member : OverwriteType(1) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.OverwriteType", PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: OverwriteType) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 0 -> Role + 1 -> Member + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [OverwriteType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Role, + Member, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/PremiumTier.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/PremiumTier.kt new file mode 100644 index 000000000000..52ec298744e1 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/PremiumTier.kt @@ -0,0 +1,100 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [PremiumTier]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild#guild-object-premium-tier). + */ +@Serializable(with = PremiumTier.Serializer::class) +public sealed class PremiumTier( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is PremiumTier && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "PremiumTier.${this::class.simpleName}(value=$value)" + + /** + * An unknown [PremiumTier]. + * + * This is used as a fallback for [PremiumTier]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : PremiumTier(value) + + /** + * Guild has not unlocked any Server Boost perks. + */ + public object None : PremiumTier(0) + + /** + * Guild has unlocked Server Boost level 1 perks. + */ + public object One : PremiumTier(1) + + /** + * Guild has unlocked Server Boost level 2 perks. + */ + public object Two : PremiumTier(2) + + /** + * Guild has unlocked Server Boost level 3 perks. + */ + public object Three : PremiumTier(3) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.PremiumTier", PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: PremiumTier) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 0 -> None + 1 -> One + 2 -> Two + 3 -> Three + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [PremiumTier]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + None, + One, + Two, + Three, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/PresenceStatus.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/PresenceStatus.kt new file mode 100644 index 000000000000..941954c578de --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/PresenceStatus.kt @@ -0,0 +1,137 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Deprecated +import kotlin.DeprecationLevel +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.ReplaceWith +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlin.jvm.JvmField +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [PresenceStatus]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/topics/gateway-events#update-presence-status-types). + */ +@Serializable(with = PresenceStatus.Serializer::class) +public sealed class PresenceStatus( + /** + * The raw value used by Discord. + */ + public val `value`: String, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is PresenceStatus && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "PresenceStatus.${this::class.simpleName}(value=$value)" + + /** + * An unknown [PresenceStatus]. + * + * This is used as a fallback for [PresenceStatus]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: String, + ) : PresenceStatus(value) + + /** + * Online. + */ + public object Online : PresenceStatus("online") + + /** + * Do Not Disturb. + */ + public object DoNotDisturb : PresenceStatus("dnd") + + /** + * AFK. + */ + public object Idle : PresenceStatus("idle") + + /** + * Invisible and shown as offline. + */ + public object Invisible : PresenceStatus("invisible") + + /** + * Offline. + */ + public object Offline : PresenceStatus("offline") + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.PresenceStatus", + PrimitiveKind.STRING) + + public override fun serialize(encoder: Encoder, `value`: PresenceStatus) = + encoder.encodeString(value.value) + + public override fun deserialize(decoder: Decoder) = + when (val value = decoder.decodeString()) { + "online" -> Online + "dnd" -> DoNotDisturb + "idle" -> Idle + "invisible" -> Invisible + "offline" -> Offline + else -> Unknown(value) + } + } + + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Use 'PresenceStatus.serializer()' instead.", + replaceWith = ReplaceWith(expression = "PresenceStatus.serializer()", imports = + arrayOf("dev.kord.common.entity.PresenceStatus")), + ) + public object StatusSerializer : KSerializer by Serializer { + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Use 'PresenceStatus.serializer()' instead.", + replaceWith = ReplaceWith(expression = "PresenceStatus.serializer()", imports = + arrayOf("dev.kord.common.entity.PresenceStatus")), + ) + public fun serializer(): KSerializer = this + } + + public companion object { + /** + * A [List] of all known [PresenceStatus]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Online, + DoNotDisturb, + Idle, + Invisible, + Offline, + ) + } + + + @Suppress(names = arrayOf("DEPRECATION_ERROR")) + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = "Binary compatibility", + ) + @JvmField + public val StatusSerializer: StatusSerializer = StatusSerializer + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ScheduledEntityType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ScheduledEntityType.kt new file mode 100644 index 000000000000..9f56df8ae1b2 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ScheduledEntityType.kt @@ -0,0 +1,113 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Deprecated +import kotlin.DeprecationLevel +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.ReplaceWith +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlin.jvm.JvmField +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [ScheduledEntityType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types). + */ +@Serializable(with = ScheduledEntityType.NewSerializer::class) +public sealed class ScheduledEntityType( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is ScheduledEntityType && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "ScheduledEntityType.${this::class.simpleName}(value=$value)" + + /** + * An unknown [ScheduledEntityType]. + * + * This is used as a fallback for [ScheduledEntityType]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : ScheduledEntityType(value) + + public object StageInstance : ScheduledEntityType(1) + + public object Voice : ScheduledEntityType(2) + + public object External : ScheduledEntityType(3) + + internal object NewSerializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.ScheduledEntityType", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: ScheduledEntityType) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> StageInstance + 2 -> Voice + 3 -> External + else -> Unknown(value) + } + } + + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Use 'ScheduledEntityType.serializer()' instead.", + replaceWith = ReplaceWith(expression = "ScheduledEntityType.serializer()", imports = + arrayOf("dev.kord.common.entity.ScheduledEntityType")), + ) + public object Serializer : KSerializer by NewSerializer { + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Use 'ScheduledEntityType.serializer()' instead.", + replaceWith = ReplaceWith(expression = "ScheduledEntityType.serializer()", imports = + arrayOf("dev.kord.common.entity.ScheduledEntityType")), + ) + public fun serializer(): KSerializer = this + } + + public companion object { + /** + * A [List] of all known [ScheduledEntityType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + StageInstance, + Voice, + External, + ) + } + + + @Suppress(names = arrayOf("DEPRECATION_ERROR")) + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = "Binary compatibility", + ) + @JvmField + public val Serializer: Serializer = Serializer + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/StageInstancePrivacyLevel.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/StageInstancePrivacyLevel.kt new file mode 100644 index 000000000000..e6511fdd1c24 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/StageInstancePrivacyLevel.kt @@ -0,0 +1,117 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Deprecated +import kotlin.DeprecationLevel +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.ReplaceWith +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlin.jvm.JvmField +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [StageInstancePrivacyLevel]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level). + */ +@Serializable(with = StageInstancePrivacyLevel.NewSerializer::class) +public sealed class StageInstancePrivacyLevel( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is StageInstancePrivacyLevel && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "StageInstancePrivacyLevel.${this::class.simpleName}(value=$value)" + + /** + * An unknown [StageInstancePrivacyLevel]. + * + * This is used as a fallback for [StageInstancePrivacyLevel]s that haven't been added to Kord + * yet. + */ + public class Unknown( + `value`: Int, + ) : StageInstancePrivacyLevel(value) + + /** + * The Stage instance is visible to only guild members. + */ + public object GuildOnly : StageInstancePrivacyLevel(2) + + /** + * The Stage instance is visible publicly. + */ + @Deprecated(message = "Stages are no longer discoverable") + public object Public : StageInstancePrivacyLevel(1) + + internal object NewSerializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.StageInstancePrivacyLevel", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: StageInstancePrivacyLevel) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> @Suppress("DEPRECATION") Public + 2 -> GuildOnly + else -> Unknown(value) + } + } + + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Use 'StageInstancePrivacyLevel.serializer()' instead.", + replaceWith = ReplaceWith(expression = "StageInstancePrivacyLevel.serializer()", imports = + arrayOf("dev.kord.common.entity.StageInstancePrivacyLevel")), + ) + public object Serializer : KSerializer by NewSerializer { + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Use 'StageInstancePrivacyLevel.serializer()' instead.", + replaceWith = ReplaceWith(expression = "StageInstancePrivacyLevel.serializer()", imports + = arrayOf("dev.kord.common.entity.StageInstancePrivacyLevel")), + ) + public fun serializer(): KSerializer = this + } + + public companion object { + /** + * A [List] of all known [StageInstancePrivacyLevel]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + @Suppress("DEPRECATION") Public, + GuildOnly, + ) + } + + + @Suppress(names = arrayOf("DEPRECATION_ERROR")) + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = "Binary compatibility", + ) + @JvmField + public val Serializer: Serializer = Serializer + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/TeamMembershipState.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/TeamMembershipState.kt new file mode 100644 index 000000000000..4bf0d827782b --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/TeamMembershipState.kt @@ -0,0 +1,110 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Deprecated +import kotlin.DeprecationLevel +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.ReplaceWith +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlin.jvm.JvmField +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [TeamMembershipState]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum). + */ +@Serializable(with = TeamMembershipState.Serializer::class) +public sealed class TeamMembershipState( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is TeamMembershipState && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "TeamMembershipState.${this::class.simpleName}(value=$value)" + + /** + * An unknown [TeamMembershipState]. + * + * This is used as a fallback for [TeamMembershipState]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : TeamMembershipState(value) + + public object Invited : TeamMembershipState(1) + + public object Accepted : TeamMembershipState(2) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.TeamMembershipState", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: TeamMembershipState) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> Invited + 2 -> Accepted + else -> Unknown(value) + } + } + + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Use 'TeamMembershipState.serializer()' instead.", + replaceWith = ReplaceWith(expression = "TeamMembershipState.serializer()", imports = + arrayOf("dev.kord.common.entity.TeamMembershipState")), + ) + public object TeamMembershipStateSerializer : KSerializer by Serializer { + @Deprecated( + level = DeprecationLevel.ERROR, + message = "Use 'TeamMembershipState.serializer()' instead.", + replaceWith = ReplaceWith(expression = "TeamMembershipState.serializer()", imports = + arrayOf("dev.kord.common.entity.TeamMembershipState")), + ) + public fun serializer(): KSerializer = this + } + + public companion object { + /** + * A [List] of all known [TeamMembershipState]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Invited, + Accepted, + ) + } + + + @Suppress(names = arrayOf("DEPRECATION_ERROR")) + @Deprecated( + level = DeprecationLevel.HIDDEN, + message = "Binary compatibility", + ) + @JvmField + public val TeamMembershipStateSerializer: TeamMembershipStateSerializer = + TeamMembershipStateSerializer + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/TextInputStyle.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/TextInputStyle.kt new file mode 100644 index 000000000000..2755562695bd --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/TextInputStyle.kt @@ -0,0 +1,89 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * Style of a [text input][dev.kord.common.entity.ComponentType.TextInput]. + * + * See [TextInputStyle]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/interactions/message-components#text-inputs-text-input-styles). + */ +@Serializable(with = TextInputStyle.Serializer::class) +public sealed class TextInputStyle( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is TextInputStyle && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "TextInputStyle.${this::class.simpleName}(value=$value)" + + /** + * An unknown [TextInputStyle]. + * + * This is used as a fallback for [TextInputStyle]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : TextInputStyle(value) + + /** + * A single-line input. + */ + public object Short : TextInputStyle(1) + + /** + * A multi-line input. + */ + public object Paragraph : TextInputStyle(2) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.TextInputStyle", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: TextInputStyle) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> Short + 2 -> Paragraph + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [TextInputStyle]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Short, + Paragraph, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/UserPremium.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/UserPremium.kt new file mode 100644 index 000000000000..9c922410ce00 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/UserPremium.kt @@ -0,0 +1,90 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * Premium types denote the level of premium a user has. + * + * See [UserPremium]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/user#user-object-premium-types). + */ +@Serializable(with = UserPremium.Serializer::class) +public sealed class UserPremium( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is UserPremium && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "UserPremium.${this::class.simpleName}(value=$value)" + + /** + * An unknown [UserPremium]. + * + * This is used as a fallback for [UserPremium]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : UserPremium(value) + + public object None : UserPremium(0) + + public object NitroClassic : UserPremium(1) + + public object Nitro : UserPremium(2) + + public object NitroBasic : UserPremium(3) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.UserPremium", PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: UserPremium) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 0 -> None + 1 -> NitroClassic + 2 -> Nitro + 3 -> NitroBasic + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [UserPremium]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + None, + NitroClassic, + Nitro, + NitroBasic, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/VerificationLevel.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/VerificationLevel.kt new file mode 100644 index 000000000000..174f9a6c3942 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/VerificationLevel.kt @@ -0,0 +1,108 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [VerificationLevel]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild#guild-object-verification-level). + */ +@Serializable(with = VerificationLevel.Serializer::class) +public sealed class VerificationLevel( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is VerificationLevel && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "VerificationLevel.${this::class.simpleName}(value=$value)" + + /** + * An unknown [VerificationLevel]. + * + * This is used as a fallback for [VerificationLevel]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : VerificationLevel(value) + + /** + * Unrestricted. + */ + public object None : VerificationLevel(0) + + /** + * Must have verified email on account. + */ + public object Low : VerificationLevel(1) + + /** + * Must be registered on Discord for longer than 5 minutes. + */ + public object Medium : VerificationLevel(2) + + /** + * Must be a member of the server for longer than 10 minutes. + */ + public object High : VerificationLevel(3) + + /** + * Must have a verified phone number. + */ + public object VeryHigh : VerificationLevel(4) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.VerificationLevel", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: VerificationLevel) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 0 -> None + 1 -> Low + 2 -> Medium + 3 -> High + 4 -> VeryHigh + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [VerificationLevel]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + None, + Low, + Medium, + High, + VeryHigh, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/VideoQualityMode.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/VideoQualityMode.kt new file mode 100644 index 000000000000..22c92b3ae03c --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/VideoQualityMode.kt @@ -0,0 +1,87 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [VideoQualityMode]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/channel#channel-object-video-quality-modes). + */ +@Serializable(with = VideoQualityMode.Serializer::class) +public sealed class VideoQualityMode( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is VideoQualityMode && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "VideoQualityMode.${this::class.simpleName}(value=$value)" + + /** + * An unknown [VideoQualityMode]. + * + * This is used as a fallback for [VideoQualityMode]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : VideoQualityMode(value) + + /** + * Discord chooses the quality for optimal performance. + */ + public object Auto : VideoQualityMode(1) + + /** + * 720p. + */ + public object Full : VideoQualityMode(2) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.VideoQualityMode", + PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: VideoQualityMode) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> Auto + 2 -> Full + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [VideoQualityMode]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Auto, + Full, + ) + } + + } +} diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/WebhookType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/WebhookType.kt new file mode 100644 index 000000000000..5a2509adc670 --- /dev/null +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/WebhookType.kt @@ -0,0 +1,94 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.common.entity + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [WebhookType]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types). + */ +@Serializable(with = WebhookType.Serializer::class) +public sealed class WebhookType( + /** + * The raw value used by Discord. + */ + public val `value`: Int, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is WebhookType && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "WebhookType.${this::class.simpleName}(value=$value)" + + /** + * An unknown [WebhookType]. + * + * This is used as a fallback for [WebhookType]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: Int, + ) : WebhookType(value) + + /** + * Incoming Webhooks can post messages to channels with a generated token. + */ + public object Incoming : WebhookType(1) + + /** + * Channel Follower Webhooks are internal webhooks used with Channel Following to post new + * messages into channels. + */ + public object ChannelFollower : WebhookType(2) + + /** + * Application webhooks are webhooks used with Interactions. + */ + public object Application : WebhookType(3) + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.common.entity.WebhookType", PrimitiveKind.INT) + + public override fun serialize(encoder: Encoder, `value`: WebhookType) = + encoder.encodeInt(value.value) + + public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { + 1 -> Incoming + 2 -> ChannelFollower + 3 -> Application + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [WebhookType]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + Incoming, + ChannelFollower, + Application, + ) + } + + } +} diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock new file mode 100644 index 000000000000..932b0c9eed86 --- /dev/null +++ b/kotlin-js-store/yarn.lock @@ -0,0 +1,583 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@js-joda/core@3.2.0": + version "3.2.0" + resolved "https://registry.yarnpkg.com/@js-joda/core/-/core-3.2.0.tgz#3e61e21b7b2b8a6be746df1335cf91d70db2a273" + integrity sha512-PMqgJ0sw5B7FKb2d5bWYIoxjri+QlW/Pys7+Rw82jSH0QN3rB05jZ/VrrsUdh1w4+i2kw9JOejXGq/KhDOX7Kg== + +"@types/node@^18.14.0": + version "18.14.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.14.1.tgz#90dad8476f1e42797c49d6f8b69aaf9f876fc69f" + integrity sha512-QH+37Qds3E0eDlReeboBxfHbX9omAcBCXEzswCu6jySP642jiM3cYSIkU/REqwhCUqXdonHFuBfJDiAJxMNhaQ== + +"@ungap/promise-all-settled@1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44" + integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q== + +ansi-colors@4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" + integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-styles@^4.0.0, ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +anymatch@~3.1.2: + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + +balanced-match@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +binary-extensions@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" + integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + +braces@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +browser-stdout@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" + integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== + +buffer-from@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" + integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== + +camelcase@^6.0.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" + integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== + +chalk@^4.1.0: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + +chokidar@3.5.3: + version "3.5.3" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" + integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" + +cliui@^7.0.2: + version "7.0.4" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" + integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.0" + wrap-ansi "^7.0.0" + +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== + +debug@4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + +decamelize@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" + integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== + +diff@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" + integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== + +dukat@0.5.8-rc.4: + version "0.5.8-rc.4" + resolved "https://registry.yarnpkg.com/dukat/-/dukat-0.5.8-rc.4.tgz#90384dcb50b14c26f0e99dae92b2dea44f5fce21" + integrity sha512-ZnMt6DGBjlVgK2uQamXfd7uP/AxH7RqI0BL9GLrrJb2gKdDxvJChWy+M9AQEaL+7/6TmxzJxFOsRiInY9oGWTA== + dependencies: + google-protobuf "3.12.2" + typescript "3.9.5" + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +escalade@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" + integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== + +escape-string-regexp@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +find-up@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + +flat@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" + integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== + +format-util@1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/format-util/-/format-util-1.0.5.tgz#1ffb450c8a03e7bccffe40643180918cc297d271" + integrity sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg== + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== + +fsevents@~2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + +get-caller-file@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + +glob-parent@~5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +glob@7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" + integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +google-protobuf@3.12.2: + version "3.12.2" + resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.12.2.tgz#50ce9f9b6281235724eb243d6a83e969a2176e53" + integrity sha512-4CZhpuRr1d6HjlyrxoXoocoGFnRYgKULgMtikMddA9ztRyYR59Aondv2FioyxWVamRo0rF2XpYawkTCBEQOSkA== + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +he@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" + integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +is-glob@^4.0.1, is-glob@~4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-plain-obj@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" + integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== + +is-unicode-supported@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" + integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== + +js-yaml@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + dependencies: + argparse "^2.0.1" + +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + +log-symbols@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" + integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== + dependencies: + chalk "^4.1.0" + is-unicode-supported "^0.1.0" + +minimatch@5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.0.1.tgz#fb9022f7528125187c92bd9e9b6366be1cf3415b" + integrity sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g== + dependencies: + brace-expansion "^2.0.1" + +minimatch@^3.0.4: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + +mocha@10.0.0: + version "10.0.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.0.0.tgz#205447d8993ec755335c4b13deba3d3a13c4def9" + integrity sha512-0Wl+elVUD43Y0BqPZBzZt8Tnkw9CMUdNYnUsTfOM1vuhJVZL+kiesFYsqwBkEEuEixaiPe5ZQdqDgX2jddhmoA== + dependencies: + "@ungap/promise-all-settled" "1.1.2" + ansi-colors "4.1.1" + browser-stdout "1.3.1" + chokidar "3.5.3" + debug "4.3.4" + diff "5.0.0" + escape-string-regexp "4.0.0" + find-up "5.0.0" + glob "7.2.0" + he "1.2.0" + js-yaml "4.1.0" + log-symbols "4.1.0" + minimatch "5.0.1" + ms "2.1.3" + nanoid "3.3.3" + serialize-javascript "6.0.0" + strip-json-comments "3.1.1" + supports-color "8.1.1" + workerpool "6.2.1" + yargs "16.2.0" + yargs-parser "20.2.4" + yargs-unparser "2.0.0" + +ms@2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + +ms@2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +nanoid@3.3.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.3.tgz#fd8e8b7aa761fe807dba2d1b98fb7241bb724a25" + integrity sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w== + +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== + dependencies: + wrappy "1" + +p-limit@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== + +picomatch@^2.0.4, picomatch@^2.2.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +randombytes@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" + integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== + dependencies: + safe-buffer "^5.1.0" + +readdirp@~3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== + dependencies: + picomatch "^2.2.1" + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== + +safe-buffer@^5.1.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +serialize-javascript@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" + integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== + dependencies: + randombytes "^2.1.0" + +source-map-support@0.5.21: + version "0.5.21" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +string-width@^4.1.0, string-width@^4.2.0: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-json-comments@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== + +supports-color@8.1.1: + version "8.1.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== + dependencies: + has-flag "^4.0.0" + +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +typescript@3.9.5: + version "3.9.5" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.5.tgz#586f0dba300cde8be52dd1ac4f7e1009c1b13f36" + integrity sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ== + +workerpool@6.2.1: + version "6.2.1" + resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" + integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== + +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== + +y18n@^5.0.5: + version "5.0.8" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" + integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== + +yargs-parser@20.2.4: + version "20.2.4" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" + integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== + +yargs-parser@^20.2.2: + version "20.2.9" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" + integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== + +yargs-unparser@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb" + integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== + dependencies: + camelcase "^6.0.0" + decamelize "^4.0.0" + flat "^5.0.2" + is-plain-obj "^2.1.0" + +yargs@16.2.0: + version "16.2.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" + integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== + dependencies: + cliui "^7.0.2" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.0" + y18n "^5.0.5" + yargs-parser "^20.2.2" + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== From bcc603d7f0f50592f072830815f448868e335b19 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Fri, 24 Feb 2023 17:15:53 +0100 Subject: [PATCH 003/136] Delete old generated output --- .../kord/common/entity/AllowedMentionType.kt | 95 ---- .../entity/ApplicationCommandOptionType.kt | 128 ----- .../ApplicationCommandPermissionType.kt | 86 ---- .../common/entity/ApplicationCommandType.kt | 94 ---- .../dev/kord/common/entity/AuditLogEvent.kt | 450 ------------------ .../common/entity/AutoModerationActionType.kt | 105 ---- .../entity/AutoModerationRuleEventType.kt | 83 ---- .../AutoModerationRuleKeywordPresetType.kt | 97 ---- .../entity/AutoModerationRuleTriggerType.kt | 104 ---- .../dev/kord/common/entity/ButtonStyle.kt | 137 ------ .../dev/kord/common/entity/ChannelType.kt | 163 ------- .../dev/kord/common/entity/ComponentType.kt | 167 ------- .../entity/DefaultMessageNotificationLevel.kt | 88 ---- .../entity/DiscordConnectionVisibility.kt | 88 ---- .../dev/kord/common/entity/EmbedType.kt | 115 ----- .../common/entity/ExplicitContentFilter.kt | 94 ---- .../dev/kord/common/entity/GuildFeature.kt | 286 ----------- .../entity/GuildScheduledEventPrivacyLevel.kt | 81 ---- .../entity/GuildScheduledEventStatus.kt | 118 ----- .../entity/IntegrationExpireBehavior.kt | 110 ----- .../common/entity/InteractionResponseType.kt | 124 ----- .../dev/kord/common/entity/InteractionType.kt | 93 ---- .../kord/common/entity/InviteTargetType.kt | 81 ---- .../kotlin/dev/kord/common/entity/MFALevel.kt | 86 ---- .../kord/common/entity/MessageActivityType.kt | 89 ---- .../kord/common/entity/MessageStickerType.kt | 101 ---- .../dev/kord/common/entity/MessageType.kt | 208 -------- .../dev/kord/common/entity/NsfwLevel.kt | 88 ---- .../dev/kord/common/entity/OverwriteType.kt | 80 ---- .../dev/kord/common/entity/PremiumTier.kt | 100 ---- .../dev/kord/common/entity/PresenceStatus.kt | 137 ------ .../kord/common/entity/ScheduledEntityType.kt | 113 ----- .../entity/StageInstancePrivacyLevel.kt | 117 ----- .../kord/common/entity/TeamMembershipState.kt | 110 ----- .../dev/kord/common/entity/TextInputStyle.kt | 89 ---- .../dev/kord/common/entity/UserPremium.kt | 90 ---- .../kord/common/entity/VerificationLevel.kt | 108 ----- .../kord/common/entity/VideoQualityMode.kt | 87 ---- .../dev/kord/common/entity/WebhookType.kt | 94 ---- 39 files changed, 4684 deletions(-) delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AllowedMentionType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ApplicationCommandOptionType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ApplicationCommandPermissionType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ApplicationCommandType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AuditLogEvent.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AutoModerationActionType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AutoModerationRuleEventType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AutoModerationRuleKeywordPresetType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AutoModerationRuleTriggerType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ButtonStyle.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ChannelType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ComponentType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/DefaultMessageNotificationLevel.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/DiscordConnectionVisibility.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/EmbedType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ExplicitContentFilter.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/GuildFeature.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/GuildScheduledEventPrivacyLevel.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/GuildScheduledEventStatus.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/IntegrationExpireBehavior.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/InteractionResponseType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/InteractionType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/InviteTargetType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/MFALevel.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/MessageActivityType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/MessageStickerType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/MessageType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/NsfwLevel.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/OverwriteType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/PremiumTier.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/PresenceStatus.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ScheduledEntityType.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/StageInstancePrivacyLevel.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/TeamMembershipState.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/TextInputStyle.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/UserPremium.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/VerificationLevel.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/VideoQualityMode.kt delete mode 100644 common/build/generated/ksp/main/kotlin/dev/kord/common/entity/WebhookType.kt diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AllowedMentionType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AllowedMentionType.kt deleted file mode 100644 index 7e0809b33c70..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AllowedMentionType.kt +++ /dev/null @@ -1,95 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [AllowedMentionType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types). - */ -@Serializable(with = AllowedMentionType.Serializer::class) -public sealed class AllowedMentionType( - /** - * The raw value used by Discord. - */ - public val `value`: String, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is AllowedMentionType && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "AllowedMentionType.${this::class.simpleName}(value=$value)" - - /** - * An unknown [AllowedMentionType]. - * - * This is used as a fallback for [AllowedMentionType]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: String, - ) : AllowedMentionType(value) - - /** - * Controls role mentions. - */ - public object RoleMentions : AllowedMentionType("roles") - - /** - * Controls user mentions - */ - public object UserMentions : AllowedMentionType("users") - - /** - * Controls @everyone and @here mentions. - */ - public object EveryoneMentions : AllowedMentionType("everyone") - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.AllowedMentionType", - PrimitiveKind.STRING) - - public override fun serialize(encoder: Encoder, `value`: AllowedMentionType) = - encoder.encodeString(value.value) - - public override fun deserialize(decoder: Decoder) = - when (val value = decoder.decodeString()) { - "roles" -> RoleMentions - "users" -> UserMentions - "everyone" -> EveryoneMentions - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [AllowedMentionType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - RoleMentions, - UserMentions, - EveryoneMentions, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ApplicationCommandOptionType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ApplicationCommandOptionType.kt deleted file mode 100644 index 3009f6405875..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ApplicationCommandOptionType.kt +++ /dev/null @@ -1,128 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [ApplicationCommandOptionType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type). - */ -@Serializable(with = ApplicationCommandOptionType.Serializer::class) -public sealed class ApplicationCommandOptionType( - /** - * The raw type used by Discord. - */ - public val type: Int, -) { - public final override fun equals(other: Any?): kotlin.Boolean = this === other || - (other is ApplicationCommandOptionType && this.type == other.type) - - public final override fun hashCode(): Int = type.hashCode() - - public final override fun toString(): kotlin.String = - "ApplicationCommandOptionType.${this::class.simpleName}(type=$type)" - - /** - * An unknown [ApplicationCommandOptionType]. - * - * This is used as a fallback for [ApplicationCommandOptionType]s that haven't been added to - * Kord yet. - */ - public class Unknown( - type: Int, - ) : ApplicationCommandOptionType(type) - - public object SubCommand : ApplicationCommandOptionType(1) - - public object SubCommandGroup : ApplicationCommandOptionType(2) - - public object String : ApplicationCommandOptionType(3) - - /** - * Any integer between `-2^53` and `2^53`. - */ - public object Integer : ApplicationCommandOptionType(4) - - public object Boolean : ApplicationCommandOptionType(5) - - public object User : ApplicationCommandOptionType(6) - - /** - * Includes all channel types + categories. - */ - public object Channel : ApplicationCommandOptionType(7) - - public object Role : ApplicationCommandOptionType(8) - - /** - * Includes users and roles. - */ - public object Mentionable : ApplicationCommandOptionType(9) - - /** - * Any double between `-2^53` and `2^53`. - */ - public object Number : ApplicationCommandOptionType(10) - - public object Attachment : ApplicationCommandOptionType(11) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.ApplicationCommandOptionType", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: ApplicationCommandOptionType) = - encoder.encodeInt(value.type) - - public override fun deserialize(decoder: Decoder) = when (val type = decoder.decodeInt()) { - 1 -> SubCommand - 2 -> SubCommandGroup - 3 -> String - 4 -> Integer - 5 -> Boolean - 6 -> User - 7 -> Channel - 8 -> Role - 9 -> Mentionable - 10 -> Number - 11 -> Attachment - else -> Unknown(type) - } - } - - public companion object { - /** - * A [List] of all known [ApplicationCommandOptionType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - SubCommand, - SubCommandGroup, - String, - Integer, - Boolean, - User, - Channel, - Role, - Mentionable, - Number, - Attachment, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ApplicationCommandPermissionType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ApplicationCommandPermissionType.kt deleted file mode 100644 index f98288a8e2de..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ApplicationCommandPermissionType.kt +++ /dev/null @@ -1,86 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [ApplicationCommandPermissionType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type). - */ -@Serializable(with = ApplicationCommandPermissionType.Serializer::class) -public sealed class ApplicationCommandPermissionType( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is ApplicationCommandPermissionType && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "ApplicationCommandPermissionType.${this::class.simpleName}(value=$value)" - - /** - * An unknown [ApplicationCommandPermissionType]. - * - * This is used as a fallback for [ApplicationCommandPermissionType]s that haven't been added to - * Kord yet. - */ - public class Unknown( - `value`: Int, - ) : ApplicationCommandPermissionType(value) - - public object Role : ApplicationCommandPermissionType(1) - - public object User : ApplicationCommandPermissionType(2) - - public object Channel : ApplicationCommandPermissionType(3) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.ApplicationCommandPermissionType", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: ApplicationCommandPermissionType) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> Role - 2 -> User - 3 -> Channel - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [ApplicationCommandPermissionType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Role, - User, - Channel, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ApplicationCommandType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ApplicationCommandType.kt deleted file mode 100644 index 37540d3e6b56..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ApplicationCommandType.kt +++ /dev/null @@ -1,94 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [ApplicationCommandType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types). - */ -@Serializable(with = ApplicationCommandType.Serializer::class) -public sealed class ApplicationCommandType( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is ApplicationCommandType && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "ApplicationCommandType.${this::class.simpleName}(value=$value)" - - /** - * An unknown [ApplicationCommandType]. - * - * This is used as a fallback for [ApplicationCommandType]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : ApplicationCommandType(value) - - /** - * A text-based command that shows up when a user types `/`. - */ - public object ChatInput : ApplicationCommandType(1) - - /** - * A UI-based command that shows up when you right-click or tap on a user. - */ - public object User : ApplicationCommandType(2) - - /** - * A UI-based command that shows up when you right-click or tap on a message. - */ - public object Message : ApplicationCommandType(3) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.ApplicationCommandType", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: ApplicationCommandType) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> ChatInput - 2 -> User - 3 -> Message - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [ApplicationCommandType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - ChatInput, - User, - Message, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AuditLogEvent.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AuditLogEvent.kt deleted file mode 100644 index 81ac1e4e0148..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AuditLogEvent.kt +++ /dev/null @@ -1,450 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [AuditLogEvent]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events). - */ -@Serializable(with = AuditLogEvent.Serializer::class) -public sealed class AuditLogEvent( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is AuditLogEvent && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "AuditLogEvent.${this::class.simpleName}(value=$value)" - - /** - * An unknown [AuditLogEvent]. - * - * This is used as a fallback for [AuditLogEvent]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : AuditLogEvent(value) - - /** - * Server settings were updated. - */ - public object GuildUpdate : AuditLogEvent(1) - - /** - * Channel was created. - */ - public object ChannelCreate : AuditLogEvent(10) - - /** - * Channel settings were updated. - */ - public object ChannelUpdate : AuditLogEvent(11) - - /** - * Channel was deleted. - */ - public object ChannelDelete : AuditLogEvent(12) - - /** - * Permission overwrite was added to a channel. - */ - public object ChannelOverwriteCreate : AuditLogEvent(13) - - /** - * Permission overwrite was updated for a channel. - */ - public object ChannelOverwriteUpdate : AuditLogEvent(14) - - /** - * Permission overwrite was deleted from a channel. - */ - public object ChannelOverwriteDelete : AuditLogEvent(15) - - /** - * Member was removed from server. - */ - public object MemberKick : AuditLogEvent(20) - - /** - * Members were pruned from server. - */ - public object MemberPrune : AuditLogEvent(21) - - /** - * Member was banned from server. - */ - public object MemberBanAdd : AuditLogEvent(22) - - /** - * Server ban was lifted for a member. - */ - public object MemberBanRemove : AuditLogEvent(23) - - /** - * Member was updated in server. - */ - public object MemberUpdate : AuditLogEvent(24) - - /** - * Member was added or removed from a role. - */ - public object MemberRoleUpdate : AuditLogEvent(25) - - /** - * Member was moved to a different voice channel. - */ - public object MemberMove : AuditLogEvent(26) - - /** - * Member was disconnected from a voice channel. - */ - public object MemberDisconnect : AuditLogEvent(27) - - /** - * Bot user was added to server. - */ - public object BotAdd : AuditLogEvent(28) - - /** - * Role was created. - */ - public object RoleCreate : AuditLogEvent(30) - - /** - * Role was edited. - */ - public object RoleUpdate : AuditLogEvent(31) - - /** - * Role was deleted. - */ - public object RoleDelete : AuditLogEvent(32) - - /** - * Server invite was created. - */ - public object InviteCreate : AuditLogEvent(40) - - /** - * Server invite was updated. - */ - public object InviteUpdate : AuditLogEvent(41) - - /** - * Server invite was deleted. - */ - public object InviteDelete : AuditLogEvent(42) - - /** - * Webhook was created. - */ - public object WebhookCreate : AuditLogEvent(50) - - /** - * Webhook properties or channel were updated. - */ - public object WebhookUpdate : AuditLogEvent(51) - - /** - * Webhook was deleted. - */ - public object WebhookDelete : AuditLogEvent(52) - - /** - * Emoji was created. - */ - public object EmojiCreate : AuditLogEvent(60) - - /** - * Emoji name was updated. - */ - public object EmojiUpdate : AuditLogEvent(61) - - /** - * Emoji was deleted. - */ - public object EmojiDelete : AuditLogEvent(62) - - /** - * Single message was deleted. - */ - public object MessageDelete : AuditLogEvent(72) - - /** - * Multiple messages were deleted. - */ - public object MessageBulkDelete : AuditLogEvent(73) - - /** - * Message was pinned to a channel. - */ - public object MessagePin : AuditLogEvent(74) - - /** - * Message was unpinned from a channel. - */ - public object MessageUnpin : AuditLogEvent(75) - - /** - * App was added to server. - */ - public object IntegrationCreate : AuditLogEvent(80) - - /** - * App was updated (as an example, its scopes were updated). - */ - public object IntegrationUpdate : AuditLogEvent(81) - - /** - * App was removed from server. - */ - public object IntegrationDelete : AuditLogEvent(82) - - /** - * Stage instance was created (stage channel becomes live). - */ - public object StageInstanceCreate : AuditLogEvent(83) - - /** - * Stage instance details were updated. - */ - public object StageInstanceUpdate : AuditLogEvent(84) - - /** - * Stage instance was deleted (stage channel no longer live). - */ - public object StageInstanceDelete : AuditLogEvent(85) - - /** - * Sticker was created. - */ - public object StickerCreate : AuditLogEvent(90) - - /** - * Sticker details were updated. - */ - public object StickerUpdate : AuditLogEvent(91) - - /** - * Sticker was deleted. - */ - public object StickerDelete : AuditLogEvent(92) - - /** - * Event was created. - */ - public object GuildScheduledEventCreate : AuditLogEvent(100) - - /** - * Event was updated. - */ - public object GuildScheduledEventUpdate : AuditLogEvent(101) - - /** - * Event was cancelled. - */ - public object GuildScheduledEventDelete : AuditLogEvent(102) - - /** - * Thread was created in a channel. - */ - public object ThreadCreate : AuditLogEvent(110) - - /** - * Thread was updated. - */ - public object ThreadUpdate : AuditLogEvent(111) - - /** - * Thread was deleted. - */ - public object ThreadDelete : AuditLogEvent(112) - - /** - * Permissions were updated for a command. - */ - public object ApplicationCommandPermissionUpdate : AuditLogEvent(121) - - /** - * Auto Moderation rule was created. - */ - public object AutoModerationRuleCreate : AuditLogEvent(140) - - /** - * Auto Moderation rule was updated. - */ - public object AutoModerationRuleUpdate : AuditLogEvent(141) - - /** - * Auto Moderation rule was deleted. - */ - public object AutoModerationRuleDelete : AuditLogEvent(142) - - /** - * Message was blocked by Auto Moderation. - */ - public object AutoModerationBlockMessage : AuditLogEvent(143) - - /** - * Message was flagged by Auto Moderation. - */ - public object AutoModerationFlagToChannel : AuditLogEvent(144) - - /** - * Member was timed out by Auto Moderation. - */ - public object AutoModerationUserCommunicationDisabled : AuditLogEvent(145) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.AuditLogEvent", PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: AuditLogEvent) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> GuildUpdate - 10 -> ChannelCreate - 11 -> ChannelUpdate - 12 -> ChannelDelete - 13 -> ChannelOverwriteCreate - 14 -> ChannelOverwriteUpdate - 15 -> ChannelOverwriteDelete - 20 -> MemberKick - 21 -> MemberPrune - 22 -> MemberBanAdd - 23 -> MemberBanRemove - 24 -> MemberUpdate - 25 -> MemberRoleUpdate - 26 -> MemberMove - 27 -> MemberDisconnect - 28 -> BotAdd - 30 -> RoleCreate - 31 -> RoleUpdate - 32 -> RoleDelete - 40 -> InviteCreate - 41 -> InviteUpdate - 42 -> InviteDelete - 50 -> WebhookCreate - 51 -> WebhookUpdate - 52 -> WebhookDelete - 60 -> EmojiCreate - 61 -> EmojiUpdate - 62 -> EmojiDelete - 72 -> MessageDelete - 73 -> MessageBulkDelete - 74 -> MessagePin - 75 -> MessageUnpin - 80 -> IntegrationCreate - 81 -> IntegrationUpdate - 82 -> IntegrationDelete - 83 -> StageInstanceCreate - 84 -> StageInstanceUpdate - 85 -> StageInstanceDelete - 90 -> StickerCreate - 91 -> StickerUpdate - 92 -> StickerDelete - 100 -> GuildScheduledEventCreate - 101 -> GuildScheduledEventUpdate - 102 -> GuildScheduledEventDelete - 110 -> ThreadCreate - 111 -> ThreadUpdate - 112 -> ThreadDelete - 121 -> ApplicationCommandPermissionUpdate - 140 -> AutoModerationRuleCreate - 141 -> AutoModerationRuleUpdate - 142 -> AutoModerationRuleDelete - 143 -> AutoModerationBlockMessage - 144 -> AutoModerationFlagToChannel - 145 -> AutoModerationUserCommunicationDisabled - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [AuditLogEvent]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - GuildUpdate, - ChannelCreate, - ChannelUpdate, - ChannelDelete, - ChannelOverwriteCreate, - ChannelOverwriteUpdate, - ChannelOverwriteDelete, - MemberKick, - MemberPrune, - MemberBanAdd, - MemberBanRemove, - MemberUpdate, - MemberRoleUpdate, - MemberMove, - MemberDisconnect, - BotAdd, - RoleCreate, - RoleUpdate, - RoleDelete, - InviteCreate, - InviteUpdate, - InviteDelete, - WebhookCreate, - WebhookUpdate, - WebhookDelete, - EmojiCreate, - EmojiUpdate, - EmojiDelete, - MessageDelete, - MessageBulkDelete, - MessagePin, - MessageUnpin, - IntegrationCreate, - IntegrationUpdate, - IntegrationDelete, - StageInstanceCreate, - StageInstanceUpdate, - StageInstanceDelete, - StickerCreate, - StickerUpdate, - StickerDelete, - GuildScheduledEventCreate, - GuildScheduledEventUpdate, - GuildScheduledEventDelete, - ThreadCreate, - ThreadUpdate, - ThreadDelete, - ApplicationCommandPermissionUpdate, - AutoModerationRuleCreate, - AutoModerationRuleUpdate, - AutoModerationRuleDelete, - AutoModerationBlockMessage, - AutoModerationFlagToChannel, - AutoModerationUserCommunicationDisabled, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AutoModerationActionType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AutoModerationActionType.kt deleted file mode 100644 index 2dd057cf911e..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AutoModerationActionType.kt +++ /dev/null @@ -1,105 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * The type of action. - * - * See [AutoModerationActionType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-action-types). - */ -@Serializable(with = AutoModerationActionType.Serializer::class) -public sealed class AutoModerationActionType( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is AutoModerationActionType && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "AutoModerationActionType.${this::class.simpleName}(value=$value)" - - /** - * An unknown [AutoModerationActionType]. - * - * This is used as a fallback for [AutoModerationActionType]s that haven't been added to Kord - * yet. - */ - public class Unknown( - `value`: Int, - ) : AutoModerationActionType(value) - - /** - * Blocks a member's message and prevents it from being posted. - * - * A custom explanation can be specified and shown to members whenever their message is blocked. - */ - public object BlockMessage : AutoModerationActionType(1) - - /** - * Logs user content to a specified channel. - */ - public object SendAlertMessage : AutoModerationActionType(2) - - /** - * Timeout user for a specified duration. - * - * A [Timeout] action can only be set up for - * [Keyword][dev.kord.common.entity.AutoModerationRuleTriggerType.Keyword] and - * [MentionSpam][dev.kord.common.entity.AutoModerationRuleTriggerType.MentionSpam] rules. The - * [ModerateMembers][dev.kord.common.entity.Permission.ModerateMembers] permission is required to - * use the [Timeout] action type. - */ - public object Timeout : AutoModerationActionType(3) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.AutoModerationActionType", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: AutoModerationActionType) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> BlockMessage - 2 -> SendAlertMessage - 3 -> Timeout - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [AutoModerationActionType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - BlockMessage, - SendAlertMessage, - Timeout, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AutoModerationRuleEventType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AutoModerationRuleEventType.kt deleted file mode 100644 index 7f285d457160..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AutoModerationRuleEventType.kt +++ /dev/null @@ -1,83 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * Indicates in what event context a rule should be checked. - * - * See [AutoModerationRuleEventType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types). - */ -@Serializable(with = AutoModerationRuleEventType.Serializer::class) -public sealed class AutoModerationRuleEventType( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is AutoModerationRuleEventType && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "AutoModerationRuleEventType.${this::class.simpleName}(value=$value)" - - /** - * An unknown [AutoModerationRuleEventType]. - * - * This is used as a fallback for [AutoModerationRuleEventType]s that haven't been added to Kord - * yet. - */ - public class Unknown( - `value`: Int, - ) : AutoModerationRuleEventType(value) - - /** - * When a member sends or edits a message in the guild. - */ - public object MessageSend : AutoModerationRuleEventType(1) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.AutoModerationRuleEventType", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: AutoModerationRuleEventType) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> MessageSend - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [AutoModerationRuleEventType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - MessageSend, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AutoModerationRuleKeywordPresetType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AutoModerationRuleKeywordPresetType.kt deleted file mode 100644 index 0fd6bd7c1ce8..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AutoModerationRuleKeywordPresetType.kt +++ /dev/null @@ -1,97 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * An internally pre-defined wordset which will be searched for in content. - * - * See [AutoModerationRuleKeywordPresetType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-preset-types). - */ -@Serializable(with = AutoModerationRuleKeywordPresetType.Serializer::class) -public sealed class AutoModerationRuleKeywordPresetType( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is AutoModerationRuleKeywordPresetType && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "AutoModerationRuleKeywordPresetType.${this::class.simpleName}(value=$value)" - - /** - * An unknown [AutoModerationRuleKeywordPresetType]. - * - * This is used as a fallback for [AutoModerationRuleKeywordPresetType]s that haven't been added - * to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : AutoModerationRuleKeywordPresetType(value) - - /** - * Words that may be considered forms of swearing or cursing. - */ - public object Profanity : AutoModerationRuleKeywordPresetType(1) - - /** - * Words that refer to sexually explicit behavior or activity. - */ - public object SexualContent : AutoModerationRuleKeywordPresetType(2) - - /** - * Personal insults or words that may be considered hate speech. - */ - public object Slurs : AutoModerationRuleKeywordPresetType(3) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.AutoModerationRuleKeywordPresetType", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, - `value`: AutoModerationRuleKeywordPresetType) = encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> Profanity - 2 -> SexualContent - 3 -> Slurs - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [AutoModerationRuleKeywordPresetType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Profanity, - SexualContent, - Slurs, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AutoModerationRuleTriggerType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AutoModerationRuleTriggerType.kt deleted file mode 100644 index 38d7f7282d96..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/AutoModerationRuleTriggerType.kt +++ /dev/null @@ -1,104 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * Characterizes the type of content which can trigger the rule. - * - * See [AutoModerationRuleTriggerType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types). - */ -@Serializable(with = AutoModerationRuleTriggerType.Serializer::class) -public sealed class AutoModerationRuleTriggerType( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is AutoModerationRuleTriggerType && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "AutoModerationRuleTriggerType.${this::class.simpleName}(value=$value)" - - /** - * An unknown [AutoModerationRuleTriggerType]. - * - * This is used as a fallback for [AutoModerationRuleTriggerType]s that haven't been added to - * Kord yet. - */ - public class Unknown( - `value`: Int, - ) : AutoModerationRuleTriggerType(value) - - /** - * Check if content contains words from a user defined list of keywords. - */ - public object Keyword : AutoModerationRuleTriggerType(1) - - /** - * Check if content represents generic spam. - */ - public object Spam : AutoModerationRuleTriggerType(3) - - /** - * Check if content contains words from internal pre-defined wordsets. - */ - public object KeywordPreset : AutoModerationRuleTriggerType(4) - - /** - * Check if content contains more unique mentions than allowed. - */ - public object MentionSpam : AutoModerationRuleTriggerType(5) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.AutoModerationRuleTriggerType", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: AutoModerationRuleTriggerType) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> Keyword - 3 -> Spam - 4 -> KeywordPreset - 5 -> MentionSpam - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [AutoModerationRuleTriggerType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Keyword, - Spam, - KeywordPreset, - MentionSpam, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ButtonStyle.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ButtonStyle.kt deleted file mode 100644 index 1e61d640d012..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ButtonStyle.kt +++ /dev/null @@ -1,137 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Deprecated -import kotlin.DeprecationLevel -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.ReplaceWith -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlin.jvm.JvmField -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * Style of a [button][dev.kord.common.entity.ComponentType.Button]. - * - * See [ButtonStyle]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/interactions/message-components#button-object-button-styles). - */ -@Serializable(with = ButtonStyle.NewSerializer::class) -public sealed class ButtonStyle( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is ButtonStyle && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "ButtonStyle.${this::class.simpleName}(value=$value)" - - /** - * An unknown [ButtonStyle]. - * - * This is used as a fallback for [ButtonStyle]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : ButtonStyle(value) - - /** - * Blurple. - */ - public object Primary : ButtonStyle(1) - - /** - * Grey. - */ - public object Secondary : ButtonStyle(2) - - /** - * Green. - */ - public object Success : ButtonStyle(3) - - /** - * Red. - */ - public object Danger : ButtonStyle(4) - - /** - * Grey, navigates to a URL. - */ - public object Link : ButtonStyle(5) - - internal object NewSerializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.ButtonStyle", PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: ButtonStyle) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> Primary - 2 -> Secondary - 3 -> Success - 4 -> Danger - 5 -> Link - else -> Unknown(value) - } - } - - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Use 'ButtonStyle.serializer()' instead.", - replaceWith = ReplaceWith(expression = "ButtonStyle.serializer()", imports = - arrayOf("dev.kord.common.entity.ButtonStyle")), - ) - public object Serializer : KSerializer by NewSerializer { - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Use 'ButtonStyle.serializer()' instead.", - replaceWith = ReplaceWith(expression = "ButtonStyle.serializer()", imports = - arrayOf("dev.kord.common.entity.ButtonStyle")), - ) - public fun serializer(): KSerializer = this - } - - public companion object { - /** - * A [List] of all known [ButtonStyle]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Primary, - Secondary, - Success, - Danger, - Link, - ) - } - - - @Suppress(names = arrayOf("DEPRECATION_ERROR")) - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Binary compatibility", - ) - @JvmField - public val Serializer: Serializer = Serializer - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ChannelType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ChannelType.kt deleted file mode 100644 index 04a3e6b1db63..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ChannelType.kt +++ /dev/null @@ -1,163 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [ChannelType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/channel#channel-object-channel-types). - */ -@Serializable(with = ChannelType.Serializer::class) -public sealed class ChannelType( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is ChannelType && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "ChannelType.${this::class.simpleName}(value=$value)" - - /** - * An unknown [ChannelType]. - * - * This is used as a fallback for [ChannelType]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : ChannelType(value) - - /** - * A text channel within a server. - */ - public object GuildText : ChannelType(0) - - /** - * A direct message between users. - */ - public object DM : ChannelType(1) - - /** - * A voice channel within a server. - */ - public object GuildVoice : ChannelType(2) - - /** - * A direct message between multiple users. - */ - public object GroupDM : ChannelType(3) - - /** - * An - * [organizational category](https://support.discord.com/hc/en-us/articles/115001580171-Channel-Categories-101) - * that contains up to 50 channels. - */ - public object GuildCategory : ChannelType(4) - - /** - * A channel that - * [users can follow and crosspost into their own server](https://support.discord.com/hc/en-us/articles/360032008192). - */ - public object GuildNews : ChannelType(5) - - /** - * A temporary sub-channel within a [GuildNews] channel. - */ - public object PublicNewsThread : ChannelType(10) - - /** - * A temporary sub-channel within a [GuildText] or [GuildForum] channel. - */ - public object PublicGuildThread : ChannelType(11) - - /** - * A temporary sub-channel within a [GuildText] channel that is only viewable by those invited - * and those with the [ManageThreads][dev.kord.common.entity.Permission.ManageThreads] permission. - */ - public object PrivateThread : ChannelType(12) - - /** - * A voice channel for - * [hosting events with an audience](https://support.discord.com/hc/en-us/articles/1500005513722). - */ - public object GuildStageVoice : ChannelType(13) - - /** - * The channel in a - * [hub](https://support.discord.com/hc/en-us/articles/4406046651927-Discord-Student-Hubs-FAQ) - * containing the listed servers. - */ - public object GuildDirectory : ChannelType(14) - - /** - * A channel that can only contain threads. - */ - public object GuildForum : ChannelType(15) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.ChannelType", PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: ChannelType) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 0 -> GuildText - 1 -> DM - 2 -> GuildVoice - 3 -> GroupDM - 4 -> GuildCategory - 5 -> GuildNews - 10 -> PublicNewsThread - 11 -> PublicGuildThread - 12 -> PrivateThread - 13 -> GuildStageVoice - 14 -> GuildDirectory - 15 -> GuildForum - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [ChannelType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - GuildText, - DM, - GuildVoice, - GroupDM, - GuildCategory, - GuildNews, - PublicNewsThread, - PublicGuildThread, - PrivateThread, - GuildStageVoice, - GuildDirectory, - GuildForum, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ComponentType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ComponentType.kt deleted file mode 100644 index b1640f27c92a..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ComponentType.kt +++ /dev/null @@ -1,167 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Deprecated -import kotlin.DeprecationLevel -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.ReplaceWith -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlin.jvm.JvmField -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [ComponentType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/interactions/message-components#component-object-component-types). - */ -@Serializable(with = ComponentType.NewSerializer::class) -public sealed class ComponentType( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is ComponentType && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "ComponentType.${this::class.simpleName}(value=$value)" - - /** - * An unknown [ComponentType]. - * - * This is used as a fallback for [ComponentType]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : ComponentType(value) - - /** - * A container for other components. - */ - public object ActionRow : ComponentType(1) - - /** - * A button object. - */ - public object Button : ComponentType(2) - - /** - * A select menu for picking from defined text options. - */ - public object StringSelect : ComponentType(3) - - /** - * A text input object. - */ - public object TextInput : ComponentType(4) - - /** - * Select menu for users. - */ - public object UserSelect : ComponentType(5) - - /** - * Select menu for roles. - */ - public object RoleSelect : ComponentType(6) - - /** - * Select menu for mentionables (users and roles). - */ - public object MentionableSelect : ComponentType(7) - - /** - * Select menu for channels. - */ - public object ChannelSelect : ComponentType(8) - - /** - * A select menu for picking from choices. - */ - @Deprecated( - level = DeprecationLevel.ERROR, - message = "Renamed by discord", - replaceWith = ReplaceWith(expression = "StringSelect", imports = - arrayOf("dev.kord.common.entity.ComponentType.StringSelect")), - ) - public object SelectMenu : ComponentType(3) - - internal object NewSerializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.ComponentType", PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: ComponentType) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> ActionRow - 2 -> Button - 3 -> StringSelect - 4 -> TextInput - 5 -> UserSelect - 6 -> RoleSelect - 7 -> MentionableSelect - 8 -> ChannelSelect - else -> Unknown(value) - } - } - - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Use 'ComponentType.serializer()' instead.", - replaceWith = ReplaceWith(expression = "ComponentType.serializer()", imports = - arrayOf("dev.kord.common.entity.ComponentType")), - ) - public object Serializer : KSerializer by NewSerializer { - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Use 'ComponentType.serializer()' instead.", - replaceWith = ReplaceWith(expression = "ComponentType.serializer()", imports = - arrayOf("dev.kord.common.entity.ComponentType")), - ) - public fun serializer(): KSerializer = this - } - - public companion object { - /** - * A [List] of all known [ComponentType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - ActionRow, - Button, - StringSelect, - TextInput, - UserSelect, - RoleSelect, - MentionableSelect, - ChannelSelect, - ) - } - - - @Suppress(names = arrayOf("DEPRECATION_ERROR")) - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Binary compatibility", - ) - @JvmField - public val Serializer: Serializer = Serializer - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/DefaultMessageNotificationLevel.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/DefaultMessageNotificationLevel.kt deleted file mode 100644 index 2f67ffa23031..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/DefaultMessageNotificationLevel.kt +++ /dev/null @@ -1,88 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [DefaultMessageNotificationLevel]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level). - */ -@Serializable(with = DefaultMessageNotificationLevel.Serializer::class) -public sealed class DefaultMessageNotificationLevel( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is DefaultMessageNotificationLevel && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "DefaultMessageNotificationLevel.${this::class.simpleName}(value=$value)" - - /** - * An unknown [DefaultMessageNotificationLevel]. - * - * This is used as a fallback for [DefaultMessageNotificationLevel]s that haven't been added to - * Kord yet. - */ - public class Unknown( - `value`: Int, - ) : DefaultMessageNotificationLevel(value) - - /** - * Members will receive notifications for all messages by default. - */ - public object AllMessages : DefaultMessageNotificationLevel(0) - - /** - * Members will receive notifications only for messages that @mention them by default. - */ - public object OnlyMentions : DefaultMessageNotificationLevel(1) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.DefaultMessageNotificationLevel", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: DefaultMessageNotificationLevel) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 0 -> AllMessages - 1 -> OnlyMentions - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [DefaultMessageNotificationLevel]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - AllMessages, - OnlyMentions, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/DiscordConnectionVisibility.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/DiscordConnectionVisibility.kt deleted file mode 100644 index 5ac2c352fc18..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/DiscordConnectionVisibility.kt +++ /dev/null @@ -1,88 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [DiscordConnectionVisibility]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/user#connection-object-visibility-types). - */ -@Serializable(with = DiscordConnectionVisibility.Serializer::class) -public sealed class DiscordConnectionVisibility( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is DiscordConnectionVisibility && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "DiscordConnectionVisibility.${this::class.simpleName}(value=$value)" - - /** - * An unknown [DiscordConnectionVisibility]. - * - * This is used as a fallback for [DiscordConnectionVisibility]s that haven't been added to Kord - * yet. - */ - public class Unknown( - `value`: Int, - ) : DiscordConnectionVisibility(value) - - /** - * Invisible to everyone except the user themselves. - */ - public object None : DiscordConnectionVisibility(0) - - /** - * Visible to everyone. - */ - public object Everyone : DiscordConnectionVisibility(1) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.DiscordConnectionVisibility", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: DiscordConnectionVisibility) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 0 -> None - 1 -> Everyone - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [DiscordConnectionVisibility]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - None, - Everyone, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/EmbedType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/EmbedType.kt deleted file mode 100644 index 7922959a0fbc..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/EmbedType.kt +++ /dev/null @@ -1,115 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [EmbedType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/channel#embed-object-embed-types). - */ -@Serializable(with = EmbedType.Serializer::class) -public sealed class EmbedType( - /** - * The raw value used by Discord. - */ - public val `value`: String, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is EmbedType && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "EmbedType.${this::class.simpleName}(value=$value)" - - /** - * An unknown [EmbedType]. - * - * This is used as a fallback for [EmbedType]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: String, - ) : EmbedType(value) - - /** - * Generic embed rendered from embed attributes. - */ - public object Rich : EmbedType("rich") - - /** - * Image embed. - */ - public object Image : EmbedType("image") - - /** - * Video embed. - */ - public object Video : EmbedType("video") - - /** - * Animated gif image embed rendered as a video embed. - */ - public object Gifv : EmbedType("gifv") - - /** - * Article embed. - */ - public object Article : EmbedType("article") - - /** - * Link embed. - */ - public object Link : EmbedType("link") - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.EmbedType", PrimitiveKind.STRING) - - public override fun serialize(encoder: Encoder, `value`: EmbedType) = - encoder.encodeString(value.value) - - public override fun deserialize(decoder: Decoder) = - when (val value = decoder.decodeString()) { - "rich" -> Rich - "image" -> Image - "video" -> Video - "gifv" -> Gifv - "article" -> Article - "link" -> Link - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [EmbedType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Rich, - Image, - Video, - Gifv, - Article, - Link, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ExplicitContentFilter.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ExplicitContentFilter.kt deleted file mode 100644 index b8f46401e9e6..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ExplicitContentFilter.kt +++ /dev/null @@ -1,94 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [ExplicitContentFilter]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level). - */ -@Serializable(with = ExplicitContentFilter.Serializer::class) -public sealed class ExplicitContentFilter( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is ExplicitContentFilter && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "ExplicitContentFilter.${this::class.simpleName}(value=$value)" - - /** - * An unknown [ExplicitContentFilter]. - * - * This is used as a fallback for [ExplicitContentFilter]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : ExplicitContentFilter(value) - - /** - * Media content will not be scanned. - */ - public object Disabled : ExplicitContentFilter(0) - - /** - * Media content sent by members without roles will be scanned. - */ - public object MembersWithoutRoles : ExplicitContentFilter(1) - - /** - * Media content sent by all members will be scanned. - */ - public object AllMembers : ExplicitContentFilter(2) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.ExplicitContentFilter", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: ExplicitContentFilter) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 0 -> Disabled - 1 -> MembersWithoutRoles - 2 -> AllMembers - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [ExplicitContentFilter]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Disabled, - MembersWithoutRoles, - AllMembers, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/GuildFeature.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/GuildFeature.kt deleted file mode 100644 index 0bc82d268fba..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/GuildFeature.kt +++ /dev/null @@ -1,286 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Deprecated -import kotlin.DeprecationLevel -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.ReplaceWith -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [GuildFeature]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild#guild-object-guild-features). - */ -@Serializable(with = GuildFeature.Serializer::class) -public sealed class GuildFeature( - /** - * The raw value used by Discord. - */ - public val `value`: String, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is GuildFeature && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "GuildFeature.${this::class.simpleName}(value=$value)" - - /** - * An unknown [GuildFeature]. - * - * This is used as a fallback for [GuildFeature]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: String, - ) : GuildFeature(value) - - /** - * Guild has access to set an animated guild banner image. - */ - public object AnimatedBanner : GuildFeature("ANIMATED_BANNER") - - /** - * Guild has access to set an animated guild icon. - */ - public object AnimatedIcon : GuildFeature("ANIMATED_ICON") - - /** - * Guild is using the old permissions configuration behavior. - */ - public object ApplicationCommandPermissionsV2 : - GuildFeature("APPLICATION_COMMAND_PERMISSIONS_V2") - - /** - * Guild has set up auto moderation rules. - */ - public object AutoModeration : GuildFeature("AUTO_MODERATION") - - /** - * Guild has access to set a guild banner image. - */ - public object Banner : GuildFeature("BANNER") - - /** - * Guild can enable welcome screen, Membership Screening, stage channels and discovery, and - * receives community updates. - */ - public object Community : GuildFeature("COMMUNITY") - - /** - * Guild has enabled monetization. - */ - public object CreatorMonetizableProvisional : GuildFeature("CREATOR_MONETIZABLE_PROVISIONAL") - - /** - * Guild has enabled the role subscription promo page. - */ - public object CreatorStorePage : GuildFeature("CREATOR_STORE_PAGE") - - /** - * Guild has been set as a support server on the App Directory. - */ - public object DeveloperSupportServer : GuildFeature("DEVELOPER_SUPPORT_SERVER") - - /** - * Guild is able to be discovered in the directory. - */ - public object Discoverable : GuildFeature("DISCOVERABLE") - - /** - * Guild is able to be featured in the directory. - */ - public object Featurable : GuildFeature("FEATURABLE") - - /** - * Guild has paused invites, preventing new users from joining. - */ - public object InvitesDisabled : GuildFeature("INVITES_DISABLED") - - /** - * Guild has access to set an invite splash background. - */ - public object InviteSplash : GuildFeature("INVITE_SPLASH") - - /** - * Guild has enabled Membership Screening. - */ - public object MemberVerificationGateEnabled : GuildFeature("MEMBER_VERIFICATION_GATE_ENABLED") - - /** - * Guild has increased custom sticker slots. - */ - public object MoreStickers : GuildFeature("MORE_STICKERS") - - /** - * Guild has access to create announcement channels. - */ - public object News : GuildFeature("NEWS") - - /** - * Guild is partnered. - */ - public object Partnered : GuildFeature("PARTNERED") - - /** - * Guild can be previewed before joining via Membership Screening or the directory. - */ - public object PreviewEnabled : GuildFeature("PREVIEW_ENABLED") - - /** - * Guild is able to set role icons. - */ - public object RoleIcons : GuildFeature("ROLE_ICONS") - - /** - * Guild has role subscriptions that can be purchased. - */ - public object RoleSubscriptionsAvailableForPurchase : - GuildFeature("ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE") - - /** - * Guild has enabled role subscriptions. - */ - public object RoleSubscriptionsEnabled : GuildFeature("ROLE_SUBSCRIPTIONS_ENABLED") - - /** - * Guild has enabled ticketed events. - */ - public object TicketedEventsEnabled : GuildFeature("TICKETED_EVENTS_ENABLED") - - /** - * Guild has access to set a vanity URL. - */ - public object VanityUrl : GuildFeature("VANITY_URL") - - /** - * Guild is verified. - */ - public object Verified : GuildFeature("VERIFIED") - - /** - * Guild has access to set 384kbps bitrate in voice (previously VIP voice servers). - */ - public object VIPRegions : GuildFeature("VIP_REGIONS") - - /** - * Guild has enabled the welcome screen. - */ - public object WelcomeScreenEnabled : GuildFeature("WELCOME_SCREEN_ENABLED") - - /** - * Guild has enabled monetization. - */ - @Deprecated( - level = DeprecationLevel.ERROR, - message = "Replaced by CreatorMonetizableProvisional.", - replaceWith = ReplaceWith(expression = "GuildFeature.CreatorMonetizableProvisional", imports - = arrayOf("dev.kord.common.entitiy.GuildFeature")), - ) - public object MonetizationEnabled : GuildFeature("MONETIZATION_ENABLED") - - /** - * Guild has access to create private threads - */ - @Deprecated( - level = DeprecationLevel.ERROR, - message = "Creating a private thread no longer requires the server to be boosted.", - ) - public object PrivateThreads : GuildFeature("PRIVATE_THREADS") - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.GuildFeature", - PrimitiveKind.STRING) - - public override fun serialize(encoder: Encoder, `value`: GuildFeature) = - encoder.encodeString(value.value) - - public override fun deserialize(decoder: Decoder) = - when (val value = decoder.decodeString()) { - "ANIMATED_BANNER" -> AnimatedBanner - "ANIMATED_ICON" -> AnimatedIcon - "APPLICATION_COMMAND_PERMISSIONS_V2" -> ApplicationCommandPermissionsV2 - "AUTO_MODERATION" -> AutoModeration - "BANNER" -> Banner - "COMMUNITY" -> Community - "CREATOR_MONETIZABLE_PROVISIONAL" -> CreatorMonetizableProvisional - "CREATOR_STORE_PAGE" -> CreatorStorePage - "DEVELOPER_SUPPORT_SERVER" -> DeveloperSupportServer - "DISCOVERABLE" -> Discoverable - "FEATURABLE" -> Featurable - "INVITES_DISABLED" -> InvitesDisabled - "INVITE_SPLASH" -> InviteSplash - "MEMBER_VERIFICATION_GATE_ENABLED" -> MemberVerificationGateEnabled - "MONETIZATION_ENABLED" -> @Suppress("DEPRECATION_ERROR") MonetizationEnabled - "MORE_STICKERS" -> MoreStickers - "NEWS" -> News - "PARTNERED" -> Partnered - "PREVIEW_ENABLED" -> PreviewEnabled - "PRIVATE_THREADS" -> @Suppress("DEPRECATION_ERROR") PrivateThreads - "ROLE_ICONS" -> RoleIcons - "ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE" -> RoleSubscriptionsAvailableForPurchase - "ROLE_SUBSCRIPTIONS_ENABLED" -> RoleSubscriptionsEnabled - "TICKETED_EVENTS_ENABLED" -> TicketedEventsEnabled - "VANITY_URL" -> VanityUrl - "VERIFIED" -> Verified - "VIP_REGIONS" -> VIPRegions - "WELCOME_SCREEN_ENABLED" -> WelcomeScreenEnabled - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [GuildFeature]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - AnimatedBanner, - AnimatedIcon, - ApplicationCommandPermissionsV2, - AutoModeration, - Banner, - Community, - CreatorMonetizableProvisional, - CreatorStorePage, - DeveloperSupportServer, - Discoverable, - Featurable, - InvitesDisabled, - InviteSplash, - MemberVerificationGateEnabled, - @Suppress("DEPRECATION_ERROR") MonetizationEnabled, - MoreStickers, - News, - Partnered, - PreviewEnabled, - @Suppress("DEPRECATION_ERROR") PrivateThreads, - RoleIcons, - RoleSubscriptionsAvailableForPurchase, - RoleSubscriptionsEnabled, - TicketedEventsEnabled, - VanityUrl, - Verified, - VIPRegions, - WelcomeScreenEnabled, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/GuildScheduledEventPrivacyLevel.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/GuildScheduledEventPrivacyLevel.kt deleted file mode 100644 index 99cea88ebdc1..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/GuildScheduledEventPrivacyLevel.kt +++ /dev/null @@ -1,81 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [GuildScheduledEventPrivacyLevel]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-privacy-level). - */ -@Serializable(with = GuildScheduledEventPrivacyLevel.Serializer::class) -public sealed class GuildScheduledEventPrivacyLevel( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is GuildScheduledEventPrivacyLevel && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "GuildScheduledEventPrivacyLevel.${this::class.simpleName}(value=$value)" - - /** - * An unknown [GuildScheduledEventPrivacyLevel]. - * - * This is used as a fallback for [GuildScheduledEventPrivacyLevel]s that haven't been added to - * Kord yet. - */ - public class Unknown( - `value`: Int, - ) : GuildScheduledEventPrivacyLevel(value) - - /** - * The scheduled event is only accessible to guild members. - */ - public object GuildOnly : GuildScheduledEventPrivacyLevel(2) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.GuildScheduledEventPrivacyLevel", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: GuildScheduledEventPrivacyLevel) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 2 -> GuildOnly - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [GuildScheduledEventPrivacyLevel]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - GuildOnly, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/GuildScheduledEventStatus.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/GuildScheduledEventStatus.kt deleted file mode 100644 index bc70863d26ff..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/GuildScheduledEventStatus.kt +++ /dev/null @@ -1,118 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Deprecated -import kotlin.DeprecationLevel -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.ReplaceWith -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlin.jvm.JvmField -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [GuildScheduledEventStatus]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status). - */ -@Serializable(with = GuildScheduledEventStatus.NewSerializer::class) -public sealed class GuildScheduledEventStatus( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is GuildScheduledEventStatus && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "GuildScheduledEventStatus.${this::class.simpleName}(value=$value)" - - /** - * An unknown [GuildScheduledEventStatus]. - * - * This is used as a fallback for [GuildScheduledEventStatus]s that haven't been added to Kord - * yet. - */ - public class Unknown( - `value`: Int, - ) : GuildScheduledEventStatus(value) - - public object Scheduled : GuildScheduledEventStatus(1) - - public object Active : GuildScheduledEventStatus(2) - - public object Completed : GuildScheduledEventStatus(3) - - public object Cancelled : GuildScheduledEventStatus(4) - - internal object NewSerializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.GuildScheduledEventStatus", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: GuildScheduledEventStatus) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> Scheduled - 2 -> Active - 3 -> Completed - 4 -> Cancelled - else -> Unknown(value) - } - } - - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Use 'GuildScheduledEventStatus.serializer()' instead.", - replaceWith = ReplaceWith(expression = "GuildScheduledEventStatus.serializer()", imports = - arrayOf("dev.kord.common.entity.GuildScheduledEventStatus")), - ) - public object Serializer : KSerializer by NewSerializer { - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Use 'GuildScheduledEventStatus.serializer()' instead.", - replaceWith = ReplaceWith(expression = "GuildScheduledEventStatus.serializer()", imports - = arrayOf("dev.kord.common.entity.GuildScheduledEventStatus")), - ) - public fun serializer(): KSerializer = this - } - - public companion object { - /** - * A [List] of all known [GuildScheduledEventStatus]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Scheduled, - Active, - Completed, - Cancelled, - ) - } - - - @Suppress(names = arrayOf("DEPRECATION_ERROR")) - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Binary compatibility", - ) - @JvmField - public val Serializer: Serializer = Serializer - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/IntegrationExpireBehavior.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/IntegrationExpireBehavior.kt deleted file mode 100644 index be12f6c672e9..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/IntegrationExpireBehavior.kt +++ /dev/null @@ -1,110 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Deprecated -import kotlin.DeprecationLevel -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.ReplaceWith -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlin.jvm.JvmField -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [IntegrationExpireBehavior]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors). - */ -@Serializable(with = IntegrationExpireBehavior.NewSerializer::class) -public sealed class IntegrationExpireBehavior( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is IntegrationExpireBehavior && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "IntegrationExpireBehavior.${this::class.simpleName}(value=$value)" - - /** - * An unknown [IntegrationExpireBehavior]. - * - * This is used as a fallback for [IntegrationExpireBehavior]s that haven't been added to Kord - * yet. - */ - public class Unknown( - `value`: Int, - ) : IntegrationExpireBehavior(value) - - public object RemoveRole : IntegrationExpireBehavior(0) - - public object Kick : IntegrationExpireBehavior(1) - - internal object NewSerializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.IntegrationExpireBehavior", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: IntegrationExpireBehavior) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 0 -> RemoveRole - 1 -> Kick - else -> Unknown(value) - } - } - - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Use 'IntegrationExpireBehavior.serializer()' instead.", - replaceWith = ReplaceWith(expression = "IntegrationExpireBehavior.serializer()", imports = - arrayOf("dev.kord.common.entity.IntegrationExpireBehavior")), - ) - public object Serializer : KSerializer by NewSerializer { - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Use 'IntegrationExpireBehavior.serializer()' instead.", - replaceWith = ReplaceWith(expression = "IntegrationExpireBehavior.serializer()", imports - = arrayOf("dev.kord.common.entity.IntegrationExpireBehavior")), - ) - public fun serializer(): KSerializer = this - } - - public companion object { - /** - * A [List] of all known [IntegrationExpireBehavior]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - RemoveRole, - Kick, - ) - } - - - @Suppress(names = arrayOf("DEPRECATION_ERROR")) - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Binary compatibility", - ) - @JvmField - public val Serializer: Serializer = Serializer - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/InteractionResponseType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/InteractionResponseType.kt deleted file mode 100644 index 81062aee2999..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/InteractionResponseType.kt +++ /dev/null @@ -1,124 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [InteractionResponseType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type). - */ -@Serializable(with = InteractionResponseType.Serializer::class) -public sealed class InteractionResponseType( - /** - * The raw type used by Discord. - */ - public val type: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is InteractionResponseType && this.type == other.type) - - public final override fun hashCode(): Int = type.hashCode() - - public final override fun toString(): String = - "InteractionResponseType.${this::class.simpleName}(type=$type)" - - /** - * An unknown [InteractionResponseType]. - * - * This is used as a fallback for [InteractionResponseType]s that haven't been added to Kord - * yet. - */ - public class Unknown( - type: Int, - ) : InteractionResponseType(type) - - /** - * ACK a [Ping][dev.kord.common.entity.InteractionType.Ping]. - */ - public object Pong : InteractionResponseType(1) - - /** - * Respond to an interaction with a message. - */ - public object ChannelMessageWithSource : InteractionResponseType(4) - - /** - * ACK an interaction and edit a response later, the user sees a loading state. - */ - public object DeferredChannelMessageWithSource : InteractionResponseType(5) - - /** - * For components, ACK an interaction and edit the original message later; the user does not see - * a loading state. - */ - public object DeferredUpdateMessage : InteractionResponseType(6) - - /** - * For components, edit the message the component was attached to. - */ - public object UpdateMessage : InteractionResponseType(7) - - /** - * Respond to an autocomplete interaction with suggested choices. - */ - public object ApplicationCommandAutoCompleteResult : InteractionResponseType(8) - - /** - * Respond to an interaction with a popup modal. - */ - public object Modal : InteractionResponseType(9) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.InteractionResponseType", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: InteractionResponseType) = - encoder.encodeInt(value.type) - - public override fun deserialize(decoder: Decoder) = when (val type = decoder.decodeInt()) { - 1 -> Pong - 4 -> ChannelMessageWithSource - 5 -> DeferredChannelMessageWithSource - 6 -> DeferredUpdateMessage - 7 -> UpdateMessage - 8 -> ApplicationCommandAutoCompleteResult - 9 -> Modal - else -> Unknown(type) - } - } - - public companion object { - /** - * A [List] of all known [InteractionResponseType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Pong, - ChannelMessageWithSource, - DeferredChannelMessageWithSource, - DeferredUpdateMessage, - UpdateMessage, - ApplicationCommandAutoCompleteResult, - Modal, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/InteractionType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/InteractionType.kt deleted file mode 100644 index 5cc9105e0a1c..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/InteractionType.kt +++ /dev/null @@ -1,93 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [InteractionType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type). - */ -@Serializable(with = InteractionType.Serializer::class) -public sealed class InteractionType( - /** - * The raw type used by Discord. - */ - public val type: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is InteractionType && this.type == other.type) - - public final override fun hashCode(): Int = type.hashCode() - - public final override fun toString(): String = - "InteractionType.${this::class.simpleName}(type=$type)" - - /** - * An unknown [InteractionType]. - * - * This is used as a fallback for [InteractionType]s that haven't been added to Kord yet. - */ - public class Unknown( - type: Int, - ) : InteractionType(type) - - public object Ping : InteractionType(1) - - public object ApplicationCommand : InteractionType(2) - - public object Component : InteractionType(3) - - public object AutoComplete : InteractionType(4) - - public object ModalSubmit : InteractionType(5) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.InteractionType", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: InteractionType) = - encoder.encodeInt(value.type) - - public override fun deserialize(decoder: Decoder) = when (val type = decoder.decodeInt()) { - 1 -> Ping - 2 -> ApplicationCommand - 3 -> Component - 4 -> AutoComplete - 5 -> ModalSubmit - else -> Unknown(type) - } - } - - public companion object { - /** - * A [List] of all known [InteractionType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Ping, - ApplicationCommand, - Component, - AutoComplete, - ModalSubmit, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/InviteTargetType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/InviteTargetType.kt deleted file mode 100644 index b2c887f81899..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/InviteTargetType.kt +++ /dev/null @@ -1,81 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [InviteTargetType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types). - */ -@Serializable(with = InviteTargetType.Serializer::class) -public sealed class InviteTargetType( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is InviteTargetType && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "InviteTargetType.${this::class.simpleName}(value=$value)" - - /** - * An unknown [InviteTargetType]. - * - * This is used as a fallback for [InviteTargetType]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : InviteTargetType(value) - - public object Stream : InviteTargetType(1) - - public object EmbeddedApplication : InviteTargetType(2) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.InviteTargetType", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: InviteTargetType) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> Stream - 2 -> EmbeddedApplication - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [InviteTargetType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Stream, - EmbeddedApplication, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/MFALevel.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/MFALevel.kt deleted file mode 100644 index 522db376f61a..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/MFALevel.kt +++ /dev/null @@ -1,86 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [MFALevel]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild#guild-object-mfa-level). - */ -@Serializable(with = MFALevel.Serializer::class) -public sealed class MFALevel( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is MFALevel && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "MFALevel.${this::class.simpleName}(value=$value)" - - /** - * An unknown [MFALevel]. - * - * This is used as a fallback for [MFALevel]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : MFALevel(value) - - /** - * Guild has no MFA/2FA requirement for moderation actions. - */ - public object None : MFALevel(0) - - /** - * Guild has a 2FA requirement for moderation actions. - */ - public object Elevated : MFALevel(1) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.MFALevel", PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: MFALevel) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 0 -> None - 1 -> Elevated - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [MFALevel]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - None, - Elevated, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/MessageActivityType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/MessageActivityType.kt deleted file mode 100644 index 5ff513a4a219..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/MessageActivityType.kt +++ /dev/null @@ -1,89 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [MessageActivityType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-activity-types). - */ -@Serializable(with = MessageActivityType.Serializer::class) -public sealed class MessageActivityType( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is MessageActivityType && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "MessageActivityType.${this::class.simpleName}(value=$value)" - - /** - * An unknown [MessageActivityType]. - * - * This is used as a fallback for [MessageActivityType]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : MessageActivityType(value) - - public object Join : MessageActivityType(1) - - public object Spectate : MessageActivityType(2) - - public object Listen : MessageActivityType(3) - - public object JoinRequest : MessageActivityType(5) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.MessageActivityType", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: MessageActivityType) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> Join - 2 -> Spectate - 3 -> Listen - 5 -> JoinRequest - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [MessageActivityType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Join, - Spectate, - Listen, - JoinRequest, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/MessageStickerType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/MessageStickerType.kt deleted file mode 100644 index e641439efbfc..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/MessageStickerType.kt +++ /dev/null @@ -1,101 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Deprecated -import kotlin.DeprecationLevel -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.ReplaceWith -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlin.collections.Set -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [MessageStickerType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types). - */ -@Serializable(with = MessageStickerType.Serializer::class) -public sealed class MessageStickerType( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is MessageStickerType && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "MessageStickerType.${this::class.simpleName}(value=$value)" - - /** - * An unknown [MessageStickerType]. - * - * This is used as a fallback for [MessageStickerType]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : MessageStickerType(value) - - public object PNG : MessageStickerType(1) - - public object APNG : MessageStickerType(2) - - public object LOTTIE : MessageStickerType(3) - - public object GIF : MessageStickerType(4) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.MessageStickerType", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: MessageStickerType) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> PNG - 2 -> APNG - 3 -> LOTTIE - 4 -> GIF - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [MessageStickerType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - PNG, - APNG, - LOTTIE, - GIF, - ) - } - - - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Renamed to 'entries'.", - replaceWith = ReplaceWith(expression = "this.entries", imports = arrayOf()), - ) - public val values: Set - get() = entries.toSet() - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/MessageType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/MessageType.kt deleted file mode 100644 index 4cbc5066bae5..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/MessageType.kt +++ /dev/null @@ -1,208 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Deprecated -import kotlin.DeprecationLevel -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.ReplaceWith -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlin.collections.Set -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [MessageType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/channel#message-object-message-types). - */ -@Serializable(with = MessageType.Serializer::class) -public sealed class MessageType( - /** - * The raw code used by Discord. - */ - public val code: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is MessageType && this.code == other.code) - - public final override fun hashCode(): Int = code.hashCode() - - public final override fun toString(): String = - "MessageType.${this::class.simpleName}(code=$code)" - - /** - * An unknown [MessageType]. - * - * This is used as a fallback for [MessageType]s that haven't been added to Kord yet. - */ - public class Unknown( - code: Int, - ) : MessageType(code) - - public object Default : MessageType(0) - - public object RecipientAdd : MessageType(1) - - public object RecipientRemove : MessageType(2) - - public object Call : MessageType(3) - - public object ChannelNameChange : MessageType(4) - - public object ChannelIconChange : MessageType(5) - - public object ChannelPinnedMessage : MessageType(6) - - public object UserJoin : MessageType(7) - - public object GuildBoost : MessageType(8) - - public object GuildBoostTier1 : MessageType(9) - - public object GuildBoostTier2 : MessageType(10) - - public object GuildBoostTier3 : MessageType(11) - - public object ChannelFollowAdd : MessageType(12) - - public object GuildDiscoveryDisqualified : MessageType(14) - - public object GuildDiscoveryRequalified : MessageType(15) - - public object GuildDiscoveryGracePeriodInitialWarning : MessageType(16) - - public object GuildDiscoveryGracePeriodFinalWarning : MessageType(17) - - public object ThreadCreated : MessageType(18) - - public object Reply : MessageType(19) - - public object ChatInputCommand : MessageType(20) - - public object ThreadStarterMessage : MessageType(21) - - public object GuildInviteReminder : MessageType(22) - - public object ContextMenuCommand : MessageType(23) - - public object AutoModerationAction : MessageType(24) - - public object RoleSubscriptionPurchase : MessageType(25) - - public object InteractionPremiumUpsell : MessageType(26) - - public object StageStart : MessageType(27) - - public object StageEnd : MessageType(28) - - public object StageSpeaker : MessageType(29) - - public object StageTopic : MessageType(31) - - public object GuildApplicationPremiumSubscription : MessageType(32) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.MessageType", PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: MessageType) = - encoder.encodeInt(value.code) - - public override fun deserialize(decoder: Decoder) = when (val code = decoder.decodeInt()) { - 0 -> Default - 1 -> RecipientAdd - 2 -> RecipientRemove - 3 -> Call - 4 -> ChannelNameChange - 5 -> ChannelIconChange - 6 -> ChannelPinnedMessage - 7 -> UserJoin - 8 -> GuildBoost - 9 -> GuildBoostTier1 - 10 -> GuildBoostTier2 - 11 -> GuildBoostTier3 - 12 -> ChannelFollowAdd - 14 -> GuildDiscoveryDisqualified - 15 -> GuildDiscoveryRequalified - 16 -> GuildDiscoveryGracePeriodInitialWarning - 17 -> GuildDiscoveryGracePeriodFinalWarning - 18 -> ThreadCreated - 19 -> Reply - 20 -> ChatInputCommand - 21 -> ThreadStarterMessage - 22 -> GuildInviteReminder - 23 -> ContextMenuCommand - 24 -> AutoModerationAction - 25 -> RoleSubscriptionPurchase - 26 -> InteractionPremiumUpsell - 27 -> StageStart - 28 -> StageEnd - 29 -> StageSpeaker - 31 -> StageTopic - 32 -> GuildApplicationPremiumSubscription - else -> Unknown(code) - } - } - - public companion object { - /** - * A [List] of all known [MessageType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Default, - RecipientAdd, - RecipientRemove, - Call, - ChannelNameChange, - ChannelIconChange, - ChannelPinnedMessage, - UserJoin, - GuildBoost, - GuildBoostTier1, - GuildBoostTier2, - GuildBoostTier3, - ChannelFollowAdd, - GuildDiscoveryDisqualified, - GuildDiscoveryRequalified, - GuildDiscoveryGracePeriodInitialWarning, - GuildDiscoveryGracePeriodFinalWarning, - ThreadCreated, - Reply, - ChatInputCommand, - ThreadStarterMessage, - GuildInviteReminder, - ContextMenuCommand, - AutoModerationAction, - RoleSubscriptionPurchase, - InteractionPremiumUpsell, - StageStart, - StageEnd, - StageSpeaker, - StageTopic, - GuildApplicationPremiumSubscription, - ) - } - - - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Renamed to 'entries'.", - replaceWith = ReplaceWith(expression = "this.entries", imports = arrayOf()), - ) - public val values: Set - get() = entries.toSet() - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/NsfwLevel.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/NsfwLevel.kt deleted file mode 100644 index ed5b734e8077..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/NsfwLevel.kt +++ /dev/null @@ -1,88 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [NsfwLevel]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild#guild-object-guild-nsfw-level). - */ -@Serializable(with = NsfwLevel.Serializer::class) -public sealed class NsfwLevel( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is NsfwLevel && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "NsfwLevel.${this::class.simpleName}(value=$value)" - - /** - * An unknown [NsfwLevel]. - * - * This is used as a fallback for [NsfwLevel]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : NsfwLevel(value) - - public object Default : NsfwLevel(0) - - public object Explicit : NsfwLevel(1) - - public object Safe : NsfwLevel(2) - - public object AgeRestricted : NsfwLevel(3) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.NsfwLevel", PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: NsfwLevel) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 0 -> Default - 1 -> Explicit - 2 -> Safe - 3 -> AgeRestricted - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [NsfwLevel]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Default, - Explicit, - Safe, - AgeRestricted, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/OverwriteType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/OverwriteType.kt deleted file mode 100644 index 7f1dfff1524c..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/OverwriteType.kt +++ /dev/null @@ -1,80 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [OverwriteType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/channel#overwrite-object-overwrite-structure). - */ -@Serializable(with = OverwriteType.Serializer::class) -public sealed class OverwriteType( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is OverwriteType && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "OverwriteType.${this::class.simpleName}(value=$value)" - - /** - * An unknown [OverwriteType]. - * - * This is used as a fallback for [OverwriteType]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : OverwriteType(value) - - public object Role : OverwriteType(0) - - public object Member : OverwriteType(1) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.OverwriteType", PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: OverwriteType) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 0 -> Role - 1 -> Member - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [OverwriteType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Role, - Member, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/PremiumTier.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/PremiumTier.kt deleted file mode 100644 index 52ec298744e1..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/PremiumTier.kt +++ /dev/null @@ -1,100 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [PremiumTier]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild#guild-object-premium-tier). - */ -@Serializable(with = PremiumTier.Serializer::class) -public sealed class PremiumTier( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is PremiumTier && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "PremiumTier.${this::class.simpleName}(value=$value)" - - /** - * An unknown [PremiumTier]. - * - * This is used as a fallback for [PremiumTier]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : PremiumTier(value) - - /** - * Guild has not unlocked any Server Boost perks. - */ - public object None : PremiumTier(0) - - /** - * Guild has unlocked Server Boost level 1 perks. - */ - public object One : PremiumTier(1) - - /** - * Guild has unlocked Server Boost level 2 perks. - */ - public object Two : PremiumTier(2) - - /** - * Guild has unlocked Server Boost level 3 perks. - */ - public object Three : PremiumTier(3) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.PremiumTier", PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: PremiumTier) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 0 -> None - 1 -> One - 2 -> Two - 3 -> Three - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [PremiumTier]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - None, - One, - Two, - Three, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/PresenceStatus.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/PresenceStatus.kt deleted file mode 100644 index 0883027dbe3b..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/PresenceStatus.kt +++ /dev/null @@ -1,137 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Deprecated -import kotlin.DeprecationLevel -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.ReplaceWith -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlin.jvm.JvmField -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [PresenceStatus]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/topics/gateway-events#update-presence-status-types). - */ -@Serializable(with = PresenceStatus.Serializer::class) -public sealed class PresenceStatus( - /** - * The raw value used by Discord. - */ - public val `value`: String, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is PresenceStatus && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "PresenceStatus.${this::class.simpleName}(value=$value)" - - /** - * An unknown [PresenceStatus]. - * - * This is used as a fallback for [PresenceStatus]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: String, - ) : PresenceStatus(value) - - /** - * Online. - */ - public object Online : PresenceStatus("online") - - /** - * Do Not Disturb. - */ - public object DoNotDisturb : PresenceStatus("dnd") - - /** - * AFK. - */ - public object Idle : PresenceStatus("idle") - - /** - * Invisible and shown as offline. - */ - public object Invisible : PresenceStatus("invisible") - - /** - * Offline. - */ - public object Offline : PresenceStatus("offline") - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.PresenceStatus", - PrimitiveKind.STRING) - - public override fun serialize(encoder: Encoder, `value`: PresenceStatus) = - encoder.encodeString(value.value) - - public override fun deserialize(decoder: Decoder) = - when (val value = decoder.decodeString()) { - "online" -> Online - "dnd" -> DoNotDisturb - "idle" -> Idle - "invisible" -> Invisible - "offline" -> Offline - else -> Unknown(value) - } - } - - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Use 'PresenceStatus.serializer()' instead.", - replaceWith = ReplaceWith(expression = "PresenceStatus.serializer()", imports = - arrayOf("dev.kord.common.entity.PresenceStatus")), - ) - public object StatusSerializer : KSerializer by Serializer { - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Use 'PresenceStatus.serializer()' instead.", - replaceWith = ReplaceWith(expression = "PresenceStatus.serializer()", imports = - arrayOf("dev.kord.common.entity.PresenceStatus")), - ) - public fun serializer(): KSerializer = this - } - - public companion object { - /** - * A [List] of all known [PresenceStatus]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Online, - DoNotDisturb, - Idle, - Invisible, - Offline, - ) - } - - - @Suppress(names = arrayOf("DEPRECATION_ERROR")) - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Binary compatibility", - ) - @JvmField - public val StatusSerializer: StatusSerializer = StatusSerializer - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ScheduledEntityType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ScheduledEntityType.kt deleted file mode 100644 index 7103621e6889..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ScheduledEntityType.kt +++ /dev/null @@ -1,113 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Deprecated -import kotlin.DeprecationLevel -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.ReplaceWith -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlin.jvm.JvmField -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [ScheduledEntityType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types). - */ -@Serializable(with = ScheduledEntityType.NewSerializer::class) -public sealed class ScheduledEntityType( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is ScheduledEntityType && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "ScheduledEntityType.${this::class.simpleName}(value=$value)" - - /** - * An unknown [ScheduledEntityType]. - * - * This is used as a fallback for [ScheduledEntityType]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : ScheduledEntityType(value) - - public object StageInstance : ScheduledEntityType(1) - - public object Voice : ScheduledEntityType(2) - - public object External : ScheduledEntityType(3) - - internal object NewSerializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.ScheduledEntityType", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: ScheduledEntityType) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> StageInstance - 2 -> Voice - 3 -> External - else -> Unknown(value) - } - } - - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Use 'ScheduledEntityType.serializer()' instead.", - replaceWith = ReplaceWith(expression = "ScheduledEntityType.serializer()", imports = - arrayOf("dev.kord.common.entity.ScheduledEntityType")), - ) - public object Serializer : KSerializer by NewSerializer { - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Use 'ScheduledEntityType.serializer()' instead.", - replaceWith = ReplaceWith(expression = "ScheduledEntityType.serializer()", imports = - arrayOf("dev.kord.common.entity.ScheduledEntityType")), - ) - public fun serializer(): KSerializer = this - } - - public companion object { - /** - * A [List] of all known [ScheduledEntityType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - StageInstance, - Voice, - External, - ) - } - - - @Suppress(names = arrayOf("DEPRECATION_ERROR")) - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Binary compatibility", - ) - @JvmField - public val Serializer: Serializer = Serializer - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/StageInstancePrivacyLevel.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/StageInstancePrivacyLevel.kt deleted file mode 100644 index b90dad5dc8ed..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/StageInstancePrivacyLevel.kt +++ /dev/null @@ -1,117 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Deprecated -import kotlin.DeprecationLevel -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.ReplaceWith -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlin.jvm.JvmField -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [StageInstancePrivacyLevel]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level). - */ -@Serializable(with = StageInstancePrivacyLevel.NewSerializer::class) -public sealed class StageInstancePrivacyLevel( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is StageInstancePrivacyLevel && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "StageInstancePrivacyLevel.${this::class.simpleName}(value=$value)" - - /** - * An unknown [StageInstancePrivacyLevel]. - * - * This is used as a fallback for [StageInstancePrivacyLevel]s that haven't been added to Kord - * yet. - */ - public class Unknown( - `value`: Int, - ) : StageInstancePrivacyLevel(value) - - /** - * The Stage instance is visible to only guild members. - */ - public object GuildOnly : StageInstancePrivacyLevel(2) - - /** - * The Stage instance is visible publicly. - */ - @Deprecated(message = "Stages are no longer discoverable") - public object Public : StageInstancePrivacyLevel(1) - - internal object NewSerializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.StageInstancePrivacyLevel", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: StageInstancePrivacyLevel) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> @Suppress("DEPRECATION") Public - 2 -> GuildOnly - else -> Unknown(value) - } - } - - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Use 'StageInstancePrivacyLevel.serializer()' instead.", - replaceWith = ReplaceWith(expression = "StageInstancePrivacyLevel.serializer()", imports = - arrayOf("dev.kord.common.entity.StageInstancePrivacyLevel")), - ) - public object Serializer : KSerializer by NewSerializer { - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Use 'StageInstancePrivacyLevel.serializer()' instead.", - replaceWith = ReplaceWith(expression = "StageInstancePrivacyLevel.serializer()", imports - = arrayOf("dev.kord.common.entity.StageInstancePrivacyLevel")), - ) - public fun serializer(): KSerializer = this - } - - public companion object { - /** - * A [List] of all known [StageInstancePrivacyLevel]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - @Suppress("DEPRECATION") Public, - GuildOnly, - ) - } - - - @Suppress(names = arrayOf("DEPRECATION_ERROR")) - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Binary compatibility", - ) - @JvmField - public val Serializer: Serializer = Serializer - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/TeamMembershipState.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/TeamMembershipState.kt deleted file mode 100644 index 9d0d97d68f90..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/TeamMembershipState.kt +++ /dev/null @@ -1,110 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Deprecated -import kotlin.DeprecationLevel -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.ReplaceWith -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlin.jvm.JvmField -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [TeamMembershipState]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum). - */ -@Serializable(with = TeamMembershipState.Serializer::class) -public sealed class TeamMembershipState( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is TeamMembershipState && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "TeamMembershipState.${this::class.simpleName}(value=$value)" - - /** - * An unknown [TeamMembershipState]. - * - * This is used as a fallback for [TeamMembershipState]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : TeamMembershipState(value) - - public object Invited : TeamMembershipState(1) - - public object Accepted : TeamMembershipState(2) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.TeamMembershipState", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: TeamMembershipState) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> Invited - 2 -> Accepted - else -> Unknown(value) - } - } - - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Use 'TeamMembershipState.serializer()' instead.", - replaceWith = ReplaceWith(expression = "TeamMembershipState.serializer()", imports = - arrayOf("dev.kord.common.entity.TeamMembershipState")), - ) - public object TeamMembershipStateSerializer : KSerializer by Serializer { - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Use 'TeamMembershipState.serializer()' instead.", - replaceWith = ReplaceWith(expression = "TeamMembershipState.serializer()", imports = - arrayOf("dev.kord.common.entity.TeamMembershipState")), - ) - public fun serializer(): KSerializer = this - } - - public companion object { - /** - * A [List] of all known [TeamMembershipState]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Invited, - Accepted, - ) - } - - - @Suppress(names = arrayOf("DEPRECATION_ERROR")) - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Binary compatibility", - ) - @JvmField - public val TeamMembershipStateSerializer: TeamMembershipStateSerializer = - TeamMembershipStateSerializer - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/TextInputStyle.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/TextInputStyle.kt deleted file mode 100644 index 2755562695bd..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/TextInputStyle.kt +++ /dev/null @@ -1,89 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * Style of a [text input][dev.kord.common.entity.ComponentType.TextInput]. - * - * See [TextInputStyle]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/interactions/message-components#text-inputs-text-input-styles). - */ -@Serializable(with = TextInputStyle.Serializer::class) -public sealed class TextInputStyle( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is TextInputStyle && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "TextInputStyle.${this::class.simpleName}(value=$value)" - - /** - * An unknown [TextInputStyle]. - * - * This is used as a fallback for [TextInputStyle]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : TextInputStyle(value) - - /** - * A single-line input. - */ - public object Short : TextInputStyle(1) - - /** - * A multi-line input. - */ - public object Paragraph : TextInputStyle(2) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.TextInputStyle", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: TextInputStyle) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> Short - 2 -> Paragraph - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [TextInputStyle]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Short, - Paragraph, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/UserPremium.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/UserPremium.kt deleted file mode 100644 index 9c922410ce00..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/UserPremium.kt +++ /dev/null @@ -1,90 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * Premium types denote the level of premium a user has. - * - * See [UserPremium]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/user#user-object-premium-types). - */ -@Serializable(with = UserPremium.Serializer::class) -public sealed class UserPremium( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is UserPremium && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "UserPremium.${this::class.simpleName}(value=$value)" - - /** - * An unknown [UserPremium]. - * - * This is used as a fallback for [UserPremium]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : UserPremium(value) - - public object None : UserPremium(0) - - public object NitroClassic : UserPremium(1) - - public object Nitro : UserPremium(2) - - public object NitroBasic : UserPremium(3) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.UserPremium", PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: UserPremium) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 0 -> None - 1 -> NitroClassic - 2 -> Nitro - 3 -> NitroBasic - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [UserPremium]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - None, - NitroClassic, - Nitro, - NitroBasic, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/VerificationLevel.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/VerificationLevel.kt deleted file mode 100644 index 174f9a6c3942..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/VerificationLevel.kt +++ /dev/null @@ -1,108 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [VerificationLevel]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/guild#guild-object-verification-level). - */ -@Serializable(with = VerificationLevel.Serializer::class) -public sealed class VerificationLevel( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is VerificationLevel && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "VerificationLevel.${this::class.simpleName}(value=$value)" - - /** - * An unknown [VerificationLevel]. - * - * This is used as a fallback for [VerificationLevel]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : VerificationLevel(value) - - /** - * Unrestricted. - */ - public object None : VerificationLevel(0) - - /** - * Must have verified email on account. - */ - public object Low : VerificationLevel(1) - - /** - * Must be registered on Discord for longer than 5 minutes. - */ - public object Medium : VerificationLevel(2) - - /** - * Must be a member of the server for longer than 10 minutes. - */ - public object High : VerificationLevel(3) - - /** - * Must have a verified phone number. - */ - public object VeryHigh : VerificationLevel(4) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.VerificationLevel", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: VerificationLevel) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 0 -> None - 1 -> Low - 2 -> Medium - 3 -> High - 4 -> VeryHigh - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [VerificationLevel]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - None, - Low, - Medium, - High, - VeryHigh, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/VideoQualityMode.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/VideoQualityMode.kt deleted file mode 100644 index 22c92b3ae03c..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/VideoQualityMode.kt +++ /dev/null @@ -1,87 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [VideoQualityMode]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/channel#channel-object-video-quality-modes). - */ -@Serializable(with = VideoQualityMode.Serializer::class) -public sealed class VideoQualityMode( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is VideoQualityMode && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "VideoQualityMode.${this::class.simpleName}(value=$value)" - - /** - * An unknown [VideoQualityMode]. - * - * This is used as a fallback for [VideoQualityMode]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : VideoQualityMode(value) - - /** - * Discord chooses the quality for optimal performance. - */ - public object Auto : VideoQualityMode(1) - - /** - * 720p. - */ - public object Full : VideoQualityMode(2) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.VideoQualityMode", - PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: VideoQualityMode) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> Auto - 2 -> Full - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [VideoQualityMode]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Auto, - Full, - ) - } - - } -} diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/WebhookType.kt b/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/WebhookType.kt deleted file mode 100644 index 5a2509adc670..000000000000 --- a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/WebhookType.kt +++ /dev/null @@ -1,94 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.common.entity - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [WebhookType]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types). - */ -@Serializable(with = WebhookType.Serializer::class) -public sealed class WebhookType( - /** - * The raw value used by Discord. - */ - public val `value`: Int, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is WebhookType && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "WebhookType.${this::class.simpleName}(value=$value)" - - /** - * An unknown [WebhookType]. - * - * This is used as a fallback for [WebhookType]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: Int, - ) : WebhookType(value) - - /** - * Incoming Webhooks can post messages to channels with a generated token. - */ - public object Incoming : WebhookType(1) - - /** - * Channel Follower Webhooks are internal webhooks used with Channel Following to post new - * messages into channels. - */ - public object ChannelFollower : WebhookType(2) - - /** - * Application webhooks are webhooks used with Interactions. - */ - public object Application : WebhookType(3) - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.common.entity.WebhookType", PrimitiveKind.INT) - - public override fun serialize(encoder: Encoder, `value`: WebhookType) = - encoder.encodeInt(value.value) - - public override fun deserialize(decoder: Decoder) = when (val value = decoder.decodeInt()) { - 1 -> Incoming - 2 -> ChannelFollower - 3 -> Application - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [WebhookType]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - Incoming, - ChannelFollower, - Application, - ) - } - - } -} From 213c3dc1f80dfdd4defd8ce83fd583db18542559 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Fri, 24 Feb 2023 17:24:05 +0100 Subject: [PATCH 004/136] Add new generated files --- buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index 9f5403e42328..d740b3b72e84 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -36,7 +36,7 @@ kotlin { } commonMain { // mark ksp src dir - kotlin.srcDir("build/generated/ksp/main/kotlin") + kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") } } } From 8471d32ac3501d1a18583359d834382ac57c1ce6 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Feb 2023 11:02:46 +0100 Subject: [PATCH 005/136] Fix JVM tests on MPP --- .../main/kotlin/kord-multiplatform-module.gradle.kts | 10 ++++++++++ common/build.gradle.kts | 3 +-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index d740b3b72e84..0d90236b6696 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -1,4 +1,6 @@ import gradle.kotlin.dsl.accessors._e5121a5856746b077c6819bbe5a86a2f.main +import gradle.kotlin.dsl.accessors._e5121a5856746b077c6819bbe5a86a2f.testing +import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest plugins { org.jetbrains.kotlin.multiplatform @@ -40,3 +42,11 @@ kotlin { } } } + +tasks { + tasks { + getByName("jvmTest") { + useJUnitPlatform() + } + } +} diff --git a/common/build.gradle.kts b/common/build.gradle.kts index b21bf6c93922..4f6cf77a963a 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -45,8 +45,7 @@ kotlin { jvmTest { dependencies { runtimeOnly(libs.bundles.test.runtime) - implementation(libs.bundles.test.implementation) - implementation(libs.bundles.test.common) + implementation(libs.kotlin.test.junit5) } } jsTest { From 22affd9b39d7ce2366f262d727f630cfe69f06df Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Feb 2023 11:11:33 +0100 Subject: [PATCH 006/136] Cleanup DiscordBitSet code --- common/src/commonMain/kotlin/DiscordBitSet.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/common/src/commonMain/kotlin/DiscordBitSet.kt b/common/src/commonMain/kotlin/DiscordBitSet.kt index 594ecafb76f5..cccfb631e998 100644 --- a/common/src/commonMain/kotlin/DiscordBitSet.kt +++ b/common/src/commonMain/kotlin/DiscordBitSet.kt @@ -31,11 +31,10 @@ public class DiscordBitSet(internal var data: LongArray) { // data is in little- public val value: String get() { // need to convert from little-endian data to big-endian expected by BigInteger - val buffer = withBuffer(data.size * Long.SIZE_BYTES) { + return withBuffer(data.size * Long.SIZE_BYTES) { writeFully(data.reversedArray()) - this.readBytes() + BigInteger.fromByteArray(readBytes(), Sign.POSITIVE).toString() } - return BigInteger.fromByteArray(buffer, Sign.POSITIVE).toString() } public val size: Int From 7353c03f4ae1ebeaedc99268befbfe77ef75b745 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Feb 2023 11:11:42 +0100 Subject: [PATCH 007/136] Fix DiscordBitSet tests --- common/src/commonTest/kotlin/BitSetTests.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/commonTest/kotlin/BitSetTests.kt b/common/src/commonTest/kotlin/BitSetTests.kt index 1c70bfc2c33b..70f7f807bf50 100644 --- a/common/src/commonTest/kotlin/BitSetTests.kt +++ b/common/src/commonTest/kotlin/BitSetTests.kt @@ -65,7 +65,7 @@ class BitSetTests { @JsName("test6") fun `get a bit out of range`() { val a = DiscordBitSet(0b101, 0) - assert(!a[10000]) + assertFalse(a[10000]) } @Test From d1ec4f04dfa2df174f1dfc4208dd356d5b74073d Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Feb 2023 14:21:19 +0100 Subject: [PATCH 008/136] Migrate rest module to MPP --- buildSrc/src/main/kotlin/Compiler.kt | 2 +- buildSrc/src/main/kotlin/Documentation.kt | 54 +++++++++++++++ buildSrc/src/main/kotlin/KspUtils.kt | 7 ++ ...d-internal-multiplatform-module.gradle.kts | 23 +++++++ .../src/main/kotlin/kord-module.gradle.kts | 53 +------------- .../kord-multiplatform-module.gradle.kts | 65 ++++++++++++++++-- common/api/common.api | 4 +- common/build.gradle.kts | 11 --- .../entity/optional/OptionalLongTest.kt | 2 +- common/src/jsTest/kotlin/file.kt | 7 +- gradle/libs.versions.toml | 6 ++ kotlin-js-store/yarn.lock | 42 +++++++++++ ksp-annotations/build.gradle.kts | 2 +- rest/api/rest.api | 61 ++++++---------- rest/build.gradle.kts | 64 ++++++++++++++--- rest/src/{main => commonMain}/kotlin/Image.kt | 5 +- rest/src/commonMain/kotlin/NamedFile.kt | 12 ++++ .../kotlin/builder/RequestBuilder.kt | 0 .../auditlog/AuditLogGetRequestBuilder.kt | 0 .../AutoModerationActionBuilder.kt | 0 .../AutoModerationRuleBuilder.kt | 0 .../AutoModerationRuleCreateBuilder.kt | 0 .../AutoModerationRuleModifyBuilder.kt | 0 .../kotlin/builder/ban/BanCreateBuilder.kt | 0 .../builder/channel/CategoryCreateBuilder.kt | 0 .../builder/channel/CategoryModifyBuilder.kt | 0 .../channel/ChannelPermissionModifyBuilder.kt | 0 .../channel/EditGuildChannelBuilder.kt | 0 .../channel/ForumChannelCreateBuilder.kt | 0 .../GuildChannelPositionModifyBuilder.kt | 0 .../builder/channel/InviteCreateBuilder.kt | 0 .../channel/NewsChannelCreateBuilder.kt | 0 .../channel/PermissionOverwriteBuilder.kt | 0 .../channel/PermissionOverwritesBuilder.kt | 0 .../channel/TextChannelCreateBuilder.kt | 0 .../channel/VoiceChannelCreateBuilder.kt | 0 .../channel/thread/StartForumThreadBuilder.kt | 0 .../channel/thread/StartThreadBuilder.kt | 0 .../thread/StartThreadWithMessageBuilder.kt | 0 .../channel/thread/ThreadModifyBuilder.kt | 0 .../builder/component/ActionRowBuilder.kt | 0 .../kotlin/builder/component/ButtonBuilder.kt | 0 .../builder/component/ComponentBuilders.kt | 0 .../builder/component/SelectMenuBuilder.kt | 0 .../builder/component/SelectOptionBuilder.kt | 0 .../builder/component/TextInputBuilder.kt | 0 .../builder/guild/EmojiCreateBuilder.kt | 0 .../builder/guild/EmojiModifyBuilder.kt | 0 .../builder/guild/GuildCreateBuilder.kt | 0 .../builder/guild/GuildModifyBuilder.kt | 2 +- .../guild/ScheduledEventCreateBuilder.kt | 0 .../builder/guild/StickerModifyBuilder.kt | 0 .../builder/guild/VoiceStateModifyBuilder.kt | 0 .../guild/WelcomeScreenModifyBuilder.kt | 0 .../builder/guild/WidgetModifyBuilder.kt | 0 .../integration/IntegrationModifyBuilder.kt | 0 .../interaction/ApplicationCommandBuilders.kt | 0 .../ApplicationCommandStateHolder.kt | 0 .../builder/interaction/InputChatBuilders.kt | 0 .../builder/interaction/Localization.kt | 0 .../interaction/MessageCommandBuilders.kt | 0 .../builder/interaction/ModalBuilder.kt | 0 .../MultiApplicationCommandBuilder.kt | 0 .../builder/interaction/OptionsBuilder.kt | 0 .../interaction/UserCommandBuilders.kt | 0 .../kotlin/builder/member/MemberAddBuilder.kt | 0 .../builder/member/MemberModifyBuilder.kt | 0 .../builder/message/AllowedMentionsBuilder.kt | 0 .../kotlin/builder/message/EmbedBuilder.kt | 0 .../create/FollowupMessageCreateBuilder.kt | 0 .../create/ForumMessageCreateBuilder.kt | 0 .../InteractionResponseCreateBuilder.kt | 0 .../message/create/MessageCreateBuilder.kt | 14 +--- ...MessageInteractionResponseCreateBuilder.kt | 0 .../create/UserMessageCreateBuilder.kt | 0 .../create/WebhookMessageCreateBuilder.kt | 0 .../modify/FollowupMessageModifyBuilder.kt | 0 .../InteractionResponseModifyBuilder.kt | 0 .../message/modify/MessageModifyBuilder.kt | 23 ------- .../modify/MessageModifyStateHolder.kt | 0 .../modify/UserMessageModifyBuilder.kt | 0 .../modify/WebhookMessageModifyBuilder.kt | 0 .../kotlin/builder/role/RoleCreateBuilder.kt | 0 .../kotlin/builder/role/RoleModifyBuilder.kt | 0 .../role/RolePositionsModifyBuilder.kt | 0 .../ScheduledEventModifyBuilder.kt | 0 .../stage/StageInstanceCreateBuilder.kt | 0 .../stage/StageInstanceModifyBuilder.kt | 0 .../builder/template/TemplateBuilders.kt | 0 .../builder/user/CurrentUserModifyBuilder.kt | 0 .../builder/user/GroupDMCreateBuilder.kt | 0 .../builder/webhook/WebhookCreateBuilder.kt | 0 .../builder/webhook/WebhookModifyBuilder.kt | 0 .../kotlin/json/JsonErrorCode.kt | 0 .../kotlin/json/request/AuditLogGetRequest.kt | 0 .../json/request/AutoModerationRequests.kt | 0 .../json/request/ChannelFollowRequest.kt | 0 .../kotlin/json/request/ChannelRequests.kt | 0 .../kotlin/json/request/EmojiRequests.kt | 0 .../kotlin/json/request/GuildRequests.kt | 0 .../json/request/InteractionsRequests.kt | 0 .../json/request/InviteCreateRequest.kt | 0 .../kotlin/json/request/MessageRequests.kt | 0 .../json/request/ScheduledEventRequests.kt | 0 .../json/request/StageInstanceRequests.kt | 0 .../kotlin/json/request/StickerRequests.kt | 0 .../kotlin/json/request/TemplateRequests.kt | 0 .../kotlin/json/request/UserRequests.kt | 0 .../kotlin/json/request/VoiceStateRequests.kt | 0 .../kotlin/json/request/WebhookRequests.kt | 0 .../kotlin/json/response/BanResponse.kt | 0 .../kotlin/json/response/Channel.kt | 0 .../kotlin/json/response/Connection.kt | 0 .../CurrentUserNicknameModifyResponse.kt | 0 .../json/response/DiscordErrorResponse.kt | 0 .../json/response/FollowedChannelResponse.kt | 0 .../kotlin/json/response/Gateway.kt | 0 .../response/GuildMFALevelModifyResponse.kt | 0 .../kotlin/json/response/Prune.kt | 0 .../kotlin/ratelimit/AbstractRateLimiter.kt | 7 +- .../ratelimit/ExclusionRequestRateLimiter.kt | 0 .../ratelimit/ParallelRequestRateLimiter.kt | 0 .../kotlin/ratelimit/RequestRateLimiter.kt | 1 + .../commonMain/kotlin/request/HttpEngine.kt | 5 ++ .../kotlin/request/HttpUtils.kt | 2 +- .../kotlin/request/KtorRequestHandler.kt | 5 +- .../kotlin/request/Request.kt | 0 .../kotlin/request/RequestBuilder.kt | 25 ------- .../kotlin/request/RequestHandler.kt | 0 .../kotlin/request/RestRequestException.kt | 0 .../StackTraceRecoveringKtorRequestHandler.kt | 10 +-- .../kotlin/route/CdnUrl.kt | 0 .../kotlin/route/DiscordCdn.kt | 0 .../kotlin/route/Position.kt | 0 .../kotlin/route/Route.kt | 0 .../kotlin/service/ApplicationService.kt | 0 .../kotlin/service/AuditLogService.kt | 0 .../kotlin/service/AutoModerationService.kt | 0 .../kotlin/service/ChannelService.kt | 0 .../kotlin/service/EmojiService.kt | 0 .../kotlin/service/GuildService.kt | 0 .../kotlin/service/InteractionService.kt | 0 .../kotlin/service/InviteService.kt | 0 .../kotlin/service/RestClient.kt | 0 .../kotlin/service/RestService.kt | 0 .../kotlin/service/StageInstanceService.kt | 0 .../kotlin/service/StickerService.kt | 0 .../kotlin/service/TemplateService.kt | 0 .../kotlin/service/UserService.kt | 0 .../kotlin/service/VoiceService.kt | 0 .../kotlin/service/WebhookService.kt | 0 rest/src/{test => commonTest}/kotlin/Utils.kt | 0 .../builder/CategoryModifyBuilderTest.kt | 11 +-- .../builder/EditGuildChannelBuilderTest.kt | 21 +++--- .../kotlin/builder/EmojiModifyBuilderTest.kt | 11 +-- .../kotlin/builder/MemberModifyBuilderTest.kt | 11 +-- .../builder/guild/GuildModifyBuilderTest.kt | 10 +-- .../kotlin/json/AuditLogResponseTest.kt | 10 ++- .../kotlin/json/ErrorTest.kt | 7 +- rest/src/commonTest/kotlin/json/Util.kt | 6 ++ .../AbstractRequestRateLimiterTest.kt | 7 ++ .../ExclusionRequestRateLimiterTest.kt | 0 .../ParallelRequestRateLimiterTest.kt | 0 .../kotlin/ratelimit/TestClock.kt | 0 .../kotlin/request/MessageRequests.kt | 28 ++++---- .../resources/images/gitlab.png | Bin .../resources/images/kord.png | Bin .../resources/json/auditlog.json | 0 .../resources/json/error.json | 0 .../resources/simplelogger.properties | 0 .../dev/kord/rest/request/HttpEngine.kt | 6 ++ .../kord/rest/request/RecoveredStackTrace.kt | 18 +++++ .../jsTest/kotlin/dev/kord/rest/json/Utils.kt | 23 +++++++ .../message/create/MessageCreateBuilder.kt | 14 ++++ .../message/modify/MessageModifyBuilder.kt | 14 ++++ .../dev/kord/rest/request/HttpEngine.kt | 6 ++ .../kord/rest/request/RecoveredStackTrace.kt | 8 +++ .../dev/kord/rest/request/RequestBuilder.kt | 8 +++ .../kotlin/dev/kord/rest/json/Utils.kt | 8 +++ .../rest}/request/StackTraceRecoveryTest.kt | 2 +- rest/src/main/kotlin/NamedFile.kt | 51 -------------- rest/src/test/kotlin/json/Util.kt | 6 -- 182 files changed, 487 insertions(+), 313 deletions(-) create mode 100644 buildSrc/src/main/kotlin/Documentation.kt create mode 100644 buildSrc/src/main/kotlin/KspUtils.kt create mode 100644 buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts rename rest/src/{main => commonMain}/kotlin/Image.kt (94%) create mode 100644 rest/src/commonMain/kotlin/NamedFile.kt rename rest/src/{main => commonMain}/kotlin/builder/RequestBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/auditlog/AuditLogGetRequestBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/automoderation/AutoModerationActionBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/automoderation/AutoModerationRuleBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/automoderation/AutoModerationRuleCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/automoderation/AutoModerationRuleModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/ban/BanCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/channel/CategoryCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/channel/CategoryModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/channel/ChannelPermissionModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/channel/EditGuildChannelBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/channel/ForumChannelCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/channel/GuildChannelPositionModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/channel/InviteCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/channel/NewsChannelCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/channel/PermissionOverwriteBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/channel/PermissionOverwritesBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/channel/TextChannelCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/channel/VoiceChannelCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/channel/thread/StartForumThreadBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/channel/thread/StartThreadBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/channel/thread/StartThreadWithMessageBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/channel/thread/ThreadModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/component/ActionRowBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/component/ButtonBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/component/ComponentBuilders.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/component/SelectMenuBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/component/SelectOptionBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/component/TextInputBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/guild/EmojiCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/guild/EmojiModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/guild/GuildCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/guild/GuildModifyBuilder.kt (99%) rename rest/src/{main => commonMain}/kotlin/builder/guild/ScheduledEventCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/guild/StickerModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/guild/VoiceStateModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/guild/WelcomeScreenModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/guild/WidgetModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/integration/IntegrationModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/interaction/ApplicationCommandBuilders.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/interaction/ApplicationCommandStateHolder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/interaction/InputChatBuilders.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/interaction/Localization.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/interaction/MessageCommandBuilders.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/interaction/ModalBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/interaction/MultiApplicationCommandBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/interaction/OptionsBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/interaction/UserCommandBuilders.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/member/MemberAddBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/member/MemberModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/message/AllowedMentionsBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/message/EmbedBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/message/create/FollowupMessageCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/message/create/ForumMessageCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/message/create/InteractionResponseCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/message/create/MessageCreateBuilder.kt (93%) rename rest/src/{main => commonMain}/kotlin/builder/message/create/UpdateMessageInteractionResponseCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/message/create/UserMessageCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/message/create/WebhookMessageCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/message/modify/FollowupMessageModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/message/modify/InteractionResponseModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/message/modify/MessageModifyBuilder.kt (77%) rename rest/src/{main => commonMain}/kotlin/builder/message/modify/MessageModifyStateHolder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/message/modify/UserMessageModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/message/modify/WebhookMessageModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/role/RoleCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/role/RoleModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/role/RolePositionsModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/scheduled_events/ScheduledEventModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/stage/StageInstanceCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/stage/StageInstanceModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/template/TemplateBuilders.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/user/CurrentUserModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/user/GroupDMCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/webhook/WebhookCreateBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/builder/webhook/WebhookModifyBuilder.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/JsonErrorCode.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/request/AuditLogGetRequest.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/request/AutoModerationRequests.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/request/ChannelFollowRequest.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/request/ChannelRequests.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/request/EmojiRequests.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/request/GuildRequests.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/request/InteractionsRequests.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/request/InviteCreateRequest.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/request/MessageRequests.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/request/ScheduledEventRequests.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/request/StageInstanceRequests.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/request/StickerRequests.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/request/TemplateRequests.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/request/UserRequests.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/request/VoiceStateRequests.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/request/WebhookRequests.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/response/BanResponse.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/response/Channel.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/response/Connection.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/response/CurrentUserNicknameModifyResponse.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/response/DiscordErrorResponse.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/response/FollowedChannelResponse.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/response/Gateway.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/response/GuildMFALevelModifyResponse.kt (100%) rename rest/src/{main => commonMain}/kotlin/json/response/Prune.kt (100%) rename rest/src/{main => commonMain}/kotlin/ratelimit/AbstractRateLimiter.kt (94%) rename rest/src/{main => commonMain}/kotlin/ratelimit/ExclusionRequestRateLimiter.kt (100%) rename rest/src/{main => commonMain}/kotlin/ratelimit/ParallelRequestRateLimiter.kt (100%) rename rest/src/{main => commonMain}/kotlin/ratelimit/RequestRateLimiter.kt (99%) create mode 100644 rest/src/commonMain/kotlin/request/HttpEngine.kt rename rest/src/{main => commonMain}/kotlin/request/HttpUtils.kt (98%) rename rest/src/{main => commonMain}/kotlin/request/KtorRequestHandler.kt (97%) rename rest/src/{main => commonMain}/kotlin/request/Request.kt (100%) rename rest/src/{main => commonMain}/kotlin/request/RequestBuilder.kt (69%) rename rest/src/{main => commonMain}/kotlin/request/RequestHandler.kt (100%) rename rest/src/{main => commonMain}/kotlin/request/RestRequestException.kt (100%) rename rest/src/{main => commonMain}/kotlin/request/StackTraceRecoveringKtorRequestHandler.kt (79%) rename rest/src/{main => commonMain}/kotlin/route/CdnUrl.kt (100%) rename rest/src/{main => commonMain}/kotlin/route/DiscordCdn.kt (100%) rename rest/src/{main => commonMain}/kotlin/route/Position.kt (100%) rename rest/src/{main => commonMain}/kotlin/route/Route.kt (100%) rename rest/src/{main => commonMain}/kotlin/service/ApplicationService.kt (100%) rename rest/src/{main => commonMain}/kotlin/service/AuditLogService.kt (100%) rename rest/src/{main => commonMain}/kotlin/service/AutoModerationService.kt (100%) rename rest/src/{main => commonMain}/kotlin/service/ChannelService.kt (100%) rename rest/src/{main => commonMain}/kotlin/service/EmojiService.kt (100%) rename rest/src/{main => commonMain}/kotlin/service/GuildService.kt (100%) rename rest/src/{main => commonMain}/kotlin/service/InteractionService.kt (100%) rename rest/src/{main => commonMain}/kotlin/service/InviteService.kt (100%) rename rest/src/{main => commonMain}/kotlin/service/RestClient.kt (100%) rename rest/src/{main => commonMain}/kotlin/service/RestService.kt (100%) rename rest/src/{main => commonMain}/kotlin/service/StageInstanceService.kt (100%) rename rest/src/{main => commonMain}/kotlin/service/StickerService.kt (100%) rename rest/src/{main => commonMain}/kotlin/service/TemplateService.kt (100%) rename rest/src/{main => commonMain}/kotlin/service/UserService.kt (100%) rename rest/src/{main => commonMain}/kotlin/service/VoiceService.kt (100%) rename rest/src/{main => commonMain}/kotlin/service/WebhookService.kt (100%) rename rest/src/{test => commonTest}/kotlin/Utils.kt (100%) rename rest/src/{test => commonTest}/kotlin/builder/CategoryModifyBuilderTest.kt (61%) rename rest/src/{test => commonTest}/kotlin/builder/EditGuildChannelBuilderTest.kt (57%) rename rest/src/{test => commonTest}/kotlin/builder/EmojiModifyBuilderTest.kt (59%) rename rest/src/{test => commonTest}/kotlin/builder/MemberModifyBuilderTest.kt (62%) rename rest/src/{test => commonTest}/kotlin/builder/guild/GuildModifyBuilderTest.kt (61%) rename rest/src/{test => commonTest}/kotlin/json/AuditLogResponseTest.kt (63%) rename rest/src/{test => commonTest}/kotlin/json/ErrorTest.kt (78%) create mode 100644 rest/src/commonTest/kotlin/json/Util.kt rename rest/src/{test => commonTest}/kotlin/ratelimit/AbstractRequestRateLimiterTest.kt (97%) rename rest/src/{test => commonTest}/kotlin/ratelimit/ExclusionRequestRateLimiterTest.kt (100%) rename rest/src/{test => commonTest}/kotlin/ratelimit/ParallelRequestRateLimiterTest.kt (100%) rename rest/src/{test => commonTest}/kotlin/ratelimit/TestClock.kt (100%) rename rest/src/{test => commonTest}/kotlin/request/MessageRequests.kt (74%) rename rest/src/{test => commonTest}/resources/images/gitlab.png (100%) rename rest/src/{test => commonTest}/resources/images/kord.png (100%) rename rest/src/{test => commonTest}/resources/json/auditlog.json (100%) rename rest/src/{test => commonTest}/resources/json/error.json (100%) rename rest/src/{test => commonTest}/resources/simplelogger.properties (100%) create mode 100644 rest/src/jsMain/kotlin/dev/kord/rest/request/HttpEngine.kt create mode 100644 rest/src/jsMain/kotlin/dev/kord/rest/request/RecoveredStackTrace.kt create mode 100644 rest/src/jsTest/kotlin/dev/kord/rest/json/Utils.kt create mode 100644 rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/MessageCreateBuilder.kt create mode 100644 rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/MessageModifyBuilder.kt create mode 100644 rest/src/jvmMain/kotlin/dev/kord/rest/request/HttpEngine.kt create mode 100644 rest/src/jvmMain/kotlin/dev/kord/rest/request/RecoveredStackTrace.kt create mode 100644 rest/src/jvmMain/kotlin/dev/kord/rest/request/RequestBuilder.kt create mode 100644 rest/src/jvmTest/kotlin/dev/kord/rest/json/Utils.kt rename rest/src/{test/kotlin => jvmTest/kotlin/dev/kord/rest}/request/StackTraceRecoveryTest.kt (93%) delete mode 100644 rest/src/main/kotlin/NamedFile.kt delete mode 100644 rest/src/test/kotlin/json/Util.kt diff --git a/buildSrc/src/main/kotlin/Compiler.kt b/buildSrc/src/main/kotlin/Compiler.kt index 5d33eff77e01..5f73b07d33d1 100644 --- a/buildSrc/src/main/kotlin/Compiler.kt +++ b/buildSrc/src/main/kotlin/Compiler.kt @@ -27,6 +27,6 @@ object Jvm { } fun KotlinCommonCompilerOptions.applyKordCompilerOptions() { - allWarningsAsErrors.set(true) + allWarningsAsErrors.set(false) freeCompilerArgs.add(CompilerArguments.progressive) } diff --git a/buildSrc/src/main/kotlin/Documentation.kt b/buildSrc/src/main/kotlin/Documentation.kt new file mode 100644 index 000000000000..2dab4c5eec0e --- /dev/null +++ b/buildSrc/src/main/kotlin/Documentation.kt @@ -0,0 +1,54 @@ +import org.gradle.api.tasks.TaskContainer +import org.gradle.kotlin.dsl.withType +import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask +import java.net.URL + +fun TaskContainer.configureDokka(additionalConfiguration: AbstractDokkaLeafTask.() -> Unit = {}) { + withType().configureEach { + // see https://kotlin.github.io/dokka//user_guide/gradle/usage/#configuration-options + + // include documentation generated by ksp + dependsOnKspKotlin() + + failOnWarning.set(true) + + dokkaSourceSets.configureEach { + + jdkVersion.set(Jvm.target) + + val baseRemoteUrl = + "https://github.com/kordlib/kord/blob/${Library.commitHashOrDefault("0.8.x")}/${project.name}" + + sourceLink { + localDirectory.set(project.file("src/main/kotlin")) + remoteUrl.set(URL("$baseRemoteUrl/src/main/kotlin")) + remoteLineSuffix.set("#L") + } + + // config for files generated by ksp + suppressGeneratedFiles.set(false) + sourceLink { + // will fail if dir doesn't exist -> always create it, won't harm if not needed + localDirectory.set(project.file("build/generated/ksp/main/kotlin").apply { mkdirs() }) + remoteUrl.set(URL("$baseRemoteUrl/build/generated/ksp/main/kotlin")) + remoteLineSuffix.set("#L") + } + + externalDocumentationLink("https://kotlinlang.org/api/kotlinx.coroutines/") + externalDocumentationLink("https://kotlinlang.org/api/kotlinx.serialization/") + externalDocumentationLink( + url = "https://kotlinlang.org/api/kotlinx-datetime/", + packageListUrl = "https://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/package-list", + ) + externalDocumentationLink("https://api.ktor.io/") + + // don't list `TweetNaclFast` in docs + perPackageOption { + matchingRegex.set("""com\.iwebpp\.crypto""") + suppress.set(true) + } + } + + additionalConfiguration() + } +} diff --git a/buildSrc/src/main/kotlin/KspUtils.kt b/buildSrc/src/main/kotlin/KspUtils.kt new file mode 100644 index 000000000000..71e20bafd576 --- /dev/null +++ b/buildSrc/src/main/kotlin/KspUtils.kt @@ -0,0 +1,7 @@ +import org.gradle.api.Task +import org.gradle.api.tasks.TaskContainer + +fun Task.dependsOnKspKotlin(name: String = "kspKotlin") { + val kspKotlin = project.tasks.findByName(name) + if (kspKotlin != null) dependsOn(kspKotlin) +} diff --git a/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts new file mode 100644 index 000000000000..53be19854869 --- /dev/null +++ b/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts @@ -0,0 +1,23 @@ +plugins { + org.jetbrains.kotlin.multiplatform +} + +repositories { + mavenCentral() +} + +kotlin { + jvm() + js(IR) { + nodejs() + } + jvmToolchain(Jvm.target) + + targets { + all { + compilations.all { + compilerOptions.options.applyKordCompilerOptions() + } + } + } +} diff --git a/buildSrc/src/main/kotlin/kord-module.gradle.kts b/buildSrc/src/main/kotlin/kord-module.gradle.kts index 37b6d0dab5b1..0b40fe453589 100644 --- a/buildSrc/src/main/kotlin/kord-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-module.gradle.kts @@ -56,58 +56,7 @@ tasks { useJUnitPlatform() } - fun Task.dependsOnKspKotlin() { - val kspKotlin = findByName("kspKotlin") - if (kspKotlin != null) dependsOn(kspKotlin) - } - - // configure both dokkaHtml and dokkaHtmlPartial tasks - // (dokkaHtmlMultiModule depends on dokkaHtmlPartial, dokkaJar depends on dokkaHtml) - withType().configureEach { - // see https://kotlin.github.io/dokka//user_guide/gradle/usage/#configuration-options - - // include documentation generated by ksp - dependsOnKspKotlin() - - failOnWarning.set(true) - - dokkaSourceSets.configureEach { - - jdkVersion.set(Jvm.target) - - val baseRemoteUrl = - "https://github.com/kordlib/kord/blob/${Library.commitHashOrDefault("0.9.x")}/${project.name}" - - sourceLink { - localDirectory.set(file("src/main/kotlin")) - remoteUrl.set(URL("$baseRemoteUrl/src/main/kotlin")) - remoteLineSuffix.set("#L") - } - - // config for files generated by ksp - suppressGeneratedFiles.set(false) - sourceLink { - // will fail if dir doesn't exist -> always create it, won't harm if not needed - localDirectory.set(file("build/generated/ksp/main/kotlin").apply { mkdirs() }) - remoteUrl.set(URL("$baseRemoteUrl/build/generated/ksp/main/kotlin")) - remoteLineSuffix.set("#L") - } - - externalDocumentationLink("https://kotlinlang.org/api/kotlinx.coroutines/") - externalDocumentationLink("https://kotlinlang.org/api/kotlinx.serialization/") - externalDocumentationLink( - url = "https://kotlinlang.org/api/kotlinx-datetime/", - packageListUrl = "https://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/package-list", - ) - externalDocumentationLink("https://api.ktor.io/") - - // don't list `TweetNaclFast` in docs - perPackageOption { - matchingRegex.set("""com\.iwebpp\.crypto""") - suppress.set(true) - } - } - } + configureDokka() withType().configureEach { doFirst { require(!Library.isUndefined) { "No release/snapshot version found." } } diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index 0d90236b6696..5d664b0e7749 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -1,5 +1,4 @@ -import gradle.kotlin.dsl.accessors._e5121a5856746b077c6819bbe5a86a2f.main -import gradle.kotlin.dsl.accessors._e5121a5856746b077c6819bbe5a86a2f.testing +import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest plugins { @@ -32,8 +31,22 @@ kotlin { sourceSets { all { - if ("Test" in name) { - languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") + languageSettings { + if ("Test" in name) { + optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") + } + listOf( + OptIns.time, + OptIns.contracts, + OptIns.kordPreview, + OptIns.kordExperimental, + OptIns.kordVoice, + ).forEach(::optIn) + } + + repositories { + // until Dokka 1.8.0 is released and we no longer need dev builds, see https://github.com/kordlib/kord/pull/755 + maven("https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev") } } commonMain { @@ -44,9 +57,47 @@ kotlin { } tasks { - tasks { - getByName("jvmTest") { - useJUnitPlatform() + getByName("jvmTest") { + useJUnitPlatform() + } + + withType() { + environment("PROJECT_ROOT", rootProject.projectDir.absolutePath) + } + + afterEvaluate { + getByName("compileKotlinJvm") { + dependsOnKspKotlin("kspCommonMainKotlinMetadata") + } + getByName("compileKotlinJs") { + dependsOnKspKotlin("kspCommonMainKotlinMetadata") + } + } + + configureDokka { + dependsOnKspKotlin("kspCommonMainKotlinMetadata") + + dokkaSourceSets { + val map = asMap + + if (map.containsKey("jsMain")) { + named("jsMain") { + displayName.set("JS") + } + } + + if (map.containsKey("jvmMain")) { + named("jvmMain") { + displayName.set("JVM") + } + } + + if (map.containsKey("commonMain")) { + named("jvmMain") { + displayName.set("Common") + } + } } + } } diff --git a/common/api/common.api b/common/api/common.api index 4ef4ee34ef28..9646a2c79701 100644 --- a/common/api/common.api +++ b/common/api/common.api @@ -15,7 +15,7 @@ public final class dev/kord/common/Color$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } -public final class dev/kord/common/ColorKt { +public final class dev/kord/common/ColorJvm { public static final fun getKColor (Ljava/awt/Color;)Ldev/kord/common/Color; } @@ -102,7 +102,6 @@ public final class dev/kord/common/Locale { public static final field Companion Ldev/kord/common/Locale$Companion; public fun (Ljava/lang/String;Ljava/lang/String;)V public synthetic fun (Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun asJavaLocale ()Ljava/util/Locale; public final fun component1 ()Ljava/lang/String; public final fun component2 ()Ljava/lang/String; public final fun copy (Ljava/lang/String;Ljava/lang/String;)Ldev/kord/common/Locale; @@ -161,6 +160,7 @@ public final class dev/kord/common/Locale$Serializer : kotlinx/serialization/KSe } public final class dev/kord/common/LocaleKt { + public static final fun asJavaLocale (Ldev/kord/common/Locale;)Ljava/util/Locale; public static final fun getKLocale (Ljava/util/Locale;)Ldev/kord/common/Locale; } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 4f6cf77a963a..2a76d67218c9 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -10,17 +10,6 @@ kotlin { explicitApi() sourceSets { - all { - languageSettings { - listOf( - OptIns.time, - OptIns.contracts, - OptIns.kordPreview, - OptIns.kordExperimental, - OptIns.kordVoice, - ).forEach(::optIn) - } - } commonMain { dependencies { api(libs.kotlinx.coroutines.core) diff --git a/common/src/commonTest/kotlin/entity/optional/OptionalLongTest.kt b/common/src/commonTest/kotlin/entity/optional/OptionalLongTest.kt index 6f29e2985cfe..d67d1e6d5d53 100644 --- a/common/src/commonTest/kotlin/entity/optional/OptionalLongTest.kt +++ b/common/src/commonTest/kotlin/entity/optional/OptionalLongTest.kt @@ -53,7 +53,7 @@ internal class OptionalLongTest { val entity = Json.decodeFromString(json) assertIs(entity.value) - assertSame(5, entity.value.value) + assertEquals(5, entity.value.value) } } diff --git a/common/src/jsTest/kotlin/file.kt b/common/src/jsTest/kotlin/file.kt index a39d74575d0c..4ea496e94b85 100644 --- a/common/src/jsTest/kotlin/file.kt +++ b/common/src/jsTest/kotlin/file.kt @@ -1,7 +1,10 @@ package dev.kord.common +import js.core.get +import node.buffer.BufferEncoding +import node.process.process import node.fs.readFile as nodeReadFile actual suspend fun readFile(prefix: String, name: String): String = - nodeReadFile("common/commonTest/resources/json/$prefix/$name.json") - .toString() + nodeReadFile("${process.env["PROJECT_ROOT"]}/common/src/commonTest/resources/json/$prefix/$name.json") + .toString(BufferEncoding.utf8) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7e47eb590ff1..6b136076ef26 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,6 +8,7 @@ kotlinx-serialization = "1.5.0" # https://github.com/Kotlin/kotlinx.serializatio kotlinx-datetime = "0.4.0" # https://github.com/Kotlin/kotlinx-datetime kotlin-logging = "3.0.5" # https://github.com/oshai/kotlin-logging kord-cache = { strictly = "[0.3.0, 0.4.0[", prefer = "latest.release" } +stately = "2.0.0-rc1" # code generation ksp = "1.8.10-1.0.9" # https://github.com/google/ksp @@ -34,6 +35,8 @@ kord-cache-map = { module = "dev.kord.cache:cache-map", version.ref = "kord-cach # ktor ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" } ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" } +ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" } +ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" } ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" } ktor-client-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" } ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" } @@ -58,6 +61,8 @@ kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlin # JDK Replacements bignum = { module = "com.ionspin.kotlin:bignum", version = "0.3.8" } +stately-collections = { module = "co.touchlab:stately-concurrent-collections", version.ref = "stately" } +stately-concurrency = { module = "co.touchlab:stately-concurrency", version.ref = "stately" } # tests kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test-common", version.ref = "kotlin" } @@ -86,6 +91,7 @@ ktor-client-serialization = ["ktor-client-content-negotiation", "ktor-serializat test-implementation = ["kotlinx-coroutines-test", "kotlin-test", "junit-jupiter-api", "mockk"] test-common = ["kotlinx-coroutines-test", "kotlin-test", "kotlin-test-annotations-common"] test-runtime = ["kotlin-test-junit5", "junit-jupiter-engine", "slf4j-simple"] +stately = ["stately-collections", "stately-concurrency"] pluginsForBuildSrc = [ "kotlin-jvm-plugin", diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index 932b0c9eed86..b14cc9615a05 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -17,6 +17,13 @@ resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44" integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q== +abort-controller@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" + integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== + dependencies: + event-target-shim "^5.0.0" + ansi-colors@4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" @@ -183,6 +190,11 @@ escape-string-regexp@4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== +event-target-shim@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" + integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== + fill-range@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" @@ -388,6 +400,13 @@ nanoid@3.3.3: resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.3.tgz#fd8e8b7aa761fe807dba2d1b98fb7241bb724a25" integrity sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w== +node-fetch@2.6.7: + version "2.6.7" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" + integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== + dependencies: + whatwg-url "^5.0.0" + normalize-path@^3.0.0, normalize-path@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" @@ -515,11 +534,29 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" +tr46@~0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== + typescript@3.9.5: version "3.9.5" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.5.tgz#586f0dba300cde8be52dd1ac4f7e1009c1b13f36" integrity sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ== +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== + +whatwg-url@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== + dependencies: + tr46 "~0.0.3" + webidl-conversions "^3.0.0" + workerpool@6.2.1: version "6.2.1" resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" @@ -539,6 +576,11 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== +ws@8.5.0: + version "8.5.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.5.0.tgz#bfb4be96600757fe5382de12c670dab984a1ed4f" + integrity sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg== + y18n@^5.0.5: version "5.0.8" resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" diff --git a/ksp-annotations/build.gradle.kts b/ksp-annotations/build.gradle.kts index 4bcb3c72f8b5..aaacf04f2c4f 100644 --- a/ksp-annotations/build.gradle.kts +++ b/ksp-annotations/build.gradle.kts @@ -1,3 +1,3 @@ plugins { - `kord-multiplatform-module` + `kord-internal-multiplatform-module` } diff --git a/rest/api/rest.api b/rest/api/rest.api index 1472010a5ec2..e8f0aee4dc4f 100644 --- a/rest/api/rest.api +++ b/rest/api/rest.api @@ -58,13 +58,10 @@ public final class dev/kord/rest/Image$Size : java/lang/Enum { public final class dev/kord/rest/NamedFile { public fun (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)V - public synthetic fun (Ljava/lang/String;Ljava/io/InputStream;)V public final fun component1 ()Ljava/lang/String; public final fun component2 ()Lio/ktor/client/request/forms/ChannelProvider; - public final synthetic fun component2 ()Ljava/io/InputStream; public final fun component3 ()Ljava/lang/String; public final fun getContentProvider ()Lio/ktor/client/request/forms/ChannelProvider; - public final synthetic fun getInputStream ()Ljava/io/InputStream; public final fun getName ()Ljava/lang/String; public final fun getUrl ()Ljava/lang/String; } @@ -355,10 +352,10 @@ public final class dev/kord/rest/builder/automoderation/UntypedAutoModerationRul public final class dev/kord/rest/builder/ban/BanCreateBuilder : dev/kord/rest/builder/AuditRequestBuilder { public fun ()V public final fun getDeleteMessageDuration-FghU774 ()Lkotlin/time/Duration; - public final synthetic fun getDeleteMessagesDays ()Ljava/lang/Integer; + public final fun getDeleteMessagesDays ()Ljava/lang/Integer; public fun getReason ()Ljava/lang/String; public final fun setDeleteMessageDuration-BwNAW2A (Lkotlin/time/Duration;)V - public final synthetic fun setDeleteMessagesDays (Ljava/lang/Integer;)V + public final fun setDeleteMessagesDays (Ljava/lang/Integer;)V public fun setReason (Ljava/lang/String;)V public fun toRequest ()Ldev/kord/rest/json/request/GuildBanCreateRequest; public synthetic fun toRequest ()Ljava/lang/Object; @@ -993,7 +990,7 @@ public final class dev/kord/rest/builder/component/UserSelectBuilder : dev/kord/ public final class dev/kord/rest/builder/guild/CurrentVoiceStateModifyBuilder : dev/kord/rest/builder/RequestBuilder { public fun ()V - public synthetic fun (Ldev/kord/common/entity/Snowflake;)V + public fun (Ldev/kord/common/entity/Snowflake;)V public final fun getChannelId ()Ldev/kord/common/entity/Snowflake; public final fun getRequestToSpeakTimestamp ()Lkotlinx/datetime/Instant; public final fun getSuppress ()Ljava/lang/Boolean; @@ -1082,7 +1079,7 @@ public final class dev/kord/rest/builder/guild/GuildModifyBuilder : dev/kord/res public final fun getName ()Ljava/lang/String; public final fun getNotificationLevel ()Ldev/kord/common/entity/DefaultMessageNotificationLevel; public final fun getOwnerId ()Ldev/kord/common/entity/Snowflake; - public final fun getPreferredLocale ()Ljava/util/Locale; + public final fun getPreferredLocale ()Ldev/kord/common/Locale; public final fun getPublicUpdatesChannelId ()Ldev/kord/common/entity/Snowflake; public fun getReason ()Ljava/lang/String; public final fun getRegion ()Ljava/lang/String; @@ -1099,7 +1096,7 @@ public final class dev/kord/rest/builder/guild/GuildModifyBuilder : dev/kord/res public final fun setName (Ljava/lang/String;)V public final fun setNotificationLevel (Ldev/kord/common/entity/DefaultMessageNotificationLevel;)V public final fun setOwnerId (Ldev/kord/common/entity/Snowflake;)V - public final fun setPreferredLocale (Ljava/util/Locale;)V + public final fun setPreferredLocale (Ldev/kord/common/Locale;)V public final fun setPublicUpdatesChannelId (Ldev/kord/common/entity/Snowflake;)V public fun setReason (Ljava/lang/String;)V public final fun setRegion (Ljava/lang/String;)V @@ -1909,8 +1906,6 @@ public final class dev/kord/rest/builder/message/EmbedBuilder$Thumbnail : dev/ko 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 fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public synthetic fun addFile (Ljava/lang/String;Ljava/io/InputStream;)Ldev/kord/rest/NamedFile; - public fun addFile (Ljava/nio/file/Path;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; public fun getComponents ()Ljava/util/List; public fun getContent ()Ljava/lang/String; @@ -1934,7 +1929,7 @@ public final class dev/kord/rest/builder/message/create/FollowupMessageCreateBui public final class dev/kord/rest/builder/message/create/ForumMessageCreateBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/create/MessageCreateBuilder { public fun ()V public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public synthetic fun addFile (Ljava/lang/String;Ljava/io/InputStream;)Ldev/kord/rest/NamedFile; + public fun addFile (Ljava/lang/String;Ljava/io/InputStream;)Ldev/kord/rest/NamedFile; public fun addFile (Ljava/nio/file/Path;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; public fun getComponents ()Ljava/util/List; @@ -1961,8 +1956,6 @@ public final class dev/kord/rest/builder/message/create/InteractionResponseCreat 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 synthetic fun addFile (Ljava/lang/String;Ljava/io/InputStream;)Ldev/kord/rest/NamedFile; - public fun addFile (Ljava/nio/file/Path;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; public fun getComponents ()Ljava/util/List; public fun getContent ()Ljava/lang/String; @@ -1985,8 +1978,6 @@ public final class dev/kord/rest/builder/message/create/InteractionResponseCreat 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 synthetic fun addFile (Ljava/lang/String;Ljava/io/InputStream;)Ldev/kord/rest/NamedFile; - public abstract fun addFile (Ljava/nio/file/Path;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; public abstract fun getComponents ()Ljava/util/List; public abstract fun getContent ()Ljava/lang/String; @@ -2006,8 +1997,10 @@ public abstract interface class dev/kord/rest/builder/message/create/MessageCrea public final class dev/kord/rest/builder/message/create/MessageCreateBuilder$DefaultImpls { public static fun addFile (Ldev/kord/rest/builder/message/create/MessageCreateBuilder;Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public static synthetic fun addFile (Ldev/kord/rest/builder/message/create/MessageCreateBuilder;Ljava/lang/String;Ljava/io/InputStream;)Ldev/kord/rest/NamedFile; - public static fun addFile (Ldev/kord/rest/builder/message/create/MessageCreateBuilder;Ljava/nio/file/Path;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/kord/rest/builder/message/create/MessageCreateBuilderJvm { + public static final fun addFile (Ldev/kord/rest/builder/message/create/MessageCreateBuilder;Ljava/nio/file/Path;)Ldev/kord/rest/NamedFile; } public final class dev/kord/rest/builder/message/create/MessageCreateBuilderKt { @@ -2021,8 +2014,6 @@ public final class dev/kord/rest/builder/message/create/MessageCreateBuilderKt { public final class dev/kord/rest/builder/message/create/UpdateMessageInteractionResponseCreateBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/create/MessageCreateBuilder { public fun ()V public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public synthetic fun addFile (Ljava/lang/String;Ljava/io/InputStream;)Ldev/kord/rest/NamedFile; - public fun addFile (Ljava/nio/file/Path;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; public fun getComponents ()Ljava/util/List; public fun getContent ()Ljava/lang/String; @@ -2048,8 +2039,6 @@ public final class dev/kord/rest/builder/message/create/UpdateMessageInteraction public final class dev/kord/rest/builder/message/create/UserMessageCreateBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/create/MessageCreateBuilder { public fun ()V public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public synthetic fun addFile (Ljava/lang/String;Ljava/io/InputStream;)Ldev/kord/rest/NamedFile; - public fun addFile (Ljava/nio/file/Path;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; public fun getComponents ()Ljava/util/List; public fun getContent ()Ljava/lang/String; @@ -2078,8 +2067,6 @@ public final class dev/kord/rest/builder/message/create/UserMessageCreateBuilder public final class dev/kord/rest/builder/message/create/WebhookMessageCreateBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/create/MessageCreateBuilder { public fun ()V public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public synthetic fun addFile (Ljava/lang/String;Ljava/io/InputStream;)Ldev/kord/rest/NamedFile; - public fun addFile (Ljava/nio/file/Path;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; public final fun getAvatarUrl ()Ljava/lang/String; public fun getComponents ()Ljava/util/List; @@ -2108,8 +2095,6 @@ public final class dev/kord/rest/builder/message/create/WebhookMessageCreateBuil 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 fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public synthetic fun addFile (Ljava/lang/String;Ljava/io/InputStream;)Ldev/kord/rest/NamedFile; - public fun addFile (Ljava/nio/file/Path;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; public fun getAttachments ()Ljava/util/List; public fun getComponents ()Ljava/util/List; @@ -2133,8 +2118,6 @@ public final class dev/kord/rest/builder/message/modify/FollowupMessageModifyBui public final class dev/kord/rest/builder/message/modify/InteractionResponseModifyBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/modify/MessageModifyBuilder { public fun ()V public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public synthetic fun addFile (Ljava/lang/String;Ljava/io/InputStream;)Ldev/kord/rest/NamedFile; - public fun addFile (Ljava/nio/file/Path;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; public fun getAttachments ()Ljava/util/List; public fun getComponents ()Ljava/util/List; @@ -2157,8 +2140,6 @@ public final class dev/kord/rest/builder/message/modify/InteractionResponseModif 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 synthetic fun addFile (Ljava/lang/String;Ljava/io/InputStream;)Ldev/kord/rest/NamedFile; - public abstract fun addFile (Ljava/nio/file/Path;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; public abstract fun getAttachments ()Ljava/util/List; public abstract fun getComponents ()Ljava/util/List; @@ -2179,8 +2160,10 @@ public abstract interface class dev/kord/rest/builder/message/modify/MessageModi public final class dev/kord/rest/builder/message/modify/MessageModifyBuilder$DefaultImpls { public static fun addFile (Ldev/kord/rest/builder/message/modify/MessageModifyBuilder;Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public static synthetic fun addFile (Ldev/kord/rest/builder/message/modify/MessageModifyBuilder;Ljava/lang/String;Ljava/io/InputStream;)Ldev/kord/rest/NamedFile; - public static fun addFile (Ldev/kord/rest/builder/message/modify/MessageModifyBuilder;Ljava/nio/file/Path;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class dev/kord/rest/builder/message/modify/MessageModifyBuilderJvm { + public static final fun addFile (Ldev/kord/rest/builder/message/modify/MessageModifyBuilder;Ljava/nio/file/Path;)Ldev/kord/rest/NamedFile; } public final class dev/kord/rest/builder/message/modify/MessageModifyBuilderKt { @@ -2194,8 +2177,6 @@ public final class dev/kord/rest/builder/message/modify/MessageModifyBuilderKt { public final class dev/kord/rest/builder/message/modify/UserMessageModifyBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/modify/MessageModifyBuilder { public fun ()V public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public synthetic fun addFile (Ljava/lang/String;Ljava/io/InputStream;)Ldev/kord/rest/NamedFile; - public fun addFile (Ljava/nio/file/Path;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; public fun getAttachments ()Ljava/util/List; public fun getComponents ()Ljava/util/List; @@ -2219,8 +2200,6 @@ public final class dev/kord/rest/builder/message/modify/UserMessageModifyBuilder public final class dev/kord/rest/builder/message/modify/WebhookMessageModifyBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/modify/MessageModifyBuilder { public fun ()V public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public synthetic fun addFile (Ljava/lang/String;Ljava/io/InputStream;)Ldev/kord/rest/NamedFile; - public fun addFile (Ljava/nio/file/Path;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; public fun getAttachments ()Ljava/util/List; public fun getComponents ()Ljava/util/List; @@ -3722,8 +3701,8 @@ public final class dev/kord/rest/json/request/GuildBanCreateRequest { public static synthetic fun copy$default (Ldev/kord/rest/json/request/GuildBanCreateRequest;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/GuildBanCreateRequest; public fun equals (Ljava/lang/Object;)Z public final fun getDeleteMessageSeconds ()Ldev/kord/common/entity/optional/Optional; - public final synthetic fun getDeleteMessagesDays ()Ldev/kord/common/entity/optional/OptionalInt; - public final synthetic fun getReason ()Ldev/kord/common/entity/optional/Optional; + public final fun getDeleteMessagesDays ()Ldev/kord/common/entity/optional/OptionalInt; + public final fun getReason ()Ldev/kord/common/entity/optional/Optional; public fun hashCode ()I public fun toString ()Ljava/lang/String; public static final fun write$Self (Ldev/kord/rest/json/request/GuildBanCreateRequest;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V @@ -6057,8 +6036,6 @@ public final class dev/kord/rest/request/RequestBuilder { public final fun build ()Ldev/kord/rest/request/Request; public final fun file (Ldev/kord/rest/NamedFile;)V public final fun file (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)V - public final synthetic fun file (Ljava/lang/String;Ljava/io/InputStream;)V - public final fun file (Ljava/nio/file/Path;)V public final fun getBaseUrl ()Ljava/lang/String; public final fun getKeys ()Ljava/util/Map; public final fun getRoute ()Ldev/kord/rest/route/Route; @@ -6071,6 +6048,10 @@ public final class dev/kord/rest/request/RequestBuilder { public final fun urlEncodedHeader (Ljava/lang/String;Ljava/lang/String;)V } +public final class dev/kord/rest/request/RequestBuilderKt { + public static final fun file (Ldev/kord/rest/request/RequestBuilder;Ljava/nio/file/Path;)V +} + public abstract interface class dev/kord/rest/request/RequestHandler { public abstract fun getToken ()Ljava/lang/String; public abstract fun handle (Ldev/kord/rest/request/Request;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -7177,7 +7158,7 @@ public final class dev/kord/rest/service/GuildServiceKt { public static synthetic fun createScheduledEvent$default (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/GuildScheduledEventPrivacyLevel;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/ScheduledEntityType;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public static final fun createTextChannel (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun createVoiceChannel (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static final synthetic fun modifyCurrentVoiceState (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun modifyCurrentVoiceState (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun modifyCurrentVoiceState (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun modifyGuildWelcomeScreen (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun modifyScheduledEvent (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; diff --git a/rest/build.gradle.kts b/rest/build.gradle.kts index da30cf30ef42..5d8736163321 100644 --- a/rest/build.gradle.kts +++ b/rest/build.gradle.kts @@ -1,16 +1,60 @@ +@Suppress("DSL_SCOPE_VIOLATION") // false positive for `libs` in IntelliJ plugins { - `kord-module` - `kord-sampled-module` - `kord-publishing` + `kord-multiplatform-module` + `kotlinx-atomicfu` + `kotlinx-serialization` + alias(libs.plugins.buildconfig) } -dependencies { - api(projects.common) +kotlin { + explicitApi() - api(libs.bundles.ktor.client.serialization) - api(libs.ktor.client.cio) + sourceSets { + commonMain { + dependencies { + api(projects.common) - testImplementation(libs.bundles.test.implementation) - testImplementation(libs.ktor.client.mock) - testRuntimeOnly(libs.bundles.test.runtime) + api(libs.bundles.ktor.client.serialization) + api(libs.ktor.client.core) + api(libs.bundles.stately) + compileOnly(projects.kspAnnotations) + + // The plugin should add this automatically, but it doesn't + compileOnly(libs.kotlinx.atomicfu) + } + } + + commonTest { + dependencies { + implementation(libs.bundles.test.common) + implementation(libs.ktor.client.mock) + } + } + + jsMain { + dependencies { + api(libs.ktor.client.js) + } + } + + jsTest { + dependencies { + implementation(libs.kotlin.test.js) + implementation(libs.kotlinx.nodejs) + } + } + + jvmMain { + dependencies { + api(libs.ktor.client.cio) + } + } + + jvmTest { + dependencies { + runtimeOnly(libs.bundles.test.runtime) + implementation(libs.kotlin.test.junit5) + } + } + } } diff --git a/rest/src/main/kotlin/Image.kt b/rest/src/commonMain/kotlin/Image.kt similarity index 94% rename from rest/src/main/kotlin/Image.kt rename to rest/src/commonMain/kotlin/Image.kt index fa2d76f94f28..1ec1ee4a6f73 100644 --- a/rest/src/main/kotlin/Image.kt +++ b/rest/src/commonMain/kotlin/Image.kt @@ -4,7 +4,6 @@ import io.ktor.client.* import io.ktor.client.call.* import io.ktor.client.request.* import io.ktor.util.* -import kotlinx.coroutines.Dispatchers public class Image private constructor(public val data: ByteArray, public val format: Format) { @@ -15,14 +14,14 @@ public class Image private constructor(public val data: ByteArray, public val fo return Image(data, format) } - public suspend fun fromUrl(client: HttpClient, url: String): Image = with(Dispatchers.IO) { + public suspend fun fromUrl(client: HttpClient, url: String): Image { val call = client.get(url) val contentType = call.headers["Content-Type"] ?: error("expected 'Content-Type' header in image request") val bytes = call.body() - Image(bytes, Format.fromContentType(contentType)) + return Image(bytes, Format.fromContentType(contentType)) } } diff --git a/rest/src/commonMain/kotlin/NamedFile.kt b/rest/src/commonMain/kotlin/NamedFile.kt new file mode 100644 index 000000000000..8ec177f408e6 --- /dev/null +++ b/rest/src/commonMain/kotlin/NamedFile.kt @@ -0,0 +1,12 @@ +package dev.kord.rest + +import io.ktor.client.request.forms.* + +public class NamedFile(public val name: String, public val contentProvider: ChannelProvider) { + + public val url: String get() = "attachment://$name" + + public operator fun component1(): String = name + public operator fun component2(): ChannelProvider = contentProvider + public operator fun component3(): String = url +} diff --git a/rest/src/main/kotlin/builder/RequestBuilder.kt b/rest/src/commonMain/kotlin/builder/RequestBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/RequestBuilder.kt rename to rest/src/commonMain/kotlin/builder/RequestBuilder.kt diff --git a/rest/src/main/kotlin/builder/auditlog/AuditLogGetRequestBuilder.kt b/rest/src/commonMain/kotlin/builder/auditlog/AuditLogGetRequestBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/auditlog/AuditLogGetRequestBuilder.kt rename to rest/src/commonMain/kotlin/builder/auditlog/AuditLogGetRequestBuilder.kt diff --git a/rest/src/main/kotlin/builder/automoderation/AutoModerationActionBuilder.kt b/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationActionBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/automoderation/AutoModerationActionBuilder.kt rename to rest/src/commonMain/kotlin/builder/automoderation/AutoModerationActionBuilder.kt diff --git a/rest/src/main/kotlin/builder/automoderation/AutoModerationRuleBuilder.kt b/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/automoderation/AutoModerationRuleBuilder.kt rename to rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleBuilder.kt diff --git a/rest/src/main/kotlin/builder/automoderation/AutoModerationRuleCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/automoderation/AutoModerationRuleCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/automoderation/AutoModerationRuleModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/automoderation/AutoModerationRuleModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/automoderation/AutoModerationRuleModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/ban/BanCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/ban/BanCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/ban/BanCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/ban/BanCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/channel/CategoryCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/CategoryCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/channel/CategoryCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/channel/CategoryCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/channel/CategoryModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/CategoryModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/channel/CategoryModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/channel/CategoryModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/channel/ChannelPermissionModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/ChannelPermissionModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/channel/ChannelPermissionModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/channel/ChannelPermissionModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/channel/EditGuildChannelBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/EditGuildChannelBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/channel/EditGuildChannelBuilder.kt rename to rest/src/commonMain/kotlin/builder/channel/EditGuildChannelBuilder.kt diff --git a/rest/src/main/kotlin/builder/channel/ForumChannelCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/ForumChannelCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/channel/ForumChannelCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/channel/ForumChannelCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/channel/GuildChannelPositionModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/GuildChannelPositionModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/channel/GuildChannelPositionModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/channel/GuildChannelPositionModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/channel/InviteCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/InviteCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/channel/InviteCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/channel/InviteCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/channel/NewsChannelCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/NewsChannelCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/channel/NewsChannelCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/channel/NewsChannelCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/channel/PermissionOverwriteBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/PermissionOverwriteBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/channel/PermissionOverwriteBuilder.kt rename to rest/src/commonMain/kotlin/builder/channel/PermissionOverwriteBuilder.kt diff --git a/rest/src/main/kotlin/builder/channel/PermissionOverwritesBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/PermissionOverwritesBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/channel/PermissionOverwritesBuilder.kt rename to rest/src/commonMain/kotlin/builder/channel/PermissionOverwritesBuilder.kt diff --git a/rest/src/main/kotlin/builder/channel/TextChannelCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/TextChannelCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/channel/TextChannelCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/channel/TextChannelCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/channel/VoiceChannelCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/VoiceChannelCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/channel/VoiceChannelCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/channel/VoiceChannelCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/channel/thread/StartForumThreadBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/thread/StartForumThreadBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/channel/thread/StartForumThreadBuilder.kt rename to rest/src/commonMain/kotlin/builder/channel/thread/StartForumThreadBuilder.kt diff --git a/rest/src/main/kotlin/builder/channel/thread/StartThreadBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/thread/StartThreadBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/channel/thread/StartThreadBuilder.kt rename to rest/src/commonMain/kotlin/builder/channel/thread/StartThreadBuilder.kt diff --git a/rest/src/main/kotlin/builder/channel/thread/StartThreadWithMessageBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/thread/StartThreadWithMessageBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/channel/thread/StartThreadWithMessageBuilder.kt rename to rest/src/commonMain/kotlin/builder/channel/thread/StartThreadWithMessageBuilder.kt diff --git a/rest/src/main/kotlin/builder/channel/thread/ThreadModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/channel/thread/ThreadModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/channel/thread/ThreadModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/channel/thread/ThreadModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/component/ActionRowBuilder.kt b/rest/src/commonMain/kotlin/builder/component/ActionRowBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/component/ActionRowBuilder.kt rename to rest/src/commonMain/kotlin/builder/component/ActionRowBuilder.kt diff --git a/rest/src/main/kotlin/builder/component/ButtonBuilder.kt b/rest/src/commonMain/kotlin/builder/component/ButtonBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/component/ButtonBuilder.kt rename to rest/src/commonMain/kotlin/builder/component/ButtonBuilder.kt diff --git a/rest/src/main/kotlin/builder/component/ComponentBuilders.kt b/rest/src/commonMain/kotlin/builder/component/ComponentBuilders.kt similarity index 100% rename from rest/src/main/kotlin/builder/component/ComponentBuilders.kt rename to rest/src/commonMain/kotlin/builder/component/ComponentBuilders.kt diff --git a/rest/src/main/kotlin/builder/component/SelectMenuBuilder.kt b/rest/src/commonMain/kotlin/builder/component/SelectMenuBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/component/SelectMenuBuilder.kt rename to rest/src/commonMain/kotlin/builder/component/SelectMenuBuilder.kt diff --git a/rest/src/main/kotlin/builder/component/SelectOptionBuilder.kt b/rest/src/commonMain/kotlin/builder/component/SelectOptionBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/component/SelectOptionBuilder.kt rename to rest/src/commonMain/kotlin/builder/component/SelectOptionBuilder.kt diff --git a/rest/src/main/kotlin/builder/component/TextInputBuilder.kt b/rest/src/commonMain/kotlin/builder/component/TextInputBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/component/TextInputBuilder.kt rename to rest/src/commonMain/kotlin/builder/component/TextInputBuilder.kt diff --git a/rest/src/main/kotlin/builder/guild/EmojiCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/guild/EmojiCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/guild/EmojiCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/guild/EmojiCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/guild/EmojiModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/guild/EmojiModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/guild/EmojiModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/guild/EmojiModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/guild/GuildCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/guild/GuildCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/guild/GuildCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/guild/GuildCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/guild/GuildModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/guild/GuildModifyBuilder.kt similarity index 99% rename from rest/src/main/kotlin/builder/guild/GuildModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/guild/GuildModifyBuilder.kt index ad3c81c10fc3..185ebb5c2952 100644 --- a/rest/src/main/kotlin/builder/guild/GuildModifyBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/guild/GuildModifyBuilder.kt @@ -1,5 +1,6 @@ package dev.kord.rest.builder.guild +import dev.kord.common.Locale import dev.kord.common.annotation.KordDsl import dev.kord.common.entity.* import dev.kord.common.entity.optional.Optional @@ -9,7 +10,6 @@ import dev.kord.common.entity.optional.map import dev.kord.rest.Image import dev.kord.rest.builder.AuditRequestBuilder import dev.kord.rest.json.request.GuildModifyRequest -import java.util.* import kotlin.time.Duration @KordDsl diff --git a/rest/src/main/kotlin/builder/guild/ScheduledEventCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/guild/ScheduledEventCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/guild/ScheduledEventCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/guild/ScheduledEventCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/guild/StickerModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/guild/StickerModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/guild/StickerModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/guild/StickerModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/guild/VoiceStateModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/guild/VoiceStateModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/guild/VoiceStateModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/guild/VoiceStateModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/guild/WelcomeScreenModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/guild/WelcomeScreenModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/guild/WelcomeScreenModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/guild/WelcomeScreenModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/guild/WidgetModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/guild/WidgetModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/guild/WidgetModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/guild/WidgetModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/integration/IntegrationModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/integration/IntegrationModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/integration/IntegrationModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/integration/IntegrationModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/interaction/ApplicationCommandBuilders.kt b/rest/src/commonMain/kotlin/builder/interaction/ApplicationCommandBuilders.kt similarity index 100% rename from rest/src/main/kotlin/builder/interaction/ApplicationCommandBuilders.kt rename to rest/src/commonMain/kotlin/builder/interaction/ApplicationCommandBuilders.kt diff --git a/rest/src/main/kotlin/builder/interaction/ApplicationCommandStateHolder.kt b/rest/src/commonMain/kotlin/builder/interaction/ApplicationCommandStateHolder.kt similarity index 100% rename from rest/src/main/kotlin/builder/interaction/ApplicationCommandStateHolder.kt rename to rest/src/commonMain/kotlin/builder/interaction/ApplicationCommandStateHolder.kt diff --git a/rest/src/main/kotlin/builder/interaction/InputChatBuilders.kt b/rest/src/commonMain/kotlin/builder/interaction/InputChatBuilders.kt similarity index 100% rename from rest/src/main/kotlin/builder/interaction/InputChatBuilders.kt rename to rest/src/commonMain/kotlin/builder/interaction/InputChatBuilders.kt diff --git a/rest/src/main/kotlin/builder/interaction/Localization.kt b/rest/src/commonMain/kotlin/builder/interaction/Localization.kt similarity index 100% rename from rest/src/main/kotlin/builder/interaction/Localization.kt rename to rest/src/commonMain/kotlin/builder/interaction/Localization.kt diff --git a/rest/src/main/kotlin/builder/interaction/MessageCommandBuilders.kt b/rest/src/commonMain/kotlin/builder/interaction/MessageCommandBuilders.kt similarity index 100% rename from rest/src/main/kotlin/builder/interaction/MessageCommandBuilders.kt rename to rest/src/commonMain/kotlin/builder/interaction/MessageCommandBuilders.kt diff --git a/rest/src/main/kotlin/builder/interaction/ModalBuilder.kt b/rest/src/commonMain/kotlin/builder/interaction/ModalBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/interaction/ModalBuilder.kt rename to rest/src/commonMain/kotlin/builder/interaction/ModalBuilder.kt diff --git a/rest/src/main/kotlin/builder/interaction/MultiApplicationCommandBuilder.kt b/rest/src/commonMain/kotlin/builder/interaction/MultiApplicationCommandBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/interaction/MultiApplicationCommandBuilder.kt rename to rest/src/commonMain/kotlin/builder/interaction/MultiApplicationCommandBuilder.kt diff --git a/rest/src/main/kotlin/builder/interaction/OptionsBuilder.kt b/rest/src/commonMain/kotlin/builder/interaction/OptionsBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/interaction/OptionsBuilder.kt rename to rest/src/commonMain/kotlin/builder/interaction/OptionsBuilder.kt diff --git a/rest/src/main/kotlin/builder/interaction/UserCommandBuilders.kt b/rest/src/commonMain/kotlin/builder/interaction/UserCommandBuilders.kt similarity index 100% rename from rest/src/main/kotlin/builder/interaction/UserCommandBuilders.kt rename to rest/src/commonMain/kotlin/builder/interaction/UserCommandBuilders.kt diff --git a/rest/src/main/kotlin/builder/member/MemberAddBuilder.kt b/rest/src/commonMain/kotlin/builder/member/MemberAddBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/member/MemberAddBuilder.kt rename to rest/src/commonMain/kotlin/builder/member/MemberAddBuilder.kt diff --git a/rest/src/main/kotlin/builder/member/MemberModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/member/MemberModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/member/MemberModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/member/MemberModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/message/AllowedMentionsBuilder.kt b/rest/src/commonMain/kotlin/builder/message/AllowedMentionsBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/message/AllowedMentionsBuilder.kt rename to rest/src/commonMain/kotlin/builder/message/AllowedMentionsBuilder.kt diff --git a/rest/src/main/kotlin/builder/message/EmbedBuilder.kt b/rest/src/commonMain/kotlin/builder/message/EmbedBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/message/EmbedBuilder.kt rename to rest/src/commonMain/kotlin/builder/message/EmbedBuilder.kt diff --git a/rest/src/main/kotlin/builder/message/create/FollowupMessageCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/FollowupMessageCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/message/create/FollowupMessageCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/message/create/FollowupMessageCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/message/create/ForumMessageCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/ForumMessageCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/message/create/ForumMessageCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/message/create/ForumMessageCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/message/create/InteractionResponseCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/InteractionResponseCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/message/create/InteractionResponseCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/message/create/InteractionResponseCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/message/create/MessageCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt similarity index 93% rename from rest/src/main/kotlin/builder/message/create/MessageCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt index 025edaf7cf67..3bfc3eef4e05 100644 --- a/rest/src/main/kotlin/builder/message/create/MessageCreateBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt @@ -11,10 +11,7 @@ import dev.kord.rest.builder.message.AllowedMentionsBuilder import dev.kord.rest.builder.message.EmbedBuilder import io.ktor.client.request.forms.* import io.ktor.util.cio.* -import io.ktor.utils.io.jvm.javaio.* -import java.io.InputStream -import java.nio.file.Path -import kotlin.DeprecationLevel.HIDDEN +import kotlin.DeprecationLevel.ERROR import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -88,7 +85,7 @@ public sealed interface MessageCreateBuilder { "io.ktor.client.request.forms.ChannelProvider", "io.ktor.utils.io.jvm.javaio.toByteReadChannel", ), - level = HIDDEN, + level = ERROR, ) public fun addFile(name: String, content: InputStream): NamedFile = addFile(name, ChannelProvider { content.toByteReadChannel() }) @@ -101,13 +98,6 @@ public sealed interface MessageCreateBuilder { files += namedFile return namedFile } - - /** - * Adds a file with the given [path] to the attachments. - */ - public suspend fun addFile(path: Path): NamedFile = - addFile(path.fileName.toString(), ChannelProvider { path.readChannel() }) - } internal fun buildMessageFlags( diff --git a/rest/src/main/kotlin/builder/message/create/UpdateMessageInteractionResponseCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/UpdateMessageInteractionResponseCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/message/create/UpdateMessageInteractionResponseCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/message/create/UpdateMessageInteractionResponseCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/message/create/UserMessageCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/UserMessageCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/message/create/UserMessageCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/message/create/UserMessageCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/message/create/WebhookMessageCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/WebhookMessageCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/message/create/WebhookMessageCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/message/create/WebhookMessageCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/message/modify/FollowupMessageModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/message/modify/FollowupMessageModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/message/modify/FollowupMessageModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/message/modify/FollowupMessageModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/message/modify/InteractionResponseModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/message/modify/InteractionResponseModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/message/modify/InteractionResponseModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/message/modify/InteractionResponseModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/message/modify/MessageModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/message/modify/MessageModifyBuilder.kt similarity index 77% rename from rest/src/main/kotlin/builder/message/modify/MessageModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/message/modify/MessageModifyBuilder.kt index f3706c866517..b1eb09744022 100644 --- a/rest/src/main/kotlin/builder/message/modify/MessageModifyBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/modify/MessageModifyBuilder.kt @@ -10,11 +10,6 @@ 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 io.ktor.util.cio.* -import io.ktor.utils.io.jvm.javaio.* -import java.io.InputStream -import java.nio.file.Path -import kotlin.DeprecationLevel.HIDDEN import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -49,24 +44,6 @@ public sealed interface MessageModifyBuilder { */ public var suppressEmbeds: Boolean? - /** - * Adds a file with the [name] and [content] to the attachments. - * - * @suppress - */ - @Deprecated( - "Use lazy ChannelProvider instead of InputStream. You should also make sure that the stream/channel is only " + - "opened inside the block of the ChannelProvider because it could otherwise be read multiple times " + - "(which isn't allowed).", - ReplaceWith( - "addFile(name, ChannelProvider { content.toByteReadChannel() })", - "io.ktor.client.request.forms.ChannelProvider", - "io.ktor.utils.io.jvm.javaio.toByteReadChannel", - ), - level = HIDDEN, - ) - public fun addFile(name: String, content: InputStream): NamedFile = - addFile(name, ChannelProvider { content.toByteReadChannel() }) /** * Adds a file with the given [path] to the attachments. diff --git a/rest/src/main/kotlin/builder/message/modify/MessageModifyStateHolder.kt b/rest/src/commonMain/kotlin/builder/message/modify/MessageModifyStateHolder.kt similarity index 100% rename from rest/src/main/kotlin/builder/message/modify/MessageModifyStateHolder.kt rename to rest/src/commonMain/kotlin/builder/message/modify/MessageModifyStateHolder.kt diff --git a/rest/src/main/kotlin/builder/message/modify/UserMessageModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/message/modify/UserMessageModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/message/modify/UserMessageModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/message/modify/UserMessageModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/message/modify/WebhookMessageModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/message/modify/WebhookMessageModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/message/modify/WebhookMessageModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/message/modify/WebhookMessageModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/role/RoleCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/role/RoleCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/role/RoleCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/role/RoleCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/role/RoleModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/role/RoleModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/role/RoleModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/role/RoleModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/role/RolePositionsModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/role/RolePositionsModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/role/RolePositionsModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/role/RolePositionsModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/scheduled_events/ScheduledEventModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/scheduled_events/ScheduledEventModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/scheduled_events/ScheduledEventModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/scheduled_events/ScheduledEventModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/stage/StageInstanceCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/stage/StageInstanceCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/stage/StageInstanceCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/stage/StageInstanceCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/stage/StageInstanceModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/stage/StageInstanceModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/stage/StageInstanceModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/stage/StageInstanceModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/template/TemplateBuilders.kt b/rest/src/commonMain/kotlin/builder/template/TemplateBuilders.kt similarity index 100% rename from rest/src/main/kotlin/builder/template/TemplateBuilders.kt rename to rest/src/commonMain/kotlin/builder/template/TemplateBuilders.kt diff --git a/rest/src/main/kotlin/builder/user/CurrentUserModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/user/CurrentUserModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/user/CurrentUserModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/user/CurrentUserModifyBuilder.kt diff --git a/rest/src/main/kotlin/builder/user/GroupDMCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/user/GroupDMCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/user/GroupDMCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/user/GroupDMCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/webhook/WebhookCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/webhook/WebhookCreateBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/webhook/WebhookCreateBuilder.kt rename to rest/src/commonMain/kotlin/builder/webhook/WebhookCreateBuilder.kt diff --git a/rest/src/main/kotlin/builder/webhook/WebhookModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/webhook/WebhookModifyBuilder.kt similarity index 100% rename from rest/src/main/kotlin/builder/webhook/WebhookModifyBuilder.kt rename to rest/src/commonMain/kotlin/builder/webhook/WebhookModifyBuilder.kt diff --git a/rest/src/main/kotlin/json/JsonErrorCode.kt b/rest/src/commonMain/kotlin/json/JsonErrorCode.kt similarity index 100% rename from rest/src/main/kotlin/json/JsonErrorCode.kt rename to rest/src/commonMain/kotlin/json/JsonErrorCode.kt diff --git a/rest/src/main/kotlin/json/request/AuditLogGetRequest.kt b/rest/src/commonMain/kotlin/json/request/AuditLogGetRequest.kt similarity index 100% rename from rest/src/main/kotlin/json/request/AuditLogGetRequest.kt rename to rest/src/commonMain/kotlin/json/request/AuditLogGetRequest.kt diff --git a/rest/src/main/kotlin/json/request/AutoModerationRequests.kt b/rest/src/commonMain/kotlin/json/request/AutoModerationRequests.kt similarity index 100% rename from rest/src/main/kotlin/json/request/AutoModerationRequests.kt rename to rest/src/commonMain/kotlin/json/request/AutoModerationRequests.kt diff --git a/rest/src/main/kotlin/json/request/ChannelFollowRequest.kt b/rest/src/commonMain/kotlin/json/request/ChannelFollowRequest.kt similarity index 100% rename from rest/src/main/kotlin/json/request/ChannelFollowRequest.kt rename to rest/src/commonMain/kotlin/json/request/ChannelFollowRequest.kt diff --git a/rest/src/main/kotlin/json/request/ChannelRequests.kt b/rest/src/commonMain/kotlin/json/request/ChannelRequests.kt similarity index 100% rename from rest/src/main/kotlin/json/request/ChannelRequests.kt rename to rest/src/commonMain/kotlin/json/request/ChannelRequests.kt diff --git a/rest/src/main/kotlin/json/request/EmojiRequests.kt b/rest/src/commonMain/kotlin/json/request/EmojiRequests.kt similarity index 100% rename from rest/src/main/kotlin/json/request/EmojiRequests.kt rename to rest/src/commonMain/kotlin/json/request/EmojiRequests.kt diff --git a/rest/src/main/kotlin/json/request/GuildRequests.kt b/rest/src/commonMain/kotlin/json/request/GuildRequests.kt similarity index 100% rename from rest/src/main/kotlin/json/request/GuildRequests.kt rename to rest/src/commonMain/kotlin/json/request/GuildRequests.kt diff --git a/rest/src/main/kotlin/json/request/InteractionsRequests.kt b/rest/src/commonMain/kotlin/json/request/InteractionsRequests.kt similarity index 100% rename from rest/src/main/kotlin/json/request/InteractionsRequests.kt rename to rest/src/commonMain/kotlin/json/request/InteractionsRequests.kt diff --git a/rest/src/main/kotlin/json/request/InviteCreateRequest.kt b/rest/src/commonMain/kotlin/json/request/InviteCreateRequest.kt similarity index 100% rename from rest/src/main/kotlin/json/request/InviteCreateRequest.kt rename to rest/src/commonMain/kotlin/json/request/InviteCreateRequest.kt diff --git a/rest/src/main/kotlin/json/request/MessageRequests.kt b/rest/src/commonMain/kotlin/json/request/MessageRequests.kt similarity index 100% rename from rest/src/main/kotlin/json/request/MessageRequests.kt rename to rest/src/commonMain/kotlin/json/request/MessageRequests.kt diff --git a/rest/src/main/kotlin/json/request/ScheduledEventRequests.kt b/rest/src/commonMain/kotlin/json/request/ScheduledEventRequests.kt similarity index 100% rename from rest/src/main/kotlin/json/request/ScheduledEventRequests.kt rename to rest/src/commonMain/kotlin/json/request/ScheduledEventRequests.kt diff --git a/rest/src/main/kotlin/json/request/StageInstanceRequests.kt b/rest/src/commonMain/kotlin/json/request/StageInstanceRequests.kt similarity index 100% rename from rest/src/main/kotlin/json/request/StageInstanceRequests.kt rename to rest/src/commonMain/kotlin/json/request/StageInstanceRequests.kt diff --git a/rest/src/main/kotlin/json/request/StickerRequests.kt b/rest/src/commonMain/kotlin/json/request/StickerRequests.kt similarity index 100% rename from rest/src/main/kotlin/json/request/StickerRequests.kt rename to rest/src/commonMain/kotlin/json/request/StickerRequests.kt diff --git a/rest/src/main/kotlin/json/request/TemplateRequests.kt b/rest/src/commonMain/kotlin/json/request/TemplateRequests.kt similarity index 100% rename from rest/src/main/kotlin/json/request/TemplateRequests.kt rename to rest/src/commonMain/kotlin/json/request/TemplateRequests.kt diff --git a/rest/src/main/kotlin/json/request/UserRequests.kt b/rest/src/commonMain/kotlin/json/request/UserRequests.kt similarity index 100% rename from rest/src/main/kotlin/json/request/UserRequests.kt rename to rest/src/commonMain/kotlin/json/request/UserRequests.kt diff --git a/rest/src/main/kotlin/json/request/VoiceStateRequests.kt b/rest/src/commonMain/kotlin/json/request/VoiceStateRequests.kt similarity index 100% rename from rest/src/main/kotlin/json/request/VoiceStateRequests.kt rename to rest/src/commonMain/kotlin/json/request/VoiceStateRequests.kt diff --git a/rest/src/main/kotlin/json/request/WebhookRequests.kt b/rest/src/commonMain/kotlin/json/request/WebhookRequests.kt similarity index 100% rename from rest/src/main/kotlin/json/request/WebhookRequests.kt rename to rest/src/commonMain/kotlin/json/request/WebhookRequests.kt diff --git a/rest/src/main/kotlin/json/response/BanResponse.kt b/rest/src/commonMain/kotlin/json/response/BanResponse.kt similarity index 100% rename from rest/src/main/kotlin/json/response/BanResponse.kt rename to rest/src/commonMain/kotlin/json/response/BanResponse.kt diff --git a/rest/src/main/kotlin/json/response/Channel.kt b/rest/src/commonMain/kotlin/json/response/Channel.kt similarity index 100% rename from rest/src/main/kotlin/json/response/Channel.kt rename to rest/src/commonMain/kotlin/json/response/Channel.kt diff --git a/rest/src/main/kotlin/json/response/Connection.kt b/rest/src/commonMain/kotlin/json/response/Connection.kt similarity index 100% rename from rest/src/main/kotlin/json/response/Connection.kt rename to rest/src/commonMain/kotlin/json/response/Connection.kt diff --git a/rest/src/main/kotlin/json/response/CurrentUserNicknameModifyResponse.kt b/rest/src/commonMain/kotlin/json/response/CurrentUserNicknameModifyResponse.kt similarity index 100% rename from rest/src/main/kotlin/json/response/CurrentUserNicknameModifyResponse.kt rename to rest/src/commonMain/kotlin/json/response/CurrentUserNicknameModifyResponse.kt diff --git a/rest/src/main/kotlin/json/response/DiscordErrorResponse.kt b/rest/src/commonMain/kotlin/json/response/DiscordErrorResponse.kt similarity index 100% rename from rest/src/main/kotlin/json/response/DiscordErrorResponse.kt rename to rest/src/commonMain/kotlin/json/response/DiscordErrorResponse.kt diff --git a/rest/src/main/kotlin/json/response/FollowedChannelResponse.kt b/rest/src/commonMain/kotlin/json/response/FollowedChannelResponse.kt similarity index 100% rename from rest/src/main/kotlin/json/response/FollowedChannelResponse.kt rename to rest/src/commonMain/kotlin/json/response/FollowedChannelResponse.kt diff --git a/rest/src/main/kotlin/json/response/Gateway.kt b/rest/src/commonMain/kotlin/json/response/Gateway.kt similarity index 100% rename from rest/src/main/kotlin/json/response/Gateway.kt rename to rest/src/commonMain/kotlin/json/response/Gateway.kt diff --git a/rest/src/main/kotlin/json/response/GuildMFALevelModifyResponse.kt b/rest/src/commonMain/kotlin/json/response/GuildMFALevelModifyResponse.kt similarity index 100% rename from rest/src/main/kotlin/json/response/GuildMFALevelModifyResponse.kt rename to rest/src/commonMain/kotlin/json/response/GuildMFALevelModifyResponse.kt diff --git a/rest/src/main/kotlin/json/response/Prune.kt b/rest/src/commonMain/kotlin/json/response/Prune.kt similarity index 100% rename from rest/src/main/kotlin/json/response/Prune.kt rename to rest/src/commonMain/kotlin/json/response/Prune.kt diff --git a/rest/src/main/kotlin/ratelimit/AbstractRateLimiter.kt b/rest/src/commonMain/kotlin/ratelimit/AbstractRateLimiter.kt similarity index 94% rename from rest/src/main/kotlin/ratelimit/AbstractRateLimiter.kt rename to rest/src/commonMain/kotlin/ratelimit/AbstractRateLimiter.kt index 08d31e2577bc..2afe10e8f122 100644 --- a/rest/src/main/kotlin/ratelimit/AbstractRateLimiter.kt +++ b/rest/src/commonMain/kotlin/ratelimit/AbstractRateLimiter.kt @@ -1,5 +1,6 @@ package dev.kord.rest.ratelimit +import co.touchlab.stately.collections.ConcurrentMutableMap import dev.kord.common.ratelimit.IntervalRateLimiter import dev.kord.rest.request.Request import dev.kord.rest.request.RequestIdentifier @@ -11,17 +12,15 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.sync.Mutex import kotlinx.datetime.Clock import mu.KLogger -import java.util.concurrent.ConcurrentHashMap import kotlin.time.Duration.Companion.minutes - public abstract class AbstractRateLimiter internal constructor(public val clock: Clock) : RequestRateLimiter { internal abstract val logger: KLogger internal val autoBanRateLimiter = IntervalRateLimiter(limit = 25000, interval = 10.minutes) private val globalSuspensionPoint = atomic(Reset(clock.now())) - internal val buckets = ConcurrentHashMap() - internal val routeBuckets = ConcurrentHashMap>() + internal val buckets = ConcurrentMutableMap() + internal val routeBuckets = ConcurrentMutableMap>() internal val BucketKey.bucket get() = buckets.getOrPut(this) { Bucket(this) } internal val Request<*, *>.buckets get() = routeBuckets[identifier].orEmpty().map { it.bucket } diff --git a/rest/src/main/kotlin/ratelimit/ExclusionRequestRateLimiter.kt b/rest/src/commonMain/kotlin/ratelimit/ExclusionRequestRateLimiter.kt similarity index 100% rename from rest/src/main/kotlin/ratelimit/ExclusionRequestRateLimiter.kt rename to rest/src/commonMain/kotlin/ratelimit/ExclusionRequestRateLimiter.kt diff --git a/rest/src/main/kotlin/ratelimit/ParallelRequestRateLimiter.kt b/rest/src/commonMain/kotlin/ratelimit/ParallelRequestRateLimiter.kt similarity index 100% rename from rest/src/main/kotlin/ratelimit/ParallelRequestRateLimiter.kt rename to rest/src/commonMain/kotlin/ratelimit/ParallelRequestRateLimiter.kt diff --git a/rest/src/main/kotlin/ratelimit/RequestRateLimiter.kt b/rest/src/commonMain/kotlin/ratelimit/RequestRateLimiter.kt similarity index 99% rename from rest/src/main/kotlin/ratelimit/RequestRateLimiter.kt rename to rest/src/commonMain/kotlin/ratelimit/RequestRateLimiter.kt index 7ad15688e1e0..02580df0ba27 100644 --- a/rest/src/main/kotlin/ratelimit/RequestRateLimiter.kt +++ b/rest/src/commonMain/kotlin/ratelimit/RequestRateLimiter.kt @@ -4,6 +4,7 @@ import dev.kord.rest.request.Request import kotlinx.datetime.Instant import kotlin.contracts.InvocationKind import kotlin.contracts.contract +import kotlin.jvm.JvmInline /** * A rate limiter that follows [Discord's rate limits](https://discord.com/developers/docs/topics/rate-limits) for diff --git a/rest/src/commonMain/kotlin/request/HttpEngine.kt b/rest/src/commonMain/kotlin/request/HttpEngine.kt new file mode 100644 index 000000000000..4808a37cc883 --- /dev/null +++ b/rest/src/commonMain/kotlin/request/HttpEngine.kt @@ -0,0 +1,5 @@ +package dev.kord.rest.request + +import io.ktor.client.engine.* + +internal expect object HttpEngine : HttpClientEngineFactory diff --git a/rest/src/main/kotlin/request/HttpUtils.kt b/rest/src/commonMain/kotlin/request/HttpUtils.kt similarity index 98% rename from rest/src/main/kotlin/request/HttpUtils.kt rename to rest/src/commonMain/kotlin/request/HttpUtils.kt index 0e95ee3d96f9..3169e6fffa1e 100644 --- a/rest/src/main/kotlin/request/HttpUtils.kt +++ b/rest/src/commonMain/kotlin/request/HttpUtils.kt @@ -56,7 +56,7 @@ public fun HttpResponse.logString(body: String): String = "[RESPONSE]:${status.value}:${call.request.method.value}:${call.request.url} body:$body" public suspend fun HttpResponse.errorString(): String { - val message = String(this.readBytes()) + val message = bodyAsText() return logString(message) } diff --git a/rest/src/main/kotlin/request/KtorRequestHandler.kt b/rest/src/commonMain/kotlin/request/KtorRequestHandler.kt similarity index 97% rename from rest/src/main/kotlin/request/KtorRequestHandler.kt rename to rest/src/commonMain/kotlin/request/KtorRequestHandler.kt index 63fa4115936f..5ca8f01b8a57 100644 --- a/rest/src/main/kotlin/request/KtorRequestHandler.kt +++ b/rest/src/commonMain/kotlin/request/KtorRequestHandler.kt @@ -4,7 +4,6 @@ import dev.kord.rest.json.response.DiscordErrorResponse import dev.kord.rest.ratelimit.* import dev.kord.rest.route.optional import io.ktor.client.* -import io.ktor.client.engine.cio.* import io.ktor.client.request.* import io.ktor.client.request.forms.* import io.ktor.client.statement.* @@ -37,7 +36,7 @@ public class KtorRequestHandler( private val parser: Json = jsonDefault, override val token: String ) : RequestHandler { - private val logger = KotlinLogging.logger("[R]:[KTOR]:[${requestRateLimiter.javaClass.simpleName}]") + private val logger = KotlinLogging.logger("[R]:[KTOR]:[${requestRateLimiter::class.simpleName}]") override tailrec suspend fun handle(request: Request): R { val response = requestRateLimiter.consume(request) { @@ -108,7 +107,7 @@ public fun KtorRequestHandler( clock: Clock = Clock.System, parser: Json = jsonDefault, ): KtorRequestHandler { - val client = HttpClient(CIO) { + val client = HttpClient(HttpEngine) { expectSuccess = false } return KtorRequestHandler(client, requestRateLimiter, clock, parser, token) diff --git a/rest/src/main/kotlin/request/Request.kt b/rest/src/commonMain/kotlin/request/Request.kt similarity index 100% rename from rest/src/main/kotlin/request/Request.kt rename to rest/src/commonMain/kotlin/request/Request.kt diff --git a/rest/src/main/kotlin/request/RequestBuilder.kt b/rest/src/commonMain/kotlin/request/RequestBuilder.kt similarity index 69% rename from rest/src/main/kotlin/request/RequestBuilder.kt rename to rest/src/commonMain/kotlin/request/RequestBuilder.kt index ce17d61c897e..255bcd4fc611 100644 --- a/rest/src/main/kotlin/request/RequestBuilder.kt +++ b/rest/src/commonMain/kotlin/request/RequestBuilder.kt @@ -5,11 +5,7 @@ import dev.kord.rest.NamedFile import dev.kord.rest.route.Route import io.ktor.client.request.forms.* import io.ktor.http.* -import io.ktor.util.cio.* import kotlinx.serialization.SerializationStrategy -import java.io.InputStream -import java.nio.file.Path -import kotlin.DeprecationLevel.HIDDEN public class RequestBuilder(public val route: Route, keySize: Int = 2) { @@ -52,27 +48,6 @@ public class RequestBuilder(public val route: Route, keySize: Int = 2) { headers.append(key, value) } - /** @suppress */ - @Deprecated( - "Use lazy ChannelProvider instead of InputStream. You should also make sure that the stream/channel is only " + - "opened inside the block of the ChannelProvider because it could otherwise be read multiple times " + - "(which isn't allowed).", - ReplaceWith( - "file(name, ChannelProvider { content.toByteReadChannel() })", - "io.ktor.client.request.forms.ChannelProvider", - "io.ktor.utils.io.jvm.javaio.toByteReadChannel", - ), - level = HIDDEN, - ) - @Suppress("DEPRECATION_ERROR") - public fun file(name: String, input: InputStream) { - files.add(NamedFile(input, name)) - } - - public fun file(path: Path) { - file(path.fileName.toString(), ChannelProvider { path.readChannel() }) - } - public fun file(name: String, contentProvider: ChannelProvider) { files.add(NamedFile(name, contentProvider)) } diff --git a/rest/src/main/kotlin/request/RequestHandler.kt b/rest/src/commonMain/kotlin/request/RequestHandler.kt similarity index 100% rename from rest/src/main/kotlin/request/RequestHandler.kt rename to rest/src/commonMain/kotlin/request/RequestHandler.kt diff --git a/rest/src/main/kotlin/request/RestRequestException.kt b/rest/src/commonMain/kotlin/request/RestRequestException.kt similarity index 100% rename from rest/src/main/kotlin/request/RestRequestException.kt rename to rest/src/commonMain/kotlin/request/RestRequestException.kt diff --git a/rest/src/main/kotlin/request/StackTraceRecoveringKtorRequestHandler.kt b/rest/src/commonMain/kotlin/request/StackTraceRecoveringKtorRequestHandler.kt similarity index 79% rename from rest/src/main/kotlin/request/StackTraceRecoveringKtorRequestHandler.kt rename to rest/src/commonMain/kotlin/request/StackTraceRecoveringKtorRequestHandler.kt index 47b4c0bb382c..66e3704c6921 100644 --- a/rest/src/main/kotlin/request/StackTraceRecoveringKtorRequestHandler.kt +++ b/rest/src/commonMain/kotlin/request/StackTraceRecoveringKtorRequestHandler.kt @@ -29,15 +29,9 @@ public class StackTraceRecoveringKtorRequestHandler(private val delegate: KtorRe } /** A [Throwable] used to save the current stack trace before executing a request. */ -internal class RecoveredStackTrace : Throwable("This is the recovered stack trace:") { +internal class RecoveredStackTrace : Throwable("This is the recovered stack trace:") - fun sanitizeStackTrace() { - // Remove artifacts of stack trace capturing. - // The first stack trace element is the creation of the RecoveredStackTrace: - // at dev.kord.rest.request.StackTraceRecoveringKtorRequestHandler.handle(StackTraceRecoveringKtorRequestHandler.kt:19) - stackTrace = stackTrace.copyOfRange(1, stackTrace.size) - } -} +internal expect fun RecoveredStackTrace.sanitizeStackTrace() /** * Returns a new [RequestHandler] with stack trace recovery enabled. diff --git a/rest/src/main/kotlin/route/CdnUrl.kt b/rest/src/commonMain/kotlin/route/CdnUrl.kt similarity index 100% rename from rest/src/main/kotlin/route/CdnUrl.kt rename to rest/src/commonMain/kotlin/route/CdnUrl.kt diff --git a/rest/src/main/kotlin/route/DiscordCdn.kt b/rest/src/commonMain/kotlin/route/DiscordCdn.kt similarity index 100% rename from rest/src/main/kotlin/route/DiscordCdn.kt rename to rest/src/commonMain/kotlin/route/DiscordCdn.kt diff --git a/rest/src/main/kotlin/route/Position.kt b/rest/src/commonMain/kotlin/route/Position.kt similarity index 100% rename from rest/src/main/kotlin/route/Position.kt rename to rest/src/commonMain/kotlin/route/Position.kt diff --git a/rest/src/main/kotlin/route/Route.kt b/rest/src/commonMain/kotlin/route/Route.kt similarity index 100% rename from rest/src/main/kotlin/route/Route.kt rename to rest/src/commonMain/kotlin/route/Route.kt diff --git a/rest/src/main/kotlin/service/ApplicationService.kt b/rest/src/commonMain/kotlin/service/ApplicationService.kt similarity index 100% rename from rest/src/main/kotlin/service/ApplicationService.kt rename to rest/src/commonMain/kotlin/service/ApplicationService.kt diff --git a/rest/src/main/kotlin/service/AuditLogService.kt b/rest/src/commonMain/kotlin/service/AuditLogService.kt similarity index 100% rename from rest/src/main/kotlin/service/AuditLogService.kt rename to rest/src/commonMain/kotlin/service/AuditLogService.kt diff --git a/rest/src/main/kotlin/service/AutoModerationService.kt b/rest/src/commonMain/kotlin/service/AutoModerationService.kt similarity index 100% rename from rest/src/main/kotlin/service/AutoModerationService.kt rename to rest/src/commonMain/kotlin/service/AutoModerationService.kt diff --git a/rest/src/main/kotlin/service/ChannelService.kt b/rest/src/commonMain/kotlin/service/ChannelService.kt similarity index 100% rename from rest/src/main/kotlin/service/ChannelService.kt rename to rest/src/commonMain/kotlin/service/ChannelService.kt diff --git a/rest/src/main/kotlin/service/EmojiService.kt b/rest/src/commonMain/kotlin/service/EmojiService.kt similarity index 100% rename from rest/src/main/kotlin/service/EmojiService.kt rename to rest/src/commonMain/kotlin/service/EmojiService.kt diff --git a/rest/src/main/kotlin/service/GuildService.kt b/rest/src/commonMain/kotlin/service/GuildService.kt similarity index 100% rename from rest/src/main/kotlin/service/GuildService.kt rename to rest/src/commonMain/kotlin/service/GuildService.kt diff --git a/rest/src/main/kotlin/service/InteractionService.kt b/rest/src/commonMain/kotlin/service/InteractionService.kt similarity index 100% rename from rest/src/main/kotlin/service/InteractionService.kt rename to rest/src/commonMain/kotlin/service/InteractionService.kt diff --git a/rest/src/main/kotlin/service/InviteService.kt b/rest/src/commonMain/kotlin/service/InviteService.kt similarity index 100% rename from rest/src/main/kotlin/service/InviteService.kt rename to rest/src/commonMain/kotlin/service/InviteService.kt diff --git a/rest/src/main/kotlin/service/RestClient.kt b/rest/src/commonMain/kotlin/service/RestClient.kt similarity index 100% rename from rest/src/main/kotlin/service/RestClient.kt rename to rest/src/commonMain/kotlin/service/RestClient.kt diff --git a/rest/src/main/kotlin/service/RestService.kt b/rest/src/commonMain/kotlin/service/RestService.kt similarity index 100% rename from rest/src/main/kotlin/service/RestService.kt rename to rest/src/commonMain/kotlin/service/RestService.kt diff --git a/rest/src/main/kotlin/service/StageInstanceService.kt b/rest/src/commonMain/kotlin/service/StageInstanceService.kt similarity index 100% rename from rest/src/main/kotlin/service/StageInstanceService.kt rename to rest/src/commonMain/kotlin/service/StageInstanceService.kt diff --git a/rest/src/main/kotlin/service/StickerService.kt b/rest/src/commonMain/kotlin/service/StickerService.kt similarity index 100% rename from rest/src/main/kotlin/service/StickerService.kt rename to rest/src/commonMain/kotlin/service/StickerService.kt diff --git a/rest/src/main/kotlin/service/TemplateService.kt b/rest/src/commonMain/kotlin/service/TemplateService.kt similarity index 100% rename from rest/src/main/kotlin/service/TemplateService.kt rename to rest/src/commonMain/kotlin/service/TemplateService.kt diff --git a/rest/src/main/kotlin/service/UserService.kt b/rest/src/commonMain/kotlin/service/UserService.kt similarity index 100% rename from rest/src/main/kotlin/service/UserService.kt rename to rest/src/commonMain/kotlin/service/UserService.kt diff --git a/rest/src/main/kotlin/service/VoiceService.kt b/rest/src/commonMain/kotlin/service/VoiceService.kt similarity index 100% rename from rest/src/main/kotlin/service/VoiceService.kt rename to rest/src/commonMain/kotlin/service/VoiceService.kt diff --git a/rest/src/main/kotlin/service/WebhookService.kt b/rest/src/commonMain/kotlin/service/WebhookService.kt similarity index 100% rename from rest/src/main/kotlin/service/WebhookService.kt rename to rest/src/commonMain/kotlin/service/WebhookService.kt diff --git a/rest/src/test/kotlin/Utils.kt b/rest/src/commonTest/kotlin/Utils.kt similarity index 100% rename from rest/src/test/kotlin/Utils.kt rename to rest/src/commonTest/kotlin/Utils.kt diff --git a/rest/src/test/kotlin/builder/CategoryModifyBuilderTest.kt b/rest/src/commonTest/kotlin/builder/CategoryModifyBuilderTest.kt similarity index 61% rename from rest/src/test/kotlin/builder/CategoryModifyBuilderTest.kt rename to rest/src/commonTest/kotlin/builder/CategoryModifyBuilderTest.kt index 5362f8a814bf..7a2efe73d386 100644 --- a/rest/src/test/kotlin/builder/CategoryModifyBuilderTest.kt +++ b/rest/src/commonTest/kotlin/builder/CategoryModifyBuilderTest.kt @@ -1,20 +1,21 @@ package dev.kord.rest.builder -import dev.kord.common.entity.Overwrite import dev.kord.common.entity.optional.Optional import dev.kord.rest.builder.channel.CategoryModifyBuilder -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.Test +import kotlin.test.assertEquals class CategoryModifyBuilderTest { @Test + @JsName("test1") fun `builder does not create empty overwrites by default`() { val builder = CategoryModifyBuilder() val request = builder.toRequest() - Assertions.assertEquals(Optional.Missing>(), request.permissionOverwrites) + assertEquals(Optional.Missing(), request.permissionOverwrites) } -} \ No newline at end of file +} diff --git a/rest/src/test/kotlin/builder/EditGuildChannelBuilderTest.kt b/rest/src/commonTest/kotlin/builder/EditGuildChannelBuilderTest.kt similarity index 57% rename from rest/src/test/kotlin/builder/EditGuildChannelBuilderTest.kt rename to rest/src/commonTest/kotlin/builder/EditGuildChannelBuilderTest.kt index 8164160e7245..bbce3de7fd79 100644 --- a/rest/src/test/kotlin/builder/EditGuildChannelBuilderTest.kt +++ b/rest/src/commonTest/kotlin/builder/EditGuildChannelBuilderTest.kt @@ -1,44 +1,41 @@ package dev.kord.rest.builder -import dev.kord.common.entity.Overwrite import dev.kord.common.entity.optional.Optional import dev.kord.rest.builder.channel.NewsChannelModifyBuilder import dev.kord.rest.builder.channel.TextChannelModifyBuilder import dev.kord.rest.builder.channel.VoiceChannelModifyBuilder -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.Test +import kotlin.test.assertEquals class EditGuildChannelBuilderTest { - /* - 2020-11-16 Kotlin 1.4.20 - You might think these explicit generic types to be unneeded, but the kotlin compiler - won't be able to generate valid bytecode without them. Remove with care. - */ - @Test + @JsName("test1") fun `text builder does not create empty overwrites by default`() { val builder = TextChannelModifyBuilder() val request = builder.toRequest() - Assertions.assertEquals(Optional.Missing>(), request.permissionOverwrites) + assertEquals(Optional.Missing(), request.permissionOverwrites) } @Test + @JsName("test2") fun `voice builder does not create empty overwrites by default`() { val builder = VoiceChannelModifyBuilder() val request = builder.toRequest() - Assertions.assertEquals(Optional.Missing>(), request.permissionOverwrites) + assertEquals(Optional.Missing(), request.permissionOverwrites) } @Test + @JsName("test3") fun `news builder does not create empty overwrites by default`() { val builder = NewsChannelModifyBuilder() val request = builder.toRequest() - Assertions.assertEquals(Optional.Missing>(), request.permissionOverwrites) + assertEquals(Optional.Missing(), request.permissionOverwrites) } } diff --git a/rest/src/test/kotlin/builder/EmojiModifyBuilderTest.kt b/rest/src/commonTest/kotlin/builder/EmojiModifyBuilderTest.kt similarity index 59% rename from rest/src/test/kotlin/builder/EmojiModifyBuilderTest.kt rename to rest/src/commonTest/kotlin/builder/EmojiModifyBuilderTest.kt index 416010494d8b..c497dd6a93a3 100644 --- a/rest/src/test/kotlin/builder/EmojiModifyBuilderTest.kt +++ b/rest/src/commonTest/kotlin/builder/EmojiModifyBuilderTest.kt @@ -1,18 +1,19 @@ -import dev.kord.common.entity.Snowflake import dev.kord.common.entity.optional.Optional import dev.kord.rest.builder.guild.EmojiModifyBuilder -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.Test +import kotlin.test.assertEquals class EmojiModifyBuilderTest { @Test + @JsName("test1") fun `builder does not create empty roles by default`() { val builder = EmojiModifyBuilder() val request = builder.toRequest() - Assertions.assertEquals(Optional.Missing>(), request.roles) + assertEquals(Optional.Missing(), request.roles) } -} \ No newline at end of file +} diff --git a/rest/src/test/kotlin/builder/MemberModifyBuilderTest.kt b/rest/src/commonTest/kotlin/builder/MemberModifyBuilderTest.kt similarity index 62% rename from rest/src/test/kotlin/builder/MemberModifyBuilderTest.kt rename to rest/src/commonTest/kotlin/builder/MemberModifyBuilderTest.kt index 204fba534d53..966f7c1a9826 100644 --- a/rest/src/test/kotlin/builder/MemberModifyBuilderTest.kt +++ b/rest/src/commonTest/kotlin/builder/MemberModifyBuilderTest.kt @@ -1,20 +1,21 @@ package dev.kord.rest.builder -import dev.kord.common.entity.Snowflake import dev.kord.common.entity.optional.Optional import dev.kord.rest.builder.member.MemberModifyBuilder -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.Test +import kotlin.test.assertEquals class MemberModifyBuilderTest { @Test + @JsName("test1") fun `builder does not create empty roles by default`() { val builder = MemberModifyBuilder() val request = builder.toRequest() - Assertions.assertEquals(Optional.Missing>(), request.roles) + assertEquals(Optional.Missing(), request.roles) } -} \ No newline at end of file +} diff --git a/rest/src/test/kotlin/builder/guild/GuildModifyBuilderTest.kt b/rest/src/commonTest/kotlin/builder/guild/GuildModifyBuilderTest.kt similarity index 61% rename from rest/src/test/kotlin/builder/guild/GuildModifyBuilderTest.kt rename to rest/src/commonTest/kotlin/builder/guild/GuildModifyBuilderTest.kt index 0762bd31f443..9404eaf5746a 100644 --- a/rest/src/test/kotlin/builder/guild/GuildModifyBuilderTest.kt +++ b/rest/src/commonTest/kotlin/builder/guild/GuildModifyBuilderTest.kt @@ -1,16 +1,18 @@ package dev.kord.rest.builder.guild +import dev.kord.common.Locale import dev.kord.common.entity.optional.Optional -import org.junit.jupiter.api.Assertions.* -import org.junit.jupiter.api.Test -import java.util.* +import kotlin.js.JsName +import kotlin.test.Test +import kotlin.test.assertEquals internal class GuildModifyBuilderTest { @Test + @JsName("test1") fun `builder omits non -region and -language`() { val builder = GuildModifyBuilder() - builder.preferredLocale = Locale.Builder().setLanguage("en").setRegion("gb").addUnicodeLocaleAttribute("short").build() + builder.preferredLocale = Locale.ENGLISH_GREAT_BRITAIN val request = builder.toRequest() assertEquals(Optional.Value("en-GB"), request.preferredLocale) diff --git a/rest/src/test/kotlin/json/AuditLogResponseTest.kt b/rest/src/commonTest/kotlin/json/AuditLogResponseTest.kt similarity index 63% rename from rest/src/test/kotlin/json/AuditLogResponseTest.kt rename to rest/src/commonTest/kotlin/json/AuditLogResponseTest.kt index 7671c9cde793..f0d5d2d84bc4 100644 --- a/rest/src/test/kotlin/json/AuditLogResponseTest.kt +++ b/rest/src/commonTest/kotlin/json/AuditLogResponseTest.kt @@ -1,19 +1,23 @@ package dev.kord.rest.json import dev.kord.common.entity.DiscordAuditLog +import kotlinx.coroutines.test.runTest import kotlinx.serialization.json.Json -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.Test object AuditLogResponseTest { @Test - fun `AuditLogResponseSerialization serialization`() { + @JsName("test1") + fun `AuditLogResponseSerialization serialization`() = runTest { val json = file("auditlog") + @Suppress("UNUSED_VARIABLE") val log = Json.decodeFromString(DiscordAuditLog.serializer(), json) } -} \ No newline at end of file +} diff --git a/rest/src/test/kotlin/json/ErrorTest.kt b/rest/src/commonTest/kotlin/json/ErrorTest.kt similarity index 78% rename from rest/src/test/kotlin/json/ErrorTest.kt rename to rest/src/commonTest/kotlin/json/ErrorTest.kt index acc30485b098..7b641c3b2180 100644 --- a/rest/src/test/kotlin/json/ErrorTest.kt +++ b/rest/src/commonTest/kotlin/json/ErrorTest.kt @@ -1,8 +1,10 @@ package dev.kord.rest.json import dev.kord.rest.json.response.DiscordErrorResponse +import kotlinx.coroutines.test.runTest import kotlinx.serialization.json.Json -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.Test import kotlin.test.assertEquals class ErrorTest { @@ -14,7 +16,8 @@ class ErrorTest { } @Test - fun `correctly serialize error`() { + @JsName("test1") + fun `correctly serialize error`() = runTest { val content = file("error") val parsed = parser.decodeFromString(DiscordErrorResponse.serializer(), content) assertEquals(40001, parsed.code.code) diff --git a/rest/src/commonTest/kotlin/json/Util.kt b/rest/src/commonTest/kotlin/json/Util.kt new file mode 100644 index 000000000000..50bd760c501f --- /dev/null +++ b/rest/src/commonTest/kotlin/json/Util.kt @@ -0,0 +1,6 @@ +package dev.kord.rest.json + +import io.ktor.utils.io.* + +internal expect suspend fun file(name: String): String +internal expect suspend fun readFile(name: String): ByteReadChannel diff --git a/rest/src/test/kotlin/ratelimit/AbstractRequestRateLimiterTest.kt b/rest/src/commonTest/kotlin/ratelimit/AbstractRequestRateLimiterTest.kt similarity index 97% rename from rest/src/test/kotlin/ratelimit/AbstractRequestRateLimiterTest.kt rename to rest/src/commonTest/kotlin/ratelimit/AbstractRequestRateLimiterTest.kt index 38a2a8902624..fcd328213564 100644 --- a/rest/src/test/kotlin/ratelimit/AbstractRequestRateLimiterTest.kt +++ b/rest/src/commonTest/kotlin/ratelimit/AbstractRequestRateLimiterTest.kt @@ -10,6 +10,7 @@ import kotlinx.coroutines.withTimeout import kotlinx.coroutines.withTimeoutOrNull import kotlinx.datetime.Clock import kotlinx.datetime.Instant +import kotlin.js.JsName import kotlin.test.Test import kotlin.test.assertEquals import kotlin.time.Duration.Companion.seconds @@ -85,6 +86,7 @@ abstract class AbstractRequestRateLimiterTest { } @Test + @JsName("test1") fun `concurrent requests on the same route are handled sequentially`() = runTest { val clock = TestClock(instant, this) val rateLimiter = newRequestRateLimiter(clock) @@ -102,6 +104,7 @@ abstract class AbstractRequestRateLimiterTest { } @Test + @JsName("test2") fun `a RequestRateLimiter will suspend for rate limited requests with the same identifier`() = runTest { val clock = TestClock(instant, this) val rateLimiter = newRequestRateLimiter(clock) @@ -113,6 +116,7 @@ abstract class AbstractRequestRateLimiterTest { } @Test + @JsName("test3") fun `a RequestRateLimiter will suspend for rate limited requests with the same bucket`() = runTest { val clock = TestClock(instant, this) val rateLimiter = newRequestRateLimiter(clock) @@ -125,6 +129,7 @@ abstract class AbstractRequestRateLimiterTest { } @Test + @JsName("test4") fun `a RequestRateLimiter will not suspend for rate limited requests that don't share an identifier`() = runTest { val clock = TestClock(instant, this) val rateLimiter = newRequestRateLimiter(clock) @@ -137,6 +142,7 @@ abstract class AbstractRequestRateLimiterTest { } @Test + @JsName("test5") fun `an exception during the handling won't lock the handler`() = runTest { val clock = TestClock(instant, this) val rateLimiter = newRequestRateLimiter(clock) @@ -163,6 +169,7 @@ abstract class AbstractRequestRateLimiterTest { } @Test + @JsName("test6") fun `REGRESSION a RequestRateLimiter encountering a non 429 error response will not throw`() = runTest { val clock = TestClock(instant, this) val rateLimiter = newRequestRateLimiter(clock) diff --git a/rest/src/test/kotlin/ratelimit/ExclusionRequestRateLimiterTest.kt b/rest/src/commonTest/kotlin/ratelimit/ExclusionRequestRateLimiterTest.kt similarity index 100% rename from rest/src/test/kotlin/ratelimit/ExclusionRequestRateLimiterTest.kt rename to rest/src/commonTest/kotlin/ratelimit/ExclusionRequestRateLimiterTest.kt diff --git a/rest/src/test/kotlin/ratelimit/ParallelRequestRateLimiterTest.kt b/rest/src/commonTest/kotlin/ratelimit/ParallelRequestRateLimiterTest.kt similarity index 100% rename from rest/src/test/kotlin/ratelimit/ParallelRequestRateLimiterTest.kt rename to rest/src/commonTest/kotlin/ratelimit/ParallelRequestRateLimiterTest.kt diff --git a/rest/src/test/kotlin/ratelimit/TestClock.kt b/rest/src/commonTest/kotlin/ratelimit/TestClock.kt similarity index 100% rename from rest/src/test/kotlin/ratelimit/TestClock.kt rename to rest/src/commonTest/kotlin/ratelimit/TestClock.kt diff --git a/rest/src/test/kotlin/request/MessageRequests.kt b/rest/src/commonTest/kotlin/request/MessageRequests.kt similarity index 74% rename from rest/src/test/kotlin/request/MessageRequests.kt rename to rest/src/commonTest/kotlin/request/MessageRequests.kt index 29ae89a92145..3a8e2b92672a 100644 --- a/rest/src/test/kotlin/request/MessageRequests.kt +++ b/rest/src/commonTest/kotlin/request/MessageRequests.kt @@ -5,17 +5,21 @@ import dev.kord.common.entity.DiscordMessage import dev.kord.common.entity.DiscordUser import dev.kord.common.entity.MessageType.Default import dev.kord.common.entity.Snowflake +import dev.kord.rest.json.readFile import dev.kord.rest.service.ChannelService import io.ktor.client.* import io.ktor.client.engine.mock.* import io.ktor.client.request.forms.* import io.ktor.util.cio.* -import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.test.runTest import kotlinx.datetime.Clock import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import org.junit.jupiter.api.Test -import kotlin.io.path.toPath +import kotlin.js.JsName +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertTrue private val mockId = Snowflake(42) private const val fileName = "linus.png" @@ -46,7 +50,8 @@ private val mockMessage = DiscordMessage( class MessageRequests { @Test - fun `attachment channel is read and closed lazily`() = runBlocking { + @JsName("test1") + fun `attachment channel is read and closed lazily`() = runTest { val mockEngine = MockEngine { request -> request.body.toByteArray() // `toByteArray()` reads `fileChannel` @@ -56,21 +61,20 @@ class MessageRequests { val channelService = ChannelService(KtorRequestHandler(client = HttpClient(mockEngine), token = "")) - val fileChannel = ClassLoader.getSystemResource("images/kord.png").toURI().toPath().readChannel() + val fileChannel = readFile("images/kord.png") with(fileChannel) { - assert(!isClosedForWrite) - assert(!isClosedForRead) - assert(totalBytesRead == 0L) + assertFalse(isClosedForRead) + assertTrue(totalBytesRead == 0L) val createdMessage = channelService.createMessage(mockId) { addFile(fileName, ChannelProvider { fileChannel }) } - assert(createdMessage == mockMessage) + assertEquals(createdMessage, mockMessage) - assert(isClosedForWrite) - assert(isClosedForRead) - assert(totalBytesRead > 0L) + assertTrue(isClosedForWrite) + assertTrue(isClosedForRead) + assertTrue(totalBytesRead > 0L) } } } diff --git a/rest/src/test/resources/images/gitlab.png b/rest/src/commonTest/resources/images/gitlab.png similarity index 100% rename from rest/src/test/resources/images/gitlab.png rename to rest/src/commonTest/resources/images/gitlab.png diff --git a/rest/src/test/resources/images/kord.png b/rest/src/commonTest/resources/images/kord.png similarity index 100% rename from rest/src/test/resources/images/kord.png rename to rest/src/commonTest/resources/images/kord.png diff --git a/rest/src/test/resources/json/auditlog.json b/rest/src/commonTest/resources/json/auditlog.json similarity index 100% rename from rest/src/test/resources/json/auditlog.json rename to rest/src/commonTest/resources/json/auditlog.json diff --git a/rest/src/test/resources/json/error.json b/rest/src/commonTest/resources/json/error.json similarity index 100% rename from rest/src/test/resources/json/error.json rename to rest/src/commonTest/resources/json/error.json diff --git a/rest/src/test/resources/simplelogger.properties b/rest/src/commonTest/resources/simplelogger.properties similarity index 100% rename from rest/src/test/resources/simplelogger.properties rename to rest/src/commonTest/resources/simplelogger.properties diff --git a/rest/src/jsMain/kotlin/dev/kord/rest/request/HttpEngine.kt b/rest/src/jsMain/kotlin/dev/kord/rest/request/HttpEngine.kt new file mode 100644 index 000000000000..4f859e5db0ff --- /dev/null +++ b/rest/src/jsMain/kotlin/dev/kord/rest/request/HttpEngine.kt @@ -0,0 +1,6 @@ +package dev.kord.rest.request + +import io.ktor.client.engine.* +import io.ktor.client.engine.js.* + +internal actual object HttpEngine : HttpClientEngineFactory by Js diff --git a/rest/src/jsMain/kotlin/dev/kord/rest/request/RecoveredStackTrace.kt b/rest/src/jsMain/kotlin/dev/kord/rest/request/RecoveredStackTrace.kt new file mode 100644 index 000000000000..fbd70f036f3d --- /dev/null +++ b/rest/src/jsMain/kotlin/dev/kord/rest/request/RecoveredStackTrace.kt @@ -0,0 +1,18 @@ +package dev.kord.rest.request + +internal actual fun RecoveredStackTrace.sanitizeStackTrace() { + // Remove artifacts of stack trace capturing + // ContextException: + // REMOVE: at 0.doResume_0(/home/mik/IdeaProjects/ktor-suspend-function-gun-tests/src/commonMain/kotlin/Request.kt:12) + // REMOVE: at .doCatching(/home/mik/IdeaProjects/ktor-suspend-function-gun-tests/src/commonMain/kotlin/Request.kt:11) + // at _no_name_provided__304.doResume_0(/home/mik/IdeaProjects/ktor-suspend-function-gun-tests/src/commonTest/kotlin/Test.kt:10) + // at _no_name_provided__304.invoke_29q9u6(/home/mik/IdeaProjects/ktor-suspend-function-gun-tests/src/commonTest/kotlin/Test.kt:9) + val dynamic = asDynamic() + val stack = dynamic.stack as String? ?: "" + stackTraceToString() + dynamic.stack = stack.lines().toMutableList().apply { + repeat(2) { + removeAt(1) + } + }.joinToString("\n") +} diff --git a/rest/src/jsTest/kotlin/dev/kord/rest/json/Utils.kt b/rest/src/jsTest/kotlin/dev/kord/rest/json/Utils.kt new file mode 100644 index 000000000000..356dfffef368 --- /dev/null +++ b/rest/src/jsTest/kotlin/dev/kord/rest/json/Utils.kt @@ -0,0 +1,23 @@ +package dev.kord.rest.json + +import io.ktor.utils.io.* +import js.core.get +import js.core.toList +import node.buffer.Buffer +import node.buffer.BufferEncoding +import node.process.process +import node.fs.readFile as nodeReadFile + +internal actual suspend fun file(name: String): String = + nodeReadFile("${process.env["PROJECT_ROOT"]}/rest/src/commonTest/resources/json/$name.json") + .toString(BufferEncoding.utf8) + +internal actual suspend fun readFile(name: String): ByteReadChannel { + val buffer = nodeReadFile("${process.env["PROJECT_ROOT"]}/rest/src/commonTest/resources/$name") + + return ByteReadChannel(buffer.toByteArray()) +} + +private fun Buffer.toByteArray() = values().toList() + .map(Int::toByte) + .toByteArray() diff --git a/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/MessageCreateBuilder.kt b/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/MessageCreateBuilder.kt new file mode 100644 index 000000000000..62065431c6bb --- /dev/null +++ b/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/MessageCreateBuilder.kt @@ -0,0 +1,14 @@ +@file:JvmName("MessageCreateBuilderJvm") +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 + + +/** + * Adds a file with the given [path] to the attachments. + */ +public fun MessageCreateBuilder.addFile(path: Path): NamedFile = + addFile(path.fileName.toString(), ChannelProvider { path.readChannel() }) diff --git a/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/MessageModifyBuilder.kt b/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/MessageModifyBuilder.kt new file mode 100644 index 000000000000..9b6bf6ef7aaa --- /dev/null +++ b/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/MessageModifyBuilder.kt @@ -0,0 +1,14 @@ +@file:JvmName("MessageModifyBuilderJvm") + +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 + +/** + * Adds a file with the given [path] to the attachments. + */ +public fun MessageModifyBuilder.addFile(path: Path): NamedFile = + addFile(path.fileName.toString(), ChannelProvider { path.readChannel() }) diff --git a/rest/src/jvmMain/kotlin/dev/kord/rest/request/HttpEngine.kt b/rest/src/jvmMain/kotlin/dev/kord/rest/request/HttpEngine.kt new file mode 100644 index 000000000000..34ef3bdde016 --- /dev/null +++ b/rest/src/jvmMain/kotlin/dev/kord/rest/request/HttpEngine.kt @@ -0,0 +1,6 @@ +package dev.kord.rest.request + +import io.ktor.client.engine.* +import io.ktor.client.engine.cio.* + +internal actual object HttpEngine : HttpClientEngineFactory by CIO diff --git a/rest/src/jvmMain/kotlin/dev/kord/rest/request/RecoveredStackTrace.kt b/rest/src/jvmMain/kotlin/dev/kord/rest/request/RecoveredStackTrace.kt new file mode 100644 index 000000000000..dcc5f408d749 --- /dev/null +++ b/rest/src/jvmMain/kotlin/dev/kord/rest/request/RecoveredStackTrace.kt @@ -0,0 +1,8 @@ +package dev.kord.rest.request + +internal actual fun RecoveredStackTrace.sanitizeStackTrace() { + // Remove artifacts of stack trace capturing. + // The first stack trace element is the creation of the RecoveredStackTrace: + // at dev.kord.rest.request.StackTraceRecoveringKtorRequestHandler.handle(StackTraceRecoveringKtorRequestHandler.kt:19) + (this as Throwable).stackTrace = stackTrace.copyOfRange(1, stackTrace.size) +} diff --git a/rest/src/jvmMain/kotlin/dev/kord/rest/request/RequestBuilder.kt b/rest/src/jvmMain/kotlin/dev/kord/rest/request/RequestBuilder.kt new file mode 100644 index 000000000000..ea17ede00177 --- /dev/null +++ b/rest/src/jvmMain/kotlin/dev/kord/rest/request/RequestBuilder.kt @@ -0,0 +1,8 @@ +package dev.kord.rest.request + +import io.ktor.client.request.forms.* +import io.ktor.util.cio.* +import java.nio.file.Path + +public fun RequestBuilder.file(path: Path): Unit = + file(path.fileName.toString(), ChannelProvider { path.readChannel() }) diff --git a/rest/src/jvmTest/kotlin/dev/kord/rest/json/Utils.kt b/rest/src/jvmTest/kotlin/dev/kord/rest/json/Utils.kt new file mode 100644 index 000000000000..a0e52f58579b --- /dev/null +++ b/rest/src/jvmTest/kotlin/dev/kord/rest/json/Utils.kt @@ -0,0 +1,8 @@ +package dev.kord.rest.json + +import io.ktor.utils.io.* +import io.ktor.utils.io.jvm.javaio.* + +internal actual suspend fun file(name: String): String = ClassLoader.getSystemResource("json/$name.json")!!.readText() +internal actual suspend fun readFile(name: String): ByteReadChannel = + ClassLoader.getSystemResourceAsStream(name)!!.toByteReadChannel() diff --git a/rest/src/test/kotlin/request/StackTraceRecoveryTest.kt b/rest/src/jvmTest/kotlin/dev/kord/rest/request/StackTraceRecoveryTest.kt similarity index 93% rename from rest/src/test/kotlin/request/StackTraceRecoveryTest.kt rename to rest/src/jvmTest/kotlin/dev/kord/rest/request/StackTraceRecoveryTest.kt index 97588c20786b..d11141077df6 100644 --- a/rest/src/test/kotlin/request/StackTraceRecoveryTest.kt +++ b/rest/src/jvmTest/kotlin/dev/kord/rest/request/StackTraceRecoveryTest.kt @@ -43,7 +43,7 @@ class StackTraceRecoveryTest { val recovered = e.suppressedExceptions.first { it is RecoveredStackTrace } recovered.printStackTrace() - // at dev.kord.rest.request.StackTraceRecoveryTest$test stack trace recovery$1.invokeSuspend(StackTraceRecoveryTest.kt:39) + // at request.StackTraceRecoveryTest$test stack trace recovery$1.invokeSuspend(StackTraceRecoveryTest.kt:39) with(recovered.stackTrace.first()) { assertEquals(stackTrace.className, className) assertEquals(stackTrace.fileName, fileName) diff --git a/rest/src/main/kotlin/NamedFile.kt b/rest/src/main/kotlin/NamedFile.kt deleted file mode 100644 index 981014e48780..000000000000 --- a/rest/src/main/kotlin/NamedFile.kt +++ /dev/null @@ -1,51 +0,0 @@ -package dev.kord.rest - -import io.ktor.client.request.forms.* -import io.ktor.utils.io.jvm.javaio.* -import java.io.InputStream -import kotlin.DeprecationLevel.HIDDEN - -public class NamedFile(public val name: String, public val contentProvider: ChannelProvider) { - /** @suppress */ - @Deprecated( - "Use lazy ChannelProvider instead of InputStream. You should also make sure that the stream/channel is only " + - "opened inside the block of the ChannelProvider because it could otherwise be read multiple times " + - "(which isn't allowed).", - ReplaceWith( - "NamedFile(name, ChannelProvider { inputStream.toByteReadChannel() })", - "io.ktor.client.request.forms.ChannelProvider", - "io.ktor.utils.io.jvm.javaio.toByteReadChannel", - ), - level = HIDDEN, - ) - public constructor(name: String, inputStream: InputStream) : this(inputStream, name) - - // TODO remove when above constructor is removed - internal constructor(inputStream: InputStream, name: String) : this( - name, - ChannelProvider { inputStream.toByteReadChannel() }, - ) - - public val url: String get() = "attachment://$name" - - /** @suppress */ - @Deprecated( - "Use ChannelProvider instead of InputStream", - ReplaceWith( - "contentProvider.block().toInputStream()", - "io.ktor.utils.io.jvm.javaio.toInputStream", - ), - level = HIDDEN, - ) - public val inputStream: InputStream get() = _inputStream - private val _inputStream get() = contentProvider.block().toInputStream() // TODO remove with `inputStream` - - public operator fun component1(): String = name - public operator fun component2(): ChannelProvider = contentProvider - public operator fun component3(): String = url - - @Deprecated("Binary compatibility", level = DeprecationLevel.HIDDEN) - @JvmName("component2") - @Suppress("DEPRECATION_ERROR", "FunctionName") - public fun _component2(): InputStream = _inputStream -} diff --git a/rest/src/test/kotlin/json/Util.kt b/rest/src/test/kotlin/json/Util.kt deleted file mode 100644 index a9008a310a30..000000000000 --- a/rest/src/test/kotlin/json/Util.kt +++ /dev/null @@ -1,6 +0,0 @@ -package dev.kord.rest.json - -internal fun file(name: String): String { - val loader = Unit::class.java.classLoader - return loader.getResource("json/$name.json").readText() -} \ No newline at end of file From 089c02de4ddbf6797581a06b585ac73548e9c92a Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Feb 2023 14:32:02 +0100 Subject: [PATCH 009/136] Improve tests - Use bundles for js dependencies - Disable InstantInEpochMillisecondsSerializerTest for now --- common/build.gradle.kts | 3 +-- .../commonTest/kotlin/serialization/InstantSerializersTests.kt | 2 ++ gradle/libs.versions.toml | 1 + rest/build.gradle.kts | 3 +-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 2a76d67218c9..16dbecc05a12 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -39,8 +39,7 @@ kotlin { } jsTest { dependencies { - implementation(libs.kotlin.test.js) - implementation(libs.kotlinx.nodejs) + implementation(libs.bundles.test.js) } } } diff --git a/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt b/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt index d9ee9f05152e..84e080fcc791 100644 --- a/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt +++ b/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt @@ -7,6 +7,7 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.SerializationException import kotlinx.serialization.json.Json import kotlin.js.JsName +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith @@ -69,6 +70,7 @@ abstract class InstantSerializerTest( } +@Ignore // currently can't pass class InstantInEpochMillisecondsSerializerTest : InstantSerializerTest( json = "796514689159", instant = Instant.fromEpochMilliseconds(796514689159), diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6b136076ef26..dba1bda5066f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -91,6 +91,7 @@ ktor-client-serialization = ["ktor-client-content-negotiation", "ktor-serializat test-implementation = ["kotlinx-coroutines-test", "kotlin-test", "junit-jupiter-api", "mockk"] test-common = ["kotlinx-coroutines-test", "kotlin-test", "kotlin-test-annotations-common"] test-runtime = ["kotlin-test-junit5", "junit-jupiter-engine", "slf4j-simple"] +test-js = ["kotlin-test-js", "kotlinx-nodejs"] stately = ["stately-collections", "stately-concurrency"] pluginsForBuildSrc = [ diff --git a/rest/build.gradle.kts b/rest/build.gradle.kts index 5d8736163321..bd0bc8ea9ebc 100644 --- a/rest/build.gradle.kts +++ b/rest/build.gradle.kts @@ -39,8 +39,7 @@ kotlin { jsTest { dependencies { - implementation(libs.kotlin.test.js) - implementation(libs.kotlinx.nodejs) + implementation(libs.bundles.test.js) } } From 330917a9c8a759ca1d1e7d8e8ccab341be9a38aa Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Feb 2023 14:58:51 +0100 Subject: [PATCH 010/136] Update publishing for MPP --- buildSrc/src/main/kotlin/kord-module.gradle.kts | 10 +--------- .../kotlin/kord-multiplatform-module.gradle.kts | 9 ++++----- .../src/main/kotlin/kord-publishing.gradle.kts | 14 ++++++++++++-- common/build.gradle.kts | 1 + rest/build.gradle.kts | 1 + 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/buildSrc/src/main/kotlin/kord-module.gradle.kts b/buildSrc/src/main/kotlin/kord-module.gradle.kts index 0b40fe453589..5f090aa34b98 100644 --- a/buildSrc/src/main/kotlin/kord-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-module.gradle.kts @@ -68,17 +68,9 @@ tasks { } } -val dokkaJar by tasks.registering(Jar::class) { - group = JavaBasePlugin.DOCUMENTATION_GROUP - description = "Assembles Kotlin docs with Dokka" - archiveClassifier.set("javadoc") - from(tasks.dokkaHtml) -} - publishing { - publications.withType().configureEach { + publications.register(Library.name) { from(components["java"]) artifact(tasks.kotlinSourcesJar) - artifact(dokkaJar) } } diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index 5d664b0e7749..e88f7caf39a3 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -66,11 +66,10 @@ tasks { } afterEvaluate { - getByName("compileKotlinJvm") { - dependsOnKspKotlin("kspCommonMainKotlinMetadata") - } - getByName("compileKotlinJs") { - dependsOnKspKotlin("kspCommonMainKotlinMetadata") + listOf("compileKotlinJvm", "compileKotlinJs", "jvmSourcesJar", "jsSourcesJar", "sourcesJar").forEach { + getByName(it) { + dependsOnKspKotlin("kspCommonMainKotlinMetadata") + } } } diff --git a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts index f080e6714f13..8f394390b7b8 100644 --- a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts @@ -1,3 +1,4 @@ +import gradle.kotlin.dsl.accessors._e5121a5856746b077c6819bbe5a86a2f.dokkaHtml import java.util.Base64 plugins { @@ -5,11 +6,20 @@ plugins { signing } +val dokkaJar by tasks.registering(Jar::class) { + group = JavaBasePlugin.DOCUMENTATION_GROUP + description = "Assembles Kotlin docs with Dokka" + archiveClassifier.set("javadoc") + from(tasks.dokkaHtml) +} + publishing { publications { - create(Library.name) { + withType { + artifact(dokkaJar) + groupId = Library.group - artifactId = "kord-${project.name}" + artifactId = "kord-${artifactId}" version = Library.version pom { diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 16dbecc05a12..0785f23335c2 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,6 +1,7 @@ @Suppress("DSL_SCOPE_VIOLATION") // false positive for `libs` in IntelliJ plugins { `kord-multiplatform-module` + `kord-publishing` `kotlinx-atomicfu` `kotlinx-serialization` alias(libs.plugins.buildconfig) diff --git a/rest/build.gradle.kts b/rest/build.gradle.kts index bd0bc8ea9ebc..cd495704cb11 100644 --- a/rest/build.gradle.kts +++ b/rest/build.gradle.kts @@ -1,6 +1,7 @@ @Suppress("DSL_SCOPE_VIOLATION") // false positive for `libs` in IntelliJ plugins { `kord-multiplatform-module` + `kord-publishing` `kotlinx-atomicfu` `kotlinx-serialization` alias(libs.plugins.buildconfig) From 4ac3a83c1e7d6fc3a92c5bcd1b19d4f6f5467e04 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Feb 2023 15:14:04 +0100 Subject: [PATCH 011/136] Put explicitApi() to kord-multiplatform-module.gradle.kts --- buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts | 2 ++ common/build.gradle.kts | 2 -- rest/build.gradle.kts | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index e88f7caf39a3..87ed0e463b0e 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -15,6 +15,8 @@ repositories { } kotlin { + explicitApi() + jvm() js(IR) { nodejs() diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 0785f23335c2..2ef9c033c0ad 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -8,8 +8,6 @@ plugins { } kotlin { - explicitApi() - sourceSets { commonMain { dependencies { diff --git a/rest/build.gradle.kts b/rest/build.gradle.kts index cd495704cb11..e38930ce2006 100644 --- a/rest/build.gradle.kts +++ b/rest/build.gradle.kts @@ -8,8 +8,6 @@ plugins { } kotlin { - explicitApi() - sourceSets { commonMain { dependencies { From 8d0f9c93530593fa764e842babd123a57b0ee179 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Feb 2023 15:14:37 +0100 Subject: [PATCH 012/136] Add samples for mpp modules --- .../kord-sampled-multiplatform-module.gradle.kts | 11 +++++++++++ rest/build.gradle.kts | 1 + 2 files changed, 12 insertions(+) create mode 100644 buildSrc/src/main/kotlin/kord-sampled-multiplatform-module.gradle.kts diff --git a/buildSrc/src/main/kotlin/kord-sampled-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-sampled-multiplatform-module.gradle.kts new file mode 100644 index 000000000000..42d3978fe5fc --- /dev/null +++ b/buildSrc/src/main/kotlin/kord-sampled-multiplatform-module.gradle.kts @@ -0,0 +1,11 @@ +plugins { + org.jetbrains.kotlin.multiplatform +} + +kotlin { + sourceSets { + create("samples") { + dependsOn(getByName("jvmMain")) + } + } +} diff --git a/rest/build.gradle.kts b/rest/build.gradle.kts index e38930ce2006..3295d0076cc5 100644 --- a/rest/build.gradle.kts +++ b/rest/build.gradle.kts @@ -4,6 +4,7 @@ plugins { `kord-publishing` `kotlinx-atomicfu` `kotlinx-serialization` + `kord-sampled-multiplatform-module` alias(libs.plugins.buildconfig) } From bec143730b4cd9557e4af41353c58bd44d1a70ee Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Feb 2023 15:14:49 +0100 Subject: [PATCH 013/136] Fix publishing for bom --- .../src/main/kotlin/kord-publishing.gradle.kts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts index 8f394390b7b8..79cc194d5a45 100644 --- a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts @@ -6,18 +6,21 @@ plugins { signing } -val dokkaJar by tasks.registering(Jar::class) { - group = JavaBasePlugin.DOCUMENTATION_GROUP - description = "Assembles Kotlin docs with Dokka" - archiveClassifier.set("javadoc") - from(tasks.dokkaHtml) +if(tasks.findByName("dokkaHtml") != null) { + val dokkaJar by tasks.registering(Jar::class) { + group = JavaBasePlugin.DOCUMENTATION_GROUP + description = "Assembles Kotlin docs with Dokka" + archiveClassifier.set("javadoc") + from(tasks.dokkaHtml) + } + publishing.publications.withType { + artifact(dokkaJar) + } } publishing { publications { withType { - artifact(dokkaJar) - groupId = Library.group artifactId = "kord-${artifactId}" version = Library.version From 3ec7fe93d5a9d46ad05e67e20a4d13ec9ef2f843 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Feb 2023 15:20:49 +0100 Subject: [PATCH 014/136] Migrate gateway test to kotlin.test --- gateway/build.gradle.kts | 1 + gateway/src/test/kotlin/gateway/DefaultGatewayTest.kt | 6 +++--- gateway/src/test/kotlin/json/CommandTest.kt | 7 +++---- gateway/src/test/kotlin/json/RegressionTests.kt | 2 +- gateway/src/test/kotlin/json/SerializationTest.kt | 2 +- .../src/test/kotlin/ratelimit/IdentifyRateLimiterTest.kt | 8 ++++---- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gateway/build.gradle.kts b/gateway/build.gradle.kts index b38ed983bec7..6a3563b33387 100644 --- a/gateway/build.gradle.kts +++ b/gateway/build.gradle.kts @@ -11,6 +11,7 @@ dependencies { api(libs.ktor.client.websockets) api(libs.ktor.client.cio) + testImplementation(libs.kotlin.test.junit5) testImplementation(libs.bundles.test.implementation) testRuntimeOnly(libs.bundles.test.runtime) } diff --git a/gateway/src/test/kotlin/gateway/DefaultGatewayTest.kt b/gateway/src/test/kotlin/gateway/DefaultGatewayTest.kt index c9873fe62eab..c5b08bbd2001 100644 --- a/gateway/src/test/kotlin/gateway/DefaultGatewayTest.kt +++ b/gateway/src/test/kotlin/gateway/DefaultGatewayTest.kt @@ -19,14 +19,14 @@ import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.runBlocking -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test +import kotlin.test.Ignore +import kotlin.test.Test import kotlin.time.Duration.Companion.seconds class DefaultGatewayTest { @OptIn(DelicateCoroutinesApi::class) @Test - @Disabled + @Ignore fun `default gateway functions correctly`() { val token = System.getenv("KORD_TEST_TOKEN") diff --git a/gateway/src/test/kotlin/json/CommandTest.kt b/gateway/src/test/kotlin/json/CommandTest.kt index 4c8d834c7711..fb27e0015f32 100644 --- a/gateway/src/test/kotlin/json/CommandTest.kt +++ b/gateway/src/test/kotlin/json/CommandTest.kt @@ -11,9 +11,8 @@ import dev.kord.common.entity.optional.optionalInt import dev.kord.gateway.* import kotlinx.datetime.Instant import kotlinx.serialization.json.* -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test -import java.util.* +import kotlin.test.assertEquals +import kotlin.test.Test private val json = Json { encodeDefaults = false } @@ -122,7 +121,7 @@ class CommandTest { put("d", buildJsonObject { put("since", since) put("activities", JsonArray(emptyList())) - put("status", status.value.lowercase(Locale.getDefault())) + put("status", status.value.lowercase()) put("afk", afk) }) }) diff --git a/gateway/src/test/kotlin/json/RegressionTests.kt b/gateway/src/test/kotlin/json/RegressionTests.kt index 8b148930f63d..84bf1ffd3232 100644 --- a/gateway/src/test/kotlin/json/RegressionTests.kt +++ b/gateway/src/test/kotlin/json/RegressionTests.kt @@ -3,7 +3,7 @@ package json import dev.kord.gateway.Event import dev.kord.gateway.Reconnect import kotlinx.serialization.json.Json -import org.junit.jupiter.api.Test +import kotlin.test.Test private fun file(name: String): String { val loader = SerializationTest::class.java.classLoader diff --git a/gateway/src/test/kotlin/json/SerializationTest.kt b/gateway/src/test/kotlin/json/SerializationTest.kt index b66a662b9424..4d1e7da66f52 100644 --- a/gateway/src/test/kotlin/json/SerializationTest.kt +++ b/gateway/src/test/kotlin/json/SerializationTest.kt @@ -6,7 +6,7 @@ import dev.kord.common.entity.optional.value import dev.kord.gateway.* import kotlinx.datetime.Instant import kotlinx.serialization.json.Json -import org.junit.jupiter.api.Test +import kotlin.test.Test import kotlin.time.Duration.Companion.seconds private fun file(name: String): String { diff --git a/gateway/src/test/kotlin/ratelimit/IdentifyRateLimiterTest.kt b/gateway/src/test/kotlin/ratelimit/IdentifyRateLimiterTest.kt index 1a591e6878ab..c0a451fd329b 100644 --- a/gateway/src/test/kotlin/ratelimit/IdentifyRateLimiterTest.kt +++ b/gateway/src/test/kotlin/ratelimit/IdentifyRateLimiterTest.kt @@ -15,12 +15,12 @@ import kotlinx.coroutines.flow.* import kotlinx.coroutines.flow.SharingStarted.Companion.Eagerly import kotlinx.coroutines.test.currentTime import kotlinx.coroutines.test.runTest -import org.junit.jupiter.api.assertThrows import kotlin.coroutines.ContinuationInterceptor import kotlin.random.Random import kotlin.random.nextInt import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith import kotlin.test.assertTrue import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds @@ -54,9 +54,9 @@ class IdentifyRateLimiterTest { @Test fun `IdentifyRateLimiter throws IAEs`() = runBlocking { - assertThrows { IdentifyRateLimiter(maxConcurrency = 0) } - assertThrows { IdentifyRateLimiter(maxConcurrency = -1) } - assertThrows { + assertFailsWith { IdentifyRateLimiter(maxConcurrency = 0) } + assertFailsWith { IdentifyRateLimiter(maxConcurrency = -1) } + assertFailsWith { val rateLimiter = IdentifyRateLimiter(maxConcurrency = 1) rateLimiter.consume(shardId = -1, events = MutableSharedFlow()) } From a5445de4da0850c0ca99eb27c53322ccc9141e30 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Feb 2023 22:00:01 +0100 Subject: [PATCH 015/136] Migrate gateway to MPP --- .gitignore | 3 + core/src/samples/kotlin/PingBot.kt | 63 +++++++++++--- gateway/build.gradle.kts | 62 +++++++++++--- .../{main => commonMain}/kotlin/Command.kt | 0 .../kotlin/DefaultGateway.kt | 26 +++--- .../kotlin/DefaultGatewayBuilder.kt | 5 +- .../src/{main => commonMain}/kotlin/Event.kt | 0 .../{main => commonMain}/kotlin/Gateway.kt | 0 .../kotlin/GatewayConfiguration.kt | 0 gateway/src/commonMain/kotlin/HttpEngine.kt | 5 ++ gateway/src/commonMain/kotlin/Inflater.kt | 7 ++ .../src/{main => commonMain}/kotlin/Intent.kt | 5 +- .../src/{main => commonMain}/kotlin/OpCode.kt | 0 .../{main => commonMain}/kotlin/Sequence.kt | 0 .../src/{main => commonMain}/kotlin/Ticker.kt | 38 +++++---- gateway/src/commonMain/kotlin/Utils.kt | 6 ++ .../kotlin/builder/LoginBuilder.kt | 0 .../kotlin/builder/PresenceBuilder.kt | 2 +- .../builder/RequestGuildMembersBuilder.kt | 0 .../kotlin/handler/Handler.kt | 4 +- .../kotlin/handler/HandshakeHandler.kt | 0 .../kotlin/handler/HeartbeatHandler.kt | 0 .../kotlin/handler/InvalidSessionHandler.kt | 0 .../kotlin/handler/ReconnectHandler.kt | 3 +- .../kotlin/handler/SequenceHandler.kt | 0 .../kotlin/ratelimit/IdentifyRateLimiter.kt | 9 +- .../kotlin/retry/LinearRetry.kt | 0 .../kotlin/retry/Retry.kt | 0 gateway/src/commonTest/kotlin/Platform.kt | 5 ++ .../kotlin/gateway/DefaultGatewayTest.kt | 50 ++++++----- .../kotlin/helper/LinearRetryTest.kt | 7 +- .../kotlin/json/CommandTest.kt | 7 ++ .../commonTest/kotlin/json/RegressionTests.kt | 42 +++++++++ .../kotlin/json/SerializationTest.kt | 37 +++++--- .../kotlin/json/SnowflakeTest.kt | 6 ++ .../{test => commonTest}/kotlin/json/Util.kt | 0 .../ratelimit/IdentifyRateLimiterTest.kt | 11 ++- .../resources/json/event/ack.json | 0 .../resources/json/event/channelcreate.json | 0 .../resources/json/event/channeldelete.json | 0 .../json/event/channelpinsupdate.json | 0 .../resources/json/event/channelupdate.json | 0 .../resources/json/event/guildbanadd.json | 0 .../resources/json/event/guildbanremove.json | 0 .../resources/json/event/guildcreate.json | 0 .../resources/json/event/guilddelete.json | 0 .../json/event/guildemojiupdate.json | 0 .../json/event/guildintegrationsupdate.json | 0 .../resources/json/event/guildmemberadd.json | 0 .../json/event/guildmemeberremove.json | 0 .../resources/json/event/guildupdate.json | 0 .../resources/json/event/hello.json | 0 .../resources/json/event/invalid.json | 0 .../resources/json/event/ready.json | 0 .../resources/json/event/reconnect.json | 0 .../resources/json/event/resumed.json | 0 .../eventWithDataThatShouldNotHaveData.json | 0 .../json/regression/eventWithUnknownData.json | 0 .../presenceReplaceWithUnknownData.json | 0 .../regression/resumeWithUnknownData.json | 0 .../resources/simplelogger.properties | 0 .../kotlin/dev/kord/gateway/DefaultGateway.kt | 7 ++ .../kotlin/dev/kord/gateway/HttpEngine.kt | 7 ++ .../kotlin/dev/kord/gateway/Inflater.kt | 16 ++++ .../dev/kord/gateway/internal/JsInflater.kt | 11 +++ .../kotlin/dev/kord/gateway/Platform.kt | 11 +++ .../kotlin/dev/kord/gateway/DefaultGateway.kt | 7 ++ .../kotlin/dev/kord/gateway/HttpEngine.kt | 6 ++ .../kotlin/dev/kord/gateway/Inflater.kt | 21 +++++ .../kotlin/dev/kord/gateway/Platform.kt | 6 ++ gateway/src/samples/kotlin/EventListener.kt | 8 -- .../src/test/kotlin/json/RegressionTests.kt | 35 -------- gradlew | 0 kotlin-js-store/yarn.lock | 10 +++ settings.gradle.kts | 1 + .../kotlin/dev/kord/voice/EncryptionMode.kt | 85 ------------------- 76 files changed, 402 insertions(+), 232 deletions(-) rename gateway/src/{main => commonMain}/kotlin/Command.kt (100%) rename gateway/src/{main => commonMain}/kotlin/DefaultGateway.kt (95%) rename gateway/src/{main => commonMain}/kotlin/DefaultGatewayBuilder.kt (95%) rename gateway/src/{main => commonMain}/kotlin/Event.kt (100%) rename gateway/src/{main => commonMain}/kotlin/Gateway.kt (100%) rename gateway/src/{main => commonMain}/kotlin/GatewayConfiguration.kt (100%) create mode 100644 gateway/src/commonMain/kotlin/HttpEngine.kt create mode 100644 gateway/src/commonMain/kotlin/Inflater.kt rename gateway/src/{main => commonMain}/kotlin/Intent.kt (99%) rename gateway/src/{main => commonMain}/kotlin/OpCode.kt (100%) rename gateway/src/{main => commonMain}/kotlin/Sequence.kt (100%) rename gateway/src/{main => commonMain}/kotlin/Ticker.kt (56%) create mode 100644 gateway/src/commonMain/kotlin/Utils.kt rename gateway/src/{main => commonMain}/kotlin/builder/LoginBuilder.kt (100%) rename gateway/src/{main => commonMain}/kotlin/builder/PresenceBuilder.kt (96%) rename gateway/src/{main => commonMain}/kotlin/builder/RequestGuildMembersBuilder.kt (100%) rename gateway/src/{main => commonMain}/kotlin/handler/Handler.kt (93%) rename gateway/src/{main => commonMain}/kotlin/handler/HandshakeHandler.kt (100%) rename gateway/src/{main => commonMain}/kotlin/handler/HeartbeatHandler.kt (100%) rename gateway/src/{main => commonMain}/kotlin/handler/InvalidSessionHandler.kt (100%) rename gateway/src/{main => commonMain}/kotlin/handler/ReconnectHandler.kt (87%) rename gateway/src/{main => commonMain}/kotlin/handler/SequenceHandler.kt (100%) rename gateway/src/{main => commonMain}/kotlin/ratelimit/IdentifyRateLimiter.kt (98%) rename gateway/src/{main => commonMain}/kotlin/retry/LinearRetry.kt (100%) rename gateway/src/{main => commonMain}/kotlin/retry/Retry.kt (100%) create mode 100644 gateway/src/commonTest/kotlin/Platform.kt rename gateway/src/{test => commonTest}/kotlin/gateway/DefaultGatewayTest.kt (55%) rename gateway/src/{test => commonTest}/kotlin/helper/LinearRetryTest.kt (87%) rename gateway/src/{test => commonTest}/kotlin/json/CommandTest.kt (97%) create mode 100644 gateway/src/commonTest/kotlin/json/RegressionTests.kt rename gateway/src/{test => commonTest}/kotlin/json/SerializationTest.kt (84%) rename gateway/src/{test => commonTest}/kotlin/json/SnowflakeTest.kt (95%) rename gateway/src/{test => commonTest}/kotlin/json/Util.kt (100%) rename gateway/src/{test => commonTest}/kotlin/ratelimit/IdentifyRateLimiterTest.kt (96%) rename gateway/src/{test => commonTest}/resources/json/event/ack.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/channelcreate.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/channeldelete.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/channelpinsupdate.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/channelupdate.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/guildbanadd.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/guildbanremove.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/guildcreate.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/guilddelete.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/guildemojiupdate.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/guildintegrationsupdate.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/guildmemberadd.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/guildmemeberremove.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/guildupdate.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/hello.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/invalid.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/ready.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/reconnect.json (100%) rename gateway/src/{test => commonTest}/resources/json/event/resumed.json (100%) rename gateway/src/{test => commonTest}/resources/json/regression/eventWithDataThatShouldNotHaveData.json (100%) rename gateway/src/{test => commonTest}/resources/json/regression/eventWithUnknownData.json (100%) rename gateway/src/{test => commonTest}/resources/json/regression/presenceReplaceWithUnknownData.json (100%) rename gateway/src/{test => commonTest}/resources/json/regression/resumeWithUnknownData.json (100%) rename gateway/src/{test => commonTest}/resources/simplelogger.properties (100%) create mode 100644 gateway/src/jsMain/kotlin/dev/kord/gateway/DefaultGateway.kt create mode 100644 gateway/src/jsMain/kotlin/dev/kord/gateway/HttpEngine.kt create mode 100644 gateway/src/jsMain/kotlin/dev/kord/gateway/Inflater.kt create mode 100644 gateway/src/jsMain/kotlin/dev/kord/gateway/internal/JsInflater.kt create mode 100644 gateway/src/jsTest/kotlin/dev/kord/gateway/Platform.kt create mode 100644 gateway/src/jvmMain/kotlin/dev/kord/gateway/DefaultGateway.kt create mode 100644 gateway/src/jvmMain/kotlin/dev/kord/gateway/HttpEngine.kt create mode 100644 gateway/src/jvmMain/kotlin/dev/kord/gateway/Inflater.kt create mode 100644 gateway/src/jvmTest/kotlin/dev/kord/gateway/Platform.kt delete mode 100644 gateway/src/test/kotlin/json/RegressionTests.kt mode change 100755 => 100644 gradlew delete mode 100644 voice/build/generated/ksp/main/kotlin/dev/kord/voice/EncryptionMode.kt diff --git a/.gitignore b/.gitignore index e46f4d6a2cc7..4635b15ea70d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ out/ !**/build/generated/ # re-exclude BuildConfigGenerated.kt common/build/generated/source/buildConfig/main/main/dev/kord/common/BuildConfigGenerated.kt + +# Schlaubi's js testing project +js-test/ diff --git a/core/src/samples/kotlin/PingBot.kt b/core/src/samples/kotlin/PingBot.kt index 8569d9e8b4aa..2a51cacd8399 100644 --- a/core/src/samples/kotlin/PingBot.kt +++ b/core/src/samples/kotlin/PingBot.kt @@ -1,21 +1,58 @@ -import dev.kord.core.Kord -import dev.kord.core.event.message.MessageCreateEvent -import dev.kord.core.on -import dev.kord.gateway.Intent -import dev.kord.gateway.PrivilegedIntent +import dev.kord.common.entity.PresenceStatus +import dev.kord.common.ratelimit.IntervalRateLimiter +import dev.kord.gateway.* +import dev.kord.gateway.retry.LinearRetry +import kotlinx.coroutines.flow.filterIsInstance +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach +import kotlin.time.Duration.Companion.seconds +import kotlin.time.ExperimentalTime -suspend fun main(args: Array) { - val kord = Kord(args.firstOrNull() ?: error("token required")) +@OptIn(ExperimentalTime::class) +suspend fun main() { + // + val token = "NTM1MTI5NDA2NjUwMzE4ODYw.GAQrFJ.r0EwX1yDw_2W2ERHl9vnvtQjxqw88vxCOhDskA" + // - kord.on { - if (message.author?.isBot == true) return@on - if (message.content == "!ping") message.channel.createMessage("pong") + val gateway = DefaultGateway { + reconnectRetry = LinearRetry(2.seconds, 20.seconds, 10) + sendRateLimiter = IntervalRateLimiter(limit = 120, interval = 60.seconds) } - kord.login { - presence { playing("!ping to pong") } + gateway.events.filterIsInstance().onEach { + val words = it.message.content.split(' ') + when (words.firstOrNull()) { + "!close" -> gateway.stop() + "!detach" -> gateway.detach() + "!status" -> when (words.getOrNull(1)) { + "playing" -> gateway.editPresence { + status = PresenceStatus.Online + afk = false + playing("Kord") + } + } + "!ping" -> gateway.editPresence { + status = PresenceStatus.Online + afk = false + listening("a ${gateway.ping.value?.inWholeMilliseconds} ms ping") + } + } + }.launchIn(gateway) + + gateway.start(token) { @OptIn(PrivilegedIntent::class) - intents += Intent.MessageContent + intents = Intents.all } } +//DEBUG: [Function] Identifying on shard 0 with rate_limit_key 0... +//TRACE: [Function] opening gateway connection to wss://gateway.discord.gg/?v=10&encoding=json&compress=zlib-stream +//TRACE: Sending WebSocket request [object Object] +//TRACE: Receive websocket session from wss://gateway.discord.gg/?v=10&encoding=json&compress=zlib-stream: [object Object] +//TRACE: [Function] Received raw frame: Frame BINARY (fin=false, buffer len = 114) +//TRACE: [Function] Gateway <<< {"t":null,"s":null,"op":10,"d":{"heartbeat_interval":41250,"_trace":["[\"gateway-prd-us-east1-d-bdzc\",{\"micros\":0.0}]"]}} +//TRACE: [Function] Gateway >>> {"op":2,"d":{"token":"token","properties":{"os":"win32","browser":"Kord","device":"Kord"},"compress":false,"large_threshold":250,"shard":[0,1],"intents":"3276799"}} +//TRACE: [Function] Gateway >>> {"op":1,"d":null} +//TRACE: [Function] Gateway >>> {"op":1,"d":null} +//TRACE: [Function] Received raw frame: Frame BINARY (fin=false, buffer len = 15) +//DEBUG: [Function] Identifying on shard 0 timed out, delaying 5s before freeing up rate_limit_key 0 diff --git a/gateway/build.gradle.kts b/gateway/build.gradle.kts index 6a3563b33387..5fc2d4b52892 100644 --- a/gateway/build.gradle.kts +++ b/gateway/build.gradle.kts @@ -1,17 +1,59 @@ plugins { - `kord-module` - `kord-sampled-module` + `kord-multiplatform-module` `kord-publishing` + `kotlinx-serialization` + `kord-sampled-multiplatform-module` } -dependencies { - api(projects.common) +kotlin { + sourceSets { + commonMain { + dependencies { + api(projects.common) + compileOnly(projects.kspAnnotations) - api(libs.bundles.ktor.client.serialization) - api(libs.ktor.client.websockets) - api(libs.ktor.client.cio) + api(libs.bundles.ktor.client.serialization) + api(libs.ktor.client.core) + api(libs.kotlinx.coroutines.core) + api(libs.ktor.client.websockets) - testImplementation(libs.kotlin.test.junit5) - testImplementation(libs.bundles.test.implementation) - testRuntimeOnly(libs.bundles.test.runtime) + // The plugin should add this automatically, but it doesn't + compileOnly(libs.kotlinx.atomicfu) + } + } + + jvmMain { + dependencies { + api(libs.ktor.client.cio) + } + } + + jsMain { + dependencies { + api(libs.ktor.client.js) + api(libs.kotlinx.nodejs) + api(npm("fast-zlib", "2.0.1")) + } + } + + commonTest { + dependencies { + implementation(libs.bundles.test.common) + implementation(libs.ktor.client.mock) + } + } + + jsTest { + dependencies { + implementation(libs.bundles.test.js) + } + } + + jvmTest { + dependencies { + runtimeOnly(libs.bundles.test.runtime) + implementation(libs.kotlin.test.junit5) + } + } + } } diff --git a/gateway/src/main/kotlin/Command.kt b/gateway/src/commonMain/kotlin/Command.kt similarity index 100% rename from gateway/src/main/kotlin/Command.kt rename to gateway/src/commonMain/kotlin/Command.kt diff --git a/gateway/src/main/kotlin/DefaultGateway.kt b/gateway/src/commonMain/kotlin/DefaultGateway.kt similarity index 95% rename from gateway/src/main/kotlin/DefaultGateway.kt rename to gateway/src/commonMain/kotlin/DefaultGateway.kt index 933e2a8ce6c4..a0d4b54dfb27 100644 --- a/gateway/src/main/kotlin/DefaultGateway.kt +++ b/gateway/src/commonMain/kotlin/DefaultGateway.kt @@ -12,6 +12,7 @@ import io.ktor.client.plugins.websocket.* import io.ktor.client.request.* import io.ktor.http.* import io.ktor.util.logging.* +import io.ktor.utils.io.charsets.* import io.ktor.websocket.* import kotlinx.atomicfu.AtomicRef import kotlinx.atomicfu.atomic @@ -27,13 +28,17 @@ import mu.KotlinLogging import java.io.ByteArrayOutputStream import java.util.zip.Inflater import java.util.zip.InflaterOutputStream +import kotlin.DeprecationLevel.HIDDEN import kotlin.contracts.InvocationKind import kotlin.contracts.contract import kotlin.coroutines.CoroutineContext +import kotlin.jvm.JvmName import kotlin.time.Duration private val defaultGatewayLogger = KotlinLogging.logger { } +internal expect fun Throwable.isTimeout(): Boolean + private sealed class State(val retry: Boolean) { object Stopped : State(false) class Running(retry: Boolean) : State(retry) @@ -122,7 +127,7 @@ public class DefaultGateway(private val data: DefaultGatewayData) : Gateway { inflater = Inflater() } catch (exception: Exception) { defaultGatewayLogger.error(exception) - if (exception is java.nio.channels.UnresolvedAddressException) { + if (exception.isTimeout()) { data.eventFlow.emit(Close.Timeout) } @@ -179,21 +184,11 @@ public class DefaultGateway(private val data: DefaultGatewayData) : Gateway { } } - private fun Frame.deflateData(): String { - val outputStream = ByteArrayOutputStream() - InflaterOutputStream(outputStream, inflater).use { - it.write(data) - } - - return outputStream.use { - String(outputStream.toByteArray(), 0, outputStream.size(), Charsets.UTF_8) - } - } - private suspend fun read(frame: Frame) { + defaultGatewayLogger.trace { "Received raw frame: $frame" } val json = when { - compression -> frame.deflateData() - else -> String(frame.data, Charsets.UTF_8) + compression -> with(inflater) { frame.inflateData() } + else -> frame.data.decodeToString() } try { @@ -221,6 +216,7 @@ public class DefaultGateway(private val data: DefaultGatewayData) : Gateway { state.update { State.Stopped } throw IllegalStateException("Gateway closed: ${reason.code} ${reason.message}") } + discordReason.resetSession -> { setStopped() } @@ -317,7 +313,7 @@ internal val GatewayConfiguration.identify ) -internal val os: String get() = System.getProperty("os.name") +internal expect val os: String internal val GatewayCloseCode.retry get() = when (this) { //this statement is intentionally structured to ensure we consider the retry for every new code diff --git a/gateway/src/main/kotlin/DefaultGatewayBuilder.kt b/gateway/src/commonMain/kotlin/DefaultGatewayBuilder.kt similarity index 95% rename from gateway/src/main/kotlin/DefaultGatewayBuilder.kt rename to gateway/src/commonMain/kotlin/DefaultGatewayBuilder.kt index ee1f319ec880..624f5ca4242c 100644 --- a/gateway/src/main/kotlin/DefaultGatewayBuilder.kt +++ b/gateway/src/commonMain/kotlin/DefaultGatewayBuilder.kt @@ -7,7 +7,6 @@ import dev.kord.gateway.ratelimit.IdentifyRateLimiter import dev.kord.gateway.retry.LinearRetry import dev.kord.gateway.retry.Retry import io.ktor.client.* -import io.ktor.client.engine.cio.* import io.ktor.client.plugins.contentnegotiation.* import io.ktor.client.plugins.websocket.* import io.ktor.client.request.* @@ -16,6 +15,8 @@ import io.ktor.serialization.kotlinx.json.* import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableSharedFlow +import kotlin.DeprecationLevel.HIDDEN +import kotlin.jvm.JvmName import kotlin.time.Duration.Companion.seconds public class DefaultGatewayBuilder { @@ -29,7 +30,7 @@ public class DefaultGatewayBuilder { public var eventFlow: MutableSharedFlow = MutableSharedFlow(extraBufferCapacity = Int.MAX_VALUE) public fun build(): DefaultGateway { - val client = client ?: HttpClient(CIO) { + val client = client ?: HttpClient(HttpEngine) { install(WebSockets) install(ContentNegotiation) { json() diff --git a/gateway/src/main/kotlin/Event.kt b/gateway/src/commonMain/kotlin/Event.kt similarity index 100% rename from gateway/src/main/kotlin/Event.kt rename to gateway/src/commonMain/kotlin/Event.kt diff --git a/gateway/src/main/kotlin/Gateway.kt b/gateway/src/commonMain/kotlin/Gateway.kt similarity index 100% rename from gateway/src/main/kotlin/Gateway.kt rename to gateway/src/commonMain/kotlin/Gateway.kt diff --git a/gateway/src/main/kotlin/GatewayConfiguration.kt b/gateway/src/commonMain/kotlin/GatewayConfiguration.kt similarity index 100% rename from gateway/src/main/kotlin/GatewayConfiguration.kt rename to gateway/src/commonMain/kotlin/GatewayConfiguration.kt diff --git a/gateway/src/commonMain/kotlin/HttpEngine.kt b/gateway/src/commonMain/kotlin/HttpEngine.kt new file mode 100644 index 000000000000..8f5f4e200dd1 --- /dev/null +++ b/gateway/src/commonMain/kotlin/HttpEngine.kt @@ -0,0 +1,5 @@ +package dev.kord.gateway + +import io.ktor.client.engine.* + +internal expect object HttpEngine : HttpClientEngineFactory diff --git a/gateway/src/commonMain/kotlin/Inflater.kt b/gateway/src/commonMain/kotlin/Inflater.kt new file mode 100644 index 000000000000..3fcdaa2b136d --- /dev/null +++ b/gateway/src/commonMain/kotlin/Inflater.kt @@ -0,0 +1,7 @@ +package dev.kord.gateway + +import io.ktor.websocket.* + +internal expect class Inflater() { + suspend fun Frame.inflateData(): String +} diff --git a/gateway/src/main/kotlin/Intent.kt b/gateway/src/commonMain/kotlin/Intent.kt similarity index 99% rename from gateway/src/main/kotlin/Intent.kt rename to gateway/src/commonMain/kotlin/Intent.kt index edc0b627cf1d..e54eff248fa0 100644 --- a/gateway/src/main/kotlin/Intent.kt +++ b/gateway/src/commonMain/kotlin/Intent.kt @@ -12,10 +12,11 @@ import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import kotlin.RequiresOptIn.Level.ERROR -import kotlin.annotation.AnnotationRetention.RUNTIME +import kotlin.annotation.AnnotationRetention.BINARY import kotlin.annotation.AnnotationTarget.* import kotlin.contracts.InvocationKind import kotlin.contracts.contract +import kotlin.jvm.JvmName /** * Some [Intent]s are defined as "privileged" due to the sensitive nature of the data and cannot be used by Kord without @@ -36,7 +37,7 @@ import kotlin.contracts.contract "more info on how to enable these.", level = ERROR, ) -@Retention(RUNTIME) +@Retention(BINARY) @Target(CLASS, PROPERTY, FUNCTION) public annotation class PrivilegedIntent diff --git a/gateway/src/main/kotlin/OpCode.kt b/gateway/src/commonMain/kotlin/OpCode.kt similarity index 100% rename from gateway/src/main/kotlin/OpCode.kt rename to gateway/src/commonMain/kotlin/OpCode.kt diff --git a/gateway/src/main/kotlin/Sequence.kt b/gateway/src/commonMain/kotlin/Sequence.kt similarity index 100% rename from gateway/src/main/kotlin/Sequence.kt rename to gateway/src/commonMain/kotlin/Sequence.kt diff --git a/gateway/src/main/kotlin/Ticker.kt b/gateway/src/commonMain/kotlin/Ticker.kt similarity index 56% rename from gateway/src/main/kotlin/Ticker.kt rename to gateway/src/commonMain/kotlin/Ticker.kt index e1cb39eaf578..419ef97c6a1b 100644 --- a/gateway/src/main/kotlin/Ticker.kt +++ b/gateway/src/commonMain/kotlin/Ticker.kt @@ -1,10 +1,10 @@ package dev.kord.gateway -import io.ktor.util.logging.* import kotlinx.coroutines.* -import kotlinx.coroutines.channels.ReceiveChannel -import kotlinx.coroutines.channels.consumeEach -import kotlinx.coroutines.channels.ticker +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import mu.KotlinLogging @@ -25,29 +25,35 @@ public class Ticker(private val dispatcher: CoroutineDispatcher = Dispatchers.De private val mutex = Mutex() - private var ticker: ReceiveChannel? = null + private var ticker: Flow? = null + private var listener: Job? = null public suspend fun tickAt(intervalMillis: Long, block: suspend () -> Unit) { stop() mutex.withLock { - ticker = ticker(intervalMillis) - - launch { - ticker?.consumeEach { - try { - block() - } catch (exception: Exception) { - logger.error(exception) - } + ticker = tickingFlow(intervalMillis) + + listener = ticker?.onEach { + try { + block() + } catch (exception: Exception) { + logger.error(exception) } - } + }?.launchIn(this) } } public suspend fun stop() { mutex.withLock { - ticker?.cancel() + listener?.cancel() } } } + +private fun tickingFlow(period: Long): Flow = flow { + while (true) { + emit(Unit) + delay(period) + } +} diff --git a/gateway/src/commonMain/kotlin/Utils.kt b/gateway/src/commonMain/kotlin/Utils.kt new file mode 100644 index 000000000000..a60a6b1a3963 --- /dev/null +++ b/gateway/src/commonMain/kotlin/Utils.kt @@ -0,0 +1,6 @@ +package dev.kord.gateway + +import mu.KLogger + +@PublishedApi +internal fun KLogger.error(throwable: Throwable): Unit = error(throwable) {} diff --git a/gateway/src/main/kotlin/builder/LoginBuilder.kt b/gateway/src/commonMain/kotlin/builder/LoginBuilder.kt similarity index 100% rename from gateway/src/main/kotlin/builder/LoginBuilder.kt rename to gateway/src/commonMain/kotlin/builder/LoginBuilder.kt diff --git a/gateway/src/main/kotlin/builder/PresenceBuilder.kt b/gateway/src/commonMain/kotlin/builder/PresenceBuilder.kt similarity index 96% rename from gateway/src/main/kotlin/builder/PresenceBuilder.kt rename to gateway/src/commonMain/kotlin/builder/PresenceBuilder.kt index fdf5b9011e6e..66204208460c 100644 --- a/gateway/src/main/kotlin/builder/PresenceBuilder.kt +++ b/gateway/src/commonMain/kotlin/builder/PresenceBuilder.kt @@ -36,7 +36,7 @@ public class PresenceBuilder { game = DiscordBotActivity(name, ActivityType.Competing) } - public fun toUpdateStatus(): UpdateStatus = UpdateStatus(since, game?.let(::listOf).orEmpty(), status, afk) + public fun toUpdateStatus(): UpdateStatus = UpdateStatus(since, listOfNotNull(game), status, afk) public fun toPresence(): DiscordPresence = DiscordPresence(status, afk, since, game) } diff --git a/gateway/src/main/kotlin/builder/RequestGuildMembersBuilder.kt b/gateway/src/commonMain/kotlin/builder/RequestGuildMembersBuilder.kt similarity index 100% rename from gateway/src/main/kotlin/builder/RequestGuildMembersBuilder.kt rename to gateway/src/commonMain/kotlin/builder/RequestGuildMembersBuilder.kt diff --git a/gateway/src/main/kotlin/handler/Handler.kt b/gateway/src/commonMain/kotlin/handler/Handler.kt similarity index 93% rename from gateway/src/main/kotlin/handler/Handler.kt rename to gateway/src/commonMain/kotlin/handler/Handler.kt index 786b7d9e3af4..70277bfd3c91 100644 --- a/gateway/src/main/kotlin/handler/Handler.kt +++ b/gateway/src/commonMain/kotlin/handler/Handler.kt @@ -14,7 +14,7 @@ private val logger = KotlinLogging.logger("[Handler]") internal abstract class Handler( val flow: Flow, val name: String, - private val dispatcher: CoroutineDispatcher = Dispatchers.Default + dispatcher: CoroutineDispatcher = Dispatchers.Default ) : CoroutineScope { override val coroutineContext: CoroutineContext = SupervisorJob() + dispatcher @@ -36,4 +36,4 @@ internal abstract class Handler( }.launchIn(this) } -} \ No newline at end of file +} diff --git a/gateway/src/main/kotlin/handler/HandshakeHandler.kt b/gateway/src/commonMain/kotlin/handler/HandshakeHandler.kt similarity index 100% rename from gateway/src/main/kotlin/handler/HandshakeHandler.kt rename to gateway/src/commonMain/kotlin/handler/HandshakeHandler.kt diff --git a/gateway/src/main/kotlin/handler/HeartbeatHandler.kt b/gateway/src/commonMain/kotlin/handler/HeartbeatHandler.kt similarity index 100% rename from gateway/src/main/kotlin/handler/HeartbeatHandler.kt rename to gateway/src/commonMain/kotlin/handler/HeartbeatHandler.kt diff --git a/gateway/src/main/kotlin/handler/InvalidSessionHandler.kt b/gateway/src/commonMain/kotlin/handler/InvalidSessionHandler.kt similarity index 100% rename from gateway/src/main/kotlin/handler/InvalidSessionHandler.kt rename to gateway/src/commonMain/kotlin/handler/InvalidSessionHandler.kt diff --git a/gateway/src/main/kotlin/handler/ReconnectHandler.kt b/gateway/src/commonMain/kotlin/handler/ReconnectHandler.kt similarity index 87% rename from gateway/src/main/kotlin/handler/ReconnectHandler.kt rename to gateway/src/commonMain/kotlin/handler/ReconnectHandler.kt index 390d0a813513..c25bed3a484b 100644 --- a/gateway/src/main/kotlin/handler/ReconnectHandler.kt +++ b/gateway/src/commonMain/kotlin/handler/ReconnectHandler.kt @@ -2,7 +2,6 @@ package dev.kord.gateway.handler import dev.kord.gateway.Event import dev.kord.gateway.Reconnect -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow internal class ReconnectHandler( @@ -15,4 +14,4 @@ internal class ReconnectHandler( reconnect() } } -} \ No newline at end of file +} diff --git a/gateway/src/main/kotlin/handler/SequenceHandler.kt b/gateway/src/commonMain/kotlin/handler/SequenceHandler.kt similarity index 100% rename from gateway/src/main/kotlin/handler/SequenceHandler.kt rename to gateway/src/commonMain/kotlin/handler/SequenceHandler.kt diff --git a/gateway/src/main/kotlin/ratelimit/IdentifyRateLimiter.kt b/gateway/src/commonMain/kotlin/ratelimit/IdentifyRateLimiter.kt similarity index 98% rename from gateway/src/main/kotlin/ratelimit/IdentifyRateLimiter.kt rename to gateway/src/commonMain/kotlin/ratelimit/IdentifyRateLimiter.kt index 9df2b725db93..abd2deba636b 100644 --- a/gateway/src/main/kotlin/ratelimit/IdentifyRateLimiter.kt +++ b/gateway/src/commonMain/kotlin/ratelimit/IdentifyRateLimiter.kt @@ -11,6 +11,8 @@ import kotlinx.coroutines.channels.onSuccess import kotlinx.coroutines.flow.* import kotlinx.coroutines.selects.select import mu.KotlinLogging +import kotlin.DeprecationLevel.ERROR +import kotlin.jvm.JvmField import kotlin.time.Duration.Companion.seconds import kotlin.time.times @@ -248,10 +250,9 @@ private class IdentifyRateLimiterImpl( private val ExceptionLogger = CoroutineExceptionHandler { context, exception -> // we can't be cancelled (GlobalScope) and we never close the channel, so all exceptions are bugs - logger.error( - "IdentifyRateLimiter threw an exception in context $context, please report this, it should not happen", - exception, - ) + logger.error(exception) { + "IdentifyRateLimiter threw an exception in context $context, please report this, it should not happen" + } } } } diff --git a/gateway/src/main/kotlin/retry/LinearRetry.kt b/gateway/src/commonMain/kotlin/retry/LinearRetry.kt similarity index 100% rename from gateway/src/main/kotlin/retry/LinearRetry.kt rename to gateway/src/commonMain/kotlin/retry/LinearRetry.kt diff --git a/gateway/src/main/kotlin/retry/Retry.kt b/gateway/src/commonMain/kotlin/retry/Retry.kt similarity index 100% rename from gateway/src/main/kotlin/retry/Retry.kt rename to gateway/src/commonMain/kotlin/retry/Retry.kt diff --git a/gateway/src/commonTest/kotlin/Platform.kt b/gateway/src/commonTest/kotlin/Platform.kt new file mode 100644 index 000000000000..68fd8dad98ee --- /dev/null +++ b/gateway/src/commonTest/kotlin/Platform.kt @@ -0,0 +1,5 @@ +package dev.kord.gateway + +internal expect fun getEnv(name: String): String? + +internal expect suspend fun readFile(prefix: String, name: String): String diff --git a/gateway/src/test/kotlin/gateway/DefaultGatewayTest.kt b/gateway/src/commonTest/kotlin/gateway/DefaultGatewayTest.kt similarity index 55% rename from gateway/src/test/kotlin/gateway/DefaultGatewayTest.kt rename to gateway/src/commonTest/kotlin/gateway/DefaultGatewayTest.kt index c5b08bbd2001..964c6803382d 100644 --- a/gateway/src/test/kotlin/gateway/DefaultGatewayTest.kt +++ b/gateway/src/commonTest/kotlin/gateway/DefaultGatewayTest.kt @@ -1,4 +1,4 @@ -package gateway +package dev.kord.gateway import dev.kord.common.entity.ActivityType import dev.kord.common.entity.DiscordBotActivity @@ -7,7 +7,6 @@ import dev.kord.common.ratelimit.IntervalRateLimiter import dev.kord.gateway.* import dev.kord.gateway.retry.LinearRetry import io.ktor.client.* -import io.ktor.client.engine.cio.* import io.ktor.client.plugins.contentnegotiation.* import io.ktor.client.plugins.websocket.* import io.ktor.serialization.kotlinx.json.* @@ -18,7 +17,8 @@ import kotlinx.coroutines.flow.filterIsInstance import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.test.runTest +import kotlin.js.JsName import kotlin.test.Ignore import kotlin.test.Test import kotlin.time.Duration.Companion.seconds @@ -26,18 +26,12 @@ import kotlin.time.Duration.Companion.seconds class DefaultGatewayTest { @OptIn(DelicateCoroutinesApi::class) @Test + @JsName("test1") @Ignore - fun `default gateway functions correctly`() { - val token = System.getenv("KORD_TEST_TOKEN") + fun `default gateway functions correctly`() = runTest { + val token = getEnv("KORD_TEST_TOKEN") ?: error("Missing env variable KORD_TEST_TOKEN") val gateway = DefaultGateway { - client = HttpClient(CIO) { - install(WebSockets) - install(ContentNegotiation) { - json() - } - } - reconnectRetry = LinearRetry(2.seconds, 20.seconds, 10) sendRateLimiter = IntervalRateLimiter(limit = 120, interval = 60.seconds) } @@ -49,17 +43,35 @@ class DefaultGatewayTest { "!restart" -> gateway.restart(Close.Reconnecting) "!detach" -> gateway.detach() "!status" -> when (words.getOrNull(1)) { - "playing" -> gateway.send(UpdateStatus(status = PresenceStatus.Online, afk = false, activities = listOf(DiscordBotActivity("Kord", ActivityType.Game)), since = null)) + "playing" -> gateway.send( + UpdateStatus( + status = PresenceStatus.Online, + afk = false, + activities = listOf(DiscordBotActivity("Kord", ActivityType.Game)), + since = null + ) + ) } - "!ping" -> gateway.send(UpdateStatus(status = PresenceStatus.Online, afk = false, activities = listOf(DiscordBotActivity("Ping is ${gateway.ping.value?.inWholeMilliseconds}", ActivityType.Game)), since = null)) + + "!ping" -> gateway.send( + UpdateStatus( + status = PresenceStatus.Online, + afk = false, + activities = listOf( + DiscordBotActivity( + "Ping is ${gateway.ping.value?.inWholeMilliseconds}", + ActivityType.Game + ) + ), + since = null + ) + ) } }.launchIn(GlobalScope) - runBlocking { - gateway.start(token) { - @OptIn(PrivilegedIntent::class) - intents = Intents.all - } + gateway.start(token) { + @OptIn(PrivilegedIntent::class) + intents = Intents.all } } } diff --git a/gateway/src/test/kotlin/helper/LinearRetryTest.kt b/gateway/src/commonTest/kotlin/helper/LinearRetryTest.kt similarity index 87% rename from gateway/src/test/kotlin/helper/LinearRetryTest.kt rename to gateway/src/commonTest/kotlin/helper/LinearRetryTest.kt index 5143c86af7b4..7f2ebfe37924 100644 --- a/gateway/src/test/kotlin/helper/LinearRetryTest.kt +++ b/gateway/src/commonTest/kotlin/helper/LinearRetryTest.kt @@ -4,6 +4,7 @@ import dev.kord.gateway.retry.LinearRetry import kotlinx.coroutines.test.currentTime import kotlinx.coroutines.test.runTest import kotlin.test.Test +import kotlin.test.assertEquals import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds @@ -23,8 +24,8 @@ class LinearRetryTest { val end = currentTime val elapsed = (end - start).milliseconds - assert(elapsed == 55.seconds) - assert(i == 10) + assertEquals(55.seconds, elapsed) + assertEquals(10, i) } @Test @@ -41,6 +42,6 @@ class LinearRetryTest { val end = currentTime val elapsed = (end - start).milliseconds - assert(elapsed == 1000.seconds) + assertEquals(1000.seconds, elapsed) } } diff --git a/gateway/src/test/kotlin/json/CommandTest.kt b/gateway/src/commonTest/kotlin/json/CommandTest.kt similarity index 97% rename from gateway/src/test/kotlin/json/CommandTest.kt rename to gateway/src/commonTest/kotlin/json/CommandTest.kt index fb27e0015f32..ded8edbead94 100644 --- a/gateway/src/test/kotlin/json/CommandTest.kt +++ b/gateway/src/commonTest/kotlin/json/CommandTest.kt @@ -11,6 +11,7 @@ import dev.kord.common.entity.optional.optionalInt import dev.kord.gateway.* import kotlinx.datetime.Instant import kotlinx.serialization.json.* +import kotlin.js.JsName import kotlin.test.assertEquals import kotlin.test.Test @@ -18,6 +19,7 @@ private val json = Json { encodeDefaults = false } class CommandTest { @Test + @JsName("test1") fun `Resume command serialization`() { val token = "token" val sessionId = "session" @@ -39,6 +41,7 @@ class CommandTest { @Test + @JsName("test2") fun `Heartbeat command serialization`() { val interval = 1337 @@ -54,6 +57,7 @@ class CommandTest { @Test + @JsName("test3") @OptIn(PrivilegedIntent::class) fun `RequestGuildMembers command serialization`() { val guildId = "1337" @@ -79,6 +83,7 @@ class CommandTest { @Test + @JsName("test4") fun `UpdateVoiceState command serialization`() { val guildId = "1337" val channelId = "420" @@ -105,6 +110,7 @@ class CommandTest { @Test + @JsName("test5") fun `UpdateState command serialization`() { val since = 1242518400L val activities = listOf() @@ -132,6 +138,7 @@ class CommandTest { @OptIn(PrivilegedIntent::class) @Test + @JsName("test6") fun `Identify command serialization`() { val token = "test" val properties = IdentifyProperties("os", "browser", "device") diff --git a/gateway/src/commonTest/kotlin/json/RegressionTests.kt b/gateway/src/commonTest/kotlin/json/RegressionTests.kt new file mode 100644 index 000000000000..f023e1e56b36 --- /dev/null +++ b/gateway/src/commonTest/kotlin/json/RegressionTests.kt @@ -0,0 +1,42 @@ +package json + +import dev.kord.gateway.Event +import dev.kord.gateway.Reconnect +import dev.kord.gateway.readFile +import kotlinx.coroutines.test.runTest +import kotlinx.serialization.json.Json +import kotlin.js.JsName +import kotlin.test.Test + +private suspend fun file(name: String): String = readFile("regression", name) + +class RegressionTests { + @Test + @JsName("test1") + fun `Resume command serialization`() = runTest { + val event = Json.decodeFromString(Event.DeserializationStrategy, file("eventWithDataThatShouldNotHaveData")) + event shouldBe Reconnect + } + + @Test + @JsName("test2") + fun `Resumed with unknown data`() = runTest { + Json.decodeFromString(Event.DeserializationStrategy, file("resumeWithUnknownData")) + } + + @Test + @JsName("test3") + fun `PresenceReplace with unknown data`() = runTest { + Json.decodeFromString(Event.DeserializationStrategy, file("presenceReplaceWithUnknownData")) + } + + @Test + @JsName("test4") + fun `Unknown event with successfully parses`() = runTest { + Json.decodeFromString( + Event.DeserializationStrategy, + file("eventWithUnknownData") + ) //dispatch event with non-existent type + } + +} diff --git a/gateway/src/test/kotlin/json/SerializationTest.kt b/gateway/src/commonTest/kotlin/json/SerializationTest.kt similarity index 84% rename from gateway/src/test/kotlin/json/SerializationTest.kt rename to gateway/src/commonTest/kotlin/json/SerializationTest.kt index 4d1e7da66f52..cf257e819fb3 100644 --- a/gateway/src/test/kotlin/json/SerializationTest.kt +++ b/gateway/src/commonTest/kotlin/json/SerializationTest.kt @@ -4,27 +4,28 @@ import dev.kord.common.entity.UserFlags import dev.kord.common.entity.UserPremium import dev.kord.common.entity.optional.value import dev.kord.gateway.* +import kotlinx.coroutines.test.runTest import kotlinx.datetime.Instant import kotlinx.serialization.json.Json +import kotlin.js.JsName import kotlin.test.Test import kotlin.time.Duration.Companion.seconds -private fun file(name: String): String { - val loader = SerializationTest::class.java.classLoader - return loader.getResource("json/event/$name.json")!!.readText() -} +private suspend fun file(name: String): String = readFile("event", name) class SerializationTest { @Test - fun `HeartbeatACK Event serialization`() { + @JsName("test1") + fun `HeartbeatACK Event serialization`() = runTest { val event = Json.decodeFromString(Event.DeserializationStrategy, file("ack")) event shouldBe HeartbeatACK } @Test - fun `Hello Event serialization`() { + @JsName("test2") + fun `Hello Event serialization`() = runTest { val event = Json.decodeFromString(Event.DeserializationStrategy, file("hello")) as Hello with(event) { heartbeatInterval shouldBe 1337 @@ -33,14 +34,16 @@ class SerializationTest { @Test - fun `Reconnect Event serialization`() { + @JsName("test3") + fun `Reconnect Event serialization`() = runTest { val event = Json.decodeFromString(Event.DeserializationStrategy, file("reconnect")) event shouldBe Reconnect } @Test - fun `Ready Event serialization`() { + @JsName("test4") + fun `Ready Event serialization`() = runTest { val event = Json.decodeFromString(Event.DeserializationStrategy, file("ready")) as Ready with(event.data) { with(event.data.guilds) { @@ -71,20 +74,23 @@ class SerializationTest { } @Test - fun `Resumed Event serialization`() { + @JsName("test5") + fun `Resumed Event serialization`() = runTest { Json.decodeFromString(Event.DeserializationStrategy, file("resumed")) as Resumed } @Test - fun `InvalidSession command serialization`() { + @JsName("test6") + fun `InvalidSession command serialization`() = runTest { val event = Json.decodeFromString(Event.DeserializationStrategy, file("invalid")) as InvalidSession with(event) { resumable shouldBe false } } @Test - fun `ChannelPinsUpdate Event serialization`() { + @JsName("test7") + fun `ChannelPinsUpdate Event serialization`() = runTest { val event = Json.decodeFromString(Event.DeserializationStrategy, file("channelpinsupdate")) as ChannelPinsUpdate with(event.pins) { guildId.value?.toString() shouldBe "41771983423143937" @@ -96,7 +102,8 @@ class SerializationTest { @Test - fun `ChannelCreate Event serialization`() { + @JsName("test8") + fun `ChannelCreate Event serialization`() = runTest { val event = Json.decodeFromString(Event.DeserializationStrategy, file("channelcreate")) as ChannelCreate with(event.channel) { id.toString() shouldBe "41771983423143937" @@ -115,7 +122,8 @@ class SerializationTest { @Test - fun `ChannelUpdate Event serialization`() { + @JsName("test9") + fun `ChannelUpdate Event serialization`() = runTest { val event = Json.decodeFromString(Event.DeserializationStrategy, file("channelupdate")) as ChannelUpdate with(event.channel) { id.toString() shouldBe "41771983423143937" @@ -133,7 +141,8 @@ class SerializationTest { } @Test - fun `ChannelDelete Event serialization`() { + @JsName("test10") + fun `ChannelDelete Event serialization`() = runTest { val event = Json.decodeFromString(Event.DeserializationStrategy, file("channeldelete")) as ChannelDelete with(event.channel) { id.toString() shouldBe "41771983423143937" diff --git a/gateway/src/test/kotlin/json/SnowflakeTest.kt b/gateway/src/commonTest/kotlin/json/SnowflakeTest.kt similarity index 95% rename from gateway/src/test/kotlin/json/SnowflakeTest.kt rename to gateway/src/commonTest/kotlin/json/SnowflakeTest.kt index bec8fd376ff9..f7d1baaf8bd7 100644 --- a/gateway/src/test/kotlin/json/SnowflakeTest.kt +++ b/gateway/src/commonTest/kotlin/json/SnowflakeTest.kt @@ -8,6 +8,7 @@ import kotlinx.serialization.json.Json import kotlinx.serialization.json.buildJsonObject import kotlinx.serialization.json.decodeFromJsonElement import kotlinx.serialization.json.put +import kotlin.js.JsName import kotlin.test.Test import kotlin.test.assertEquals @@ -17,6 +18,7 @@ class SnowflakeTest { private data class SnowflakeContainer(val snowflake: Snowflake) @Test + @JsName("test1") fun `Deserialization of Snowflake as String completes successfully`() { val value = "1337" val json = buildJsonObject { @@ -28,6 +30,7 @@ class SnowflakeTest { } @Test + @JsName("test2") fun `Deserialization of Snowflake as large String completes successfully`() { val value = Snowflake.validValues.last.toString() val json = buildJsonObject { @@ -39,6 +42,7 @@ class SnowflakeTest { } @Test + @JsName("test3") fun `Deserialization of Snowflake as Number completes successfully`() { val value = 1337L val json = buildJsonObject { @@ -50,6 +54,7 @@ class SnowflakeTest { } @Test + @JsName("test4") fun `Deserialization of Snowflake as large Number completes successfully`() { // ULong is inline class and therefore cannot extend abstract class Number but put only takes Number val value = Snowflake.validValues.last.toNumber() @@ -62,6 +67,7 @@ class SnowflakeTest { } @Test + @JsName("test5") fun `Reserialization of Snowflake completes successfully`() { val json = buildJsonObject { put("snowflake", 1337L) } diff --git a/gateway/src/test/kotlin/json/Util.kt b/gateway/src/commonTest/kotlin/json/Util.kt similarity index 100% rename from gateway/src/test/kotlin/json/Util.kt rename to gateway/src/commonTest/kotlin/json/Util.kt diff --git a/gateway/src/test/kotlin/ratelimit/IdentifyRateLimiterTest.kt b/gateway/src/commonTest/kotlin/ratelimit/IdentifyRateLimiterTest.kt similarity index 96% rename from gateway/src/test/kotlin/ratelimit/IdentifyRateLimiterTest.kt rename to gateway/src/commonTest/kotlin/ratelimit/IdentifyRateLimiterTest.kt index c0a451fd329b..4a2995b1de4e 100644 --- a/gateway/src/test/kotlin/ratelimit/IdentifyRateLimiterTest.kt +++ b/gateway/src/commonTest/kotlin/ratelimit/IdentifyRateLimiterTest.kt @@ -16,6 +16,7 @@ import kotlinx.coroutines.flow.SharingStarted.Companion.Eagerly import kotlinx.coroutines.test.currentTime import kotlinx.coroutines.test.runTest import kotlin.coroutines.ContinuationInterceptor +import kotlin.js.JsName import kotlin.random.Random import kotlin.random.nextInt import kotlin.test.Test @@ -53,7 +54,8 @@ private val CLOSE = DiscordClose(closeCode = Unknown, recoverable = true) class IdentifyRateLimiterTest { @Test - fun `IdentifyRateLimiter throws IAEs`() = runBlocking { + @JsName("test1") + fun `IdentifyRateLimiter throws IAEs`() = runTest { assertFailsWith { IdentifyRateLimiter(maxConcurrency = 0) } assertFailsWith { IdentifyRateLimiter(maxConcurrency = -1) } assertFailsWith { @@ -136,26 +138,32 @@ class IdentifyRateLimiterTest { // probably the most common case @Test + @JsName("test2") fun `single shard`() = testRateLimiter(shardIds = listOf(0), maxConcurrency = 1, expectedBuckets = 1) // https://discord.com/developers/docs/topics/gateway#sharding-max-concurrency @Test + @JsName("test3") fun `example 1`() = testRateLimiter(shardIds = 0..15, maxConcurrency = 16, expectedBuckets = 1) // https://discord.com/developers/docs/topics/gateway#sharding-max-concurrency @Test + @JsName("test4") fun `example 2`() = testRateLimiter(shardIds = 0..31, maxConcurrency = 16, expectedBuckets = 2) // https://discord.com/channels/613425648685547541/697489244649816084/1021565107949551676 @Test + @JsName("test5") fun `example 2 but without shards 15-30`() = testRateLimiter(shardIds = (0..14) + 31, maxConcurrency = 16, expectedBuckets = 1) // https://discord.com/channels/556525343595298817/1021384687337353216 @Test + @JsName("test6") fun `Schlaubi's case`() = testRateLimiter(shardIds = 0..14, maxConcurrency = 1, expectedBuckets = 15) @Test + @JsName("test7") fun `randomly distributed shards`() = testRateLimiter( shardIds = listOf(0, 4, 5, 10, 23), maxConcurrency = 2, @@ -164,6 +172,7 @@ class IdentifyRateLimiterTest { @Test + @JsName("test8") fun `IdentifyRateLimiter timeouts unresponsive gateways`() = runTest { val rateLimiter = IdentifyRateLimiter( maxConcurrency = 1, diff --git a/gateway/src/test/resources/json/event/ack.json b/gateway/src/commonTest/resources/json/event/ack.json similarity index 100% rename from gateway/src/test/resources/json/event/ack.json rename to gateway/src/commonTest/resources/json/event/ack.json diff --git a/gateway/src/test/resources/json/event/channelcreate.json b/gateway/src/commonTest/resources/json/event/channelcreate.json similarity index 100% rename from gateway/src/test/resources/json/event/channelcreate.json rename to gateway/src/commonTest/resources/json/event/channelcreate.json diff --git a/gateway/src/test/resources/json/event/channeldelete.json b/gateway/src/commonTest/resources/json/event/channeldelete.json similarity index 100% rename from gateway/src/test/resources/json/event/channeldelete.json rename to gateway/src/commonTest/resources/json/event/channeldelete.json diff --git a/gateway/src/test/resources/json/event/channelpinsupdate.json b/gateway/src/commonTest/resources/json/event/channelpinsupdate.json similarity index 100% rename from gateway/src/test/resources/json/event/channelpinsupdate.json rename to gateway/src/commonTest/resources/json/event/channelpinsupdate.json diff --git a/gateway/src/test/resources/json/event/channelupdate.json b/gateway/src/commonTest/resources/json/event/channelupdate.json similarity index 100% rename from gateway/src/test/resources/json/event/channelupdate.json rename to gateway/src/commonTest/resources/json/event/channelupdate.json diff --git a/gateway/src/test/resources/json/event/guildbanadd.json b/gateway/src/commonTest/resources/json/event/guildbanadd.json similarity index 100% rename from gateway/src/test/resources/json/event/guildbanadd.json rename to gateway/src/commonTest/resources/json/event/guildbanadd.json diff --git a/gateway/src/test/resources/json/event/guildbanremove.json b/gateway/src/commonTest/resources/json/event/guildbanremove.json similarity index 100% rename from gateway/src/test/resources/json/event/guildbanremove.json rename to gateway/src/commonTest/resources/json/event/guildbanremove.json diff --git a/gateway/src/test/resources/json/event/guildcreate.json b/gateway/src/commonTest/resources/json/event/guildcreate.json similarity index 100% rename from gateway/src/test/resources/json/event/guildcreate.json rename to gateway/src/commonTest/resources/json/event/guildcreate.json diff --git a/gateway/src/test/resources/json/event/guilddelete.json b/gateway/src/commonTest/resources/json/event/guilddelete.json similarity index 100% rename from gateway/src/test/resources/json/event/guilddelete.json rename to gateway/src/commonTest/resources/json/event/guilddelete.json diff --git a/gateway/src/test/resources/json/event/guildemojiupdate.json b/gateway/src/commonTest/resources/json/event/guildemojiupdate.json similarity index 100% rename from gateway/src/test/resources/json/event/guildemojiupdate.json rename to gateway/src/commonTest/resources/json/event/guildemojiupdate.json diff --git a/gateway/src/test/resources/json/event/guildintegrationsupdate.json b/gateway/src/commonTest/resources/json/event/guildintegrationsupdate.json similarity index 100% rename from gateway/src/test/resources/json/event/guildintegrationsupdate.json rename to gateway/src/commonTest/resources/json/event/guildintegrationsupdate.json diff --git a/gateway/src/test/resources/json/event/guildmemberadd.json b/gateway/src/commonTest/resources/json/event/guildmemberadd.json similarity index 100% rename from gateway/src/test/resources/json/event/guildmemberadd.json rename to gateway/src/commonTest/resources/json/event/guildmemberadd.json diff --git a/gateway/src/test/resources/json/event/guildmemeberremove.json b/gateway/src/commonTest/resources/json/event/guildmemeberremove.json similarity index 100% rename from gateway/src/test/resources/json/event/guildmemeberremove.json rename to gateway/src/commonTest/resources/json/event/guildmemeberremove.json diff --git a/gateway/src/test/resources/json/event/guildupdate.json b/gateway/src/commonTest/resources/json/event/guildupdate.json similarity index 100% rename from gateway/src/test/resources/json/event/guildupdate.json rename to gateway/src/commonTest/resources/json/event/guildupdate.json diff --git a/gateway/src/test/resources/json/event/hello.json b/gateway/src/commonTest/resources/json/event/hello.json similarity index 100% rename from gateway/src/test/resources/json/event/hello.json rename to gateway/src/commonTest/resources/json/event/hello.json diff --git a/gateway/src/test/resources/json/event/invalid.json b/gateway/src/commonTest/resources/json/event/invalid.json similarity index 100% rename from gateway/src/test/resources/json/event/invalid.json rename to gateway/src/commonTest/resources/json/event/invalid.json diff --git a/gateway/src/test/resources/json/event/ready.json b/gateway/src/commonTest/resources/json/event/ready.json similarity index 100% rename from gateway/src/test/resources/json/event/ready.json rename to gateway/src/commonTest/resources/json/event/ready.json diff --git a/gateway/src/test/resources/json/event/reconnect.json b/gateway/src/commonTest/resources/json/event/reconnect.json similarity index 100% rename from gateway/src/test/resources/json/event/reconnect.json rename to gateway/src/commonTest/resources/json/event/reconnect.json diff --git a/gateway/src/test/resources/json/event/resumed.json b/gateway/src/commonTest/resources/json/event/resumed.json similarity index 100% rename from gateway/src/test/resources/json/event/resumed.json rename to gateway/src/commonTest/resources/json/event/resumed.json diff --git a/gateway/src/test/resources/json/regression/eventWithDataThatShouldNotHaveData.json b/gateway/src/commonTest/resources/json/regression/eventWithDataThatShouldNotHaveData.json similarity index 100% rename from gateway/src/test/resources/json/regression/eventWithDataThatShouldNotHaveData.json rename to gateway/src/commonTest/resources/json/regression/eventWithDataThatShouldNotHaveData.json diff --git a/gateway/src/test/resources/json/regression/eventWithUnknownData.json b/gateway/src/commonTest/resources/json/regression/eventWithUnknownData.json similarity index 100% rename from gateway/src/test/resources/json/regression/eventWithUnknownData.json rename to gateway/src/commonTest/resources/json/regression/eventWithUnknownData.json diff --git a/gateway/src/test/resources/json/regression/presenceReplaceWithUnknownData.json b/gateway/src/commonTest/resources/json/regression/presenceReplaceWithUnknownData.json similarity index 100% rename from gateway/src/test/resources/json/regression/presenceReplaceWithUnknownData.json rename to gateway/src/commonTest/resources/json/regression/presenceReplaceWithUnknownData.json diff --git a/gateway/src/test/resources/json/regression/resumeWithUnknownData.json b/gateway/src/commonTest/resources/json/regression/resumeWithUnknownData.json similarity index 100% rename from gateway/src/test/resources/json/regression/resumeWithUnknownData.json rename to gateway/src/commonTest/resources/json/regression/resumeWithUnknownData.json diff --git a/gateway/src/test/resources/simplelogger.properties b/gateway/src/commonTest/resources/simplelogger.properties similarity index 100% rename from gateway/src/test/resources/simplelogger.properties rename to gateway/src/commonTest/resources/simplelogger.properties diff --git a/gateway/src/jsMain/kotlin/dev/kord/gateway/DefaultGateway.kt b/gateway/src/jsMain/kotlin/dev/kord/gateway/DefaultGateway.kt new file mode 100644 index 000000000000..c4d0d9eacf87 --- /dev/null +++ b/gateway/src/jsMain/kotlin/dev/kord/gateway/DefaultGateway.kt @@ -0,0 +1,7 @@ +package dev.kord.gateway + +import io.ktor.client.plugins.websocket.* +import node.process.process + +internal actual fun Throwable.isTimeout() = this is WebSocketException && "ENOTFOUND" in toString() +internal actual val os: String get() = process.platform.toString() diff --git a/gateway/src/jsMain/kotlin/dev/kord/gateway/HttpEngine.kt b/gateway/src/jsMain/kotlin/dev/kord/gateway/HttpEngine.kt new file mode 100644 index 000000000000..65e588d50386 --- /dev/null +++ b/gateway/src/jsMain/kotlin/dev/kord/gateway/HttpEngine.kt @@ -0,0 +1,7 @@ +package dev.kord.gateway + +import io.ktor.client.engine.* +import io.ktor.client.engine.js.* + +internal actual object HttpEngine : HttpClientEngineFactory by Js + diff --git a/gateway/src/jsMain/kotlin/dev/kord/gateway/Inflater.kt b/gateway/src/jsMain/kotlin/dev/kord/gateway/Inflater.kt new file mode 100644 index 000000000000..9ad8c6a3e13b --- /dev/null +++ b/gateway/src/jsMain/kotlin/dev/kord/gateway/Inflater.kt @@ -0,0 +1,16 @@ +package dev.kord.gateway + +import dev.kord.gateway.internal.Inflate +import io.ktor.websocket.* +import node.buffer.Buffer +import node.buffer.BufferEncoding + +internal actual class Inflater { + private val inflate = Inflate() + + actual suspend fun Frame.inflateData(): String { + val buffer = Buffer.from(data) + + return inflate.process(buffer).toString(BufferEncoding.utf8) + } +} diff --git a/gateway/src/jsMain/kotlin/dev/kord/gateway/internal/JsInflater.kt b/gateway/src/jsMain/kotlin/dev/kord/gateway/internal/JsInflater.kt new file mode 100644 index 000000000000..04f8913d17a3 --- /dev/null +++ b/gateway/src/jsMain/kotlin/dev/kord/gateway/internal/JsInflater.kt @@ -0,0 +1,11 @@ +@file:JsModule("fast-zlib") +@file:JsNonModule + +package dev.kord.gateway.internal + +import js.typedarrays.Uint8Array +import node.buffer.Buffer + +internal open external class Inflate { + open fun process(data: Uint8Array): Buffer +} diff --git a/gateway/src/jsTest/kotlin/dev/kord/gateway/Platform.kt b/gateway/src/jsTest/kotlin/dev/kord/gateway/Platform.kt new file mode 100644 index 000000000000..e8cc8e43bd91 --- /dev/null +++ b/gateway/src/jsTest/kotlin/dev/kord/gateway/Platform.kt @@ -0,0 +1,11 @@ +package dev.kord.gateway + +import js.core.get +import node.buffer.BufferEncoding +import node.process.process + +internal actual fun getEnv(name: String) = process.env[name] + +actual suspend fun readFile(prefix: String, name: String): String = + node.fs.readFile("${process.env["PROJECT_ROOT"]}/gateway/src/commonTest/resources/json/$prefix/$name.json") + .toString(BufferEncoding.utf8) diff --git a/gateway/src/jvmMain/kotlin/dev/kord/gateway/DefaultGateway.kt b/gateway/src/jvmMain/kotlin/dev/kord/gateway/DefaultGateway.kt new file mode 100644 index 000000000000..9077eba296ef --- /dev/null +++ b/gateway/src/jvmMain/kotlin/dev/kord/gateway/DefaultGateway.kt @@ -0,0 +1,7 @@ +@file:JvmName("DefaultGatewayJvm") +package dev.kord.gateway + +import java.nio.channels.UnresolvedAddressException + +internal actual fun Throwable.isTimeout() = this is UnresolvedAddressException +internal actual val os: String get() = System.getProperty("os.name") diff --git a/gateway/src/jvmMain/kotlin/dev/kord/gateway/HttpEngine.kt b/gateway/src/jvmMain/kotlin/dev/kord/gateway/HttpEngine.kt new file mode 100644 index 000000000000..4f33f4a89be8 --- /dev/null +++ b/gateway/src/jvmMain/kotlin/dev/kord/gateway/HttpEngine.kt @@ -0,0 +1,6 @@ +package dev.kord.gateway + +import io.ktor.client.engine.* +import io.ktor.client.engine.cio.* + +internal actual object HttpEngine : HttpClientEngineFactory by CIO diff --git a/gateway/src/jvmMain/kotlin/dev/kord/gateway/Inflater.kt b/gateway/src/jvmMain/kotlin/dev/kord/gateway/Inflater.kt new file mode 100644 index 000000000000..307f75d9684e --- /dev/null +++ b/gateway/src/jvmMain/kotlin/dev/kord/gateway/Inflater.kt @@ -0,0 +1,21 @@ +package dev.kord.gateway + +import io.ktor.websocket.* +import java.io.ByteArrayOutputStream +import java.util.zip.InflaterOutputStream +import java.util.zip.Inflater as JvmInflater + +internal actual class Inflater { + private val delegate = JvmInflater() + + actual suspend fun Frame.inflateData(): String { + val outputStream = ByteArrayOutputStream() + InflaterOutputStream(outputStream, delegate).use { + it.write(data) + } + + return outputStream.use { + String(outputStream.toByteArray(), 0, outputStream.size(), Charsets.UTF_8) + } + } +} diff --git a/gateway/src/jvmTest/kotlin/dev/kord/gateway/Platform.kt b/gateway/src/jvmTest/kotlin/dev/kord/gateway/Platform.kt new file mode 100644 index 000000000000..c590b965ee90 --- /dev/null +++ b/gateway/src/jvmTest/kotlin/dev/kord/gateway/Platform.kt @@ -0,0 +1,6 @@ +package dev.kord.gateway + +internal actual fun getEnv(name: String): String? = System.getenv(name) + +internal actual suspend fun readFile(prefix: String, name: String): String = + ClassLoader.getSystemResource("json/$prefix/$name.json").readText() diff --git a/gateway/src/samples/kotlin/EventListener.kt b/gateway/src/samples/kotlin/EventListener.kt index 1e6e92d062f7..762bc041915d 100644 --- a/gateway/src/samples/kotlin/EventListener.kt +++ b/gateway/src/samples/kotlin/EventListener.kt @@ -3,7 +3,6 @@ import dev.kord.common.ratelimit.IntervalRateLimiter import dev.kord.gateway.* import dev.kord.gateway.retry.LinearRetry import io.ktor.client.* -import io.ktor.client.engine.cio.* import io.ktor.client.plugins.contentnegotiation.* import io.ktor.client.plugins.websocket.* import io.ktor.serialization.kotlinx.json.* @@ -16,13 +15,6 @@ suspend fun main(args: Array) { val token = args.firstOrNull() ?: error("expected a token") val gateway = DefaultGateway { - client = HttpClient(CIO) { - install(WebSockets) - install(ContentNegotiation) { - json() - } - } - reconnectRetry = LinearRetry(2.seconds, 20.seconds, 10) sendRateLimiter = IntervalRateLimiter(limit = 120, interval = 60.seconds) } diff --git a/gateway/src/test/kotlin/json/RegressionTests.kt b/gateway/src/test/kotlin/json/RegressionTests.kt deleted file mode 100644 index 84bf1ffd3232..000000000000 --- a/gateway/src/test/kotlin/json/RegressionTests.kt +++ /dev/null @@ -1,35 +0,0 @@ -package json - -import dev.kord.gateway.Event -import dev.kord.gateway.Reconnect -import kotlinx.serialization.json.Json -import kotlin.test.Test - -private fun file(name: String): String { - val loader = SerializationTest::class.java.classLoader - return loader.getResource("json/regression/$name.json").readText() -} - -class RegressionTests { - @Test - fun `Resume command serialization`() { - val event = Json.decodeFromString(Event.DeserializationStrategy, file("eventWithDataThatShouldNotHaveData")) - event shouldBe Reconnect - } - - @Test - fun `Resumed with unknown data`() { - Json.decodeFromString(Event.DeserializationStrategy, file("resumeWithUnknownData")) - } - - @Test - fun `PresenceReplace with unknown data`() { - Json.decodeFromString(Event.DeserializationStrategy, file("presenceReplaceWithUnknownData")) - } - - @Test - fun `Unknown event with successfully parses`() { - Json.decodeFromString(Event.DeserializationStrategy, file("eventWithUnknownData")) //dispatch event with non-existent type - } - -} diff --git a/gradlew b/gradlew old mode 100755 new mode 100644 diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index b14cc9615a05..1173a5e9c97d 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -195,6 +195,11 @@ event-target-shim@^5.0.0: resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== +fast-zlib@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/fast-zlib/-/fast-zlib-2.0.1.tgz#be624f592fc80ad8019ee2025d16a367a4e9b024" + integrity sha512-DCoYgNagM2Bt1VIpXpdGnRx4LzqJeYG0oh6Nf/7cWo6elTXkFGMw9CrRCYYUIapYNrozYMoyDRflx9mgT3Awyw== + fill-range@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" @@ -544,6 +549,11 @@ typescript@3.9.5: resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.5.tgz#586f0dba300cde8be52dd1ac4f7e1009c1b13f36" integrity sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ== +typescript@4.7.4: + version "4.7.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235" + integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ== + webidl-conversions@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" diff --git a/settings.gradle.kts b/settings.gradle.kts index 4a02889a492c..08ea1eb4d203 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -13,6 +13,7 @@ include( "ksp-processors", "rest", "voice", + "js-test" ) enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") diff --git a/voice/build/generated/ksp/main/kotlin/dev/kord/voice/EncryptionMode.kt b/voice/build/generated/ksp/main/kotlin/dev/kord/voice/EncryptionMode.kt deleted file mode 100644 index c977d45f5d20..000000000000 --- a/voice/build/generated/ksp/main/kotlin/dev/kord/voice/EncryptionMode.kt +++ /dev/null @@ -1,85 +0,0 @@ -// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! -@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", - "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) - -package dev.kord.voice - -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.LazyThreadSafetyMode.PUBLICATION -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlinx.serialization.KSerializer -import kotlinx.serialization.Serializable -import kotlinx.serialization.descriptors.PrimitiveKind -import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor -import kotlinx.serialization.descriptors.SerialDescriptor -import kotlinx.serialization.encoding.Decoder -import kotlinx.serialization.encoding.Encoder - -/** - * See [EncryptionMode]s in the - * [Discord Developer Documentation](https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-encryption-modes). - */ -@Serializable(with = EncryptionMode.Serializer::class) -public sealed class EncryptionMode( - /** - * The raw value used by Discord. - */ - public val `value`: String, -) { - public final override fun equals(other: Any?): Boolean = this === other || - (other is EncryptionMode && this.value == other.value) - - public final override fun hashCode(): Int = value.hashCode() - - public final override fun toString(): String = - "EncryptionMode.${this::class.simpleName}(value=$value)" - - /** - * An unknown [EncryptionMode]. - * - * This is used as a fallback for [EncryptionMode]s that haven't been added to Kord yet. - */ - public class Unknown( - `value`: String, - ) : EncryptionMode(value) - - public object XSalsa20Poly1305 : EncryptionMode("xsalsa20_poly1305") - - public object XSalsa20Poly1305Suffix : EncryptionMode("xsalsa20_poly1305_suffix") - - public object XSalsa20Poly1305Lite : EncryptionMode("xsalsa20_poly1305_lite") - - internal object Serializer : KSerializer { - public override val descriptor: SerialDescriptor = - PrimitiveSerialDescriptor("dev.kord.voice.EncryptionMode", PrimitiveKind.STRING) - - public override fun serialize(encoder: Encoder, `value`: EncryptionMode) = - encoder.encodeString(value.value) - - public override fun deserialize(decoder: Decoder) = - when (val value = decoder.decodeString()) { - "xsalsa20_poly1305" -> XSalsa20Poly1305 - "xsalsa20_poly1305_suffix" -> XSalsa20Poly1305Suffix - "xsalsa20_poly1305_lite" -> XSalsa20Poly1305Lite - else -> Unknown(value) - } - } - - public companion object { - /** - * A [List] of all known [EncryptionMode]s. - */ - public val entries: List by lazy(mode = PUBLICATION) { - listOf( - XSalsa20Poly1305, - XSalsa20Poly1305Suffix, - XSalsa20Poly1305Lite, - ) - } - - } -} From 13cb3e4e6c41e5ab601a84f6a1ff85c2517b7773 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Feb 2023 22:03:49 +0100 Subject: [PATCH 016/136] Fix core tests --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dba1bda5066f..6c5cef251009 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -88,7 +88,7 @@ ksp-plugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin ktor-client-serialization = ["ktor-client-content-negotiation", "ktor-serialization-kotlinx-json"] -test-implementation = ["kotlinx-coroutines-test", "kotlin-test", "junit-jupiter-api", "mockk"] +test-implementation = ["kotlinx-coroutines-test", "kotlin-test-junit5", "junit-jupiter-api", "mockk"] test-common = ["kotlinx-coroutines-test", "kotlin-test", "kotlin-test-annotations-common"] test-runtime = ["kotlin-test-junit5", "junit-jupiter-engine", "slf4j-simple"] test-js = ["kotlin-test-js", "kotlinx-nodejs"] From ca1c841c3aff495f2dfb2b563933d87bf7170721 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Feb 2023 22:07:21 +0100 Subject: [PATCH 017/136] Make gradlew executable again --- gradlew | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 gradlew diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 From 6d2a8c167dbf142c552a45a2a3ae6d12a37d0abb Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Feb 2023 22:16:05 +0100 Subject: [PATCH 018/136] Whoops --- core/src/samples/kotlin/PingBot.kt | 63 ++++++------------------------ 1 file changed, 13 insertions(+), 50 deletions(-) diff --git a/core/src/samples/kotlin/PingBot.kt b/core/src/samples/kotlin/PingBot.kt index 2a51cacd8399..8569d9e8b4aa 100644 --- a/core/src/samples/kotlin/PingBot.kt +++ b/core/src/samples/kotlin/PingBot.kt @@ -1,58 +1,21 @@ -import dev.kord.common.entity.PresenceStatus -import dev.kord.common.ratelimit.IntervalRateLimiter -import dev.kord.gateway.* -import dev.kord.gateway.retry.LinearRetry -import kotlinx.coroutines.flow.filterIsInstance -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach -import kotlin.time.Duration.Companion.seconds -import kotlin.time.ExperimentalTime +import dev.kord.core.Kord +import dev.kord.core.event.message.MessageCreateEvent +import dev.kord.core.on +import dev.kord.gateway.Intent +import dev.kord.gateway.PrivilegedIntent -@OptIn(ExperimentalTime::class) -suspend fun main() { - // - val token = "NTM1MTI5NDA2NjUwMzE4ODYw.GAQrFJ.r0EwX1yDw_2W2ERHl9vnvtQjxqw88vxCOhDskA" - // +suspend fun main(args: Array) { + val kord = Kord(args.firstOrNull() ?: error("token required")) - val gateway = DefaultGateway { - reconnectRetry = LinearRetry(2.seconds, 20.seconds, 10) - sendRateLimiter = IntervalRateLimiter(limit = 120, interval = 60.seconds) + kord.on { + if (message.author?.isBot == true) return@on + if (message.content == "!ping") message.channel.createMessage("pong") } - gateway.events.filterIsInstance().onEach { - val words = it.message.content.split(' ') - when (words.firstOrNull()) { - "!close" -> gateway.stop() - "!detach" -> gateway.detach() - "!status" -> when (words.getOrNull(1)) { - "playing" -> gateway.editPresence { - status = PresenceStatus.Online - afk = false - playing("Kord") - } - } + kord.login { + presence { playing("!ping to pong") } - "!ping" -> gateway.editPresence { - status = PresenceStatus.Online - afk = false - listening("a ${gateway.ping.value?.inWholeMilliseconds} ms ping") - } - } - }.launchIn(gateway) - - gateway.start(token) { @OptIn(PrivilegedIntent::class) - intents = Intents.all + intents += Intent.MessageContent } } -//DEBUG: [Function] Identifying on shard 0 with rate_limit_key 0... -//TRACE: [Function] opening gateway connection to wss://gateway.discord.gg/?v=10&encoding=json&compress=zlib-stream -//TRACE: Sending WebSocket request [object Object] -//TRACE: Receive websocket session from wss://gateway.discord.gg/?v=10&encoding=json&compress=zlib-stream: [object Object] -//TRACE: [Function] Received raw frame: Frame BINARY (fin=false, buffer len = 114) -//TRACE: [Function] Gateway <<< {"t":null,"s":null,"op":10,"d":{"heartbeat_interval":41250,"_trace":["[\"gateway-prd-us-east1-d-bdzc\",{\"micros\":0.0}]"]}} -//TRACE: [Function] Gateway >>> {"op":2,"d":{"token":"token","properties":{"os":"win32","browser":"Kord","device":"Kord"},"compress":false,"large_threshold":250,"shard":[0,1],"intents":"3276799"}} -//TRACE: [Function] Gateway >>> {"op":1,"d":null} -//TRACE: [Function] Gateway >>> {"op":1,"d":null} -//TRACE: [Function] Received raw frame: Frame BINARY (fin=false, buffer len = 15) -//DEBUG: [Function] Identifying on shard 0 timed out, delaying 5s before freeing up rate_limit_key 0 From 93849d54c41fed18cfd64691f61ba6741e25f064 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 27 Feb 2023 13:04:46 +0100 Subject: [PATCH 019/136] Migrate core --- .../main/kotlin/kord-publishing.gradle.kts | 3 +- ...rd-sampled-multiplatform-module.gradle.kts | 11 -------- common/src/commonTest/kotlin/BitSetTests.kt | 6 ++-- .../kotlin/ClientResources.kt | 0 core/src/{main => commonMain}/kotlin/Kord.kt | 0 .../{main => commonMain}/kotlin/KordObject.kt | 0 .../src/{main => commonMain}/kotlin/Unsafe.kt | 0 core/src/{main => commonMain}/kotlin/Util.kt | 3 ++ .../behavior/ChatInputCommandBehavior.kt | 0 .../GlobalApplicationCommandBehavior.kt | 0 .../kotlin/behavior/GuildBehavior.kt | 4 +-- .../kotlin/behavior/GuildEmojiBehavior.kt | 4 +-- .../behavior/GuildScheduledEventBehavior.kt | 0 .../kotlin/behavior/MemberBehavior.kt | 5 ++-- .../kotlin/behavior/MessageBehavior.kt | 4 +-- .../kotlin/behavior/MessageCommandBehavior.kt | 0 .../kotlin/behavior/RoleBehavior.kt | 4 +-- .../kotlin/behavior/StageInstanceBehavior.kt | 0 .../kotlin/behavior/StickerBehavior.kt | 0 .../kotlin/behavior/TemplateBehavior.kt | 4 +-- .../kotlin/behavior/ThreadMemberBehavior.kt | 0 .../kotlin/behavior/UserBehavior.kt | 4 +-- .../kotlin/behavior/UserCommandBehavior.kt | 0 .../kotlin/behavior/WebhookBehavior.kt | 4 +-- .../AutoModerationRuleBehavior.kt | 4 +-- .../channel/BaseVoiceChannelBehavior.kt | 0 .../channel/CategorizableChannelBehavior.kt | 4 +-- .../behavior/channel/CategoryBehavior.kt | 4 +-- .../behavior/channel/ChannelBehavior.kt | 4 +-- .../behavior/channel/ForumChannelBehavior.kt | 0 .../behavior/channel/GuildChannelBehavior.kt | 4 +-- .../channel/GuildMessageChannelBehavior.kt | 0 .../channel/MessageChannelBehavior.kt | 8 ++++-- .../behavior/channel/NewsChannelBehavior.kt | 6 ++-- .../behavior/channel/StageChannelBehavior.kt | 0 .../behavior/channel/TextChannelBehavior.kt | 6 ++-- .../channel/TopGuildChannelBehavior.kt | 4 +-- .../channel/TopGuildMessageChannelBehavior.kt | 8 ++++-- .../behavior/channel/VoiceChannelBehavior.kt | 4 +-- .../channel/threads/ThreadChannelBehavior.kt | 0 .../threads/ThreadParentChannelBehavior.kt | 6 ++-- .../interaction/ActionInteractionBehavior.kt | 0 .../ApplicationCommandInteractionBehavior.kt | 0 .../AutoCompleteInteractionBehavior.kt | 0 .../ComponentInteractionBehavior.kt | 0 .../interaction/DataInteractionBehavior.kt | 0 .../interaction/GlobalInteractionBehavior.kt | 0 .../interaction/GuildInteractionBehavior.kt | 0 .../interaction/InteractionBehavior.kt | 0 .../ModalParentInteractionBehavior.kt | 0 .../EphemeralFollowupMessageBehavior.kt | 0 .../followup/FollowupMessageBehavior.kt | 0 .../followup/PublicFollowupMessageBehavior.kt | 0 ...rredEphemeralMessageInteractionBehavior.kt | 0 ...erredMessageInteractionResponseBehavior.kt | 0 ...ublicMessageInteractionResponseBehavior.kt | 0 .../response/EditOriginalResponse.kt | 0 .../EphemeralInteractionResponseBehavior.kt | 0 ...meralMessageInteractionResponseBehavior.kt | 0 ...upPermittingInteractionResponseBehavior.kt | 0 .../response/InteractionResponseBehavior.kt | 0 .../MessageInteractionResponseBehavior.kt | 0 .../PopupInteractionResponseBehavior.kt | 0 .../PublicInteractionResponseBehavior.kt | 0 ...PublicMesageInteractionResponseBehavior.kt | 0 .../component/ButtonBuilderExtensions.kt | 0 .../kotlin/builder/kord/KordBuilder.kt | 25 +++++------------ .../kotlin/builder/kord/KordBuilderUtil.kt | 5 ++-- .../kotlin/builder/kord/KordProxyBuilder.kt | 0 .../builder/kord/KordRestOnlyBuilder.kt | 0 .../kotlin/builder/kord/RestOnlyBuilder.kt | 0 .../kotlin/cache/CachingGateway.kt | 0 .../kotlin/cache/DataCacheExtensions.kt | 0 .../kotlin/cache/DataCacheView.kt | 0 .../kotlin/cache/KordCache.kt | 13 ++------- .../kotlin/cache/Query.kt | 1 + .../kotlin/cache/data/ActivityData.kt | 0 .../cache/data/ApplicationCommandData.kt | 0 .../kotlin/cache/data/ApplicationData.kt | 0 .../kotlin/cache/data/AttachmentData.kt | 0 .../kotlin/cache/data/AutoModeration.kt | 0 .../kotlin/cache/data/BanData.kt | 0 .../kotlin/cache/data/ChannelData.kt | 0 .../kotlin/cache/data/ClientStatusData.kt | 0 .../kotlin/cache/data/ComponentData.kt | 0 .../kotlin/cache/data/EmbedData.kt | 0 .../kotlin/cache/data/EmojiData.kt | 0 .../GuildApplicationCommandPermissionData.kt | 3 ++ .../GuildApplicationCommandPermissionsData.kt | 0 .../kotlin/cache/data/GuildData.kt | 0 .../kotlin/cache/data/GuildPreviewData.kt | 0 .../cache/data/GuildScheduledEventData.kt | 0 .../kotlin/cache/data/GuildWidgetData.kt | 0 .../kotlin/cache/data/IntegrationData.kt | 0 .../cache/data/IntegrationsAccountData.kt | 0 .../kotlin/cache/data/InteractionData.kt | 0 .../kotlin/cache/data/InviteCreateData.kt | 0 .../kotlin/cache/data/InviteData.kt | 0 .../kotlin/cache/data/InviteDeleteData.kt | 0 .../kotlin/cache/data/MemberData.kt | 0 .../kotlin/cache/data/MembersChunkData.kt | 0 .../kotlin/cache/data/MessageData.kt | 0 .../cache/data/MessageInteractionData.kt | 0 .../kotlin/cache/data/MessageReferenceData.kt | 0 .../kotlin/cache/data/PartialGuildData.kt | 0 .../cache/data/PermissionOverwriteData.kt | 0 .../kotlin/cache/data/PresenceData.kt | 0 .../kotlin/cache/data/ReactionData.kt | 0 .../cache/data/ReactionRemoveEmojiData.kt | 0 .../kotlin/cache/data/RegionData.kt | 0 .../kotlin/cache/data/RoleData.kt | 0 .../kotlin/cache/data/RoleTagsData.kt | 0 .../kotlin/cache/data/SelectOptionData.kt | 0 .../kotlin/cache/data/StageInstanceData.kt | 0 .../kotlin/cache/data/StickerData.kt | 0 .../kotlin/cache/data/TeamData.kt | 0 .../kotlin/cache/data/TemplateData.kt | 0 .../kotlin/cache/data/ThreadListSyncData.kt | 0 .../kotlin/cache/data/ThreadMemberData.kt | 0 .../data/ThreadMembersUpdateEventData.kt | 0 .../kotlin/cache/data/UserData.kt | 0 .../kotlin/cache/data/VoiceStateData.kt | 0 .../kotlin/cache/data/WebhookData.kt | 0 .../kotlin/cache/data/WelcomeScreenData.kt | 0 .../kotlin/entity/Activity.kt | 0 .../kotlin/entity/Application.kt | 4 +-- .../kotlin/entity/Attachment.kt | 4 +-- .../kotlin/entity/AuditLog.kt | 0 .../{main => commonMain}/kotlin/entity/Ban.kt | 0 .../kotlin/entity/Embed.kt | 0 .../kotlin/entity/Entity.kt | 1 - .../kotlin/entity/Guild.kt | 8 ++++-- .../kotlin/entity/GuildEmoji.kt | 4 +-- .../kotlin/entity/GuildPreview.kt | 0 .../kotlin/entity/GuildScheduledEvent.kt | 0 .../kotlin/entity/GuildWidget.kt | 0 .../kotlin/entity/Icon.kt | 2 +- .../kotlin/entity/Integration.kt | 0 .../kotlin/entity/Invite.kt | 0 .../kotlin/entity/Member.kt | 4 +-- .../kotlin/entity/Message.kt | 4 +-- .../kotlin/entity/MessageReference.kt | 0 .../kotlin/entity/PartialGuild.kt | 4 +-- .../kotlin/entity/PermissionOverwrite.kt | 0 .../entity/PermissionOverwriteEntity.kt | 0 .../kotlin/entity/Presence.kt | 0 .../kotlin/entity/Reaction.kt | 0 .../kotlin/entity/ReactionEmoji.kt | 0 .../kotlin/entity/Region.kt | 4 +-- .../kotlin/entity/Role.kt | 4 +-- .../kotlin/entity/RoleTags.kt | 0 .../kotlin/entity/StageInstance.kt | 0 .../kotlin/entity/Sticker.kt | 0 .../kotlin/entity/Strategizable.kt | 0 .../kotlin/entity/Team.kt | 0 .../kotlin/entity/Template.kt | 0 .../kotlin/entity/User.kt | 0 .../kotlin/entity/VoiceState.kt | 0 .../kotlin/entity/Webhook.kt | 4 +-- .../kotlin/entity/WelcomeScreen.kt | 0 .../entity/application/ApplicationCommand.kt | 0 .../ApplicationGuildCommandPermissions.kt | 2 ++ .../application/ChatInputCommandCommand.kt | 0 .../entity/application/MessageCommand.kt | 0 .../kotlin/entity/application/UserCommand.kt | 0 .../automoderation/AutoModerationAction.kt | 0 .../automoderation/AutoModerationRule.kt | 0 .../entity/channel/CategorizableChannel.kt | 0 .../kotlin/entity/channel/Category.kt | 4 +-- .../kotlin/entity/channel/Channel.kt | 0 .../kotlin/entity/channel/DmChannel.kt | 5 ++-- .../kotlin/entity/channel/ForumChannel.kt | 0 .../kotlin/entity/channel/GuildChannel.kt | 0 .../entity/channel/GuildMessageChannel.kt | 0 .../kotlin/entity/channel/MessageChannel.kt | 0 .../kotlin/entity/channel/NewsChannel.kt | 4 +-- .../kotlin/entity/channel/ResolvedChannel.kt | 0 .../entity/channel/StageVoiceChannel.kt | 4 +-- .../kotlin/entity/channel/TextChannel.kt | 4 +-- .../entity/channel/ThreadParentChannel.kt | 0 .../kotlin/entity/channel/TopGuildChannel.kt | 0 .../entity/channel/TopGuildMessageChannel.kt | 0 .../kotlin/entity/channel/VoiceChannel.kt | 4 +-- .../entity/channel/WelcomeScreenChannel.kt | 0 .../channel/thread/DeletedThreadChannel.kt | 0 .../channel/thread/NewsChannelThread.kt | 0 .../channel/thread/TextChannelThread.kt | 0 .../entity/channel/thread/ThreadChannel.kt | 0 .../entity/channel/thread/ThreadMember.kt | 0 .../entity/component/ActionRowComponent.kt | 0 .../entity/component/ButtonComponent.kt | 0 .../kotlin/entity/component/Component.kt | 0 .../entity/component/SelectMenuComponent.kt | 1 + .../entity/component/TextInputComponent.kt | 0 .../entity/component/UnknownComponent.kt | 0 .../entity/interaction/ActionInteraction.kt | 0 .../ApplicationCommandInteraction.kt | 0 .../interaction/AutoCompleteInteraction.kt | 0 .../entity/interaction/ButtonInteraction.kt | 0 .../ChatInputCommandInteraction.kt | 0 .../interaction/ComponentInteraction.kt | 0 .../entity/interaction/DataInteraction.kt | 0 .../entity/interaction/GlobalInteraction.kt | 0 .../entity/interaction/GuildInteraction.kt | 0 .../kotlin/entity/interaction/Interaction.kt | 0 .../entity/interaction/InteractionCommand.kt | 0 .../interaction/MessageCommandInteraction.kt | 0 .../interaction/ModalSubmitInteraction.kt | 0 .../kotlin/entity/interaction/OptionValue.kt | 0 .../entity/interaction/ResolvedObjects.kt | 0 .../interaction/SelectMenuInteraction.kt | 0 .../interaction/UserCommandInteraction.kt | 0 .../followup/EphemeralFollowupMessage.kt | 0 .../interaction/followup/FollowupMessage.kt | 0 .../followup/PublicFollowupMessage.kt | 0 .../EphemeralMessageInteractionResponse.kt | 0 .../response/MessageInteractionResponse.kt | 0 .../PublicMessageInteractionResponse.kt | 0 .../kotlin/event/Event.kt | 0 .../AutoModerationActionExecutionEvent.kt | 0 .../automoderation/AutoModerationEvent.kt | 0 .../AutoModerationRuleConfigurationEvent.kt | 0 .../AutoModerationActionExecutionEventData.kt | 0 .../event/channel/ChannelCreateEvent.kt | 0 .../event/channel/ChannelDeleteEvent.kt | 0 .../event/channel/ChannelPinsUpdateEvent.kt | 0 .../event/channel/ChannelUpdateEvent.kt | 0 .../kotlin/event/channel/TypingStartEvent.kt | 0 .../data/ChannelPinsUpdateEventData.kt | 0 .../channel/data/TypingStartEventData.kt | 0 .../event/channel/thread/ThreadCreateEvent.kt | 0 .../event/channel/thread/ThreadDeleteEvent.kt | 0 .../channel/thread/ThreadListSyncEvent.kt | 0 .../channel/thread/ThreadMemberUpdateEvent.kt | 0 .../thread/ThreadMembersUpdateEvent.kt | 0 .../event/channel/thread/ThreadUpdateEvent.kt | 0 .../kotlin/event/gateway/Events.kt | 0 .../kotlin/event/guild/BanAddEvent.kt | 0 .../kotlin/event/guild/BanRemoveEvent.kt | 0 .../kotlin/event/guild/EmojisUpdateEvent.kt | 0 .../guild/GuildAuditLogEntryCreateEvent.kt | 0 .../kotlin/event/guild/GuildCreateEvent.kt | 0 .../kotlin/event/guild/GuildDeleteEvent.kt | 0 .../guild/GuildScheduledEventCreateEvent.kt | 0 .../guild/GuildScheduledEventDeleteEvent.kt | 0 .../event/guild/GuildScheduledEventEvent.kt | 0 .../guild/GuildScheduledEventUpdateEvent.kt | 0 .../guild/GuildScheduledEventUserEvent.kt | 0 .../kotlin/event/guild/GuildUpdateEvent.kt | 0 .../event/guild/IntegrationCreateEvent.kt | 0 .../event/guild/IntegrationDeleteEvent.kt | 0 .../event/guild/IntegrationUpdateEvent.kt | 0 .../event/guild/IntegrationsUpdateEvent.kt | 0 .../kotlin/event/guild/InviteCreateEvent.kt | 0 .../kotlin/event/guild/InviteDeleteEvent.kt | 0 .../kotlin/event/guild/MemberJoinEvent.kt | 0 .../kotlin/event/guild/MemberLeaveEvent.kt | 0 .../kotlin/event/guild/MemberUpdateEvent.kt | 0 .../kotlin/event/guild/MembersChunkEvent.kt | 0 .../event/guild/VoiceServerUpdateEvent.kt | 0 .../kotlin/event/guild/WebhookUpdateEvent.kt | 0 .../interaction/ApplicationCommandCreate.kt | 0 .../interaction/ApplicationCommandDelete.kt | 0 .../ApplicationCommandInteractionCreate.kt | 0 ...pplicationCommandPermissionsUpdateEvent.kt | 0 .../interaction/ApplicationCommandUpdate.kt | 0 .../AutoCompleteInteractionCreate.kt | 0 .../interaction/ComponentInteractionCreate.kt | 0 .../event/interaction/InteractionCreate.kt | 0 .../ModalSubmitInteractionCreate.kt | 0 .../event/message/MessageBulkDeleteEvent.kt | 0 .../event/message/MessageCreateEvent.kt | 0 .../event/message/MessageDeleteEvent.kt | 0 .../event/message/MessageUpdateEvent.kt | 0 .../kotlin/event/message/ReactionAddEvent.kt | 0 .../event/message/ReactionRemoveAllEvent.kt | 0 .../event/message/ReactionRemoveEmojiEvent.kt | 0 .../event/message/ReactionRemoveEvent.kt | 0 .../kotlin/event/role/RoleCreateEvent.kt | 0 .../kotlin/event/role/RoleDeleteEvent.kt | 0 .../kotlin/event/role/RoleUpdateEvent.kt | 0 .../kotlin/event/user/PresenceUpdateEvent.kt | 0 .../kotlin/event/user/UserUpdateEvent.kt | 0 .../event/user/VoiceStateUpdateEvent.kt | 0 .../exception/EntityNotFoundException.kt | 0 .../exception/GatewayNotFoundException.kt | 0 .../exception/KordInitializationException.kt | 0 .../kotlin/gateway/DefaultMasterGateway.kt | 0 .../kotlin/gateway/MasterGateway.kt | 0 .../handler/AutoModerationEventHandler.kt | 0 .../handler/BaseGatewayEventHandler.kt | 0 .../gateway/handler/ChannelEventHandler.kt | 0 .../handler/DefaultGatewayEventInterceptor.kt | 2 +- .../handler/GatewayEventInterceptor.kt | 0 .../gateway/handler/GuildEventHandler.kt | 0 .../handler/InteractionEventHandler.kt | 0 .../gateway/handler/LifeCycleEventHandler.kt | 0 .../gateway/handler/MessageEventHandler.kt | 0 .../gateway/handler/ThreadEventHandler.kt | 0 .../gateway/handler/UnknownEventHandler.kt | 0 .../gateway/handler/UserEventHandler.kt | 0 .../gateway/handler/VoiceEventHandler.kt | 0 .../gateway/handler/WebhookEventHandler.kt | 0 .../kotlin/live/LiveGuild.kt | 0 .../kotlin/live/LiveKordEntity.kt | 0 .../kotlin/live/LiveMember.kt | 0 .../kotlin/live/LiveMessage.kt | 0 .../kotlin/live/LiveRole.kt | 0 .../kotlin/live/LiveUser.kt | 0 .../kotlin/live/channel/LiveCategory.kt | 0 .../kotlin/live/channel/LiveChannel.kt | 0 .../kotlin/live/channel/LiveDmChannel.kt | 0 .../kotlin/live/channel/LiveGuildChannel.kt | 0 .../live/channel/LiveGuildMessageChannel.kt | 0 .../kotlin/live/channel/LiveVoiceChannel.kt | 0 .../exception/LiveCancellationException.kt | 2 +- .../kotlin/supplier/CacheEntitySupplier.kt | 0 .../kotlin/supplier/EntitySupplier.kt | 0 .../kotlin/supplier/EntitySupplyStrategy.kt | 0 .../kotlin/supplier/FallbackEntitySupplier.kt | 0 .../kotlin/supplier/RestEntitySupplier.kt | 0 .../kotlin/supplier/StoreEntitySupplier.kt | 0 .../dev/kord/core/builder/kord/KordBuilder.kt | 3 ++ .../dev/kord/core/builder/kord/KordBuilder.kt | 26 ++++++++++++++++++ .../dev/kord/core/cache/KordCacheBuilder.kt | 17 ++++++++++++ core/src/{test => jvmTest}/kotlin/KordTest.kt | 0 .../{test => jvmTest}/kotlin/StrategyTest.kt | 0 core/src/{test => jvmTest}/kotlin/Util.kt | 0 .../{test => jvmTest}/kotlin/UtilKtTest.kt | 0 .../kotlin/behavior/GuildBehaviorTest.kt | 0 .../kotlin/behavior/MemberBehaviorTest.kt | 0 .../kotlin/behavior/MessageBehaviorTest.kt | 0 .../kotlin/behavior/RoleBehaviorTest.kt | 0 .../kotlin/behavior/UserBehaviorTest.kt | 0 .../kotlin/behavior/WebhookBehaviorTest.kt | 0 .../behavior/channel/CategoryBehaviorTest.kt | 0 .../behavior/channel/ChannelBehaviorTest.kt | 0 .../channel/GuildChannelBehaviorTest.kt | 0 .../GuildMessageChannelBehaviorTest.kt | 0 .../channel/MessageChannelBehaviorTest.kt | 0 .../channel/NewsChannelBehaviorTest.kt | 0 .../channel/TextChannelBehaviorTest.kt | 0 .../channel/VoiceChannelBehaviorTest.kt | 0 .../kotlin/cache/data/ComponentDataTest.kt | 0 .../kotlin/entity/ApplicationTest.kt | 0 .../kotlin/entity/AttachmentTest.kt | 0 .../kotlin/entity/GuildEmojiTest.kt | 0 .../kotlin/entity/GuildTest.kt | 0 .../kotlin/entity/IntegrationTest.kt | 0 .../kotlin/entity/MemberTest.kt | 0 .../kotlin/entity/MessageTest.kt | 0 .../kotlin/entity/RoleTest.kt | 0 .../kotlin/entity/UserTest.kt | 0 .../kotlin/entity/WebhookTest.kt | 0 .../kotlin/entity/channel/CategoryTest.kt | 0 .../kotlin/entity/channel/DmChannelTest.kt | 0 .../kotlin/entity/channel/NewsChannelTest.kt | 0 .../kotlin/entity/channel/TextChannelTest.kt | 0 .../kotlin/entity/channel/VoiceChannelTest.kt | 0 .../kotlin/equality/BehaviorEqualityTest.kt | 0 .../kotlin/equality/ChannelEqualityTest.kt | 0 .../kotlin/equality/EntityEqualityTest.kt | 0 .../equality/GuildChannelEqualityTest.kt | 0 .../equality/GuildEntityEqualityTest.kt | 0 .../kotlin/gateway/MasterGatewayTest.kt | 0 .../kotlin/interaction/CommandTypesTest.kt | 0 .../kotlin/live/AbstractLiveEntityTest.kt | 0 .../kotlin/live/LiveGuildTest.kt | 0 .../kotlin/live/LiveKordEntityTest.kt | 0 .../kotlin/live/LiveMemberTest.kt | 0 .../kotlin/live/LiveMessageTest.kt | 0 .../kotlin/live/LiveRoleTest.kt | 0 .../kotlin/live/LiveUserTest.kt | 0 .../kotlin/live/channel/LiveCategoryTest.kt | 0 .../kotlin/live/channel/LiveChannelTest.kt | 0 .../kotlin/live/channel/LiveDmChannelTest.kt | 0 .../live/channel/LiveGuildChannelTest.kt | 0 .../kotlin/live/channel/LiveGuildTextTest.kt | 0 .../live/channel/LiveVoiceChannelTest.kt | 0 .../kotlin/performance/KordEventDropTest.kt | 0 .../kotlin/regression/CacheMissRegression.kt | 0 .../kotlin/regression/ReactionEmojiTest.kt | 0 .../{test => jvmTest}/kotlin/rest/RestTest.kt | 0 .../supplier/CacheEntitySupplierTest.kt | 0 .../resources/images/gitlab.png | Bin .../resources/images/kord.png | Bin .../resources/images/kord_icon.png | Bin .../interaction/groupsubcommand.json | 0 .../resources/interaction/rootcommand.json | 0 .../resources/interaction/subcommand.json | 0 .../resources/simplelogger.properties | 0 .../channel/BaseVoiceChannelBehavior.kt | 4 +-- 392 files changed, 164 insertions(+), 130 deletions(-) delete mode 100644 buildSrc/src/main/kotlin/kord-sampled-multiplatform-module.gradle.kts rename core/src/{main => commonMain}/kotlin/ClientResources.kt (100%) rename core/src/{main => commonMain}/kotlin/Kord.kt (100%) rename core/src/{main => commonMain}/kotlin/KordObject.kt (100%) rename core/src/{main => commonMain}/kotlin/Unsafe.kt (100%) rename core/src/{main => commonMain}/kotlin/Util.kt (99%) rename core/src/{main => commonMain}/kotlin/behavior/ChatInputCommandBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/GlobalApplicationCommandBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/GuildBehavior.kt (99%) rename core/src/{main => commonMain}/kotlin/behavior/GuildEmojiBehavior.kt (97%) rename core/src/{main => commonMain}/kotlin/behavior/GuildScheduledEventBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/MemberBehavior.kt (98%) rename core/src/{main => commonMain}/kotlin/behavior/MessageBehavior.kt (99%) rename core/src/{main => commonMain}/kotlin/behavior/MessageCommandBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/RoleBehavior.kt (98%) rename core/src/{main => commonMain}/kotlin/behavior/StageInstanceBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/StickerBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/TemplateBehavior.kt (96%) rename core/src/{main => commonMain}/kotlin/behavior/ThreadMemberBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/UserBehavior.kt (98%) rename core/src/{main => commonMain}/kotlin/behavior/UserCommandBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/WebhookBehavior.kt (98%) rename core/src/{main => commonMain}/kotlin/behavior/automoderation/AutoModerationRuleBehavior.kt (99%) rename core/src/{main => commonMain}/kotlin/behavior/channel/BaseVoiceChannelBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/channel/CategorizableChannelBehavior.kt (98%) rename core/src/{main => commonMain}/kotlin/behavior/channel/CategoryBehavior.kt (98%) rename core/src/{main => commonMain}/kotlin/behavior/channel/ChannelBehavior.kt (98%) rename core/src/{main => commonMain}/kotlin/behavior/channel/ForumChannelBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/channel/GuildChannelBehavior.kt (98%) rename core/src/{main => commonMain}/kotlin/behavior/channel/GuildMessageChannelBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/channel/MessageChannelBehavior.kt (98%) rename core/src/{main => commonMain}/kotlin/behavior/channel/NewsChannelBehavior.kt (98%) rename core/src/{main => commonMain}/kotlin/behavior/channel/StageChannelBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/channel/TextChannelBehavior.kt (98%) rename core/src/{main => commonMain}/kotlin/behavior/channel/TopGuildChannelBehavior.kt (98%) rename core/src/{main => commonMain}/kotlin/behavior/channel/TopGuildMessageChannelBehavior.kt (94%) rename core/src/{main => commonMain}/kotlin/behavior/channel/VoiceChannelBehavior.kt (98%) rename core/src/{main => commonMain}/kotlin/behavior/channel/threads/ThreadChannelBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/channel/threads/ThreadParentChannelBehavior.kt (98%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/ActionInteractionBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/ApplicationCommandInteractionBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/AutoCompleteInteractionBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/ComponentInteractionBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/DataInteractionBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/GlobalInteractionBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/GuildInteractionBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/InteractionBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/ModalParentInteractionBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/followup/EphemeralFollowupMessageBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/followup/FollowupMessageBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/followup/PublicFollowupMessageBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/response/DeferredEphemeralMessageInteractionBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/response/DeferredMessageInteractionResponseBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/response/DeferredPublicMessageInteractionResponseBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/response/EditOriginalResponse.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/response/EphemeralInteractionResponseBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/response/EphemeralMessageInteractionResponseBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/response/FollowupPermittingInteractionResponseBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/response/InteractionResponseBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/response/MessageInteractionResponseBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/response/PopupInteractionResponseBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/response/PublicInteractionResponseBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/behavior/interaction/response/PublicMesageInteractionResponseBehavior.kt (100%) rename core/src/{main => commonMain}/kotlin/builder/component/ButtonBuilderExtensions.kt (100%) rename core/src/{main => commonMain}/kotlin/builder/kord/KordBuilder.kt (94%) rename core/src/{main => commonMain}/kotlin/builder/kord/KordBuilderUtil.kt (92%) rename core/src/{main => commonMain}/kotlin/builder/kord/KordProxyBuilder.kt (100%) rename core/src/{main => commonMain}/kotlin/builder/kord/KordRestOnlyBuilder.kt (100%) rename core/src/{main => commonMain}/kotlin/builder/kord/RestOnlyBuilder.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/CachingGateway.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/DataCacheExtensions.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/DataCacheView.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/KordCache.kt (90%) rename core/src/{main => commonMain}/kotlin/cache/Query.kt (98%) rename core/src/{main => commonMain}/kotlin/cache/data/ActivityData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/ApplicationCommandData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/ApplicationData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/AttachmentData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/AutoModeration.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/BanData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/ChannelData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/ClientStatusData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/ComponentData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/EmbedData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/EmojiData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/GuildApplicationCommandPermissionData.kt (90%) rename core/src/{main => commonMain}/kotlin/cache/data/GuildApplicationCommandPermissionsData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/GuildData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/GuildPreviewData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/GuildScheduledEventData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/GuildWidgetData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/IntegrationData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/IntegrationsAccountData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/InteractionData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/InviteCreateData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/InviteData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/InviteDeleteData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/MemberData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/MembersChunkData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/MessageData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/MessageInteractionData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/MessageReferenceData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/PartialGuildData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/PermissionOverwriteData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/PresenceData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/ReactionData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/ReactionRemoveEmojiData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/RegionData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/RoleData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/RoleTagsData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/SelectOptionData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/StageInstanceData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/StickerData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/TeamData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/TemplateData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/ThreadListSyncData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/ThreadMemberData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/ThreadMembersUpdateEventData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/UserData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/VoiceStateData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/WebhookData.kt (100%) rename core/src/{main => commonMain}/kotlin/cache/data/WelcomeScreenData.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/Activity.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/Application.kt (98%) rename core/src/{main => commonMain}/kotlin/entity/Attachment.kt (96%) rename core/src/{main => commonMain}/kotlin/entity/AuditLog.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/Ban.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/Embed.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/Entity.kt (95%) rename core/src/{main => commonMain}/kotlin/entity/Guild.kt (98%) rename core/src/{main => commonMain}/kotlin/entity/GuildEmoji.kt (98%) rename core/src/{main => commonMain}/kotlin/entity/GuildPreview.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/GuildScheduledEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/GuildWidget.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/Icon.kt (95%) rename core/src/{main => commonMain}/kotlin/entity/Integration.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/Invite.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/Member.kt (98%) rename core/src/{main => commonMain}/kotlin/entity/Message.kt (99%) rename core/src/{main => commonMain}/kotlin/entity/MessageReference.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/PartialGuild.kt (98%) rename core/src/{main => commonMain}/kotlin/entity/PermissionOverwrite.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/PermissionOverwriteEntity.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/Presence.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/Reaction.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/ReactionEmoji.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/Region.kt (90%) rename core/src/{main => commonMain}/kotlin/entity/Role.kt (96%) rename core/src/{main => commonMain}/kotlin/entity/RoleTags.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/StageInstance.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/Sticker.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/Strategizable.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/Team.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/Template.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/User.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/VoiceState.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/Webhook.kt (97%) rename core/src/{main => commonMain}/kotlin/entity/WelcomeScreen.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/application/ApplicationCommand.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/application/ApplicationGuildCommandPermissions.kt (94%) rename core/src/{main => commonMain}/kotlin/entity/application/ChatInputCommandCommand.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/application/MessageCommand.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/application/UserCommand.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/automoderation/AutoModerationAction.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/automoderation/AutoModerationRule.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/channel/CategorizableChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/channel/Category.kt (95%) rename core/src/{main => commonMain}/kotlin/entity/channel/Channel.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/channel/DmChannel.kt (96%) rename core/src/{main => commonMain}/kotlin/entity/channel/ForumChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/channel/GuildChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/channel/GuildMessageChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/channel/MessageChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/channel/NewsChannel.kt (94%) rename core/src/{main => commonMain}/kotlin/entity/channel/ResolvedChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/channel/StageVoiceChannel.kt (95%) rename core/src/{main => commonMain}/kotlin/entity/channel/TextChannel.kt (96%) rename core/src/{main => commonMain}/kotlin/entity/channel/ThreadParentChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/channel/TopGuildChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/channel/TopGuildMessageChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/channel/VoiceChannel.kt (97%) rename core/src/{main => commonMain}/kotlin/entity/channel/WelcomeScreenChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/channel/thread/DeletedThreadChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/channel/thread/NewsChannelThread.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/channel/thread/TextChannelThread.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/channel/thread/ThreadChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/channel/thread/ThreadMember.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/component/ActionRowComponent.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/component/ButtonComponent.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/component/Component.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/component/SelectMenuComponent.kt (99%) rename core/src/{main => commonMain}/kotlin/entity/component/TextInputComponent.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/component/UnknownComponent.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/ActionInteraction.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/ApplicationCommandInteraction.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/AutoCompleteInteraction.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/ButtonInteraction.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/ChatInputCommandInteraction.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/ComponentInteraction.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/DataInteraction.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/GlobalInteraction.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/GuildInteraction.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/Interaction.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/InteractionCommand.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/MessageCommandInteraction.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/ModalSubmitInteraction.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/OptionValue.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/ResolvedObjects.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/SelectMenuInteraction.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/UserCommandInteraction.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/followup/EphemeralFollowupMessage.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/followup/FollowupMessage.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/followup/PublicFollowupMessage.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/response/EphemeralMessageInteractionResponse.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/response/MessageInteractionResponse.kt (100%) rename core/src/{main => commonMain}/kotlin/entity/interaction/response/PublicMessageInteractionResponse.kt (100%) rename core/src/{main => commonMain}/kotlin/event/Event.kt (100%) rename core/src/{main => commonMain}/kotlin/event/automoderation/AutoModerationActionExecutionEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/automoderation/AutoModerationEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/automoderation/AutoModerationRuleConfigurationEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/automoderation/data/AutoModerationActionExecutionEventData.kt (100%) rename core/src/{main => commonMain}/kotlin/event/channel/ChannelCreateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/channel/ChannelDeleteEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/channel/ChannelPinsUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/channel/ChannelUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/channel/TypingStartEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/channel/data/ChannelPinsUpdateEventData.kt (100%) rename core/src/{main => commonMain}/kotlin/event/channel/data/TypingStartEventData.kt (100%) rename core/src/{main => commonMain}/kotlin/event/channel/thread/ThreadCreateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/channel/thread/ThreadDeleteEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/channel/thread/ThreadListSyncEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/channel/thread/ThreadMemberUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/channel/thread/ThreadMembersUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/channel/thread/ThreadUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/gateway/Events.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/BanAddEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/BanRemoveEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/EmojisUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/GuildAuditLogEntryCreateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/GuildCreateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/GuildDeleteEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/GuildScheduledEventCreateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/GuildScheduledEventDeleteEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/GuildScheduledEventEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/GuildScheduledEventUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/GuildScheduledEventUserEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/GuildUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/IntegrationCreateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/IntegrationDeleteEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/IntegrationUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/IntegrationsUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/InviteCreateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/InviteDeleteEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/MemberJoinEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/MemberLeaveEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/MemberUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/MembersChunkEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/VoiceServerUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/guild/WebhookUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/interaction/ApplicationCommandCreate.kt (100%) rename core/src/{main => commonMain}/kotlin/event/interaction/ApplicationCommandDelete.kt (100%) rename core/src/{main => commonMain}/kotlin/event/interaction/ApplicationCommandInteractionCreate.kt (100%) rename core/src/{main => commonMain}/kotlin/event/interaction/ApplicationCommandPermissionsUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/interaction/ApplicationCommandUpdate.kt (100%) rename core/src/{main => commonMain}/kotlin/event/interaction/AutoCompleteInteractionCreate.kt (100%) rename core/src/{main => commonMain}/kotlin/event/interaction/ComponentInteractionCreate.kt (100%) rename core/src/{main => commonMain}/kotlin/event/interaction/InteractionCreate.kt (100%) rename core/src/{main => commonMain}/kotlin/event/interaction/ModalSubmitInteractionCreate.kt (100%) rename core/src/{main => commonMain}/kotlin/event/message/MessageBulkDeleteEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/message/MessageCreateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/message/MessageDeleteEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/message/MessageUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/message/ReactionAddEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/message/ReactionRemoveAllEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/message/ReactionRemoveEmojiEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/message/ReactionRemoveEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/role/RoleCreateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/role/RoleDeleteEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/role/RoleUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/user/PresenceUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/user/UserUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/event/user/VoiceStateUpdateEvent.kt (100%) rename core/src/{main => commonMain}/kotlin/exception/EntityNotFoundException.kt (100%) rename core/src/{main => commonMain}/kotlin/exception/GatewayNotFoundException.kt (100%) rename core/src/{main => commonMain}/kotlin/exception/KordInitializationException.kt (100%) rename core/src/{main => commonMain}/kotlin/gateway/DefaultMasterGateway.kt (100%) rename core/src/{main => commonMain}/kotlin/gateway/MasterGateway.kt (100%) rename core/src/{main => commonMain}/kotlin/gateway/handler/AutoModerationEventHandler.kt (100%) rename core/src/{main => commonMain}/kotlin/gateway/handler/BaseGatewayEventHandler.kt (100%) rename core/src/{main => commonMain}/kotlin/gateway/handler/ChannelEventHandler.kt (100%) rename core/src/{main => commonMain}/kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt (98%) rename core/src/{main => commonMain}/kotlin/gateway/handler/GatewayEventInterceptor.kt (100%) rename core/src/{main => commonMain}/kotlin/gateway/handler/GuildEventHandler.kt (100%) rename core/src/{main => commonMain}/kotlin/gateway/handler/InteractionEventHandler.kt (100%) rename core/src/{main => commonMain}/kotlin/gateway/handler/LifeCycleEventHandler.kt (100%) rename core/src/{main => commonMain}/kotlin/gateway/handler/MessageEventHandler.kt (100%) rename core/src/{main => commonMain}/kotlin/gateway/handler/ThreadEventHandler.kt (100%) rename core/src/{main => commonMain}/kotlin/gateway/handler/UnknownEventHandler.kt (100%) rename core/src/{main => commonMain}/kotlin/gateway/handler/UserEventHandler.kt (100%) rename core/src/{main => commonMain}/kotlin/gateway/handler/VoiceEventHandler.kt (100%) rename core/src/{main => commonMain}/kotlin/gateway/handler/WebhookEventHandler.kt (100%) rename core/src/{main => commonMain}/kotlin/live/LiveGuild.kt (100%) rename core/src/{main => commonMain}/kotlin/live/LiveKordEntity.kt (100%) rename core/src/{main => commonMain}/kotlin/live/LiveMember.kt (100%) rename core/src/{main => commonMain}/kotlin/live/LiveMessage.kt (100%) rename core/src/{main => commonMain}/kotlin/live/LiveRole.kt (100%) rename core/src/{main => commonMain}/kotlin/live/LiveUser.kt (100%) rename core/src/{main => commonMain}/kotlin/live/channel/LiveCategory.kt (100%) rename core/src/{main => commonMain}/kotlin/live/channel/LiveChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/live/channel/LiveDmChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/live/channel/LiveGuildChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/live/channel/LiveGuildMessageChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/live/channel/LiveVoiceChannel.kt (100%) rename core/src/{main => commonMain}/kotlin/live/exception/LiveCancellationException.kt (79%) rename core/src/{main => commonMain}/kotlin/supplier/CacheEntitySupplier.kt (100%) rename core/src/{main => commonMain}/kotlin/supplier/EntitySupplier.kt (100%) rename core/src/{main => commonMain}/kotlin/supplier/EntitySupplyStrategy.kt (100%) rename core/src/{main => commonMain}/kotlin/supplier/FallbackEntitySupplier.kt (100%) rename core/src/{main => commonMain}/kotlin/supplier/RestEntitySupplier.kt (100%) rename core/src/{main => commonMain}/kotlin/supplier/StoreEntitySupplier.kt (100%) create mode 100644 core/src/jsMain/kotlin/dev/kord/core/builder/kord/KordBuilder.kt create mode 100644 core/src/jvmMain/kotlin/dev/kord/core/builder/kord/KordBuilder.kt create mode 100644 core/src/jvmMain/kotlin/dev/kord/core/cache/KordCacheBuilder.kt rename core/src/{test => jvmTest}/kotlin/KordTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/StrategyTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/Util.kt (100%) rename core/src/{test => jvmTest}/kotlin/UtilKtTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/behavior/GuildBehaviorTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/behavior/MemberBehaviorTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/behavior/MessageBehaviorTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/behavior/RoleBehaviorTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/behavior/UserBehaviorTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/behavior/WebhookBehaviorTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/behavior/channel/CategoryBehaviorTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/behavior/channel/ChannelBehaviorTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/behavior/channel/GuildChannelBehaviorTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/behavior/channel/GuildMessageChannelBehaviorTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/behavior/channel/MessageChannelBehaviorTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/behavior/channel/NewsChannelBehaviorTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/behavior/channel/TextChannelBehaviorTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/behavior/channel/VoiceChannelBehaviorTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/cache/data/ComponentDataTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/entity/ApplicationTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/entity/AttachmentTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/entity/GuildEmojiTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/entity/GuildTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/entity/IntegrationTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/entity/MemberTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/entity/MessageTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/entity/RoleTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/entity/UserTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/entity/WebhookTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/entity/channel/CategoryTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/entity/channel/DmChannelTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/entity/channel/NewsChannelTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/entity/channel/TextChannelTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/entity/channel/VoiceChannelTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/equality/BehaviorEqualityTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/equality/ChannelEqualityTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/equality/EntityEqualityTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/equality/GuildChannelEqualityTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/equality/GuildEntityEqualityTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/gateway/MasterGatewayTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/interaction/CommandTypesTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/live/AbstractLiveEntityTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/live/LiveGuildTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/live/LiveKordEntityTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/live/LiveMemberTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/live/LiveMessageTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/live/LiveRoleTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/live/LiveUserTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/live/channel/LiveCategoryTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/live/channel/LiveChannelTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/live/channel/LiveDmChannelTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/live/channel/LiveGuildChannelTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/live/channel/LiveGuildTextTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/live/channel/LiveVoiceChannelTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/performance/KordEventDropTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/regression/CacheMissRegression.kt (100%) rename core/src/{test => jvmTest}/kotlin/regression/ReactionEmojiTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/rest/RestTest.kt (100%) rename core/src/{test => jvmTest}/kotlin/supplier/CacheEntitySupplierTest.kt (100%) rename core/src/{test => jvmTest}/resources/images/gitlab.png (100%) rename core/src/{test => jvmTest}/resources/images/kord.png (100%) rename core/src/{test => jvmTest}/resources/images/kord_icon.png (100%) rename core/src/{test => jvmTest}/resources/interaction/groupsubcommand.json (100%) rename core/src/{test => jvmTest}/resources/interaction/rootcommand.json (100%) rename core/src/{test => jvmTest}/resources/interaction/subcommand.json (100%) rename core/src/{test => jvmTest}/resources/simplelogger.properties (100%) rename core/{src/voice => voice/src/main}/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehavior.kt (87%) diff --git a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts index 79cc194d5a45..6bff04ef271e 100644 --- a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts @@ -1,4 +1,3 @@ -import gradle.kotlin.dsl.accessors._e5121a5856746b077c6819bbe5a86a2f.dokkaHtml import java.util.Base64 plugins { @@ -11,7 +10,7 @@ if(tasks.findByName("dokkaHtml") != null) { group = JavaBasePlugin.DOCUMENTATION_GROUP description = "Assembles Kotlin docs with Dokka" archiveClassifier.set("javadoc") - from(tasks.dokkaHtml) + from(tasks.getByName("dokkaHtml")) } publishing.publications.withType { artifact(dokkaJar) diff --git a/buildSrc/src/main/kotlin/kord-sampled-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-sampled-multiplatform-module.gradle.kts deleted file mode 100644 index 42d3978fe5fc..000000000000 --- a/buildSrc/src/main/kotlin/kord-sampled-multiplatform-module.gradle.kts +++ /dev/null @@ -1,11 +0,0 @@ -plugins { - org.jetbrains.kotlin.multiplatform -} - -kotlin { - sourceSets { - create("samples") { - dependsOn(getByName("jvmMain")) - } - } -} diff --git a/common/src/commonTest/kotlin/BitSetTests.kt b/common/src/commonTest/kotlin/BitSetTests.kt index 70f7f807bf50..c827b5c20f8e 100644 --- a/common/src/commonTest/kotlin/BitSetTests.kt +++ b/common/src/commonTest/kotlin/BitSetTests.kt @@ -73,9 +73,9 @@ class BitSetTests { fun `add and remove a bit`() { val a = DiscordBitSet(0b101, 0) a.add(DiscordBitSet(0b111)) - assert(a.value == 0b111.toString()) + assertEquals(0b111.toString(), a.value) a.remove(DiscordBitSet(0b001)) - assert(a.value == 0b110.toString()) + assertEquals(0b110.toString(), a.value) } @Test @@ -83,7 +83,7 @@ class BitSetTests { fun `remove a bit`() { val a = DiscordBitSet(0b101, 0) a.remove(DiscordBitSet(0b111)) - assert(a.value == "0") + assertEquals("0", a.value) } @Test diff --git a/core/src/main/kotlin/ClientResources.kt b/core/src/commonMain/kotlin/ClientResources.kt similarity index 100% rename from core/src/main/kotlin/ClientResources.kt rename to core/src/commonMain/kotlin/ClientResources.kt diff --git a/core/src/main/kotlin/Kord.kt b/core/src/commonMain/kotlin/Kord.kt similarity index 100% rename from core/src/main/kotlin/Kord.kt rename to core/src/commonMain/kotlin/Kord.kt diff --git a/core/src/main/kotlin/KordObject.kt b/core/src/commonMain/kotlin/KordObject.kt similarity index 100% rename from core/src/main/kotlin/KordObject.kt rename to core/src/commonMain/kotlin/KordObject.kt diff --git a/core/src/main/kotlin/Unsafe.kt b/core/src/commonMain/kotlin/Unsafe.kt similarity index 100% rename from core/src/main/kotlin/Unsafe.kt rename to core/src/commonMain/kotlin/Unsafe.kt diff --git a/core/src/main/kotlin/Util.kt b/core/src/commonMain/kotlin/Util.kt similarity index 99% rename from core/src/main/kotlin/Util.kt rename to core/src/commonMain/kotlin/Util.kt index 49e8e660a499..3e1ab0894397 100644 --- a/core/src/main/kotlin/Util.kt +++ b/core/src/commonMain/kotlin/Util.kt @@ -476,3 +476,6 @@ public fun Intents.IntentsBuilder.enableEvent(event: KClass): Unit = else -> Unit } + +// Replacement of hash +internal fun hash(vararg values: Any?) = values.contentHashCode() diff --git a/core/src/main/kotlin/behavior/ChatInputCommandBehavior.kt b/core/src/commonMain/kotlin/behavior/ChatInputCommandBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/ChatInputCommandBehavior.kt rename to core/src/commonMain/kotlin/behavior/ChatInputCommandBehavior.kt diff --git a/core/src/main/kotlin/behavior/GlobalApplicationCommandBehavior.kt b/core/src/commonMain/kotlin/behavior/GlobalApplicationCommandBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/GlobalApplicationCommandBehavior.kt rename to core/src/commonMain/kotlin/behavior/GlobalApplicationCommandBehavior.kt diff --git a/core/src/main/kotlin/behavior/GuildBehavior.kt b/core/src/commonMain/kotlin/behavior/GuildBehavior.kt similarity index 99% rename from core/src/main/kotlin/behavior/GuildBehavior.kt rename to core/src/commonMain/kotlin/behavior/GuildBehavior.kt index d2eb16c0bf5a..dd799b81a3dd 100644 --- a/core/src/main/kotlin/behavior/GuildBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/GuildBehavior.kt @@ -22,6 +22,7 @@ import dev.kord.core.entity.channel.* import dev.kord.core.entity.channel.thread.ThreadChannel import dev.kord.core.event.guild.MembersChunkEvent import dev.kord.core.exception.EntityNotFoundException +import dev.kord.core.hash import dev.kord.core.supplier.* import dev.kord.core.supplier.EntitySupplyStrategy.Companion.rest import dev.kord.gateway.Gateway @@ -53,7 +54,6 @@ import dev.kord.rest.request.RestRequestException import dev.kord.rest.service.* import kotlinx.coroutines.flow.* import kotlinx.datetime.Instant -import java.util.Objects import kotlin.contracts.InvocationKind import kotlin.contracts.InvocationKind.EXACTLY_ONCE import kotlin.contracts.contract @@ -658,7 +658,7 @@ public fun GuildBehavior( override val kord: Kord = kord override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id) + override fun hashCode(): Int = hash(id) override fun equals(other: Any?): Boolean = when (other) { is GuildBehavior -> other.id == id diff --git a/core/src/main/kotlin/behavior/GuildEmojiBehavior.kt b/core/src/commonMain/kotlin/behavior/GuildEmojiBehavior.kt similarity index 97% rename from core/src/main/kotlin/behavior/GuildEmojiBehavior.kt rename to core/src/commonMain/kotlin/behavior/GuildEmojiBehavior.kt index 31242215bdce..d71f3aa431bc 100644 --- a/core/src/main/kotlin/behavior/GuildEmojiBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/GuildEmojiBehavior.kt @@ -6,11 +6,11 @@ import dev.kord.core.cache.data.EmojiData import dev.kord.core.entity.KordEntity import dev.kord.core.entity.GuildEmoji import dev.kord.core.entity.Strategizable +import dev.kord.core.hash import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.rest.builder.guild.EmojiModifyBuilder import dev.kord.rest.request.RestRequestException -import java.util.* import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -57,7 +57,7 @@ internal fun GuildEmojiBehavior( override val kord: Kord = kord override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id) + override fun hashCode(): Int = hash(id) override fun equals(other: Any?): Boolean = when (other) { is GuildEmojiBehavior -> other.id == id diff --git a/core/src/main/kotlin/behavior/GuildScheduledEventBehavior.kt b/core/src/commonMain/kotlin/behavior/GuildScheduledEventBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/GuildScheduledEventBehavior.kt rename to core/src/commonMain/kotlin/behavior/GuildScheduledEventBehavior.kt diff --git a/core/src/main/kotlin/behavior/MemberBehavior.kt b/core/src/commonMain/kotlin/behavior/MemberBehavior.kt similarity index 98% rename from core/src/main/kotlin/behavior/MemberBehavior.kt rename to core/src/commonMain/kotlin/behavior/MemberBehavior.kt index 59ac4763568b..b27cdbd1bab2 100644 --- a/core/src/main/kotlin/behavior/MemberBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/MemberBehavior.kt @@ -11,12 +11,13 @@ import dev.kord.core.cache.data.VoiceStateData import dev.kord.core.cache.idEq import dev.kord.core.entity.* import dev.kord.core.exception.EntityNotFoundException +import dev.kord.core.hash import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.rest.builder.ban.BanCreateBuilder import dev.kord.rest.builder.member.MemberModifyBuilder import dev.kord.rest.request.RestRequestException -import java.util.Objects +import dev.kord.core.hash import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -193,7 +194,7 @@ public fun MemberBehavior( override val kord: Kord = kord override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is MemberBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/behavior/MessageBehavior.kt b/core/src/commonMain/kotlin/behavior/MessageBehavior.kt similarity index 99% rename from core/src/main/kotlin/behavior/MessageBehavior.kt rename to core/src/commonMain/kotlin/behavior/MessageBehavior.kt index 1619b4d2b128..fbf1b2e01ce1 100644 --- a/core/src/main/kotlin/behavior/MessageBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/MessageBehavior.kt @@ -20,7 +20,7 @@ import dev.kord.rest.builder.message.modify.WebhookMessageModifyBuilder import dev.kord.rest.request.RestRequestException import dev.kord.rest.service.RestClient import kotlinx.coroutines.flow.Flow -import java.util.Objects +import dev.kord.core.hash import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -229,7 +229,7 @@ public fun MessageBehavior( override val kord: Kord = kord override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id) + override fun hashCode(): Int = hash(id) override fun equals(other: Any?): Boolean = when (other) { is MessageBehavior -> other.id == id && other.channelId == channelId diff --git a/core/src/main/kotlin/behavior/MessageCommandBehavior.kt b/core/src/commonMain/kotlin/behavior/MessageCommandBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/MessageCommandBehavior.kt rename to core/src/commonMain/kotlin/behavior/MessageCommandBehavior.kt diff --git a/core/src/main/kotlin/behavior/RoleBehavior.kt b/core/src/commonMain/kotlin/behavior/RoleBehavior.kt similarity index 98% rename from core/src/main/kotlin/behavior/RoleBehavior.kt rename to core/src/commonMain/kotlin/behavior/RoleBehavior.kt index 281568185990..66850198adf8 100644 --- a/core/src/main/kotlin/behavior/RoleBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/RoleBehavior.kt @@ -8,6 +8,7 @@ import dev.kord.core.entity.KordEntity import dev.kord.core.entity.Role import dev.kord.core.entity.Strategizable import dev.kord.core.exception.EntityNotFoundException +import dev.kord.core.hash import dev.kord.core.indexOfFirstOrNull import dev.kord.core.sorted import dev.kord.core.supplier.EntitySupplier @@ -17,7 +18,6 @@ import dev.kord.rest.request.RestRequestException import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.map -import java.util.* import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -129,7 +129,7 @@ public fun RoleBehavior( override val kord: Kord = kord override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is RoleBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/behavior/StageInstanceBehavior.kt b/core/src/commonMain/kotlin/behavior/StageInstanceBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/StageInstanceBehavior.kt rename to core/src/commonMain/kotlin/behavior/StageInstanceBehavior.kt diff --git a/core/src/main/kotlin/behavior/StickerBehavior.kt b/core/src/commonMain/kotlin/behavior/StickerBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/StickerBehavior.kt rename to core/src/commonMain/kotlin/behavior/StickerBehavior.kt diff --git a/core/src/main/kotlin/behavior/TemplateBehavior.kt b/core/src/commonMain/kotlin/behavior/TemplateBehavior.kt similarity index 96% rename from core/src/main/kotlin/behavior/TemplateBehavior.kt rename to core/src/commonMain/kotlin/behavior/TemplateBehavior.kt index e81cfa207236..7ed3674b675c 100644 --- a/core/src/main/kotlin/behavior/TemplateBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/TemplateBehavior.kt @@ -8,7 +8,7 @@ import dev.kord.core.entity.Guild import dev.kord.core.entity.Template import dev.kord.rest.builder.template.GuildFromTemplateCreateBuilder import dev.kord.rest.builder.template.GuildTemplateModifyBuilder -import java.util.* +import dev.kord.core.hash import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -52,7 +52,7 @@ public fun TemplateBehavior(guildId: Snowflake, code: String, kord: Kord): Templ override val guildId: Snowflake = guildId override val kord: Kord = kord - override fun hashCode(): Int = Objects.hash(code) + override fun hashCode(): Int = hash(code) override fun equals(other: Any?): Boolean = other is TemplateBehavior && other.code == code diff --git a/core/src/main/kotlin/behavior/ThreadMemberBehavior.kt b/core/src/commonMain/kotlin/behavior/ThreadMemberBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/ThreadMemberBehavior.kt rename to core/src/commonMain/kotlin/behavior/ThreadMemberBehavior.kt diff --git a/core/src/main/kotlin/behavior/UserBehavior.kt b/core/src/commonMain/kotlin/behavior/UserBehavior.kt similarity index 98% rename from core/src/main/kotlin/behavior/UserBehavior.kt rename to core/src/commonMain/kotlin/behavior/UserBehavior.kt index 0a91a7998f2e..bc4bfe226e60 100644 --- a/core/src/main/kotlin/behavior/UserBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/UserBehavior.kt @@ -15,7 +15,7 @@ import dev.kord.rest.json.request.DMCreateRequest import dev.kord.rest.request.RestRequestException import dev.kord.rest.service.RestClient import io.ktor.http.* -import java.util.* +import dev.kord.core.hash /** * The behavior of a [Discord User](https://discord.com/developers/docs/resources/user) @@ -145,7 +145,7 @@ public fun UserBehavior( override val kord: Kord = kord override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id) + override fun hashCode(): Int = hash(id) override fun equals(other: Any?): Boolean = when (other) { is UserBehavior -> other.id == id diff --git a/core/src/main/kotlin/behavior/UserCommandBehavior.kt b/core/src/commonMain/kotlin/behavior/UserCommandBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/UserCommandBehavior.kt rename to core/src/commonMain/kotlin/behavior/UserCommandBehavior.kt diff --git a/core/src/main/kotlin/behavior/WebhookBehavior.kt b/core/src/commonMain/kotlin/behavior/WebhookBehavior.kt similarity index 98% rename from core/src/main/kotlin/behavior/WebhookBehavior.kt rename to core/src/commonMain/kotlin/behavior/WebhookBehavior.kt index b70f37fca7cc..9fae71abca0d 100644 --- a/core/src/main/kotlin/behavior/WebhookBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/WebhookBehavior.kt @@ -15,7 +15,7 @@ import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.rest.builder.message.create.WebhookMessageCreateBuilder import dev.kord.rest.builder.webhook.WebhookModifyBuilder import dev.kord.rest.request.RestRequestException -import java.util.* +import dev.kord.core.hash import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -102,7 +102,7 @@ internal fun WebhookBehavior( override val kord: Kord = kord override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id) + override fun hashCode(): Int = hash(id) override fun equals(other: Any?): Boolean = when (other) { is WebhookBehavior -> other.id == id diff --git a/core/src/main/kotlin/behavior/automoderation/AutoModerationRuleBehavior.kt b/core/src/commonMain/kotlin/behavior/automoderation/AutoModerationRuleBehavior.kt similarity index 99% rename from core/src/main/kotlin/behavior/automoderation/AutoModerationRuleBehavior.kt rename to core/src/commonMain/kotlin/behavior/automoderation/AutoModerationRuleBehavior.kt index a8d2359722c4..9da181c459f5 100644 --- a/core/src/main/kotlin/behavior/automoderation/AutoModerationRuleBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/automoderation/AutoModerationRuleBehavior.kt @@ -17,7 +17,7 @@ import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.rest.builder.automoderation.* import dev.kord.rest.request.RestRequestException -import java.util.Objects +import dev.kord.core.hash import kotlin.contracts.InvocationKind.EXACTLY_ONCE import kotlin.contracts.contract @@ -106,7 +106,7 @@ internal class AutoModerationRuleBehaviorImpl( internal fun AutoModerationRuleBehavior.autoModerationRuleEquals(other: Any?) = this === other || (other is AutoModerationRuleBehavior && this.id == other.id && this.guildId == other.guildId) -internal fun AutoModerationRuleBehavior.autoModerationRuleHashCode() = Objects.hash(id, guildId) +internal fun AutoModerationRuleBehavior.autoModerationRuleHashCode() = hash(id, guildId) /** * Requests to edit this [AutoModerationRule] and returns the edited rule. diff --git a/core/src/main/kotlin/behavior/channel/BaseVoiceChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/BaseVoiceChannelBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/channel/BaseVoiceChannelBehavior.kt rename to core/src/commonMain/kotlin/behavior/channel/BaseVoiceChannelBehavior.kt diff --git a/core/src/main/kotlin/behavior/channel/CategorizableChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/CategorizableChannelBehavior.kt similarity index 98% rename from core/src/main/kotlin/behavior/channel/CategorizableChannelBehavior.kt rename to core/src/commonMain/kotlin/behavior/channel/CategorizableChannelBehavior.kt index 21c4a0d5297e..9b1f843ca237 100644 --- a/core/src/main/kotlin/behavior/channel/CategorizableChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/CategorizableChannelBehavior.kt @@ -17,7 +17,7 @@ import dev.kord.rest.request.RestRequestException import dev.kord.rest.service.RestClient import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow -import java.util.* +import dev.kord.core.hash import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -110,7 +110,7 @@ internal fun CategorizableChannelBehavior( override val kord: Kord = kord override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is GuildChannelBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/behavior/channel/CategoryBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/CategoryBehavior.kt similarity index 98% rename from core/src/main/kotlin/behavior/channel/CategoryBehavior.kt rename to core/src/commonMain/kotlin/behavior/channel/CategoryBehavior.kt index ee163b1d680c..e7057d60a8b2 100644 --- a/core/src/main/kotlin/behavior/channel/CategoryBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/CategoryBehavior.kt @@ -22,7 +22,7 @@ import dev.kord.rest.service.patchCategory import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filterIsInstance -import java.util.* +import dev.kord.core.hash import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -101,7 +101,7 @@ public fun CategoryBehavior( override val kord: Kord = kord override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is TopGuildChannelBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/behavior/channel/ChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/ChannelBehavior.kt similarity index 98% rename from core/src/main/kotlin/behavior/channel/ChannelBehavior.kt rename to core/src/commonMain/kotlin/behavior/channel/ChannelBehavior.kt index 5db6749f6f36..42ffd8272b1c 100644 --- a/core/src/main/kotlin/behavior/channel/ChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/ChannelBehavior.kt @@ -12,7 +12,7 @@ import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.core.supplier.getChannelOf import dev.kord.core.supplier.getChannelOfOrNull import dev.kord.rest.request.RestRequestException -import java.util.* +import dev.kord.core.hash /** * The behavior of a [Discord Channel](https://discord.com/developers/docs/resources/channel) @@ -101,7 +101,7 @@ public fun ChannelBehavior(id: Snowflake, kord: Kord, strategy: EntitySupplyStra override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id) + override fun hashCode(): Int = hash(id) override fun equals(other: Any?): Boolean = when (other) { is ChannelBehavior -> other.id == id diff --git a/core/src/main/kotlin/behavior/channel/ForumChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/ForumChannelBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/channel/ForumChannelBehavior.kt rename to core/src/commonMain/kotlin/behavior/channel/ForumChannelBehavior.kt diff --git a/core/src/main/kotlin/behavior/channel/GuildChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/GuildChannelBehavior.kt similarity index 98% rename from core/src/main/kotlin/behavior/channel/GuildChannelBehavior.kt rename to core/src/commonMain/kotlin/behavior/channel/GuildChannelBehavior.kt index 06a1a066512d..63640b2ad495 100644 --- a/core/src/main/kotlin/behavior/channel/GuildChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/GuildChannelBehavior.kt @@ -12,7 +12,7 @@ import dev.kord.core.entity.channel.TopGuildChannel import dev.kord.core.exception.EntityNotFoundException import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy -import java.util.* +import dev.kord.core.hash /** * The behavior of a Discord channel associated to a [guild]. @@ -110,7 +110,7 @@ public fun GuildChannelBehavior( override val kord: Kord = kord override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is GuildChannelBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/behavior/channel/GuildMessageChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/GuildMessageChannelBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/channel/GuildMessageChannelBehavior.kt rename to core/src/commonMain/kotlin/behavior/channel/GuildMessageChannelBehavior.kt diff --git a/core/src/main/kotlin/behavior/channel/MessageChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/MessageChannelBehavior.kt similarity index 98% rename from core/src/main/kotlin/behavior/channel/MessageChannelBehavior.kt rename to core/src/commonMain/kotlin/behavior/channel/MessageChannelBehavior.kt index 88854a12b8b4..5d25b19a2c75 100644 --- a/core/src/main/kotlin/behavior/channel/MessageChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/MessageChannelBehavior.kt @@ -25,9 +25,12 @@ import kotlinx.coroutines.flow.takeWhile import kotlinx.coroutines.launch import kotlinx.datetime.Clock import kotlinx.datetime.Instant -import java.util.Objects +import dev.kord.core.hash +import kotlin.DeprecationLevel.HIDDEN import kotlin.contracts.InvocationKind import kotlin.contracts.contract +import kotlin.coroutines.coroutineContext +import kotlin.js.JsName import kotlin.time.Duration.Companion.seconds import kotlin.time.TimeMark @@ -212,6 +215,7 @@ public interface MessageChannelBehavior : ChannelBehavior, Strategizable { * * @throws [RestRequestException] if something went wrong during the request. */ + @JsName("sendTyping") // otherwise clashes with channel typefield public suspend fun type() { kord.rest.channel.triggerTypingIndicator(id) } @@ -259,7 +263,7 @@ public fun MessageChannelBehavior( override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id) + override fun hashCode(): Int = hash(id) override fun equals(other: Any?): Boolean = when (other) { is ChannelBehavior -> other.id == id diff --git a/core/src/main/kotlin/behavior/channel/NewsChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/NewsChannelBehavior.kt similarity index 98% rename from core/src/main/kotlin/behavior/channel/NewsChannelBehavior.kt rename to core/src/commonMain/kotlin/behavior/channel/NewsChannelBehavior.kt index d188f66af30a..cc5b7bd3e84e 100644 --- a/core/src/main/kotlin/behavior/channel/NewsChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/NewsChannelBehavior.kt @@ -25,8 +25,8 @@ import dev.kord.rest.service.patchNewsChannel import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.filterIsInstance import kotlinx.datetime.Instant -import java.util.Objects -import kotlin.DeprecationLevel.ERROR +import kotlin.DeprecationLevel.WARNING +import dev.kord.core.hash import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -156,7 +156,7 @@ public fun NewsChannelBehavior( override val kord: Kord = kord override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is GuildChannelBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/behavior/channel/StageChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/StageChannelBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/channel/StageChannelBehavior.kt rename to core/src/commonMain/kotlin/behavior/channel/StageChannelBehavior.kt diff --git a/core/src/main/kotlin/behavior/channel/TextChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/TextChannelBehavior.kt similarity index 98% rename from core/src/main/kotlin/behavior/channel/TextChannelBehavior.kt rename to core/src/commonMain/kotlin/behavior/channel/TextChannelBehavior.kt index f4c33a8f91b0..b36e9184388e 100644 --- a/core/src/main/kotlin/behavior/channel/TextChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/TextChannelBehavior.kt @@ -23,8 +23,8 @@ import dev.kord.rest.service.patchTextChannel import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.filterIsInstance import kotlinx.datetime.Instant -import java.util.* -import kotlin.DeprecationLevel.ERROR +import kotlin.DeprecationLevel.WARNING +import dev.kord.core.hash import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -170,7 +170,7 @@ public fun TextChannelBehavior( override val kord: Kord = kord override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is GuildChannelBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/behavior/channel/TopGuildChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/TopGuildChannelBehavior.kt similarity index 98% rename from core/src/main/kotlin/behavior/channel/TopGuildChannelBehavior.kt rename to core/src/commonMain/kotlin/behavior/channel/TopGuildChannelBehavior.kt index cc6f0bec0565..ed93a4edbe77 100644 --- a/core/src/main/kotlin/behavior/channel/TopGuildChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/TopGuildChannelBehavior.kt @@ -14,7 +14,7 @@ import dev.kord.rest.service.editMemberPermissions import dev.kord.rest.service.editRolePermission import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.withIndex -import java.util.* +import dev.kord.core.hash import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -103,7 +103,7 @@ internal fun TopGuildChannelBehavior( override val kord: Kord = kord override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is GuildChannelBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/behavior/channel/TopGuildMessageChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/TopGuildMessageChannelBehavior.kt similarity index 94% rename from core/src/main/kotlin/behavior/channel/TopGuildMessageChannelBehavior.kt rename to core/src/commonMain/kotlin/behavior/channel/TopGuildMessageChannelBehavior.kt index 8a930746d006..4028beeb5213 100644 --- a/core/src/main/kotlin/behavior/channel/TopGuildMessageChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/TopGuildMessageChannelBehavior.kt @@ -9,8 +9,12 @@ import dev.kord.core.exception.EntityNotFoundException import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.rest.builder.webhook.WebhookCreateBuilder -import java.util.* import kotlin.DeprecationLevel.HIDDEN +import dev.kord.rest.request.RestRequestException +import dev.kord.rest.service.RestClient +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flow +import dev.kord.core.hash import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -78,7 +82,7 @@ internal fun TopGuildMessageChannelBehavior( override val kord: Kord = kord override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is GuildChannelBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/behavior/channel/VoiceChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/VoiceChannelBehavior.kt similarity index 98% rename from core/src/main/kotlin/behavior/channel/VoiceChannelBehavior.kt rename to core/src/commonMain/kotlin/behavior/channel/VoiceChannelBehavior.kt index caa781deadd8..0c1b1ed48748 100644 --- a/core/src/main/kotlin/behavior/channel/VoiceChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/VoiceChannelBehavior.kt @@ -12,7 +12,7 @@ import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.rest.builder.channel.VoiceChannelModifyBuilder import dev.kord.rest.request.RestRequestException import dev.kord.rest.service.patchVoiceChannel -import java.util.* +import dev.kord.core.hash import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -73,7 +73,7 @@ public fun VoiceChannelBehavior( override val kord: Kord = kord override val supplier: EntitySupplier = strategy.supply(kord) - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is GuildChannelBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/behavior/channel/threads/ThreadChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/threads/ThreadChannelBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/channel/threads/ThreadChannelBehavior.kt rename to core/src/commonMain/kotlin/behavior/channel/threads/ThreadChannelBehavior.kt diff --git a/core/src/main/kotlin/behavior/channel/threads/ThreadParentChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/threads/ThreadParentChannelBehavior.kt similarity index 98% rename from core/src/main/kotlin/behavior/channel/threads/ThreadParentChannelBehavior.kt rename to core/src/commonMain/kotlin/behavior/channel/threads/ThreadParentChannelBehavior.kt index 75914d7e7a7a..32d1c4e4a693 100644 --- a/core/src/main/kotlin/behavior/channel/threads/ThreadParentChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/threads/ThreadParentChannelBehavior.kt @@ -19,7 +19,7 @@ import dev.kord.rest.builder.channel.thread.StartThreadBuilder import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.filter import kotlinx.datetime.Instant -import java.util.* +import dev.kord.core.hash /** * Behavior of channels that can contain public threads. @@ -169,7 +169,7 @@ internal fun ThreadParentChannelBehavior( override val supplier: EntitySupplier get() = supplier - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is GuildChannelBehavior -> other.id == id && other.guildId == guildId @@ -201,7 +201,7 @@ internal fun PrivateThreadParentChannelBehavior( override val supplier: EntitySupplier get() = supplier - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is GuildChannelBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/behavior/interaction/ActionInteractionBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/ActionInteractionBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/ActionInteractionBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/ActionInteractionBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/ApplicationCommandInteractionBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/ApplicationCommandInteractionBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/ApplicationCommandInteractionBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/ApplicationCommandInteractionBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/AutoCompleteInteractionBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/AutoCompleteInteractionBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/AutoCompleteInteractionBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/AutoCompleteInteractionBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/ComponentInteractionBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/ComponentInteractionBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/ComponentInteractionBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/ComponentInteractionBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/DataInteractionBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/DataInteractionBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/DataInteractionBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/DataInteractionBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/GlobalInteractionBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/GlobalInteractionBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/GlobalInteractionBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/GlobalInteractionBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/GuildInteractionBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/GuildInteractionBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/GuildInteractionBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/GuildInteractionBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/InteractionBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/InteractionBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/InteractionBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/InteractionBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/ModalParentInteractionBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/ModalParentInteractionBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/ModalParentInteractionBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/ModalParentInteractionBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/followup/EphemeralFollowupMessageBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/followup/EphemeralFollowupMessageBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/followup/EphemeralFollowupMessageBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/followup/EphemeralFollowupMessageBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/followup/FollowupMessageBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/followup/FollowupMessageBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/followup/FollowupMessageBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/followup/FollowupMessageBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/followup/PublicFollowupMessageBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/followup/PublicFollowupMessageBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/followup/PublicFollowupMessageBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/followup/PublicFollowupMessageBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/response/DeferredEphemeralMessageInteractionBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/response/DeferredEphemeralMessageInteractionBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/response/DeferredEphemeralMessageInteractionBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/response/DeferredEphemeralMessageInteractionBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/response/DeferredMessageInteractionResponseBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/response/DeferredMessageInteractionResponseBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/response/DeferredMessageInteractionResponseBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/response/DeferredMessageInteractionResponseBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/response/DeferredPublicMessageInteractionResponseBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/response/DeferredPublicMessageInteractionResponseBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/response/DeferredPublicMessageInteractionResponseBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/response/DeferredPublicMessageInteractionResponseBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/response/EditOriginalResponse.kt b/core/src/commonMain/kotlin/behavior/interaction/response/EditOriginalResponse.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/response/EditOriginalResponse.kt rename to core/src/commonMain/kotlin/behavior/interaction/response/EditOriginalResponse.kt diff --git a/core/src/main/kotlin/behavior/interaction/response/EphemeralInteractionResponseBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/response/EphemeralInteractionResponseBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/response/EphemeralInteractionResponseBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/response/EphemeralInteractionResponseBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/response/EphemeralMessageInteractionResponseBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/response/EphemeralMessageInteractionResponseBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/response/EphemeralMessageInteractionResponseBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/response/EphemeralMessageInteractionResponseBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/response/FollowupPermittingInteractionResponseBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/response/FollowupPermittingInteractionResponseBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/response/FollowupPermittingInteractionResponseBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/response/FollowupPermittingInteractionResponseBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/response/InteractionResponseBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/response/InteractionResponseBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/response/InteractionResponseBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/response/InteractionResponseBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/response/MessageInteractionResponseBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/response/MessageInteractionResponseBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/response/MessageInteractionResponseBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/response/MessageInteractionResponseBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/response/PopupInteractionResponseBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/response/PopupInteractionResponseBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/response/PopupInteractionResponseBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/response/PopupInteractionResponseBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/response/PublicInteractionResponseBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/response/PublicInteractionResponseBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/response/PublicInteractionResponseBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/response/PublicInteractionResponseBehavior.kt diff --git a/core/src/main/kotlin/behavior/interaction/response/PublicMesageInteractionResponseBehavior.kt b/core/src/commonMain/kotlin/behavior/interaction/response/PublicMesageInteractionResponseBehavior.kt similarity index 100% rename from core/src/main/kotlin/behavior/interaction/response/PublicMesageInteractionResponseBehavior.kt rename to core/src/commonMain/kotlin/behavior/interaction/response/PublicMesageInteractionResponseBehavior.kt diff --git a/core/src/main/kotlin/builder/component/ButtonBuilderExtensions.kt b/core/src/commonMain/kotlin/builder/component/ButtonBuilderExtensions.kt similarity index 100% rename from core/src/main/kotlin/builder/component/ButtonBuilderExtensions.kt rename to core/src/commonMain/kotlin/builder/component/ButtonBuilderExtensions.kt diff --git a/core/src/main/kotlin/builder/kord/KordBuilder.kt b/core/src/commonMain/kotlin/builder/kord/KordBuilder.kt similarity index 94% rename from core/src/main/kotlin/builder/kord/KordBuilder.kt rename to core/src/commonMain/kotlin/builder/kord/KordBuilder.kt index e55b0832da46..224544929bc8 100644 --- a/core/src/main/kotlin/builder/kord/KordBuilder.kt +++ b/core/src/commonMain/kotlin/builder/kord/KordBuilder.kt @@ -36,11 +36,9 @@ import io.ktor.http.HttpHeaders.UserAgent import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableSharedFlow -import kotlinx.coroutines.runBlocking import kotlinx.serialization.json.Json import mu.KotlinLogging -import kotlin.DeprecationLevel.HIDDEN -import kotlin.concurrent.thread +import kotlin.DeprecationLevel.ERROR import kotlin.contracts.InvocationKind import kotlin.contracts.contract import kotlin.time.Duration.Companion.seconds @@ -64,7 +62,9 @@ public operator fun DefaultGateway.Companion.invoke( private val logger = KotlinLogging.logger { } private val gatewayInfoJson = Json { ignoreUnknownKeys = true } -public class KordBuilder(public val token: String) { +public expect class KordBuilder(token: String) : KordBuilderBase + +public abstract class KordBuilderBase internal constructor(public val token: String) { private var shardsBuilder: (recommended: Int) -> Shards = { Shards(it) } private var gatewayBuilder: (resources: ClientResources, shards: List) -> List = { resources, shards -> @@ -92,11 +92,6 @@ public class KordBuilder(public val token: String) { */ public var stackTraceRecovery: Boolean = false - /** - * Enable adding a [Runtime.addShutdownHook] to log out of the [Gateway] when the process is killed. - */ - public var enableShutdownHook: Boolean = true - /** * The event flow used by [Kord.eventFlow] to publish [events][Kord.events]. * @@ -236,7 +231,9 @@ public class KordBuilder(public val token: String) { /** * @throws KordInitializationException if something went wrong while getting the bot's gateway information. */ - public suspend fun build(): Kord { + public open suspend fun build(): Kord = buildBase() + + protected suspend fun buildBase(): Kord { val client = httpClient.configure() val gatewayInfo = client.getGatewayInfo() @@ -289,14 +286,6 @@ public class KordBuilder(public val token: String) { val self = getBotIdFromToken(token) - if (enableShutdownHook) { - Runtime.getRuntime().addShutdownHook(thread(false) { - runBlocking { - gateway.detachAll() - } - }) - } - return Kord( resources = resources, cache = cache, diff --git a/core/src/main/kotlin/builder/kord/KordBuilderUtil.kt b/core/src/commonMain/kotlin/builder/kord/KordBuilderUtil.kt similarity index 92% rename from core/src/main/kotlin/builder/kord/KordBuilderUtil.kt rename to core/src/commonMain/kotlin/builder/kord/KordBuilderUtil.kt index cc957bcbfd36..e8c393a872e0 100644 --- a/core/src/main/kotlin/builder/kord/KordBuilderUtil.kt +++ b/core/src/commonMain/kotlin/builder/kord/KordBuilderUtil.kt @@ -1,9 +1,8 @@ package dev.kord.core.builder.kord import dev.kord.common.entity.Snowflake +import dev.kord.rest.request.HttpEngine import io.ktor.client.* -import io.ktor.client.engine.cio.* -import io.ktor.client.plugins.* import io.ktor.client.plugins.contentnegotiation.* import io.ktor.client.plugins.websocket.* import io.ktor.serialization.kotlinx.json.* @@ -31,7 +30,7 @@ internal fun HttpClient?.configure(): HttpClient { isLenient = true } - return HttpClient(CIO) { + return HttpClient(HttpEngine) { defaultConfig() install(ContentNegotiation) { json(json) diff --git a/core/src/main/kotlin/builder/kord/KordProxyBuilder.kt b/core/src/commonMain/kotlin/builder/kord/KordProxyBuilder.kt similarity index 100% rename from core/src/main/kotlin/builder/kord/KordProxyBuilder.kt rename to core/src/commonMain/kotlin/builder/kord/KordProxyBuilder.kt diff --git a/core/src/main/kotlin/builder/kord/KordRestOnlyBuilder.kt b/core/src/commonMain/kotlin/builder/kord/KordRestOnlyBuilder.kt similarity index 100% rename from core/src/main/kotlin/builder/kord/KordRestOnlyBuilder.kt rename to core/src/commonMain/kotlin/builder/kord/KordRestOnlyBuilder.kt diff --git a/core/src/main/kotlin/builder/kord/RestOnlyBuilder.kt b/core/src/commonMain/kotlin/builder/kord/RestOnlyBuilder.kt similarity index 100% rename from core/src/main/kotlin/builder/kord/RestOnlyBuilder.kt rename to core/src/commonMain/kotlin/builder/kord/RestOnlyBuilder.kt diff --git a/core/src/main/kotlin/cache/CachingGateway.kt b/core/src/commonMain/kotlin/cache/CachingGateway.kt similarity index 100% rename from core/src/main/kotlin/cache/CachingGateway.kt rename to core/src/commonMain/kotlin/cache/CachingGateway.kt diff --git a/core/src/main/kotlin/cache/DataCacheExtensions.kt b/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt similarity index 100% rename from core/src/main/kotlin/cache/DataCacheExtensions.kt rename to core/src/commonMain/kotlin/cache/DataCacheExtensions.kt diff --git a/core/src/main/kotlin/cache/DataCacheView.kt b/core/src/commonMain/kotlin/cache/DataCacheView.kt similarity index 100% rename from core/src/main/kotlin/cache/DataCacheView.kt rename to core/src/commonMain/kotlin/cache/DataCacheView.kt diff --git a/core/src/main/kotlin/cache/KordCache.kt b/core/src/commonMain/kotlin/cache/KordCache.kt similarity index 90% rename from core/src/main/kotlin/cache/KordCache.kt rename to core/src/commonMain/kotlin/cache/KordCache.kt index c886b88d1713..8a129b1e9667 100644 --- a/core/src/main/kotlin/cache/KordCache.kt +++ b/core/src/commonMain/kotlin/cache/KordCache.kt @@ -1,5 +1,6 @@ package dev.kord.core.cache +import co.touchlab.stately.collections.ConcurrentMutableMap import dev.kord.cache.api.DataCache import dev.kord.cache.api.DataEntryCache import dev.kord.cache.api.data.DataDescription @@ -7,17 +8,15 @@ import dev.kord.cache.api.delegate.DelegatingDataCache import dev.kord.cache.api.delegate.EntrySupplier import dev.kord.cache.map.MapLikeCollection import dev.kord.cache.map.internal.MapEntryCache -import dev.kord.cache.map.lruLinkedHashMap import dev.kord.common.entity.Snowflake import dev.kord.core.cache.data.* -import java.util.concurrent.ConcurrentHashMap public typealias Generator = (cache: DataCache, description: DataDescription) -> DataEntryCache public class KordCacheBuilder { /** - * The default behavior for all types not explicitly configured, by default a [ConcurrentHashMap] is supplied. + * The default behavior for all types not explicitly configured, by default a [ConcurrentMutableMap] is supplied. */ public var defaultGenerator: Generator = { cache, description -> MapEntryCache(cache, description, MapLikeCollection.concurrentHashMap()) @@ -42,14 +41,6 @@ public class KordCacheBuilder { */ public fun none(): Generator = { _, _ -> DataEntryCache.none() } - /** - * A Generator creating [DataEntryCaches][DataEntryCache] with a maximum [size], removing items on last insertion. - * Shortcut for [lruLinkedHashMap]. - */ - public fun lruCache(size: Int = 100): Generator = { cache, description -> - MapEntryCache(cache, description, MapLikeCollection.lruLinkedHashMap(size)) - } - @Suppress("UNCHECKED_CAST") public fun forDescription(description: DataDescription, generator: Generator?) { if (generator == null) return run { diff --git a/core/src/main/kotlin/cache/Query.kt b/core/src/commonMain/kotlin/cache/Query.kt similarity index 98% rename from core/src/main/kotlin/cache/Query.kt rename to core/src/commonMain/kotlin/cache/Query.kt index 43328bc17884..4a68a89b2966 100644 --- a/core/src/main/kotlin/cache/Query.kt +++ b/core/src/commonMain/kotlin/cache/Query.kt @@ -5,6 +5,7 @@ import dev.kord.common.entity.Snowflake import dev.kord.common.entity.optional.Optional import dev.kord.common.entity.optional.OptionalSnowflake import dev.kord.common.entity.optional.optionalSnowflake +import kotlin.jvm.JvmName import kotlin.reflect.KProperty1 public fun QueryBuilder.idEq(property: KProperty1, value: Snowflake?) { diff --git a/core/src/main/kotlin/cache/data/ActivityData.kt b/core/src/commonMain/kotlin/cache/data/ActivityData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/ActivityData.kt rename to core/src/commonMain/kotlin/cache/data/ActivityData.kt diff --git a/core/src/main/kotlin/cache/data/ApplicationCommandData.kt b/core/src/commonMain/kotlin/cache/data/ApplicationCommandData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/ApplicationCommandData.kt rename to core/src/commonMain/kotlin/cache/data/ApplicationCommandData.kt diff --git a/core/src/main/kotlin/cache/data/ApplicationData.kt b/core/src/commonMain/kotlin/cache/data/ApplicationData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/ApplicationData.kt rename to core/src/commonMain/kotlin/cache/data/ApplicationData.kt diff --git a/core/src/main/kotlin/cache/data/AttachmentData.kt b/core/src/commonMain/kotlin/cache/data/AttachmentData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/AttachmentData.kt rename to core/src/commonMain/kotlin/cache/data/AttachmentData.kt diff --git a/core/src/main/kotlin/cache/data/AutoModeration.kt b/core/src/commonMain/kotlin/cache/data/AutoModeration.kt similarity index 100% rename from core/src/main/kotlin/cache/data/AutoModeration.kt rename to core/src/commonMain/kotlin/cache/data/AutoModeration.kt diff --git a/core/src/main/kotlin/cache/data/BanData.kt b/core/src/commonMain/kotlin/cache/data/BanData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/BanData.kt rename to core/src/commonMain/kotlin/cache/data/BanData.kt diff --git a/core/src/main/kotlin/cache/data/ChannelData.kt b/core/src/commonMain/kotlin/cache/data/ChannelData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/ChannelData.kt rename to core/src/commonMain/kotlin/cache/data/ChannelData.kt diff --git a/core/src/main/kotlin/cache/data/ClientStatusData.kt b/core/src/commonMain/kotlin/cache/data/ClientStatusData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/ClientStatusData.kt rename to core/src/commonMain/kotlin/cache/data/ClientStatusData.kt diff --git a/core/src/main/kotlin/cache/data/ComponentData.kt b/core/src/commonMain/kotlin/cache/data/ComponentData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/ComponentData.kt rename to core/src/commonMain/kotlin/cache/data/ComponentData.kt diff --git a/core/src/main/kotlin/cache/data/EmbedData.kt b/core/src/commonMain/kotlin/cache/data/EmbedData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/EmbedData.kt rename to core/src/commonMain/kotlin/cache/data/EmbedData.kt diff --git a/core/src/main/kotlin/cache/data/EmojiData.kt b/core/src/commonMain/kotlin/cache/data/EmojiData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/EmojiData.kt rename to core/src/commonMain/kotlin/cache/data/EmojiData.kt diff --git a/core/src/main/kotlin/cache/data/GuildApplicationCommandPermissionData.kt b/core/src/commonMain/kotlin/cache/data/GuildApplicationCommandPermissionData.kt similarity index 90% rename from core/src/main/kotlin/cache/data/GuildApplicationCommandPermissionData.kt rename to core/src/commonMain/kotlin/cache/data/GuildApplicationCommandPermissionData.kt index 7da1ef525417..f0b66404ebf2 100644 --- a/core/src/main/kotlin/cache/data/GuildApplicationCommandPermissionData.kt +++ b/core/src/commonMain/kotlin/cache/data/GuildApplicationCommandPermissionData.kt @@ -3,6 +3,9 @@ package dev.kord.core.cache.data import dev.kord.common.entity.ApplicationCommandPermissionType import dev.kord.common.entity.DiscordGuildApplicationCommandPermission import dev.kord.common.entity.Snowflake +import kotlin.DeprecationLevel.HIDDEN +import kotlin.jvm.JvmName + public data class GuildApplicationCommandPermissionData( val id: Snowflake, diff --git a/core/src/main/kotlin/cache/data/GuildApplicationCommandPermissionsData.kt b/core/src/commonMain/kotlin/cache/data/GuildApplicationCommandPermissionsData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/GuildApplicationCommandPermissionsData.kt rename to core/src/commonMain/kotlin/cache/data/GuildApplicationCommandPermissionsData.kt diff --git a/core/src/main/kotlin/cache/data/GuildData.kt b/core/src/commonMain/kotlin/cache/data/GuildData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/GuildData.kt rename to core/src/commonMain/kotlin/cache/data/GuildData.kt diff --git a/core/src/main/kotlin/cache/data/GuildPreviewData.kt b/core/src/commonMain/kotlin/cache/data/GuildPreviewData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/GuildPreviewData.kt rename to core/src/commonMain/kotlin/cache/data/GuildPreviewData.kt diff --git a/core/src/main/kotlin/cache/data/GuildScheduledEventData.kt b/core/src/commonMain/kotlin/cache/data/GuildScheduledEventData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/GuildScheduledEventData.kt rename to core/src/commonMain/kotlin/cache/data/GuildScheduledEventData.kt diff --git a/core/src/main/kotlin/cache/data/GuildWidgetData.kt b/core/src/commonMain/kotlin/cache/data/GuildWidgetData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/GuildWidgetData.kt rename to core/src/commonMain/kotlin/cache/data/GuildWidgetData.kt diff --git a/core/src/main/kotlin/cache/data/IntegrationData.kt b/core/src/commonMain/kotlin/cache/data/IntegrationData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/IntegrationData.kt rename to core/src/commonMain/kotlin/cache/data/IntegrationData.kt diff --git a/core/src/main/kotlin/cache/data/IntegrationsAccountData.kt b/core/src/commonMain/kotlin/cache/data/IntegrationsAccountData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/IntegrationsAccountData.kt rename to core/src/commonMain/kotlin/cache/data/IntegrationsAccountData.kt diff --git a/core/src/main/kotlin/cache/data/InteractionData.kt b/core/src/commonMain/kotlin/cache/data/InteractionData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/InteractionData.kt rename to core/src/commonMain/kotlin/cache/data/InteractionData.kt diff --git a/core/src/main/kotlin/cache/data/InviteCreateData.kt b/core/src/commonMain/kotlin/cache/data/InviteCreateData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/InviteCreateData.kt rename to core/src/commonMain/kotlin/cache/data/InviteCreateData.kt diff --git a/core/src/main/kotlin/cache/data/InviteData.kt b/core/src/commonMain/kotlin/cache/data/InviteData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/InviteData.kt rename to core/src/commonMain/kotlin/cache/data/InviteData.kt diff --git a/core/src/main/kotlin/cache/data/InviteDeleteData.kt b/core/src/commonMain/kotlin/cache/data/InviteDeleteData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/InviteDeleteData.kt rename to core/src/commonMain/kotlin/cache/data/InviteDeleteData.kt diff --git a/core/src/main/kotlin/cache/data/MemberData.kt b/core/src/commonMain/kotlin/cache/data/MemberData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/MemberData.kt rename to core/src/commonMain/kotlin/cache/data/MemberData.kt diff --git a/core/src/main/kotlin/cache/data/MembersChunkData.kt b/core/src/commonMain/kotlin/cache/data/MembersChunkData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/MembersChunkData.kt rename to core/src/commonMain/kotlin/cache/data/MembersChunkData.kt diff --git a/core/src/main/kotlin/cache/data/MessageData.kt b/core/src/commonMain/kotlin/cache/data/MessageData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/MessageData.kt rename to core/src/commonMain/kotlin/cache/data/MessageData.kt diff --git a/core/src/main/kotlin/cache/data/MessageInteractionData.kt b/core/src/commonMain/kotlin/cache/data/MessageInteractionData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/MessageInteractionData.kt rename to core/src/commonMain/kotlin/cache/data/MessageInteractionData.kt diff --git a/core/src/main/kotlin/cache/data/MessageReferenceData.kt b/core/src/commonMain/kotlin/cache/data/MessageReferenceData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/MessageReferenceData.kt rename to core/src/commonMain/kotlin/cache/data/MessageReferenceData.kt diff --git a/core/src/main/kotlin/cache/data/PartialGuildData.kt b/core/src/commonMain/kotlin/cache/data/PartialGuildData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/PartialGuildData.kt rename to core/src/commonMain/kotlin/cache/data/PartialGuildData.kt diff --git a/core/src/main/kotlin/cache/data/PermissionOverwriteData.kt b/core/src/commonMain/kotlin/cache/data/PermissionOverwriteData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/PermissionOverwriteData.kt rename to core/src/commonMain/kotlin/cache/data/PermissionOverwriteData.kt diff --git a/core/src/main/kotlin/cache/data/PresenceData.kt b/core/src/commonMain/kotlin/cache/data/PresenceData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/PresenceData.kt rename to core/src/commonMain/kotlin/cache/data/PresenceData.kt diff --git a/core/src/main/kotlin/cache/data/ReactionData.kt b/core/src/commonMain/kotlin/cache/data/ReactionData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/ReactionData.kt rename to core/src/commonMain/kotlin/cache/data/ReactionData.kt diff --git a/core/src/main/kotlin/cache/data/ReactionRemoveEmojiData.kt b/core/src/commonMain/kotlin/cache/data/ReactionRemoveEmojiData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/ReactionRemoveEmojiData.kt rename to core/src/commonMain/kotlin/cache/data/ReactionRemoveEmojiData.kt diff --git a/core/src/main/kotlin/cache/data/RegionData.kt b/core/src/commonMain/kotlin/cache/data/RegionData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/RegionData.kt rename to core/src/commonMain/kotlin/cache/data/RegionData.kt diff --git a/core/src/main/kotlin/cache/data/RoleData.kt b/core/src/commonMain/kotlin/cache/data/RoleData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/RoleData.kt rename to core/src/commonMain/kotlin/cache/data/RoleData.kt diff --git a/core/src/main/kotlin/cache/data/RoleTagsData.kt b/core/src/commonMain/kotlin/cache/data/RoleTagsData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/RoleTagsData.kt rename to core/src/commonMain/kotlin/cache/data/RoleTagsData.kt diff --git a/core/src/main/kotlin/cache/data/SelectOptionData.kt b/core/src/commonMain/kotlin/cache/data/SelectOptionData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/SelectOptionData.kt rename to core/src/commonMain/kotlin/cache/data/SelectOptionData.kt diff --git a/core/src/main/kotlin/cache/data/StageInstanceData.kt b/core/src/commonMain/kotlin/cache/data/StageInstanceData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/StageInstanceData.kt rename to core/src/commonMain/kotlin/cache/data/StageInstanceData.kt diff --git a/core/src/main/kotlin/cache/data/StickerData.kt b/core/src/commonMain/kotlin/cache/data/StickerData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/StickerData.kt rename to core/src/commonMain/kotlin/cache/data/StickerData.kt diff --git a/core/src/main/kotlin/cache/data/TeamData.kt b/core/src/commonMain/kotlin/cache/data/TeamData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/TeamData.kt rename to core/src/commonMain/kotlin/cache/data/TeamData.kt diff --git a/core/src/main/kotlin/cache/data/TemplateData.kt b/core/src/commonMain/kotlin/cache/data/TemplateData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/TemplateData.kt rename to core/src/commonMain/kotlin/cache/data/TemplateData.kt diff --git a/core/src/main/kotlin/cache/data/ThreadListSyncData.kt b/core/src/commonMain/kotlin/cache/data/ThreadListSyncData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/ThreadListSyncData.kt rename to core/src/commonMain/kotlin/cache/data/ThreadListSyncData.kt diff --git a/core/src/main/kotlin/cache/data/ThreadMemberData.kt b/core/src/commonMain/kotlin/cache/data/ThreadMemberData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/ThreadMemberData.kt rename to core/src/commonMain/kotlin/cache/data/ThreadMemberData.kt diff --git a/core/src/main/kotlin/cache/data/ThreadMembersUpdateEventData.kt b/core/src/commonMain/kotlin/cache/data/ThreadMembersUpdateEventData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/ThreadMembersUpdateEventData.kt rename to core/src/commonMain/kotlin/cache/data/ThreadMembersUpdateEventData.kt diff --git a/core/src/main/kotlin/cache/data/UserData.kt b/core/src/commonMain/kotlin/cache/data/UserData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/UserData.kt rename to core/src/commonMain/kotlin/cache/data/UserData.kt diff --git a/core/src/main/kotlin/cache/data/VoiceStateData.kt b/core/src/commonMain/kotlin/cache/data/VoiceStateData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/VoiceStateData.kt rename to core/src/commonMain/kotlin/cache/data/VoiceStateData.kt diff --git a/core/src/main/kotlin/cache/data/WebhookData.kt b/core/src/commonMain/kotlin/cache/data/WebhookData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/WebhookData.kt rename to core/src/commonMain/kotlin/cache/data/WebhookData.kt diff --git a/core/src/main/kotlin/cache/data/WelcomeScreenData.kt b/core/src/commonMain/kotlin/cache/data/WelcomeScreenData.kt similarity index 100% rename from core/src/main/kotlin/cache/data/WelcomeScreenData.kt rename to core/src/commonMain/kotlin/cache/data/WelcomeScreenData.kt diff --git a/core/src/main/kotlin/entity/Activity.kt b/core/src/commonMain/kotlin/entity/Activity.kt similarity index 100% rename from core/src/main/kotlin/entity/Activity.kt rename to core/src/commonMain/kotlin/entity/Activity.kt diff --git a/core/src/main/kotlin/entity/Application.kt b/core/src/commonMain/kotlin/entity/Application.kt similarity index 98% rename from core/src/main/kotlin/entity/Application.kt rename to core/src/commonMain/kotlin/entity/Application.kt index 61deac4406c3..f00c41bd06e4 100644 --- a/core/src/main/kotlin/entity/Application.kt +++ b/core/src/commonMain/kotlin/entity/Application.kt @@ -13,7 +13,7 @@ import dev.kord.core.cache.data.PartialApplicationData import dev.kord.core.event.guild.InviteCreateEvent import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy -import java.util.Objects +import dev.kord.core.hash public sealed class BaseApplication( final override val kord: Kord, @@ -74,7 +74,7 @@ public sealed class BaseApplication( abstract override fun withStrategy(strategy: EntitySupplyStrategy<*>): BaseApplication - final override fun hashCode(): Int = Objects.hash(id) + final override fun hashCode(): Int = hash(id) final override fun equals(other: Any?): Boolean = other is BaseApplication && this.id == other.id } diff --git a/core/src/main/kotlin/entity/Attachment.kt b/core/src/commonMain/kotlin/entity/Attachment.kt similarity index 96% rename from core/src/main/kotlin/entity/Attachment.kt rename to core/src/commonMain/kotlin/entity/Attachment.kt index 926a917b9376..6bd5b83254cc 100644 --- a/core/src/main/kotlin/entity/Attachment.kt +++ b/core/src/commonMain/kotlin/entity/Attachment.kt @@ -6,7 +6,7 @@ import dev.kord.common.entity.optional.value import dev.kord.core.Kord import dev.kord.core.cache.data.AttachmentData import dev.kord.rest.Image -import java.util.* +import dev.kord.core.hash /** * An instance of a [Discord Attachment](https://discord.com/developers/docs/resources/channel#attachment-object). @@ -69,7 +69,7 @@ public data class Attachment(val data: AttachmentData, override val kord: Kord) */ val isImage: Boolean get() = Image.Format.isSupported(filename) - override fun hashCode(): Int = Objects.hash(id) + override fun hashCode(): Int = hash(id) override fun equals(other: Any?): Boolean = when (other) { is Attachment -> other.id == id diff --git a/core/src/main/kotlin/entity/AuditLog.kt b/core/src/commonMain/kotlin/entity/AuditLog.kt similarity index 100% rename from core/src/main/kotlin/entity/AuditLog.kt rename to core/src/commonMain/kotlin/entity/AuditLog.kt diff --git a/core/src/main/kotlin/entity/Ban.kt b/core/src/commonMain/kotlin/entity/Ban.kt similarity index 100% rename from core/src/main/kotlin/entity/Ban.kt rename to core/src/commonMain/kotlin/entity/Ban.kt diff --git a/core/src/main/kotlin/entity/Embed.kt b/core/src/commonMain/kotlin/entity/Embed.kt similarity index 100% rename from core/src/main/kotlin/entity/Embed.kt rename to core/src/commonMain/kotlin/entity/Embed.kt diff --git a/core/src/main/kotlin/entity/Entity.kt b/core/src/commonMain/kotlin/entity/Entity.kt similarity index 95% rename from core/src/main/kotlin/entity/Entity.kt rename to core/src/commonMain/kotlin/entity/Entity.kt index 55c5007281db..592c39cfb15d 100644 --- a/core/src/main/kotlin/entity/Entity.kt +++ b/core/src/commonMain/kotlin/entity/Entity.kt @@ -2,7 +2,6 @@ package dev.kord.core.entity import dev.kord.common.entity.Snowflake import dev.kord.core.KordObject -import java.util.Comparator public interface Entity : Comparable { /** diff --git a/core/src/main/kotlin/entity/Guild.kt b/core/src/commonMain/kotlin/entity/Guild.kt similarity index 98% rename from core/src/main/kotlin/entity/Guild.kt rename to core/src/commonMain/kotlin/entity/Guild.kt index 5584ea2e0d07..6d465c5b2282 100644 --- a/core/src/main/kotlin/entity/Guild.kt +++ b/core/src/commonMain/kotlin/entity/Guild.kt @@ -1,5 +1,6 @@ package dev.kord.core.entity +import dev.kord.common.Locale import dev.kord.common.entity.* import dev.kord.common.entity.optional.* import dev.kord.common.exception.RequestException @@ -23,7 +24,8 @@ import dev.kord.rest.service.RestClient import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlinx.datetime.Instant -import java.util.* +import dev.kord.core.hash +import kotlin.DeprecationLevel.HIDDEN import kotlin.time.Duration /** @@ -214,7 +216,7 @@ public class Guild( TopGuildMessageChannelBehavior(guildId = id, id = it, kord = kord) } - public val preferredLocale: Locale get() = Locale.forLanguageTag(data.preferredLocale) + public val preferredLocale: Locale get() = Locale.fromString(data.preferredLocale) /** * The behaviors of all [channels][TopGuildChannel]. @@ -497,7 +499,7 @@ public class Guild( */ override fun withStrategy(strategy: EntitySupplyStrategy<*>): Guild = Guild(data, kord, strategy.supply(kord)) - override fun hashCode(): Int = Objects.hash(id) + override fun hashCode(): Int = hash(id) override fun equals(other: Any?): Boolean = when (other) { is GuildBehavior -> other.id == id diff --git a/core/src/main/kotlin/entity/GuildEmoji.kt b/core/src/commonMain/kotlin/entity/GuildEmoji.kt similarity index 98% rename from core/src/main/kotlin/entity/GuildEmoji.kt rename to core/src/commonMain/kotlin/entity/GuildEmoji.kt index 549f076e5bca..ebdbd9917789 100644 --- a/core/src/main/kotlin/entity/GuildEmoji.kt +++ b/core/src/commonMain/kotlin/entity/GuildEmoji.kt @@ -14,7 +14,7 @@ import dev.kord.rest.builder.guild.EmojiModifyBuilder import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.filter -import java.util.* +import dev.kord.core.hash import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -150,7 +150,7 @@ public class GuildEmoji( */ override fun withStrategy(strategy: EntitySupplyStrategy<*>): GuildEmoji = GuildEmoji(data, kord, strategy.supply(kord)) - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is GuildEmoji -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/entity/GuildPreview.kt b/core/src/commonMain/kotlin/entity/GuildPreview.kt similarity index 100% rename from core/src/main/kotlin/entity/GuildPreview.kt rename to core/src/commonMain/kotlin/entity/GuildPreview.kt diff --git a/core/src/main/kotlin/entity/GuildScheduledEvent.kt b/core/src/commonMain/kotlin/entity/GuildScheduledEvent.kt similarity index 100% rename from core/src/main/kotlin/entity/GuildScheduledEvent.kt rename to core/src/commonMain/kotlin/entity/GuildScheduledEvent.kt diff --git a/core/src/main/kotlin/entity/GuildWidget.kt b/core/src/commonMain/kotlin/entity/GuildWidget.kt similarity index 100% rename from core/src/main/kotlin/entity/GuildWidget.kt rename to core/src/commonMain/kotlin/entity/GuildWidget.kt diff --git a/core/src/main/kotlin/entity/Icon.kt b/core/src/commonMain/kotlin/entity/Icon.kt similarity index 95% rename from core/src/main/kotlin/entity/Icon.kt rename to core/src/commonMain/kotlin/entity/Icon.kt index cfc623174ed1..77020b2f91e6 100644 --- a/core/src/main/kotlin/entity/Icon.kt +++ b/core/src/commonMain/kotlin/entity/Icon.kt @@ -37,7 +37,7 @@ public sealed class Icon( }) override fun toString(): String { - return "Icon(type=${javaClass.name},format=$format,animated=$animated,cdnUrl=$cdnUrl,kord=$kord)" + return "Icon(type=${this::class.simpleName},format=$format,animated=$animated,cdnUrl=$cdnUrl,kord=$kord)" } public class EmojiIcon(animated: Boolean, emojiId: Snowflake, kord: Kord) : diff --git a/core/src/main/kotlin/entity/Integration.kt b/core/src/commonMain/kotlin/entity/Integration.kt similarity index 100% rename from core/src/main/kotlin/entity/Integration.kt rename to core/src/commonMain/kotlin/entity/Integration.kt diff --git a/core/src/main/kotlin/entity/Invite.kt b/core/src/commonMain/kotlin/entity/Invite.kt similarity index 100% rename from core/src/main/kotlin/entity/Invite.kt rename to core/src/commonMain/kotlin/entity/Invite.kt diff --git a/core/src/main/kotlin/entity/Member.kt b/core/src/commonMain/kotlin/entity/Member.kt similarity index 98% rename from core/src/main/kotlin/entity/Member.kt rename to core/src/commonMain/kotlin/entity/Member.kt index 511a4f73f9a1..ac86987ee908 100644 --- a/core/src/main/kotlin/entity/Member.kt +++ b/core/src/commonMain/kotlin/entity/Member.kt @@ -14,7 +14,7 @@ import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import kotlinx.coroutines.flow.* import kotlinx.datetime.Instant -import java.util.* +import dev.kord.core.hash /** * An instance of a [Discord Member](https://discord.com/developers/docs/resources/guild#guild-member-object). @@ -134,7 +134,7 @@ public class Member( override suspend fun asMemberOrNull(): Member = this - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is MemberBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/entity/Message.kt b/core/src/commonMain/kotlin/entity/Message.kt similarity index 99% rename from core/src/main/kotlin/entity/Message.kt rename to core/src/commonMain/kotlin/entity/Message.kt index bd2a7cba89ba..e193aaf835fd 100644 --- a/core/src/main/kotlin/entity/Message.kt +++ b/core/src/commonMain/kotlin/entity/Message.kt @@ -29,7 +29,7 @@ import dev.kord.core.supplier.getChannelOf import dev.kord.core.supplier.getChannelOfOrNull import kotlinx.coroutines.flow.* import kotlinx.datetime.Instant -import java.util.Objects +import dev.kord.core.hash /** * An instance of a [Discord Message][https://discord.com/developers/docs/resources/channel#message-object]. @@ -367,7 +367,7 @@ public class Message( */ override fun withStrategy(strategy: EntitySupplyStrategy<*>): Message = Message(data, kord, strategy.supply(kord)) - override fun hashCode(): Int = Objects.hash(id) + override fun hashCode(): Int = hash(id) override fun equals(other: Any?): Boolean = when (other) { is MessageBehavior -> other.id == id && other.channelId == channelId diff --git a/core/src/main/kotlin/entity/MessageReference.kt b/core/src/commonMain/kotlin/entity/MessageReference.kt similarity index 100% rename from core/src/main/kotlin/entity/MessageReference.kt rename to core/src/commonMain/kotlin/entity/MessageReference.kt diff --git a/core/src/main/kotlin/entity/PartialGuild.kt b/core/src/commonMain/kotlin/entity/PartialGuild.kt similarity index 98% rename from core/src/main/kotlin/entity/PartialGuild.kt rename to core/src/commonMain/kotlin/entity/PartialGuild.kt index 24d960e7d288..9f7220cdac90 100644 --- a/core/src/main/kotlin/entity/PartialGuild.kt +++ b/core/src/commonMain/kotlin/entity/PartialGuild.kt @@ -15,7 +15,7 @@ import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.rest.Image import dev.kord.rest.service.RestClient -import java.util.* +import dev.kord.core.hash public class PartialGuild( public val data: PartialGuildData, @@ -154,7 +154,7 @@ public class PartialGuild( public suspend fun getGuildOrNull(): Guild? = supplier.getGuildOrNull(id) - override fun hashCode(): Int = Objects.hash(id) + override fun hashCode(): Int = hash(id) override fun equals(other: Any?): Boolean = when (other) { is GuildBehavior -> other.id == id diff --git a/core/src/main/kotlin/entity/PermissionOverwrite.kt b/core/src/commonMain/kotlin/entity/PermissionOverwrite.kt similarity index 100% rename from core/src/main/kotlin/entity/PermissionOverwrite.kt rename to core/src/commonMain/kotlin/entity/PermissionOverwrite.kt diff --git a/core/src/main/kotlin/entity/PermissionOverwriteEntity.kt b/core/src/commonMain/kotlin/entity/PermissionOverwriteEntity.kt similarity index 100% rename from core/src/main/kotlin/entity/PermissionOverwriteEntity.kt rename to core/src/commonMain/kotlin/entity/PermissionOverwriteEntity.kt diff --git a/core/src/main/kotlin/entity/Presence.kt b/core/src/commonMain/kotlin/entity/Presence.kt similarity index 100% rename from core/src/main/kotlin/entity/Presence.kt rename to core/src/commonMain/kotlin/entity/Presence.kt diff --git a/core/src/main/kotlin/entity/Reaction.kt b/core/src/commonMain/kotlin/entity/Reaction.kt similarity index 100% rename from core/src/main/kotlin/entity/Reaction.kt rename to core/src/commonMain/kotlin/entity/Reaction.kt diff --git a/core/src/main/kotlin/entity/ReactionEmoji.kt b/core/src/commonMain/kotlin/entity/ReactionEmoji.kt similarity index 100% rename from core/src/main/kotlin/entity/ReactionEmoji.kt rename to core/src/commonMain/kotlin/entity/ReactionEmoji.kt diff --git a/core/src/main/kotlin/entity/Region.kt b/core/src/commonMain/kotlin/entity/Region.kt similarity index 90% rename from core/src/main/kotlin/entity/Region.kt rename to core/src/commonMain/kotlin/entity/Region.kt index 26c9b4334dcd..e6ff8acd7472 100644 --- a/core/src/main/kotlin/entity/Region.kt +++ b/core/src/commonMain/kotlin/entity/Region.kt @@ -3,7 +3,7 @@ package dev.kord.core.entity import dev.kord.core.Kord import dev.kord.core.KordObject import dev.kord.core.cache.data.RegionData -import java.util.* +import dev.kord.core.hash public class Region(public val data: RegionData, override val kord: Kord) : KordObject { public val id: String @@ -17,7 +17,7 @@ public class Region(public val data: RegionData, override val kord: Kord) : Kord public val isOptimal: Boolean get() = data.optimal - override fun hashCode(): Int = Objects.hash(id) + override fun hashCode(): Int = hash(id) override fun equals(other: Any?): Boolean = when (other) { is Region -> other.id == id diff --git a/core/src/main/kotlin/entity/Role.kt b/core/src/commonMain/kotlin/entity/Role.kt similarity index 96% rename from core/src/main/kotlin/entity/Role.kt rename to core/src/commonMain/kotlin/entity/Role.kt index c2ccede750ec..88408436f480 100644 --- a/core/src/main/kotlin/entity/Role.kt +++ b/core/src/commonMain/kotlin/entity/Role.kt @@ -9,7 +9,7 @@ import dev.kord.core.behavior.RoleBehavior import dev.kord.core.cache.data.RoleData import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy -import java.util.* +import dev.kord.core.hash public data class Role( val data: RoleData, @@ -60,7 +60,7 @@ public data class Role( */ override fun withStrategy(strategy: EntitySupplyStrategy<*>): Role = Role(data, kord, strategy.supply(kord)) - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is RoleBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/entity/RoleTags.kt b/core/src/commonMain/kotlin/entity/RoleTags.kt similarity index 100% rename from core/src/main/kotlin/entity/RoleTags.kt rename to core/src/commonMain/kotlin/entity/RoleTags.kt diff --git a/core/src/main/kotlin/entity/StageInstance.kt b/core/src/commonMain/kotlin/entity/StageInstance.kt similarity index 100% rename from core/src/main/kotlin/entity/StageInstance.kt rename to core/src/commonMain/kotlin/entity/StageInstance.kt diff --git a/core/src/main/kotlin/entity/Sticker.kt b/core/src/commonMain/kotlin/entity/Sticker.kt similarity index 100% rename from core/src/main/kotlin/entity/Sticker.kt rename to core/src/commonMain/kotlin/entity/Sticker.kt diff --git a/core/src/main/kotlin/entity/Strategizable.kt b/core/src/commonMain/kotlin/entity/Strategizable.kt similarity index 100% rename from core/src/main/kotlin/entity/Strategizable.kt rename to core/src/commonMain/kotlin/entity/Strategizable.kt diff --git a/core/src/main/kotlin/entity/Team.kt b/core/src/commonMain/kotlin/entity/Team.kt similarity index 100% rename from core/src/main/kotlin/entity/Team.kt rename to core/src/commonMain/kotlin/entity/Team.kt diff --git a/core/src/main/kotlin/entity/Template.kt b/core/src/commonMain/kotlin/entity/Template.kt similarity index 100% rename from core/src/main/kotlin/entity/Template.kt rename to core/src/commonMain/kotlin/entity/Template.kt diff --git a/core/src/main/kotlin/entity/User.kt b/core/src/commonMain/kotlin/entity/User.kt similarity index 100% rename from core/src/main/kotlin/entity/User.kt rename to core/src/commonMain/kotlin/entity/User.kt diff --git a/core/src/main/kotlin/entity/VoiceState.kt b/core/src/commonMain/kotlin/entity/VoiceState.kt similarity index 100% rename from core/src/main/kotlin/entity/VoiceState.kt rename to core/src/commonMain/kotlin/entity/VoiceState.kt diff --git a/core/src/main/kotlin/entity/Webhook.kt b/core/src/commonMain/kotlin/entity/Webhook.kt similarity index 97% rename from core/src/main/kotlin/entity/Webhook.kt rename to core/src/commonMain/kotlin/entity/Webhook.kt index 64ae09d499e2..2874331d5050 100644 --- a/core/src/main/kotlin/entity/Webhook.kt +++ b/core/src/commonMain/kotlin/entity/Webhook.kt @@ -15,7 +15,7 @@ import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.core.supplier.getChannelOf import dev.kord.core.supplier.getChannelOfOrNull -import java.util.Objects +import dev.kord.core.hash public data class Webhook( val data: WebhookData, @@ -72,7 +72,7 @@ public data class Webhook( override fun withStrategy(strategy: EntitySupplyStrategy<*>): Webhook = Webhook(data, kord, strategy.supply(kord)) - override fun hashCode(): Int = Objects.hash(id) + override fun hashCode(): Int = hash(id) override fun equals(other: Any?): Boolean = when (other) { is WebhookBehavior -> other.id == id diff --git a/core/src/main/kotlin/entity/WelcomeScreen.kt b/core/src/commonMain/kotlin/entity/WelcomeScreen.kt similarity index 100% rename from core/src/main/kotlin/entity/WelcomeScreen.kt rename to core/src/commonMain/kotlin/entity/WelcomeScreen.kt diff --git a/core/src/main/kotlin/entity/application/ApplicationCommand.kt b/core/src/commonMain/kotlin/entity/application/ApplicationCommand.kt similarity index 100% rename from core/src/main/kotlin/entity/application/ApplicationCommand.kt rename to core/src/commonMain/kotlin/entity/application/ApplicationCommand.kt diff --git a/core/src/main/kotlin/entity/application/ApplicationGuildCommandPermissions.kt b/core/src/commonMain/kotlin/entity/application/ApplicationGuildCommandPermissions.kt similarity index 94% rename from core/src/main/kotlin/entity/application/ApplicationGuildCommandPermissions.kt rename to core/src/commonMain/kotlin/entity/application/ApplicationGuildCommandPermissions.kt index a7580794ffe9..72f070ea7ab8 100644 --- a/core/src/main/kotlin/entity/application/ApplicationGuildCommandPermissions.kt +++ b/core/src/commonMain/kotlin/entity/application/ApplicationGuildCommandPermissions.kt @@ -6,6 +6,8 @@ import dev.kord.core.cache.data.GuildApplicationCommandPermissionData import dev.kord.core.cache.data.GuildApplicationCommandPermissionsData import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow +import kotlin.DeprecationLevel.HIDDEN +import kotlin.jvm.JvmName public class GuildApplicationCommandPermission(public val data: GuildApplicationCommandPermissionData) { diff --git a/core/src/main/kotlin/entity/application/ChatInputCommandCommand.kt b/core/src/commonMain/kotlin/entity/application/ChatInputCommandCommand.kt similarity index 100% rename from core/src/main/kotlin/entity/application/ChatInputCommandCommand.kt rename to core/src/commonMain/kotlin/entity/application/ChatInputCommandCommand.kt diff --git a/core/src/main/kotlin/entity/application/MessageCommand.kt b/core/src/commonMain/kotlin/entity/application/MessageCommand.kt similarity index 100% rename from core/src/main/kotlin/entity/application/MessageCommand.kt rename to core/src/commonMain/kotlin/entity/application/MessageCommand.kt diff --git a/core/src/main/kotlin/entity/application/UserCommand.kt b/core/src/commonMain/kotlin/entity/application/UserCommand.kt similarity index 100% rename from core/src/main/kotlin/entity/application/UserCommand.kt rename to core/src/commonMain/kotlin/entity/application/UserCommand.kt diff --git a/core/src/main/kotlin/entity/automoderation/AutoModerationAction.kt b/core/src/commonMain/kotlin/entity/automoderation/AutoModerationAction.kt similarity index 100% rename from core/src/main/kotlin/entity/automoderation/AutoModerationAction.kt rename to core/src/commonMain/kotlin/entity/automoderation/AutoModerationAction.kt diff --git a/core/src/main/kotlin/entity/automoderation/AutoModerationRule.kt b/core/src/commonMain/kotlin/entity/automoderation/AutoModerationRule.kt similarity index 100% rename from core/src/main/kotlin/entity/automoderation/AutoModerationRule.kt rename to core/src/commonMain/kotlin/entity/automoderation/AutoModerationRule.kt diff --git a/core/src/main/kotlin/entity/channel/CategorizableChannel.kt b/core/src/commonMain/kotlin/entity/channel/CategorizableChannel.kt similarity index 100% rename from core/src/main/kotlin/entity/channel/CategorizableChannel.kt rename to core/src/commonMain/kotlin/entity/channel/CategorizableChannel.kt diff --git a/core/src/main/kotlin/entity/channel/Category.kt b/core/src/commonMain/kotlin/entity/channel/Category.kt similarity index 95% rename from core/src/main/kotlin/entity/channel/Category.kt rename to core/src/commonMain/kotlin/entity/channel/Category.kt index c9d7ac4902ac..76b2cdfc13e7 100644 --- a/core/src/main/kotlin/entity/channel/Category.kt +++ b/core/src/commonMain/kotlin/entity/channel/Category.kt @@ -10,7 +10,7 @@ import dev.kord.core.cache.data.ChannelData import dev.kord.core.entity.Entity import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy -import java.util.* +import dev.kord.core.hash /** * An instance of a Discord category associated to a [guild]. @@ -42,7 +42,7 @@ public class Category( Category(data, kord, strategy.supply(kord)) - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is GuildChannelBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/entity/channel/Channel.kt b/core/src/commonMain/kotlin/entity/channel/Channel.kt similarity index 100% rename from core/src/main/kotlin/entity/channel/Channel.kt rename to core/src/commonMain/kotlin/entity/channel/Channel.kt diff --git a/core/src/main/kotlin/entity/channel/DmChannel.kt b/core/src/commonMain/kotlin/entity/channel/DmChannel.kt similarity index 96% rename from core/src/main/kotlin/entity/channel/DmChannel.kt rename to core/src/commonMain/kotlin/entity/channel/DmChannel.kt index 07e64539975c..af5540e6eca4 100644 --- a/core/src/main/kotlin/entity/channel/DmChannel.kt +++ b/core/src/commonMain/kotlin/entity/channel/DmChannel.kt @@ -8,13 +8,14 @@ import dev.kord.core.behavior.UserBehavior import dev.kord.core.behavior.channel.ChannelBehavior import dev.kord.core.cache.data.ChannelData import dev.kord.core.entity.User +import dev.kord.core.hash import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.map -import java.util.* +import kotlin.js.JsName /** * An instance of a Discord DM channel. @@ -60,7 +61,7 @@ public data class DmChannel( DmChannel(data, kord, strategy.supply(kord)) - override fun hashCode(): Int = Objects.hash(id) + override fun hashCode(): Int = hash(id) override fun equals(other: Any?): Boolean = when (other) { is ChannelBehavior -> other.id == id diff --git a/core/src/main/kotlin/entity/channel/ForumChannel.kt b/core/src/commonMain/kotlin/entity/channel/ForumChannel.kt similarity index 100% rename from core/src/main/kotlin/entity/channel/ForumChannel.kt rename to core/src/commonMain/kotlin/entity/channel/ForumChannel.kt diff --git a/core/src/main/kotlin/entity/channel/GuildChannel.kt b/core/src/commonMain/kotlin/entity/channel/GuildChannel.kt similarity index 100% rename from core/src/main/kotlin/entity/channel/GuildChannel.kt rename to core/src/commonMain/kotlin/entity/channel/GuildChannel.kt diff --git a/core/src/main/kotlin/entity/channel/GuildMessageChannel.kt b/core/src/commonMain/kotlin/entity/channel/GuildMessageChannel.kt similarity index 100% rename from core/src/main/kotlin/entity/channel/GuildMessageChannel.kt rename to core/src/commonMain/kotlin/entity/channel/GuildMessageChannel.kt diff --git a/core/src/main/kotlin/entity/channel/MessageChannel.kt b/core/src/commonMain/kotlin/entity/channel/MessageChannel.kt similarity index 100% rename from core/src/main/kotlin/entity/channel/MessageChannel.kt rename to core/src/commonMain/kotlin/entity/channel/MessageChannel.kt diff --git a/core/src/main/kotlin/entity/channel/NewsChannel.kt b/core/src/commonMain/kotlin/entity/channel/NewsChannel.kt similarity index 94% rename from core/src/main/kotlin/entity/channel/NewsChannel.kt rename to core/src/commonMain/kotlin/entity/channel/NewsChannel.kt index 187e6e9ffdba..348edf553091 100644 --- a/core/src/main/kotlin/entity/channel/NewsChannel.kt +++ b/core/src/commonMain/kotlin/entity/channel/NewsChannel.kt @@ -7,7 +7,7 @@ import dev.kord.core.behavior.channel.NewsChannelBehavior import dev.kord.core.cache.data.ChannelData import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy -import java.util.* +import dev.kord.core.hash /** * An instance of a Discord News Channel associated to a guild. @@ -18,7 +18,7 @@ public class NewsChannel( override val supplier: EntitySupplier = kord.defaultSupplier ) : CategorizableChannel, TopGuildMessageChannel, ThreadParentChannel, NewsChannelBehavior { - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is TopGuildChannelBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/entity/channel/ResolvedChannel.kt b/core/src/commonMain/kotlin/entity/channel/ResolvedChannel.kt similarity index 100% rename from core/src/main/kotlin/entity/channel/ResolvedChannel.kt rename to core/src/commonMain/kotlin/entity/channel/ResolvedChannel.kt diff --git a/core/src/main/kotlin/entity/channel/StageVoiceChannel.kt b/core/src/commonMain/kotlin/entity/channel/StageVoiceChannel.kt similarity index 95% rename from core/src/main/kotlin/entity/channel/StageVoiceChannel.kt rename to core/src/commonMain/kotlin/entity/channel/StageVoiceChannel.kt index 02468b01ed26..31ce9c43de74 100644 --- a/core/src/main/kotlin/entity/channel/StageVoiceChannel.kt +++ b/core/src/commonMain/kotlin/entity/channel/StageVoiceChannel.kt @@ -8,7 +8,7 @@ import dev.kord.core.behavior.channel.StageChannelBehavior import dev.kord.core.cache.data.ChannelData import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy -import java.util.* +import dev.kord.core.hash /** * An instance of a [Discord Stage Channel](https://support.discord.com/hc/en-us/articles/1500005513722) @@ -42,7 +42,7 @@ public class StageChannel( override suspend fun asChannelOrNull(): StageChannel = this - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is GuildChannelBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/entity/channel/TextChannel.kt b/core/src/commonMain/kotlin/entity/channel/TextChannel.kt similarity index 96% rename from core/src/main/kotlin/entity/channel/TextChannel.kt rename to core/src/commonMain/kotlin/entity/channel/TextChannel.kt index 4bb53c2b6f69..ed37d7925eed 100644 --- a/core/src/main/kotlin/entity/channel/TextChannel.kt +++ b/core/src/commonMain/kotlin/entity/channel/TextChannel.kt @@ -9,7 +9,7 @@ import dev.kord.core.behavior.channel.TextChannelBehavior import dev.kord.core.cache.data.ChannelData import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy -import java.util.* +import dev.kord.core.hash import kotlin.time.Duration /** @@ -47,7 +47,7 @@ public class TextChannel( override suspend fun asChannelOrNull(): TextChannel = this - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is GuildChannelBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/entity/channel/ThreadParentChannel.kt b/core/src/commonMain/kotlin/entity/channel/ThreadParentChannel.kt similarity index 100% rename from core/src/main/kotlin/entity/channel/ThreadParentChannel.kt rename to core/src/commonMain/kotlin/entity/channel/ThreadParentChannel.kt diff --git a/core/src/main/kotlin/entity/channel/TopGuildChannel.kt b/core/src/commonMain/kotlin/entity/channel/TopGuildChannel.kt similarity index 100% rename from core/src/main/kotlin/entity/channel/TopGuildChannel.kt rename to core/src/commonMain/kotlin/entity/channel/TopGuildChannel.kt diff --git a/core/src/main/kotlin/entity/channel/TopGuildMessageChannel.kt b/core/src/commonMain/kotlin/entity/channel/TopGuildMessageChannel.kt similarity index 100% rename from core/src/main/kotlin/entity/channel/TopGuildMessageChannel.kt rename to core/src/commonMain/kotlin/entity/channel/TopGuildMessageChannel.kt diff --git a/core/src/main/kotlin/entity/channel/VoiceChannel.kt b/core/src/commonMain/kotlin/entity/channel/VoiceChannel.kt similarity index 97% rename from core/src/main/kotlin/entity/channel/VoiceChannel.kt rename to core/src/commonMain/kotlin/entity/channel/VoiceChannel.kt index e5d2de37face..46db97f0372d 100644 --- a/core/src/main/kotlin/entity/channel/VoiceChannel.kt +++ b/core/src/commonMain/kotlin/entity/channel/VoiceChannel.kt @@ -16,7 +16,7 @@ import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.firstOrNull -import java.util.* +import dev.kord.core.hash /** * An instance of a Discord Voice Channel associated to a guild. @@ -76,7 +76,7 @@ public class VoiceChannel( override suspend fun asChannelOrNull(): VoiceChannel = this - override fun hashCode(): Int = Objects.hash(id, guildId) + override fun hashCode(): Int = hash(id, guildId) override fun equals(other: Any?): Boolean = when (other) { is GuildChannelBehavior -> other.id == id && other.guildId == guildId diff --git a/core/src/main/kotlin/entity/channel/WelcomeScreenChannel.kt b/core/src/commonMain/kotlin/entity/channel/WelcomeScreenChannel.kt similarity index 100% rename from core/src/main/kotlin/entity/channel/WelcomeScreenChannel.kt rename to core/src/commonMain/kotlin/entity/channel/WelcomeScreenChannel.kt diff --git a/core/src/main/kotlin/entity/channel/thread/DeletedThreadChannel.kt b/core/src/commonMain/kotlin/entity/channel/thread/DeletedThreadChannel.kt similarity index 100% rename from core/src/main/kotlin/entity/channel/thread/DeletedThreadChannel.kt rename to core/src/commonMain/kotlin/entity/channel/thread/DeletedThreadChannel.kt diff --git a/core/src/main/kotlin/entity/channel/thread/NewsChannelThread.kt b/core/src/commonMain/kotlin/entity/channel/thread/NewsChannelThread.kt similarity index 100% rename from core/src/main/kotlin/entity/channel/thread/NewsChannelThread.kt rename to core/src/commonMain/kotlin/entity/channel/thread/NewsChannelThread.kt diff --git a/core/src/main/kotlin/entity/channel/thread/TextChannelThread.kt b/core/src/commonMain/kotlin/entity/channel/thread/TextChannelThread.kt similarity index 100% rename from core/src/main/kotlin/entity/channel/thread/TextChannelThread.kt rename to core/src/commonMain/kotlin/entity/channel/thread/TextChannelThread.kt diff --git a/core/src/main/kotlin/entity/channel/thread/ThreadChannel.kt b/core/src/commonMain/kotlin/entity/channel/thread/ThreadChannel.kt similarity index 100% rename from core/src/main/kotlin/entity/channel/thread/ThreadChannel.kt rename to core/src/commonMain/kotlin/entity/channel/thread/ThreadChannel.kt diff --git a/core/src/main/kotlin/entity/channel/thread/ThreadMember.kt b/core/src/commonMain/kotlin/entity/channel/thread/ThreadMember.kt similarity index 100% rename from core/src/main/kotlin/entity/channel/thread/ThreadMember.kt rename to core/src/commonMain/kotlin/entity/channel/thread/ThreadMember.kt diff --git a/core/src/main/kotlin/entity/component/ActionRowComponent.kt b/core/src/commonMain/kotlin/entity/component/ActionRowComponent.kt similarity index 100% rename from core/src/main/kotlin/entity/component/ActionRowComponent.kt rename to core/src/commonMain/kotlin/entity/component/ActionRowComponent.kt diff --git a/core/src/main/kotlin/entity/component/ButtonComponent.kt b/core/src/commonMain/kotlin/entity/component/ButtonComponent.kt similarity index 100% rename from core/src/main/kotlin/entity/component/ButtonComponent.kt rename to core/src/commonMain/kotlin/entity/component/ButtonComponent.kt diff --git a/core/src/main/kotlin/entity/component/Component.kt b/core/src/commonMain/kotlin/entity/component/Component.kt similarity index 100% rename from core/src/main/kotlin/entity/component/Component.kt rename to core/src/commonMain/kotlin/entity/component/Component.kt diff --git a/core/src/main/kotlin/entity/component/SelectMenuComponent.kt b/core/src/commonMain/kotlin/entity/component/SelectMenuComponent.kt similarity index 99% rename from core/src/main/kotlin/entity/component/SelectMenuComponent.kt rename to core/src/commonMain/kotlin/entity/component/SelectMenuComponent.kt index f63d6d260117..eaa6047b3712 100644 --- a/core/src/main/kotlin/entity/component/SelectMenuComponent.kt +++ b/core/src/commonMain/kotlin/entity/component/SelectMenuComponent.kt @@ -10,6 +10,7 @@ import dev.kord.core.cache.data.ComponentData import dev.kord.core.cache.data.SelectOptionData import dev.kord.core.entity.Message import dev.kord.core.entity.interaction.SelectMenuInteraction +import kotlin.jvm.JvmName /** * An interactive dropdown menu rendered on a [Message] that consists of multiple [options]. diff --git a/core/src/main/kotlin/entity/component/TextInputComponent.kt b/core/src/commonMain/kotlin/entity/component/TextInputComponent.kt similarity index 100% rename from core/src/main/kotlin/entity/component/TextInputComponent.kt rename to core/src/commonMain/kotlin/entity/component/TextInputComponent.kt diff --git a/core/src/main/kotlin/entity/component/UnknownComponent.kt b/core/src/commonMain/kotlin/entity/component/UnknownComponent.kt similarity index 100% rename from core/src/main/kotlin/entity/component/UnknownComponent.kt rename to core/src/commonMain/kotlin/entity/component/UnknownComponent.kt diff --git a/core/src/main/kotlin/entity/interaction/ActionInteraction.kt b/core/src/commonMain/kotlin/entity/interaction/ActionInteraction.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/ActionInteraction.kt rename to core/src/commonMain/kotlin/entity/interaction/ActionInteraction.kt diff --git a/core/src/main/kotlin/entity/interaction/ApplicationCommandInteraction.kt b/core/src/commonMain/kotlin/entity/interaction/ApplicationCommandInteraction.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/ApplicationCommandInteraction.kt rename to core/src/commonMain/kotlin/entity/interaction/ApplicationCommandInteraction.kt diff --git a/core/src/main/kotlin/entity/interaction/AutoCompleteInteraction.kt b/core/src/commonMain/kotlin/entity/interaction/AutoCompleteInteraction.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/AutoCompleteInteraction.kt rename to core/src/commonMain/kotlin/entity/interaction/AutoCompleteInteraction.kt diff --git a/core/src/main/kotlin/entity/interaction/ButtonInteraction.kt b/core/src/commonMain/kotlin/entity/interaction/ButtonInteraction.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/ButtonInteraction.kt rename to core/src/commonMain/kotlin/entity/interaction/ButtonInteraction.kt diff --git a/core/src/main/kotlin/entity/interaction/ChatInputCommandInteraction.kt b/core/src/commonMain/kotlin/entity/interaction/ChatInputCommandInteraction.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/ChatInputCommandInteraction.kt rename to core/src/commonMain/kotlin/entity/interaction/ChatInputCommandInteraction.kt diff --git a/core/src/main/kotlin/entity/interaction/ComponentInteraction.kt b/core/src/commonMain/kotlin/entity/interaction/ComponentInteraction.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/ComponentInteraction.kt rename to core/src/commonMain/kotlin/entity/interaction/ComponentInteraction.kt diff --git a/core/src/main/kotlin/entity/interaction/DataInteraction.kt b/core/src/commonMain/kotlin/entity/interaction/DataInteraction.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/DataInteraction.kt rename to core/src/commonMain/kotlin/entity/interaction/DataInteraction.kt diff --git a/core/src/main/kotlin/entity/interaction/GlobalInteraction.kt b/core/src/commonMain/kotlin/entity/interaction/GlobalInteraction.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/GlobalInteraction.kt rename to core/src/commonMain/kotlin/entity/interaction/GlobalInteraction.kt diff --git a/core/src/main/kotlin/entity/interaction/GuildInteraction.kt b/core/src/commonMain/kotlin/entity/interaction/GuildInteraction.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/GuildInteraction.kt rename to core/src/commonMain/kotlin/entity/interaction/GuildInteraction.kt diff --git a/core/src/main/kotlin/entity/interaction/Interaction.kt b/core/src/commonMain/kotlin/entity/interaction/Interaction.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/Interaction.kt rename to core/src/commonMain/kotlin/entity/interaction/Interaction.kt diff --git a/core/src/main/kotlin/entity/interaction/InteractionCommand.kt b/core/src/commonMain/kotlin/entity/interaction/InteractionCommand.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/InteractionCommand.kt rename to core/src/commonMain/kotlin/entity/interaction/InteractionCommand.kt diff --git a/core/src/main/kotlin/entity/interaction/MessageCommandInteraction.kt b/core/src/commonMain/kotlin/entity/interaction/MessageCommandInteraction.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/MessageCommandInteraction.kt rename to core/src/commonMain/kotlin/entity/interaction/MessageCommandInteraction.kt diff --git a/core/src/main/kotlin/entity/interaction/ModalSubmitInteraction.kt b/core/src/commonMain/kotlin/entity/interaction/ModalSubmitInteraction.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/ModalSubmitInteraction.kt rename to core/src/commonMain/kotlin/entity/interaction/ModalSubmitInteraction.kt diff --git a/core/src/main/kotlin/entity/interaction/OptionValue.kt b/core/src/commonMain/kotlin/entity/interaction/OptionValue.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/OptionValue.kt rename to core/src/commonMain/kotlin/entity/interaction/OptionValue.kt diff --git a/core/src/main/kotlin/entity/interaction/ResolvedObjects.kt b/core/src/commonMain/kotlin/entity/interaction/ResolvedObjects.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/ResolvedObjects.kt rename to core/src/commonMain/kotlin/entity/interaction/ResolvedObjects.kt diff --git a/core/src/main/kotlin/entity/interaction/SelectMenuInteraction.kt b/core/src/commonMain/kotlin/entity/interaction/SelectMenuInteraction.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/SelectMenuInteraction.kt rename to core/src/commonMain/kotlin/entity/interaction/SelectMenuInteraction.kt diff --git a/core/src/main/kotlin/entity/interaction/UserCommandInteraction.kt b/core/src/commonMain/kotlin/entity/interaction/UserCommandInteraction.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/UserCommandInteraction.kt rename to core/src/commonMain/kotlin/entity/interaction/UserCommandInteraction.kt diff --git a/core/src/main/kotlin/entity/interaction/followup/EphemeralFollowupMessage.kt b/core/src/commonMain/kotlin/entity/interaction/followup/EphemeralFollowupMessage.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/followup/EphemeralFollowupMessage.kt rename to core/src/commonMain/kotlin/entity/interaction/followup/EphemeralFollowupMessage.kt diff --git a/core/src/main/kotlin/entity/interaction/followup/FollowupMessage.kt b/core/src/commonMain/kotlin/entity/interaction/followup/FollowupMessage.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/followup/FollowupMessage.kt rename to core/src/commonMain/kotlin/entity/interaction/followup/FollowupMessage.kt diff --git a/core/src/main/kotlin/entity/interaction/followup/PublicFollowupMessage.kt b/core/src/commonMain/kotlin/entity/interaction/followup/PublicFollowupMessage.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/followup/PublicFollowupMessage.kt rename to core/src/commonMain/kotlin/entity/interaction/followup/PublicFollowupMessage.kt diff --git a/core/src/main/kotlin/entity/interaction/response/EphemeralMessageInteractionResponse.kt b/core/src/commonMain/kotlin/entity/interaction/response/EphemeralMessageInteractionResponse.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/response/EphemeralMessageInteractionResponse.kt rename to core/src/commonMain/kotlin/entity/interaction/response/EphemeralMessageInteractionResponse.kt diff --git a/core/src/main/kotlin/entity/interaction/response/MessageInteractionResponse.kt b/core/src/commonMain/kotlin/entity/interaction/response/MessageInteractionResponse.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/response/MessageInteractionResponse.kt rename to core/src/commonMain/kotlin/entity/interaction/response/MessageInteractionResponse.kt diff --git a/core/src/main/kotlin/entity/interaction/response/PublicMessageInteractionResponse.kt b/core/src/commonMain/kotlin/entity/interaction/response/PublicMessageInteractionResponse.kt similarity index 100% rename from core/src/main/kotlin/entity/interaction/response/PublicMessageInteractionResponse.kt rename to core/src/commonMain/kotlin/entity/interaction/response/PublicMessageInteractionResponse.kt diff --git a/core/src/main/kotlin/event/Event.kt b/core/src/commonMain/kotlin/event/Event.kt similarity index 100% rename from core/src/main/kotlin/event/Event.kt rename to core/src/commonMain/kotlin/event/Event.kt diff --git a/core/src/main/kotlin/event/automoderation/AutoModerationActionExecutionEvent.kt b/core/src/commonMain/kotlin/event/automoderation/AutoModerationActionExecutionEvent.kt similarity index 100% rename from core/src/main/kotlin/event/automoderation/AutoModerationActionExecutionEvent.kt rename to core/src/commonMain/kotlin/event/automoderation/AutoModerationActionExecutionEvent.kt diff --git a/core/src/main/kotlin/event/automoderation/AutoModerationEvent.kt b/core/src/commonMain/kotlin/event/automoderation/AutoModerationEvent.kt similarity index 100% rename from core/src/main/kotlin/event/automoderation/AutoModerationEvent.kt rename to core/src/commonMain/kotlin/event/automoderation/AutoModerationEvent.kt diff --git a/core/src/main/kotlin/event/automoderation/AutoModerationRuleConfigurationEvent.kt b/core/src/commonMain/kotlin/event/automoderation/AutoModerationRuleConfigurationEvent.kt similarity index 100% rename from core/src/main/kotlin/event/automoderation/AutoModerationRuleConfigurationEvent.kt rename to core/src/commonMain/kotlin/event/automoderation/AutoModerationRuleConfigurationEvent.kt diff --git a/core/src/main/kotlin/event/automoderation/data/AutoModerationActionExecutionEventData.kt b/core/src/commonMain/kotlin/event/automoderation/data/AutoModerationActionExecutionEventData.kt similarity index 100% rename from core/src/main/kotlin/event/automoderation/data/AutoModerationActionExecutionEventData.kt rename to core/src/commonMain/kotlin/event/automoderation/data/AutoModerationActionExecutionEventData.kt diff --git a/core/src/main/kotlin/event/channel/ChannelCreateEvent.kt b/core/src/commonMain/kotlin/event/channel/ChannelCreateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/channel/ChannelCreateEvent.kt rename to core/src/commonMain/kotlin/event/channel/ChannelCreateEvent.kt diff --git a/core/src/main/kotlin/event/channel/ChannelDeleteEvent.kt b/core/src/commonMain/kotlin/event/channel/ChannelDeleteEvent.kt similarity index 100% rename from core/src/main/kotlin/event/channel/ChannelDeleteEvent.kt rename to core/src/commonMain/kotlin/event/channel/ChannelDeleteEvent.kt diff --git a/core/src/main/kotlin/event/channel/ChannelPinsUpdateEvent.kt b/core/src/commonMain/kotlin/event/channel/ChannelPinsUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/channel/ChannelPinsUpdateEvent.kt rename to core/src/commonMain/kotlin/event/channel/ChannelPinsUpdateEvent.kt diff --git a/core/src/main/kotlin/event/channel/ChannelUpdateEvent.kt b/core/src/commonMain/kotlin/event/channel/ChannelUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/channel/ChannelUpdateEvent.kt rename to core/src/commonMain/kotlin/event/channel/ChannelUpdateEvent.kt diff --git a/core/src/main/kotlin/event/channel/TypingStartEvent.kt b/core/src/commonMain/kotlin/event/channel/TypingStartEvent.kt similarity index 100% rename from core/src/main/kotlin/event/channel/TypingStartEvent.kt rename to core/src/commonMain/kotlin/event/channel/TypingStartEvent.kt diff --git a/core/src/main/kotlin/event/channel/data/ChannelPinsUpdateEventData.kt b/core/src/commonMain/kotlin/event/channel/data/ChannelPinsUpdateEventData.kt similarity index 100% rename from core/src/main/kotlin/event/channel/data/ChannelPinsUpdateEventData.kt rename to core/src/commonMain/kotlin/event/channel/data/ChannelPinsUpdateEventData.kt diff --git a/core/src/main/kotlin/event/channel/data/TypingStartEventData.kt b/core/src/commonMain/kotlin/event/channel/data/TypingStartEventData.kt similarity index 100% rename from core/src/main/kotlin/event/channel/data/TypingStartEventData.kt rename to core/src/commonMain/kotlin/event/channel/data/TypingStartEventData.kt diff --git a/core/src/main/kotlin/event/channel/thread/ThreadCreateEvent.kt b/core/src/commonMain/kotlin/event/channel/thread/ThreadCreateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/channel/thread/ThreadCreateEvent.kt rename to core/src/commonMain/kotlin/event/channel/thread/ThreadCreateEvent.kt diff --git a/core/src/main/kotlin/event/channel/thread/ThreadDeleteEvent.kt b/core/src/commonMain/kotlin/event/channel/thread/ThreadDeleteEvent.kt similarity index 100% rename from core/src/main/kotlin/event/channel/thread/ThreadDeleteEvent.kt rename to core/src/commonMain/kotlin/event/channel/thread/ThreadDeleteEvent.kt diff --git a/core/src/main/kotlin/event/channel/thread/ThreadListSyncEvent.kt b/core/src/commonMain/kotlin/event/channel/thread/ThreadListSyncEvent.kt similarity index 100% rename from core/src/main/kotlin/event/channel/thread/ThreadListSyncEvent.kt rename to core/src/commonMain/kotlin/event/channel/thread/ThreadListSyncEvent.kt diff --git a/core/src/main/kotlin/event/channel/thread/ThreadMemberUpdateEvent.kt b/core/src/commonMain/kotlin/event/channel/thread/ThreadMemberUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/channel/thread/ThreadMemberUpdateEvent.kt rename to core/src/commonMain/kotlin/event/channel/thread/ThreadMemberUpdateEvent.kt diff --git a/core/src/main/kotlin/event/channel/thread/ThreadMembersUpdateEvent.kt b/core/src/commonMain/kotlin/event/channel/thread/ThreadMembersUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/channel/thread/ThreadMembersUpdateEvent.kt rename to core/src/commonMain/kotlin/event/channel/thread/ThreadMembersUpdateEvent.kt diff --git a/core/src/main/kotlin/event/channel/thread/ThreadUpdateEvent.kt b/core/src/commonMain/kotlin/event/channel/thread/ThreadUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/channel/thread/ThreadUpdateEvent.kt rename to core/src/commonMain/kotlin/event/channel/thread/ThreadUpdateEvent.kt diff --git a/core/src/main/kotlin/event/gateway/Events.kt b/core/src/commonMain/kotlin/event/gateway/Events.kt similarity index 100% rename from core/src/main/kotlin/event/gateway/Events.kt rename to core/src/commonMain/kotlin/event/gateway/Events.kt diff --git a/core/src/main/kotlin/event/guild/BanAddEvent.kt b/core/src/commonMain/kotlin/event/guild/BanAddEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/BanAddEvent.kt rename to core/src/commonMain/kotlin/event/guild/BanAddEvent.kt diff --git a/core/src/main/kotlin/event/guild/BanRemoveEvent.kt b/core/src/commonMain/kotlin/event/guild/BanRemoveEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/BanRemoveEvent.kt rename to core/src/commonMain/kotlin/event/guild/BanRemoveEvent.kt diff --git a/core/src/main/kotlin/event/guild/EmojisUpdateEvent.kt b/core/src/commonMain/kotlin/event/guild/EmojisUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/EmojisUpdateEvent.kt rename to core/src/commonMain/kotlin/event/guild/EmojisUpdateEvent.kt diff --git a/core/src/main/kotlin/event/guild/GuildAuditLogEntryCreateEvent.kt b/core/src/commonMain/kotlin/event/guild/GuildAuditLogEntryCreateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/GuildAuditLogEntryCreateEvent.kt rename to core/src/commonMain/kotlin/event/guild/GuildAuditLogEntryCreateEvent.kt diff --git a/core/src/main/kotlin/event/guild/GuildCreateEvent.kt b/core/src/commonMain/kotlin/event/guild/GuildCreateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/GuildCreateEvent.kt rename to core/src/commonMain/kotlin/event/guild/GuildCreateEvent.kt diff --git a/core/src/main/kotlin/event/guild/GuildDeleteEvent.kt b/core/src/commonMain/kotlin/event/guild/GuildDeleteEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/GuildDeleteEvent.kt rename to core/src/commonMain/kotlin/event/guild/GuildDeleteEvent.kt diff --git a/core/src/main/kotlin/event/guild/GuildScheduledEventCreateEvent.kt b/core/src/commonMain/kotlin/event/guild/GuildScheduledEventCreateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/GuildScheduledEventCreateEvent.kt rename to core/src/commonMain/kotlin/event/guild/GuildScheduledEventCreateEvent.kt diff --git a/core/src/main/kotlin/event/guild/GuildScheduledEventDeleteEvent.kt b/core/src/commonMain/kotlin/event/guild/GuildScheduledEventDeleteEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/GuildScheduledEventDeleteEvent.kt rename to core/src/commonMain/kotlin/event/guild/GuildScheduledEventDeleteEvent.kt diff --git a/core/src/main/kotlin/event/guild/GuildScheduledEventEvent.kt b/core/src/commonMain/kotlin/event/guild/GuildScheduledEventEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/GuildScheduledEventEvent.kt rename to core/src/commonMain/kotlin/event/guild/GuildScheduledEventEvent.kt diff --git a/core/src/main/kotlin/event/guild/GuildScheduledEventUpdateEvent.kt b/core/src/commonMain/kotlin/event/guild/GuildScheduledEventUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/GuildScheduledEventUpdateEvent.kt rename to core/src/commonMain/kotlin/event/guild/GuildScheduledEventUpdateEvent.kt diff --git a/core/src/main/kotlin/event/guild/GuildScheduledEventUserEvent.kt b/core/src/commonMain/kotlin/event/guild/GuildScheduledEventUserEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/GuildScheduledEventUserEvent.kt rename to core/src/commonMain/kotlin/event/guild/GuildScheduledEventUserEvent.kt diff --git a/core/src/main/kotlin/event/guild/GuildUpdateEvent.kt b/core/src/commonMain/kotlin/event/guild/GuildUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/GuildUpdateEvent.kt rename to core/src/commonMain/kotlin/event/guild/GuildUpdateEvent.kt diff --git a/core/src/main/kotlin/event/guild/IntegrationCreateEvent.kt b/core/src/commonMain/kotlin/event/guild/IntegrationCreateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/IntegrationCreateEvent.kt rename to core/src/commonMain/kotlin/event/guild/IntegrationCreateEvent.kt diff --git a/core/src/main/kotlin/event/guild/IntegrationDeleteEvent.kt b/core/src/commonMain/kotlin/event/guild/IntegrationDeleteEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/IntegrationDeleteEvent.kt rename to core/src/commonMain/kotlin/event/guild/IntegrationDeleteEvent.kt diff --git a/core/src/main/kotlin/event/guild/IntegrationUpdateEvent.kt b/core/src/commonMain/kotlin/event/guild/IntegrationUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/IntegrationUpdateEvent.kt rename to core/src/commonMain/kotlin/event/guild/IntegrationUpdateEvent.kt diff --git a/core/src/main/kotlin/event/guild/IntegrationsUpdateEvent.kt b/core/src/commonMain/kotlin/event/guild/IntegrationsUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/IntegrationsUpdateEvent.kt rename to core/src/commonMain/kotlin/event/guild/IntegrationsUpdateEvent.kt diff --git a/core/src/main/kotlin/event/guild/InviteCreateEvent.kt b/core/src/commonMain/kotlin/event/guild/InviteCreateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/InviteCreateEvent.kt rename to core/src/commonMain/kotlin/event/guild/InviteCreateEvent.kt diff --git a/core/src/main/kotlin/event/guild/InviteDeleteEvent.kt b/core/src/commonMain/kotlin/event/guild/InviteDeleteEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/InviteDeleteEvent.kt rename to core/src/commonMain/kotlin/event/guild/InviteDeleteEvent.kt diff --git a/core/src/main/kotlin/event/guild/MemberJoinEvent.kt b/core/src/commonMain/kotlin/event/guild/MemberJoinEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/MemberJoinEvent.kt rename to core/src/commonMain/kotlin/event/guild/MemberJoinEvent.kt diff --git a/core/src/main/kotlin/event/guild/MemberLeaveEvent.kt b/core/src/commonMain/kotlin/event/guild/MemberLeaveEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/MemberLeaveEvent.kt rename to core/src/commonMain/kotlin/event/guild/MemberLeaveEvent.kt diff --git a/core/src/main/kotlin/event/guild/MemberUpdateEvent.kt b/core/src/commonMain/kotlin/event/guild/MemberUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/MemberUpdateEvent.kt rename to core/src/commonMain/kotlin/event/guild/MemberUpdateEvent.kt diff --git a/core/src/main/kotlin/event/guild/MembersChunkEvent.kt b/core/src/commonMain/kotlin/event/guild/MembersChunkEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/MembersChunkEvent.kt rename to core/src/commonMain/kotlin/event/guild/MembersChunkEvent.kt diff --git a/core/src/main/kotlin/event/guild/VoiceServerUpdateEvent.kt b/core/src/commonMain/kotlin/event/guild/VoiceServerUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/VoiceServerUpdateEvent.kt rename to core/src/commonMain/kotlin/event/guild/VoiceServerUpdateEvent.kt diff --git a/core/src/main/kotlin/event/guild/WebhookUpdateEvent.kt b/core/src/commonMain/kotlin/event/guild/WebhookUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/guild/WebhookUpdateEvent.kt rename to core/src/commonMain/kotlin/event/guild/WebhookUpdateEvent.kt diff --git a/core/src/main/kotlin/event/interaction/ApplicationCommandCreate.kt b/core/src/commonMain/kotlin/event/interaction/ApplicationCommandCreate.kt similarity index 100% rename from core/src/main/kotlin/event/interaction/ApplicationCommandCreate.kt rename to core/src/commonMain/kotlin/event/interaction/ApplicationCommandCreate.kt diff --git a/core/src/main/kotlin/event/interaction/ApplicationCommandDelete.kt b/core/src/commonMain/kotlin/event/interaction/ApplicationCommandDelete.kt similarity index 100% rename from core/src/main/kotlin/event/interaction/ApplicationCommandDelete.kt rename to core/src/commonMain/kotlin/event/interaction/ApplicationCommandDelete.kt diff --git a/core/src/main/kotlin/event/interaction/ApplicationCommandInteractionCreate.kt b/core/src/commonMain/kotlin/event/interaction/ApplicationCommandInteractionCreate.kt similarity index 100% rename from core/src/main/kotlin/event/interaction/ApplicationCommandInteractionCreate.kt rename to core/src/commonMain/kotlin/event/interaction/ApplicationCommandInteractionCreate.kt diff --git a/core/src/main/kotlin/event/interaction/ApplicationCommandPermissionsUpdateEvent.kt b/core/src/commonMain/kotlin/event/interaction/ApplicationCommandPermissionsUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/interaction/ApplicationCommandPermissionsUpdateEvent.kt rename to core/src/commonMain/kotlin/event/interaction/ApplicationCommandPermissionsUpdateEvent.kt diff --git a/core/src/main/kotlin/event/interaction/ApplicationCommandUpdate.kt b/core/src/commonMain/kotlin/event/interaction/ApplicationCommandUpdate.kt similarity index 100% rename from core/src/main/kotlin/event/interaction/ApplicationCommandUpdate.kt rename to core/src/commonMain/kotlin/event/interaction/ApplicationCommandUpdate.kt diff --git a/core/src/main/kotlin/event/interaction/AutoCompleteInteractionCreate.kt b/core/src/commonMain/kotlin/event/interaction/AutoCompleteInteractionCreate.kt similarity index 100% rename from core/src/main/kotlin/event/interaction/AutoCompleteInteractionCreate.kt rename to core/src/commonMain/kotlin/event/interaction/AutoCompleteInteractionCreate.kt diff --git a/core/src/main/kotlin/event/interaction/ComponentInteractionCreate.kt b/core/src/commonMain/kotlin/event/interaction/ComponentInteractionCreate.kt similarity index 100% rename from core/src/main/kotlin/event/interaction/ComponentInteractionCreate.kt rename to core/src/commonMain/kotlin/event/interaction/ComponentInteractionCreate.kt diff --git a/core/src/main/kotlin/event/interaction/InteractionCreate.kt b/core/src/commonMain/kotlin/event/interaction/InteractionCreate.kt similarity index 100% rename from core/src/main/kotlin/event/interaction/InteractionCreate.kt rename to core/src/commonMain/kotlin/event/interaction/InteractionCreate.kt diff --git a/core/src/main/kotlin/event/interaction/ModalSubmitInteractionCreate.kt b/core/src/commonMain/kotlin/event/interaction/ModalSubmitInteractionCreate.kt similarity index 100% rename from core/src/main/kotlin/event/interaction/ModalSubmitInteractionCreate.kt rename to core/src/commonMain/kotlin/event/interaction/ModalSubmitInteractionCreate.kt diff --git a/core/src/main/kotlin/event/message/MessageBulkDeleteEvent.kt b/core/src/commonMain/kotlin/event/message/MessageBulkDeleteEvent.kt similarity index 100% rename from core/src/main/kotlin/event/message/MessageBulkDeleteEvent.kt rename to core/src/commonMain/kotlin/event/message/MessageBulkDeleteEvent.kt diff --git a/core/src/main/kotlin/event/message/MessageCreateEvent.kt b/core/src/commonMain/kotlin/event/message/MessageCreateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/message/MessageCreateEvent.kt rename to core/src/commonMain/kotlin/event/message/MessageCreateEvent.kt diff --git a/core/src/main/kotlin/event/message/MessageDeleteEvent.kt b/core/src/commonMain/kotlin/event/message/MessageDeleteEvent.kt similarity index 100% rename from core/src/main/kotlin/event/message/MessageDeleteEvent.kt rename to core/src/commonMain/kotlin/event/message/MessageDeleteEvent.kt diff --git a/core/src/main/kotlin/event/message/MessageUpdateEvent.kt b/core/src/commonMain/kotlin/event/message/MessageUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/message/MessageUpdateEvent.kt rename to core/src/commonMain/kotlin/event/message/MessageUpdateEvent.kt diff --git a/core/src/main/kotlin/event/message/ReactionAddEvent.kt b/core/src/commonMain/kotlin/event/message/ReactionAddEvent.kt similarity index 100% rename from core/src/main/kotlin/event/message/ReactionAddEvent.kt rename to core/src/commonMain/kotlin/event/message/ReactionAddEvent.kt diff --git a/core/src/main/kotlin/event/message/ReactionRemoveAllEvent.kt b/core/src/commonMain/kotlin/event/message/ReactionRemoveAllEvent.kt similarity index 100% rename from core/src/main/kotlin/event/message/ReactionRemoveAllEvent.kt rename to core/src/commonMain/kotlin/event/message/ReactionRemoveAllEvent.kt diff --git a/core/src/main/kotlin/event/message/ReactionRemoveEmojiEvent.kt b/core/src/commonMain/kotlin/event/message/ReactionRemoveEmojiEvent.kt similarity index 100% rename from core/src/main/kotlin/event/message/ReactionRemoveEmojiEvent.kt rename to core/src/commonMain/kotlin/event/message/ReactionRemoveEmojiEvent.kt diff --git a/core/src/main/kotlin/event/message/ReactionRemoveEvent.kt b/core/src/commonMain/kotlin/event/message/ReactionRemoveEvent.kt similarity index 100% rename from core/src/main/kotlin/event/message/ReactionRemoveEvent.kt rename to core/src/commonMain/kotlin/event/message/ReactionRemoveEvent.kt diff --git a/core/src/main/kotlin/event/role/RoleCreateEvent.kt b/core/src/commonMain/kotlin/event/role/RoleCreateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/role/RoleCreateEvent.kt rename to core/src/commonMain/kotlin/event/role/RoleCreateEvent.kt diff --git a/core/src/main/kotlin/event/role/RoleDeleteEvent.kt b/core/src/commonMain/kotlin/event/role/RoleDeleteEvent.kt similarity index 100% rename from core/src/main/kotlin/event/role/RoleDeleteEvent.kt rename to core/src/commonMain/kotlin/event/role/RoleDeleteEvent.kt diff --git a/core/src/main/kotlin/event/role/RoleUpdateEvent.kt b/core/src/commonMain/kotlin/event/role/RoleUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/role/RoleUpdateEvent.kt rename to core/src/commonMain/kotlin/event/role/RoleUpdateEvent.kt diff --git a/core/src/main/kotlin/event/user/PresenceUpdateEvent.kt b/core/src/commonMain/kotlin/event/user/PresenceUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/user/PresenceUpdateEvent.kt rename to core/src/commonMain/kotlin/event/user/PresenceUpdateEvent.kt diff --git a/core/src/main/kotlin/event/user/UserUpdateEvent.kt b/core/src/commonMain/kotlin/event/user/UserUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/user/UserUpdateEvent.kt rename to core/src/commonMain/kotlin/event/user/UserUpdateEvent.kt diff --git a/core/src/main/kotlin/event/user/VoiceStateUpdateEvent.kt b/core/src/commonMain/kotlin/event/user/VoiceStateUpdateEvent.kt similarity index 100% rename from core/src/main/kotlin/event/user/VoiceStateUpdateEvent.kt rename to core/src/commonMain/kotlin/event/user/VoiceStateUpdateEvent.kt diff --git a/core/src/main/kotlin/exception/EntityNotFoundException.kt b/core/src/commonMain/kotlin/exception/EntityNotFoundException.kt similarity index 100% rename from core/src/main/kotlin/exception/EntityNotFoundException.kt rename to core/src/commonMain/kotlin/exception/EntityNotFoundException.kt diff --git a/core/src/main/kotlin/exception/GatewayNotFoundException.kt b/core/src/commonMain/kotlin/exception/GatewayNotFoundException.kt similarity index 100% rename from core/src/main/kotlin/exception/GatewayNotFoundException.kt rename to core/src/commonMain/kotlin/exception/GatewayNotFoundException.kt diff --git a/core/src/main/kotlin/exception/KordInitializationException.kt b/core/src/commonMain/kotlin/exception/KordInitializationException.kt similarity index 100% rename from core/src/main/kotlin/exception/KordInitializationException.kt rename to core/src/commonMain/kotlin/exception/KordInitializationException.kt diff --git a/core/src/main/kotlin/gateway/DefaultMasterGateway.kt b/core/src/commonMain/kotlin/gateway/DefaultMasterGateway.kt similarity index 100% rename from core/src/main/kotlin/gateway/DefaultMasterGateway.kt rename to core/src/commonMain/kotlin/gateway/DefaultMasterGateway.kt diff --git a/core/src/main/kotlin/gateway/MasterGateway.kt b/core/src/commonMain/kotlin/gateway/MasterGateway.kt similarity index 100% rename from core/src/main/kotlin/gateway/MasterGateway.kt rename to core/src/commonMain/kotlin/gateway/MasterGateway.kt diff --git a/core/src/main/kotlin/gateway/handler/AutoModerationEventHandler.kt b/core/src/commonMain/kotlin/gateway/handler/AutoModerationEventHandler.kt similarity index 100% rename from core/src/main/kotlin/gateway/handler/AutoModerationEventHandler.kt rename to core/src/commonMain/kotlin/gateway/handler/AutoModerationEventHandler.kt diff --git a/core/src/main/kotlin/gateway/handler/BaseGatewayEventHandler.kt b/core/src/commonMain/kotlin/gateway/handler/BaseGatewayEventHandler.kt similarity index 100% rename from core/src/main/kotlin/gateway/handler/BaseGatewayEventHandler.kt rename to core/src/commonMain/kotlin/gateway/handler/BaseGatewayEventHandler.kt diff --git a/core/src/main/kotlin/gateway/handler/ChannelEventHandler.kt b/core/src/commonMain/kotlin/gateway/handler/ChannelEventHandler.kt similarity index 100% rename from core/src/main/kotlin/gateway/handler/ChannelEventHandler.kt rename to core/src/commonMain/kotlin/gateway/handler/ChannelEventHandler.kt diff --git a/core/src/main/kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt b/core/src/commonMain/kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt similarity index 98% rename from core/src/main/kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt rename to core/src/commonMain/kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt index 6d80c82cb3af..3b000435df80 100644 --- a/core/src/main/kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt +++ b/core/src/commonMain/kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt @@ -60,7 +60,7 @@ public class DefaultGatewayEventInterceptor @KordPreview public constructor( } return null }.onFailure { - logger.error(it) + logger.error(it) {} }.getOrNull() } } diff --git a/core/src/main/kotlin/gateway/handler/GatewayEventInterceptor.kt b/core/src/commonMain/kotlin/gateway/handler/GatewayEventInterceptor.kt similarity index 100% rename from core/src/main/kotlin/gateway/handler/GatewayEventInterceptor.kt rename to core/src/commonMain/kotlin/gateway/handler/GatewayEventInterceptor.kt diff --git a/core/src/main/kotlin/gateway/handler/GuildEventHandler.kt b/core/src/commonMain/kotlin/gateway/handler/GuildEventHandler.kt similarity index 100% rename from core/src/main/kotlin/gateway/handler/GuildEventHandler.kt rename to core/src/commonMain/kotlin/gateway/handler/GuildEventHandler.kt diff --git a/core/src/main/kotlin/gateway/handler/InteractionEventHandler.kt b/core/src/commonMain/kotlin/gateway/handler/InteractionEventHandler.kt similarity index 100% rename from core/src/main/kotlin/gateway/handler/InteractionEventHandler.kt rename to core/src/commonMain/kotlin/gateway/handler/InteractionEventHandler.kt diff --git a/core/src/main/kotlin/gateway/handler/LifeCycleEventHandler.kt b/core/src/commonMain/kotlin/gateway/handler/LifeCycleEventHandler.kt similarity index 100% rename from core/src/main/kotlin/gateway/handler/LifeCycleEventHandler.kt rename to core/src/commonMain/kotlin/gateway/handler/LifeCycleEventHandler.kt diff --git a/core/src/main/kotlin/gateway/handler/MessageEventHandler.kt b/core/src/commonMain/kotlin/gateway/handler/MessageEventHandler.kt similarity index 100% rename from core/src/main/kotlin/gateway/handler/MessageEventHandler.kt rename to core/src/commonMain/kotlin/gateway/handler/MessageEventHandler.kt diff --git a/core/src/main/kotlin/gateway/handler/ThreadEventHandler.kt b/core/src/commonMain/kotlin/gateway/handler/ThreadEventHandler.kt similarity index 100% rename from core/src/main/kotlin/gateway/handler/ThreadEventHandler.kt rename to core/src/commonMain/kotlin/gateway/handler/ThreadEventHandler.kt diff --git a/core/src/main/kotlin/gateway/handler/UnknownEventHandler.kt b/core/src/commonMain/kotlin/gateway/handler/UnknownEventHandler.kt similarity index 100% rename from core/src/main/kotlin/gateway/handler/UnknownEventHandler.kt rename to core/src/commonMain/kotlin/gateway/handler/UnknownEventHandler.kt diff --git a/core/src/main/kotlin/gateway/handler/UserEventHandler.kt b/core/src/commonMain/kotlin/gateway/handler/UserEventHandler.kt similarity index 100% rename from core/src/main/kotlin/gateway/handler/UserEventHandler.kt rename to core/src/commonMain/kotlin/gateway/handler/UserEventHandler.kt diff --git a/core/src/main/kotlin/gateway/handler/VoiceEventHandler.kt b/core/src/commonMain/kotlin/gateway/handler/VoiceEventHandler.kt similarity index 100% rename from core/src/main/kotlin/gateway/handler/VoiceEventHandler.kt rename to core/src/commonMain/kotlin/gateway/handler/VoiceEventHandler.kt diff --git a/core/src/main/kotlin/gateway/handler/WebhookEventHandler.kt b/core/src/commonMain/kotlin/gateway/handler/WebhookEventHandler.kt similarity index 100% rename from core/src/main/kotlin/gateway/handler/WebhookEventHandler.kt rename to core/src/commonMain/kotlin/gateway/handler/WebhookEventHandler.kt diff --git a/core/src/main/kotlin/live/LiveGuild.kt b/core/src/commonMain/kotlin/live/LiveGuild.kt similarity index 100% rename from core/src/main/kotlin/live/LiveGuild.kt rename to core/src/commonMain/kotlin/live/LiveGuild.kt diff --git a/core/src/main/kotlin/live/LiveKordEntity.kt b/core/src/commonMain/kotlin/live/LiveKordEntity.kt similarity index 100% rename from core/src/main/kotlin/live/LiveKordEntity.kt rename to core/src/commonMain/kotlin/live/LiveKordEntity.kt diff --git a/core/src/main/kotlin/live/LiveMember.kt b/core/src/commonMain/kotlin/live/LiveMember.kt similarity index 100% rename from core/src/main/kotlin/live/LiveMember.kt rename to core/src/commonMain/kotlin/live/LiveMember.kt diff --git a/core/src/main/kotlin/live/LiveMessage.kt b/core/src/commonMain/kotlin/live/LiveMessage.kt similarity index 100% rename from core/src/main/kotlin/live/LiveMessage.kt rename to core/src/commonMain/kotlin/live/LiveMessage.kt diff --git a/core/src/main/kotlin/live/LiveRole.kt b/core/src/commonMain/kotlin/live/LiveRole.kt similarity index 100% rename from core/src/main/kotlin/live/LiveRole.kt rename to core/src/commonMain/kotlin/live/LiveRole.kt diff --git a/core/src/main/kotlin/live/LiveUser.kt b/core/src/commonMain/kotlin/live/LiveUser.kt similarity index 100% rename from core/src/main/kotlin/live/LiveUser.kt rename to core/src/commonMain/kotlin/live/LiveUser.kt diff --git a/core/src/main/kotlin/live/channel/LiveCategory.kt b/core/src/commonMain/kotlin/live/channel/LiveCategory.kt similarity index 100% rename from core/src/main/kotlin/live/channel/LiveCategory.kt rename to core/src/commonMain/kotlin/live/channel/LiveCategory.kt diff --git a/core/src/main/kotlin/live/channel/LiveChannel.kt b/core/src/commonMain/kotlin/live/channel/LiveChannel.kt similarity index 100% rename from core/src/main/kotlin/live/channel/LiveChannel.kt rename to core/src/commonMain/kotlin/live/channel/LiveChannel.kt diff --git a/core/src/main/kotlin/live/channel/LiveDmChannel.kt b/core/src/commonMain/kotlin/live/channel/LiveDmChannel.kt similarity index 100% rename from core/src/main/kotlin/live/channel/LiveDmChannel.kt rename to core/src/commonMain/kotlin/live/channel/LiveDmChannel.kt diff --git a/core/src/main/kotlin/live/channel/LiveGuildChannel.kt b/core/src/commonMain/kotlin/live/channel/LiveGuildChannel.kt similarity index 100% rename from core/src/main/kotlin/live/channel/LiveGuildChannel.kt rename to core/src/commonMain/kotlin/live/channel/LiveGuildChannel.kt diff --git a/core/src/main/kotlin/live/channel/LiveGuildMessageChannel.kt b/core/src/commonMain/kotlin/live/channel/LiveGuildMessageChannel.kt similarity index 100% rename from core/src/main/kotlin/live/channel/LiveGuildMessageChannel.kt rename to core/src/commonMain/kotlin/live/channel/LiveGuildMessageChannel.kt diff --git a/core/src/main/kotlin/live/channel/LiveVoiceChannel.kt b/core/src/commonMain/kotlin/live/channel/LiveVoiceChannel.kt similarity index 100% rename from core/src/main/kotlin/live/channel/LiveVoiceChannel.kt rename to core/src/commonMain/kotlin/live/channel/LiveVoiceChannel.kt diff --git a/core/src/main/kotlin/live/exception/LiveCancellationException.kt b/core/src/commonMain/kotlin/live/exception/LiveCancellationException.kt similarity index 79% rename from core/src/main/kotlin/live/exception/LiveCancellationException.kt rename to core/src/commonMain/kotlin/live/exception/LiveCancellationException.kt index 03ba7e5fed91..986a58ed7780 100644 --- a/core/src/main/kotlin/live/exception/LiveCancellationException.kt +++ b/core/src/commonMain/kotlin/live/exception/LiveCancellationException.kt @@ -1,7 +1,7 @@ package dev.kord.core.live.exception import dev.kord.core.event.Event -import java.util.concurrent.CancellationException +import kotlinx.coroutines.CancellationException public class LiveCancellationException(public val event: Event, message: String? = null) : CancellationException(message) diff --git a/core/src/main/kotlin/supplier/CacheEntitySupplier.kt b/core/src/commonMain/kotlin/supplier/CacheEntitySupplier.kt similarity index 100% rename from core/src/main/kotlin/supplier/CacheEntitySupplier.kt rename to core/src/commonMain/kotlin/supplier/CacheEntitySupplier.kt diff --git a/core/src/main/kotlin/supplier/EntitySupplier.kt b/core/src/commonMain/kotlin/supplier/EntitySupplier.kt similarity index 100% rename from core/src/main/kotlin/supplier/EntitySupplier.kt rename to core/src/commonMain/kotlin/supplier/EntitySupplier.kt diff --git a/core/src/main/kotlin/supplier/EntitySupplyStrategy.kt b/core/src/commonMain/kotlin/supplier/EntitySupplyStrategy.kt similarity index 100% rename from core/src/main/kotlin/supplier/EntitySupplyStrategy.kt rename to core/src/commonMain/kotlin/supplier/EntitySupplyStrategy.kt diff --git a/core/src/main/kotlin/supplier/FallbackEntitySupplier.kt b/core/src/commonMain/kotlin/supplier/FallbackEntitySupplier.kt similarity index 100% rename from core/src/main/kotlin/supplier/FallbackEntitySupplier.kt rename to core/src/commonMain/kotlin/supplier/FallbackEntitySupplier.kt diff --git a/core/src/main/kotlin/supplier/RestEntitySupplier.kt b/core/src/commonMain/kotlin/supplier/RestEntitySupplier.kt similarity index 100% rename from core/src/main/kotlin/supplier/RestEntitySupplier.kt rename to core/src/commonMain/kotlin/supplier/RestEntitySupplier.kt diff --git a/core/src/main/kotlin/supplier/StoreEntitySupplier.kt b/core/src/commonMain/kotlin/supplier/StoreEntitySupplier.kt similarity index 100% rename from core/src/main/kotlin/supplier/StoreEntitySupplier.kt rename to core/src/commonMain/kotlin/supplier/StoreEntitySupplier.kt diff --git a/core/src/jsMain/kotlin/dev/kord/core/builder/kord/KordBuilder.kt b/core/src/jsMain/kotlin/dev/kord/core/builder/kord/KordBuilder.kt new file mode 100644 index 000000000000..bf295b40f3a6 --- /dev/null +++ b/core/src/jsMain/kotlin/dev/kord/core/builder/kord/KordBuilder.kt @@ -0,0 +1,3 @@ +package dev.kord.core.builder.kord + +public actual class KordBuilder actual constructor(token: String) : KordBuilderBase(token) diff --git a/core/src/jvmMain/kotlin/dev/kord/core/builder/kord/KordBuilder.kt b/core/src/jvmMain/kotlin/dev/kord/core/builder/kord/KordBuilder.kt new file mode 100644 index 000000000000..c9a74b5c91b8 --- /dev/null +++ b/core/src/jvmMain/kotlin/dev/kord/core/builder/kord/KordBuilder.kt @@ -0,0 +1,26 @@ +package dev.kord.core.builder.kord + +import dev.kord.core.Kord +import dev.kord.gateway.Gateway +import kotlinx.coroutines.runBlocking +import kotlin.concurrent.thread + +public actual class KordBuilder actual constructor(token: String) : KordBuilderBase(token) { + /** + * Enable adding a [Runtime.addShutdownHook] to log out of the [Gateway] when the process is killed. + */ + public var enableShutdownHook: Boolean = true + + override suspend fun build(): Kord { + val kord = buildBase() + if (enableShutdownHook) { + Runtime.getRuntime().addShutdownHook(thread(false) { + runBlocking { + kord.gateway.detachAll() + } + }) + } + + return kord + } +} diff --git a/core/src/jvmMain/kotlin/dev/kord/core/cache/KordCacheBuilder.kt b/core/src/jvmMain/kotlin/dev/kord/core/cache/KordCacheBuilder.kt new file mode 100644 index 000000000000..eed914958f24 --- /dev/null +++ b/core/src/jvmMain/kotlin/dev/kord/core/cache/KordCacheBuilder.kt @@ -0,0 +1,17 @@ +@file:JvmName("KordCacheBuilderJvm") + +package dev.kord.core.cache + +import dev.kord.cache.api.DataEntryCache +import dev.kord.cache.map.MapLikeCollection +import dev.kord.cache.map.internal.MapEntryCache +import dev.kord.cache.map.lruLinkedHashMap + +/** + * A Generator creating [DataEntryCaches][DataEntryCache] with a maximum [size], removing items on last insertion. + * Shortcut for [lruLinkedHashMap]. + */ +@Suppress("UnusedReceiverParameter") // used for scoping +public fun KordCacheBuilder.lruCache(size: Int = 100): Generator = { cache, description -> + MapEntryCache(cache, description, MapLikeCollection.lruLinkedHashMap(size)) +} diff --git a/core/src/test/kotlin/KordTest.kt b/core/src/jvmTest/kotlin/KordTest.kt similarity index 100% rename from core/src/test/kotlin/KordTest.kt rename to core/src/jvmTest/kotlin/KordTest.kt diff --git a/core/src/test/kotlin/StrategyTest.kt b/core/src/jvmTest/kotlin/StrategyTest.kt similarity index 100% rename from core/src/test/kotlin/StrategyTest.kt rename to core/src/jvmTest/kotlin/StrategyTest.kt diff --git a/core/src/test/kotlin/Util.kt b/core/src/jvmTest/kotlin/Util.kt similarity index 100% rename from core/src/test/kotlin/Util.kt rename to core/src/jvmTest/kotlin/Util.kt diff --git a/core/src/test/kotlin/UtilKtTest.kt b/core/src/jvmTest/kotlin/UtilKtTest.kt similarity index 100% rename from core/src/test/kotlin/UtilKtTest.kt rename to core/src/jvmTest/kotlin/UtilKtTest.kt diff --git a/core/src/test/kotlin/behavior/GuildBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/GuildBehaviorTest.kt similarity index 100% rename from core/src/test/kotlin/behavior/GuildBehaviorTest.kt rename to core/src/jvmTest/kotlin/behavior/GuildBehaviorTest.kt diff --git a/core/src/test/kotlin/behavior/MemberBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/MemberBehaviorTest.kt similarity index 100% rename from core/src/test/kotlin/behavior/MemberBehaviorTest.kt rename to core/src/jvmTest/kotlin/behavior/MemberBehaviorTest.kt diff --git a/core/src/test/kotlin/behavior/MessageBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/MessageBehaviorTest.kt similarity index 100% rename from core/src/test/kotlin/behavior/MessageBehaviorTest.kt rename to core/src/jvmTest/kotlin/behavior/MessageBehaviorTest.kt diff --git a/core/src/test/kotlin/behavior/RoleBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/RoleBehaviorTest.kt similarity index 100% rename from core/src/test/kotlin/behavior/RoleBehaviorTest.kt rename to core/src/jvmTest/kotlin/behavior/RoleBehaviorTest.kt diff --git a/core/src/test/kotlin/behavior/UserBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/UserBehaviorTest.kt similarity index 100% rename from core/src/test/kotlin/behavior/UserBehaviorTest.kt rename to core/src/jvmTest/kotlin/behavior/UserBehaviorTest.kt diff --git a/core/src/test/kotlin/behavior/WebhookBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/WebhookBehaviorTest.kt similarity index 100% rename from core/src/test/kotlin/behavior/WebhookBehaviorTest.kt rename to core/src/jvmTest/kotlin/behavior/WebhookBehaviorTest.kt diff --git a/core/src/test/kotlin/behavior/channel/CategoryBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/channel/CategoryBehaviorTest.kt similarity index 100% rename from core/src/test/kotlin/behavior/channel/CategoryBehaviorTest.kt rename to core/src/jvmTest/kotlin/behavior/channel/CategoryBehaviorTest.kt diff --git a/core/src/test/kotlin/behavior/channel/ChannelBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/channel/ChannelBehaviorTest.kt similarity index 100% rename from core/src/test/kotlin/behavior/channel/ChannelBehaviorTest.kt rename to core/src/jvmTest/kotlin/behavior/channel/ChannelBehaviorTest.kt diff --git a/core/src/test/kotlin/behavior/channel/GuildChannelBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/channel/GuildChannelBehaviorTest.kt similarity index 100% rename from core/src/test/kotlin/behavior/channel/GuildChannelBehaviorTest.kt rename to core/src/jvmTest/kotlin/behavior/channel/GuildChannelBehaviorTest.kt diff --git a/core/src/test/kotlin/behavior/channel/GuildMessageChannelBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/channel/GuildMessageChannelBehaviorTest.kt similarity index 100% rename from core/src/test/kotlin/behavior/channel/GuildMessageChannelBehaviorTest.kt rename to core/src/jvmTest/kotlin/behavior/channel/GuildMessageChannelBehaviorTest.kt diff --git a/core/src/test/kotlin/behavior/channel/MessageChannelBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/channel/MessageChannelBehaviorTest.kt similarity index 100% rename from core/src/test/kotlin/behavior/channel/MessageChannelBehaviorTest.kt rename to core/src/jvmTest/kotlin/behavior/channel/MessageChannelBehaviorTest.kt diff --git a/core/src/test/kotlin/behavior/channel/NewsChannelBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/channel/NewsChannelBehaviorTest.kt similarity index 100% rename from core/src/test/kotlin/behavior/channel/NewsChannelBehaviorTest.kt rename to core/src/jvmTest/kotlin/behavior/channel/NewsChannelBehaviorTest.kt diff --git a/core/src/test/kotlin/behavior/channel/TextChannelBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/channel/TextChannelBehaviorTest.kt similarity index 100% rename from core/src/test/kotlin/behavior/channel/TextChannelBehaviorTest.kt rename to core/src/jvmTest/kotlin/behavior/channel/TextChannelBehaviorTest.kt diff --git a/core/src/test/kotlin/behavior/channel/VoiceChannelBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/channel/VoiceChannelBehaviorTest.kt similarity index 100% rename from core/src/test/kotlin/behavior/channel/VoiceChannelBehaviorTest.kt rename to core/src/jvmTest/kotlin/behavior/channel/VoiceChannelBehaviorTest.kt diff --git a/core/src/test/kotlin/cache/data/ComponentDataTest.kt b/core/src/jvmTest/kotlin/cache/data/ComponentDataTest.kt similarity index 100% rename from core/src/test/kotlin/cache/data/ComponentDataTest.kt rename to core/src/jvmTest/kotlin/cache/data/ComponentDataTest.kt diff --git a/core/src/test/kotlin/entity/ApplicationTest.kt b/core/src/jvmTest/kotlin/entity/ApplicationTest.kt similarity index 100% rename from core/src/test/kotlin/entity/ApplicationTest.kt rename to core/src/jvmTest/kotlin/entity/ApplicationTest.kt diff --git a/core/src/test/kotlin/entity/AttachmentTest.kt b/core/src/jvmTest/kotlin/entity/AttachmentTest.kt similarity index 100% rename from core/src/test/kotlin/entity/AttachmentTest.kt rename to core/src/jvmTest/kotlin/entity/AttachmentTest.kt diff --git a/core/src/test/kotlin/entity/GuildEmojiTest.kt b/core/src/jvmTest/kotlin/entity/GuildEmojiTest.kt similarity index 100% rename from core/src/test/kotlin/entity/GuildEmojiTest.kt rename to core/src/jvmTest/kotlin/entity/GuildEmojiTest.kt diff --git a/core/src/test/kotlin/entity/GuildTest.kt b/core/src/jvmTest/kotlin/entity/GuildTest.kt similarity index 100% rename from core/src/test/kotlin/entity/GuildTest.kt rename to core/src/jvmTest/kotlin/entity/GuildTest.kt diff --git a/core/src/test/kotlin/entity/IntegrationTest.kt b/core/src/jvmTest/kotlin/entity/IntegrationTest.kt similarity index 100% rename from core/src/test/kotlin/entity/IntegrationTest.kt rename to core/src/jvmTest/kotlin/entity/IntegrationTest.kt diff --git a/core/src/test/kotlin/entity/MemberTest.kt b/core/src/jvmTest/kotlin/entity/MemberTest.kt similarity index 100% rename from core/src/test/kotlin/entity/MemberTest.kt rename to core/src/jvmTest/kotlin/entity/MemberTest.kt diff --git a/core/src/test/kotlin/entity/MessageTest.kt b/core/src/jvmTest/kotlin/entity/MessageTest.kt similarity index 100% rename from core/src/test/kotlin/entity/MessageTest.kt rename to core/src/jvmTest/kotlin/entity/MessageTest.kt diff --git a/core/src/test/kotlin/entity/RoleTest.kt b/core/src/jvmTest/kotlin/entity/RoleTest.kt similarity index 100% rename from core/src/test/kotlin/entity/RoleTest.kt rename to core/src/jvmTest/kotlin/entity/RoleTest.kt diff --git a/core/src/test/kotlin/entity/UserTest.kt b/core/src/jvmTest/kotlin/entity/UserTest.kt similarity index 100% rename from core/src/test/kotlin/entity/UserTest.kt rename to core/src/jvmTest/kotlin/entity/UserTest.kt diff --git a/core/src/test/kotlin/entity/WebhookTest.kt b/core/src/jvmTest/kotlin/entity/WebhookTest.kt similarity index 100% rename from core/src/test/kotlin/entity/WebhookTest.kt rename to core/src/jvmTest/kotlin/entity/WebhookTest.kt diff --git a/core/src/test/kotlin/entity/channel/CategoryTest.kt b/core/src/jvmTest/kotlin/entity/channel/CategoryTest.kt similarity index 100% rename from core/src/test/kotlin/entity/channel/CategoryTest.kt rename to core/src/jvmTest/kotlin/entity/channel/CategoryTest.kt diff --git a/core/src/test/kotlin/entity/channel/DmChannelTest.kt b/core/src/jvmTest/kotlin/entity/channel/DmChannelTest.kt similarity index 100% rename from core/src/test/kotlin/entity/channel/DmChannelTest.kt rename to core/src/jvmTest/kotlin/entity/channel/DmChannelTest.kt diff --git a/core/src/test/kotlin/entity/channel/NewsChannelTest.kt b/core/src/jvmTest/kotlin/entity/channel/NewsChannelTest.kt similarity index 100% rename from core/src/test/kotlin/entity/channel/NewsChannelTest.kt rename to core/src/jvmTest/kotlin/entity/channel/NewsChannelTest.kt diff --git a/core/src/test/kotlin/entity/channel/TextChannelTest.kt b/core/src/jvmTest/kotlin/entity/channel/TextChannelTest.kt similarity index 100% rename from core/src/test/kotlin/entity/channel/TextChannelTest.kt rename to core/src/jvmTest/kotlin/entity/channel/TextChannelTest.kt diff --git a/core/src/test/kotlin/entity/channel/VoiceChannelTest.kt b/core/src/jvmTest/kotlin/entity/channel/VoiceChannelTest.kt similarity index 100% rename from core/src/test/kotlin/entity/channel/VoiceChannelTest.kt rename to core/src/jvmTest/kotlin/entity/channel/VoiceChannelTest.kt diff --git a/core/src/test/kotlin/equality/BehaviorEqualityTest.kt b/core/src/jvmTest/kotlin/equality/BehaviorEqualityTest.kt similarity index 100% rename from core/src/test/kotlin/equality/BehaviorEqualityTest.kt rename to core/src/jvmTest/kotlin/equality/BehaviorEqualityTest.kt diff --git a/core/src/test/kotlin/equality/ChannelEqualityTest.kt b/core/src/jvmTest/kotlin/equality/ChannelEqualityTest.kt similarity index 100% rename from core/src/test/kotlin/equality/ChannelEqualityTest.kt rename to core/src/jvmTest/kotlin/equality/ChannelEqualityTest.kt diff --git a/core/src/test/kotlin/equality/EntityEqualityTest.kt b/core/src/jvmTest/kotlin/equality/EntityEqualityTest.kt similarity index 100% rename from core/src/test/kotlin/equality/EntityEqualityTest.kt rename to core/src/jvmTest/kotlin/equality/EntityEqualityTest.kt diff --git a/core/src/test/kotlin/equality/GuildChannelEqualityTest.kt b/core/src/jvmTest/kotlin/equality/GuildChannelEqualityTest.kt similarity index 100% rename from core/src/test/kotlin/equality/GuildChannelEqualityTest.kt rename to core/src/jvmTest/kotlin/equality/GuildChannelEqualityTest.kt diff --git a/core/src/test/kotlin/equality/GuildEntityEqualityTest.kt b/core/src/jvmTest/kotlin/equality/GuildEntityEqualityTest.kt similarity index 100% rename from core/src/test/kotlin/equality/GuildEntityEqualityTest.kt rename to core/src/jvmTest/kotlin/equality/GuildEntityEqualityTest.kt diff --git a/core/src/test/kotlin/gateway/MasterGatewayTest.kt b/core/src/jvmTest/kotlin/gateway/MasterGatewayTest.kt similarity index 100% rename from core/src/test/kotlin/gateway/MasterGatewayTest.kt rename to core/src/jvmTest/kotlin/gateway/MasterGatewayTest.kt diff --git a/core/src/test/kotlin/interaction/CommandTypesTest.kt b/core/src/jvmTest/kotlin/interaction/CommandTypesTest.kt similarity index 100% rename from core/src/test/kotlin/interaction/CommandTypesTest.kt rename to core/src/jvmTest/kotlin/interaction/CommandTypesTest.kt diff --git a/core/src/test/kotlin/live/AbstractLiveEntityTest.kt b/core/src/jvmTest/kotlin/live/AbstractLiveEntityTest.kt similarity index 100% rename from core/src/test/kotlin/live/AbstractLiveEntityTest.kt rename to core/src/jvmTest/kotlin/live/AbstractLiveEntityTest.kt diff --git a/core/src/test/kotlin/live/LiveGuildTest.kt b/core/src/jvmTest/kotlin/live/LiveGuildTest.kt similarity index 100% rename from core/src/test/kotlin/live/LiveGuildTest.kt rename to core/src/jvmTest/kotlin/live/LiveGuildTest.kt diff --git a/core/src/test/kotlin/live/LiveKordEntityTest.kt b/core/src/jvmTest/kotlin/live/LiveKordEntityTest.kt similarity index 100% rename from core/src/test/kotlin/live/LiveKordEntityTest.kt rename to core/src/jvmTest/kotlin/live/LiveKordEntityTest.kt diff --git a/core/src/test/kotlin/live/LiveMemberTest.kt b/core/src/jvmTest/kotlin/live/LiveMemberTest.kt similarity index 100% rename from core/src/test/kotlin/live/LiveMemberTest.kt rename to core/src/jvmTest/kotlin/live/LiveMemberTest.kt diff --git a/core/src/test/kotlin/live/LiveMessageTest.kt b/core/src/jvmTest/kotlin/live/LiveMessageTest.kt similarity index 100% rename from core/src/test/kotlin/live/LiveMessageTest.kt rename to core/src/jvmTest/kotlin/live/LiveMessageTest.kt diff --git a/core/src/test/kotlin/live/LiveRoleTest.kt b/core/src/jvmTest/kotlin/live/LiveRoleTest.kt similarity index 100% rename from core/src/test/kotlin/live/LiveRoleTest.kt rename to core/src/jvmTest/kotlin/live/LiveRoleTest.kt diff --git a/core/src/test/kotlin/live/LiveUserTest.kt b/core/src/jvmTest/kotlin/live/LiveUserTest.kt similarity index 100% rename from core/src/test/kotlin/live/LiveUserTest.kt rename to core/src/jvmTest/kotlin/live/LiveUserTest.kt diff --git a/core/src/test/kotlin/live/channel/LiveCategoryTest.kt b/core/src/jvmTest/kotlin/live/channel/LiveCategoryTest.kt similarity index 100% rename from core/src/test/kotlin/live/channel/LiveCategoryTest.kt rename to core/src/jvmTest/kotlin/live/channel/LiveCategoryTest.kt diff --git a/core/src/test/kotlin/live/channel/LiveChannelTest.kt b/core/src/jvmTest/kotlin/live/channel/LiveChannelTest.kt similarity index 100% rename from core/src/test/kotlin/live/channel/LiveChannelTest.kt rename to core/src/jvmTest/kotlin/live/channel/LiveChannelTest.kt diff --git a/core/src/test/kotlin/live/channel/LiveDmChannelTest.kt b/core/src/jvmTest/kotlin/live/channel/LiveDmChannelTest.kt similarity index 100% rename from core/src/test/kotlin/live/channel/LiveDmChannelTest.kt rename to core/src/jvmTest/kotlin/live/channel/LiveDmChannelTest.kt diff --git a/core/src/test/kotlin/live/channel/LiveGuildChannelTest.kt b/core/src/jvmTest/kotlin/live/channel/LiveGuildChannelTest.kt similarity index 100% rename from core/src/test/kotlin/live/channel/LiveGuildChannelTest.kt rename to core/src/jvmTest/kotlin/live/channel/LiveGuildChannelTest.kt diff --git a/core/src/test/kotlin/live/channel/LiveGuildTextTest.kt b/core/src/jvmTest/kotlin/live/channel/LiveGuildTextTest.kt similarity index 100% rename from core/src/test/kotlin/live/channel/LiveGuildTextTest.kt rename to core/src/jvmTest/kotlin/live/channel/LiveGuildTextTest.kt diff --git a/core/src/test/kotlin/live/channel/LiveVoiceChannelTest.kt b/core/src/jvmTest/kotlin/live/channel/LiveVoiceChannelTest.kt similarity index 100% rename from core/src/test/kotlin/live/channel/LiveVoiceChannelTest.kt rename to core/src/jvmTest/kotlin/live/channel/LiveVoiceChannelTest.kt diff --git a/core/src/test/kotlin/performance/KordEventDropTest.kt b/core/src/jvmTest/kotlin/performance/KordEventDropTest.kt similarity index 100% rename from core/src/test/kotlin/performance/KordEventDropTest.kt rename to core/src/jvmTest/kotlin/performance/KordEventDropTest.kt diff --git a/core/src/test/kotlin/regression/CacheMissRegression.kt b/core/src/jvmTest/kotlin/regression/CacheMissRegression.kt similarity index 100% rename from core/src/test/kotlin/regression/CacheMissRegression.kt rename to core/src/jvmTest/kotlin/regression/CacheMissRegression.kt diff --git a/core/src/test/kotlin/regression/ReactionEmojiTest.kt b/core/src/jvmTest/kotlin/regression/ReactionEmojiTest.kt similarity index 100% rename from core/src/test/kotlin/regression/ReactionEmojiTest.kt rename to core/src/jvmTest/kotlin/regression/ReactionEmojiTest.kt diff --git a/core/src/test/kotlin/rest/RestTest.kt b/core/src/jvmTest/kotlin/rest/RestTest.kt similarity index 100% rename from core/src/test/kotlin/rest/RestTest.kt rename to core/src/jvmTest/kotlin/rest/RestTest.kt diff --git a/core/src/test/kotlin/supplier/CacheEntitySupplierTest.kt b/core/src/jvmTest/kotlin/supplier/CacheEntitySupplierTest.kt similarity index 100% rename from core/src/test/kotlin/supplier/CacheEntitySupplierTest.kt rename to core/src/jvmTest/kotlin/supplier/CacheEntitySupplierTest.kt diff --git a/core/src/test/resources/images/gitlab.png b/core/src/jvmTest/resources/images/gitlab.png similarity index 100% rename from core/src/test/resources/images/gitlab.png rename to core/src/jvmTest/resources/images/gitlab.png diff --git a/core/src/test/resources/images/kord.png b/core/src/jvmTest/resources/images/kord.png similarity index 100% rename from core/src/test/resources/images/kord.png rename to core/src/jvmTest/resources/images/kord.png diff --git a/core/src/test/resources/images/kord_icon.png b/core/src/jvmTest/resources/images/kord_icon.png similarity index 100% rename from core/src/test/resources/images/kord_icon.png rename to core/src/jvmTest/resources/images/kord_icon.png diff --git a/core/src/test/resources/interaction/groupsubcommand.json b/core/src/jvmTest/resources/interaction/groupsubcommand.json similarity index 100% rename from core/src/test/resources/interaction/groupsubcommand.json rename to core/src/jvmTest/resources/interaction/groupsubcommand.json diff --git a/core/src/test/resources/interaction/rootcommand.json b/core/src/jvmTest/resources/interaction/rootcommand.json similarity index 100% rename from core/src/test/resources/interaction/rootcommand.json rename to core/src/jvmTest/resources/interaction/rootcommand.json diff --git a/core/src/test/resources/interaction/subcommand.json b/core/src/jvmTest/resources/interaction/subcommand.json similarity index 100% rename from core/src/test/resources/interaction/subcommand.json rename to core/src/jvmTest/resources/interaction/subcommand.json diff --git a/core/src/test/resources/simplelogger.properties b/core/src/jvmTest/resources/simplelogger.properties similarity index 100% rename from core/src/test/resources/simplelogger.properties rename to core/src/jvmTest/resources/simplelogger.properties diff --git a/core/src/voice/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehavior.kt b/core/voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehavior.kt similarity index 87% rename from core/src/voice/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehavior.kt rename to core/voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehavior.kt index b5c920d7f0e0..948c979020a2 100644 --- a/core/src/voice/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehavior.kt +++ b/core/voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehavior.kt @@ -1,4 +1,4 @@ -@file:JvmName("VoiceBaseVoiceChannelBehavior") +@file:JvmName("BaseVoiceChannelBehaviorJvm") package dev.kord.core.behavior.channel @@ -17,7 +17,7 @@ import dev.kord.voice.VoiceConnectionBuilder * @return a [VoiceConnection] representing the connection to this [VoiceConnection]. */ @KordVoice -suspend fun BaseVoiceChannelBehavior.connect(builder: VoiceConnectionBuilder.() -> Unit): VoiceConnection { +public suspend fun BaseVoiceChannelBehavior.connect(builder: VoiceConnectionBuilder.() -> Unit): VoiceConnection { val voiceConnection = VoiceConnection( guild.gateway ?: GatewayNotFoundException.voiceConnectionGatewayNotFound(guildId), kord.selfId, From b97e1a4745f3a025fbd7e5ec98d19a21edb15f03 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 27 Feb 2023 13:13:04 +0100 Subject: [PATCH 020/136] Remove outdated samples plugin --- gateway/build.gradle.kts | 1 - rest/build.gradle.kts | 1 - 2 files changed, 2 deletions(-) diff --git a/gateway/build.gradle.kts b/gateway/build.gradle.kts index 5fc2d4b52892..5b71cfa416e1 100644 --- a/gateway/build.gradle.kts +++ b/gateway/build.gradle.kts @@ -2,7 +2,6 @@ plugins { `kord-multiplatform-module` `kord-publishing` `kotlinx-serialization` - `kord-sampled-multiplatform-module` } kotlin { diff --git a/rest/build.gradle.kts b/rest/build.gradle.kts index 3295d0076cc5..e38930ce2006 100644 --- a/rest/build.gradle.kts +++ b/rest/build.gradle.kts @@ -4,7 +4,6 @@ plugins { `kord-publishing` `kotlinx-atomicfu` `kotlinx-serialization` - `kord-sampled-multiplatform-module` alias(libs.plugins.buildconfig) } From 193f1275f906f5c089baf3c742c424bf1ea68ac2 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Tue, 28 Feb 2023 18:51:26 +0100 Subject: [PATCH 021/136] Add EncryptionMode.kt --- .../kotlin/dev/kord/voice/EncryptionMode.kt | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 voice/build/generated/ksp/main/kotlin/dev/kord/voice/EncryptionMode.kt diff --git a/voice/build/generated/ksp/main/kotlin/dev/kord/voice/EncryptionMode.kt b/voice/build/generated/ksp/main/kotlin/dev/kord/voice/EncryptionMode.kt new file mode 100644 index 000000000000..c977d45f5d20 --- /dev/null +++ b/voice/build/generated/ksp/main/kotlin/dev/kord/voice/EncryptionMode.kt @@ -0,0 +1,85 @@ +// THIS FILE IS AUTO-GENERATED BY KordEnumProcessor.kt, DO NOT EDIT! +@file:Suppress(names = arrayOf("RedundantVisibilityModifier", "IncorrectFormatting", + "ReplaceArrayOfWithLiteral", "SpellCheckingInspection", "GrazieInspection")) + +package dev.kord.voice + +import kotlin.Any +import kotlin.Boolean +import kotlin.Int +import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.String +import kotlin.Suppress +import kotlin.collections.List +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder + +/** + * See [EncryptionMode]s in the + * [Discord Developer Documentation](https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-encryption-modes). + */ +@Serializable(with = EncryptionMode.Serializer::class) +public sealed class EncryptionMode( + /** + * The raw value used by Discord. + */ + public val `value`: String, +) { + public final override fun equals(other: Any?): Boolean = this === other || + (other is EncryptionMode && this.value == other.value) + + public final override fun hashCode(): Int = value.hashCode() + + public final override fun toString(): String = + "EncryptionMode.${this::class.simpleName}(value=$value)" + + /** + * An unknown [EncryptionMode]. + * + * This is used as a fallback for [EncryptionMode]s that haven't been added to Kord yet. + */ + public class Unknown( + `value`: String, + ) : EncryptionMode(value) + + public object XSalsa20Poly1305 : EncryptionMode("xsalsa20_poly1305") + + public object XSalsa20Poly1305Suffix : EncryptionMode("xsalsa20_poly1305_suffix") + + public object XSalsa20Poly1305Lite : EncryptionMode("xsalsa20_poly1305_lite") + + internal object Serializer : KSerializer { + public override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("dev.kord.voice.EncryptionMode", PrimitiveKind.STRING) + + public override fun serialize(encoder: Encoder, `value`: EncryptionMode) = + encoder.encodeString(value.value) + + public override fun deserialize(decoder: Decoder) = + when (val value = decoder.decodeString()) { + "xsalsa20_poly1305" -> XSalsa20Poly1305 + "xsalsa20_poly1305_suffix" -> XSalsa20Poly1305Suffix + "xsalsa20_poly1305_lite" -> XSalsa20Poly1305Lite + else -> Unknown(value) + } + } + + public companion object { + /** + * A [List] of all known [EncryptionMode]s. + */ + public val entries: List by lazy(mode = PUBLICATION) { + listOf( + XSalsa20Poly1305, + XSalsa20Poly1305Suffix, + XSalsa20Poly1305Lite, + ) + } + + } +} From 00b9554eea0bbc1b14d0e9e98c0205aa66b8de4f Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Tue, 28 Feb 2023 18:51:35 +0100 Subject: [PATCH 022/136] Api dump --- gateway/api/gateway.api | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gateway/api/gateway.api b/gateway/api/gateway.api index a69e58ec7562..ce80685b8460 100644 --- a/gateway/api/gateway.api +++ b/gateway/api/gateway.api @@ -1918,6 +1918,10 @@ public final class dev/kord/gateway/UserUpdate : dev/kord/gateway/DispatchEvent public fun toString ()Ljava/lang/String; } +public final class dev/kord/gateway/UtilsKt { + public static final fun error (Lmu/KLogger;Ljava/lang/Throwable;)V +} + public final class dev/kord/gateway/VoiceServerUpdate : dev/kord/gateway/DispatchEvent { public fun (Ldev/kord/common/entity/DiscordVoiceServerUpdateData;Ljava/lang/Integer;)V public final fun component1 ()Ldev/kord/common/entity/DiscordVoiceServerUpdateData; From e1708a417389d436b9f74df893f354ba27bb9518 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Tue, 28 Feb 2023 18:52:11 +0100 Subject: [PATCH 023/136] Update SnowflakeTest --- common/src/commonTest/kotlin/entity/SnowflakeTest.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/src/commonTest/kotlin/entity/SnowflakeTest.kt b/common/src/commonTest/kotlin/entity/SnowflakeTest.kt index 19ca2fbc02ec..2ad05062d6b7 100644 --- a/common/src/commonTest/kotlin/entity/SnowflakeTest.kt +++ b/common/src/commonTest/kotlin/entity/SnowflakeTest.kt @@ -100,6 +100,7 @@ class SnowflakeTest { } @Test + @JsName("test12") fun `Snowflakes are compared correctly`() { // timestamp worker process increment // vvv vvv vvv vvv @@ -130,11 +131,12 @@ class SnowflakeTest { } @Test + @JsName("test13") fun `Snowflake's natural order works with SortedSets`() { val a = Snowflake(0b0_00000_00000_000000000000_u) val b = Snowflake(0b0_00000_00000_000000000001_u) val c = Snowflake(0b1_00000_00000_000000000000_u) - assertEquals(2, sortedSetOf(a, b).size) - assertEquals(2, sortedSetOf(a, c).size) + assertEquals(2, setOf(a, b).size) + assertEquals(2, setOf(a, c).size) } } From e21264d91e626dfa4ed36a41e1f970c5030cf795 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Wed, 1 Mar 2023 17:33:45 +0100 Subject: [PATCH 024/136] Final touches - Add test-kit - Add samples - Move HttpEngine to common --- build.gradle.kts | 7 ++- buildSrc/src/main/kotlin/Compiler.kt | 2 + .../kord-multiplatform-module.gradle.kts | 12 +++- common/api/common.api | 15 +++++ common/build.gradle.kts | 16 ++---- common/src/commonMain/kotlin/Platform.kt | 10 ++++ .../kotlin/annotation/Annotations.kt | 11 +++- .../src/commonMain/kotlin/http/HttpEngine.kt | 7 +++ common/src/commonTest/kotlin/file.kt | 4 +- .../serialization/InstantSerializersTests.kt | 4 +- .../jsMain/kotlin/dev/kord/common/Platform.kt | 13 +++++ .../kotlin/dev/kord/common/http/HttpEngine.kt | 5 ++ common/src/jsTest/kotlin/file.kt | 10 ---- common/src/jvmMain/kotlin/Color.kt | 3 +- common/src/jvmMain/kotlin/Platform.kt | 7 +++ common/src/jvmMain/kotlin/http/HttpEngine.kt | 6 ++ common/src/jvmTest/kotlin/file.kt | 4 -- core-voice/build.gradle.kts | 9 +++ .../channel/BaseVoiceChannelBehavior.kt | 0 core/build.gradle.kts | 50 ++++++----------- .../kotlin/builder/kord/KordBuilderUtil.kt | 2 +- .../kotlin/DefaultGatewayBuilder.kt | 1 + gateway/src/commonMain/kotlin/HttpEngine.kt | 5 -- gateway/src/commonTest/kotlin/Platform.kt | 5 -- .../kotlin/gateway/DefaultGatewayTest.kt | 1 + .../commonTest/kotlin/json/RegressionTests.kt | 1 - gateway/src/commonTest/kotlin/json/Util.kt | 3 + .../kotlin/dev/kord/gateway/HttpEngine.kt | 7 --- .../kotlin/dev/kord/gateway/Platform.kt | 11 ---- .../kotlin/dev/kord/gateway/HttpEngine.kt | 6 -- .../kotlin/dev/kord/gateway/Platform.kt | 6 -- gradle/libs.versions.toml | 4 +- rest/build.gradle.kts | 14 +---- .../commonMain/kotlin/request/HttpEngine.kt | 5 -- .../kotlin/request/KtorRequestHandler.kt | 1 + rest/src/commonTest/kotlin/json/Util.kt | 6 +- .../dev/kord/rest/request/HttpEngine.kt | 6 -- .../jsTest/kotlin/dev/kord/rest/json/Utils.kt | 23 -------- .../dev/kord/rest/request/HttpEngine.kt | 6 -- .../kotlin/dev/kord/rest/json/Utils.kt | 8 --- .../rest/request/StackTraceRecoveryTest.kt | 55 ------------------- samples/build.gradle.kts | 23 ++++++++ .../kotlin/dev/kord/core}/PingBot.kt | 4 +- .../kotlin/dev/kord/gateway/GatewayExample.kt | 50 +++++++++++++++++ .../kotlin/dev/kord/rest}/RestExample.kt | 0 settings.gradle.kts | 4 +- test-kit/build.gradle.kts | 29 ++++++++++ .../kotlin/dev/kord/test/Annotations.kt | 19 +++++++ .../kotlin/dev/kord/test/Platfrom.kt | 7 +++ .../jsMain/kotlin/dev/kord/test/IgnoreOnJs.kt | 5 ++ .../jsMain/kotlin/dev/kord/test/Platform.kt | 14 +++++ .../kotlin/dev/kord/test/Platform.node.kt | 22 ++++++++ .../kotlin/dev/kord/test/IgnoreOnJvm.kt | 5 ++ .../jvmMain/kotlin/dev/kord/test/Platform.kt | 9 +++ 54 files changed, 331 insertions(+), 231 deletions(-) create mode 100644 common/src/commonMain/kotlin/Platform.kt create mode 100644 common/src/commonMain/kotlin/http/HttpEngine.kt create mode 100644 common/src/jsMain/kotlin/dev/kord/common/Platform.kt create mode 100644 common/src/jsMain/kotlin/dev/kord/common/http/HttpEngine.kt delete mode 100644 common/src/jsTest/kotlin/file.kt create mode 100644 common/src/jvmMain/kotlin/Platform.kt create mode 100644 common/src/jvmMain/kotlin/http/HttpEngine.kt delete mode 100644 common/src/jvmTest/kotlin/file.kt create mode 100644 core-voice/build.gradle.kts rename {core/voice => core-voice}/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehavior.kt (100%) delete mode 100644 gateway/src/commonMain/kotlin/HttpEngine.kt delete mode 100644 gateway/src/commonTest/kotlin/Platform.kt delete mode 100644 gateway/src/jsMain/kotlin/dev/kord/gateway/HttpEngine.kt delete mode 100644 gateway/src/jsTest/kotlin/dev/kord/gateway/Platform.kt delete mode 100644 gateway/src/jvmMain/kotlin/dev/kord/gateway/HttpEngine.kt delete mode 100644 gateway/src/jvmTest/kotlin/dev/kord/gateway/Platform.kt delete mode 100644 rest/src/commonMain/kotlin/request/HttpEngine.kt delete mode 100644 rest/src/jsMain/kotlin/dev/kord/rest/request/HttpEngine.kt delete mode 100644 rest/src/jsTest/kotlin/dev/kord/rest/json/Utils.kt delete mode 100644 rest/src/jvmMain/kotlin/dev/kord/rest/request/HttpEngine.kt delete mode 100644 rest/src/jvmTest/kotlin/dev/kord/rest/json/Utils.kt delete mode 100644 rest/src/jvmTest/kotlin/dev/kord/rest/request/StackTraceRecoveryTest.kt create mode 100644 samples/build.gradle.kts rename {core/src/samples/kotlin => samples/src/commonMain/kotlin/dev/kord/core}/PingBot.kt (91%) create mode 100644 samples/src/commonMain/kotlin/dev/kord/gateway/GatewayExample.kt rename {rest/src/samples/kotlin => samples/src/commonMain/kotlin/dev/kord/rest}/RestExample.kt (100%) create mode 100644 test-kit/build.gradle.kts create mode 100644 test-kit/src/commonMain/kotlin/dev/kord/test/Annotations.kt create mode 100644 test-kit/src/commonMain/kotlin/dev/kord/test/Platfrom.kt create mode 100644 test-kit/src/jsMain/kotlin/dev/kord/test/IgnoreOnJs.kt create mode 100644 test-kit/src/jsMain/kotlin/dev/kord/test/Platform.kt create mode 100644 test-kit/src/jsMain/kotlin/dev/kord/test/Platform.node.kt create mode 100644 test-kit/src/jvmMain/kotlin/dev/kord/test/IgnoreOnJvm.kt create mode 100644 test-kit/src/jvmMain/kotlin/dev/kord/test/Platform.kt diff --git a/build.gradle.kts b/build.gradle.kts index a1cd46774e82..bfe1c7cfc034 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,8 +2,11 @@ plugins { org.jetbrains.dokka // for dokkaHtmlMultiModule task } -repositories { - mavenCentral() +allprojects { + repositories { + mavenCentral() + mavenLocal() + } } group = Library.group diff --git a/buildSrc/src/main/kotlin/Compiler.kt b/buildSrc/src/main/kotlin/Compiler.kt index 5f73b07d33d1..444bf1b2bc24 100644 --- a/buildSrc/src/main/kotlin/Compiler.kt +++ b/buildSrc/src/main/kotlin/Compiler.kt @@ -3,7 +3,9 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions object OptIns { const val time = "kotlin.time.ExperimentalTime" const val contracts = "kotlin.contracts.ExperimentalContracts" + const val coroutines = "kotlinx.coroutines.ExperimentalCoroutinesApi" + const val kordInternal = "dev.kord.common.annotation.KordInternal" const val kordPreview = "dev.kord.common.annotation.KordPreview" const val kordExperimental = "dev.kord.common.annotation.KordExperimental" const val kordVoice = "dev.kord.common.annotation.KordVoice" diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index 87ed0e463b0e..e43d1e3b6333 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -35,8 +35,9 @@ kotlin { all { languageSettings { if ("Test" in name) { - optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") + optIn(OptIns.coroutines) } + optIn(OptIns.kordInternal) listOf( OptIns.time, OptIns.contracts, @@ -55,6 +56,15 @@ kotlin { // mark ksp src dir kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") } + + targets.forEach { + val safeName = if(it.name == "metadata") "common" else it.name + findByName("${safeName}Test")?.apply { + dependencies { + implementation(project(":test-kit")) + } + } + } } } diff --git a/common/api/common.api b/common/api/common.api index 9646a2c79701..c470d1120255 100644 --- a/common/api/common.api +++ b/common/api/common.api @@ -164,6 +164,13 @@ public final class dev/kord/common/LocaleKt { public static final fun getKLocale (Ljava/util/Locale;)Ldev/kord/common/Locale; } +public final class dev/kord/common/Platform { + public static final field INSTANCE Ldev/kord/common/Platform; + public final fun getIS_BROWSER ()Z + public final fun getIS_JVM ()Z + public final fun getIS_NODE ()Z +} + public abstract interface annotation class dev/kord/common/annotation/DeprecatedSinceKord : java/lang/annotation/Annotation { public abstract fun version ()Ljava/lang/String; } @@ -174,6 +181,9 @@ public abstract interface annotation class dev/kord/common/annotation/KordDsl : public abstract interface annotation class dev/kord/common/annotation/KordExperimental : java/lang/annotation/Annotation { } +public abstract interface annotation class dev/kord/common/annotation/KordInternal : java/lang/annotation/Annotation { +} + public abstract interface annotation class dev/kord/common/annotation/KordPreview : java/lang/annotation/Annotation { } @@ -8504,6 +8514,11 @@ public abstract class dev/kord/common/exception/RequestException : java/lang/Exc public fun (Ljava/lang/Throwable;)V } +public final class dev/kord/common/http/HttpEngine : io/ktor/client/engine/HttpClientEngineFactory { + public static final field INSTANCE Ldev/kord/common/http/HttpEngine; + public fun create (Lkotlin/jvm/functions/Function1;)Lio/ktor/client/engine/HttpClientEngine; +} + public abstract class dev/kord/common/ratelimit/AbstractIntervalRateLimiter : dev/kord/common/ratelimit/IntervalRateLimiter { public synthetic fun (IJLkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun consume (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 2ef9c033c0ad..dd7227fe65a7 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -18,27 +18,21 @@ kotlin { api(libs.bignum) // Replacement for java.io api(libs.ktor.utils) + api(libs.ktor.client.core) compileOnly(projects.kspAnnotations) // The plugin should add this automatically, but it doesn't compileOnly(libs.kotlinx.atomicfu) } } - - commonTest { - dependencies { - implementation(libs.bundles.test.common) - } - } - jvmTest { + jvmMain { dependencies { - runtimeOnly(libs.bundles.test.runtime) - implementation(libs.kotlin.test.junit5) + api(libs.ktor.client.cio) } } - jsTest { + jsMain { dependencies { - implementation(libs.bundles.test.js) + api(libs.ktor.client.js) } } } diff --git a/common/src/commonMain/kotlin/Platform.kt b/common/src/commonMain/kotlin/Platform.kt new file mode 100644 index 000000000000..e69599df10c9 --- /dev/null +++ b/common/src/commonMain/kotlin/Platform.kt @@ -0,0 +1,10 @@ +package dev.kord.common + +import dev.kord.common.annotation.KordInternal + +@KordInternal +public expect object Platform { + public val IS_JVM: Boolean + public val IS_NODE: Boolean + public val IS_BROWSER: Boolean +} diff --git a/common/src/commonMain/kotlin/annotation/Annotations.kt b/common/src/commonMain/kotlin/annotation/Annotations.kt index 202fb4cb5edd..37684ff7b704 100644 --- a/common/src/commonMain/kotlin/annotation/Annotations.kt +++ b/common/src/commonMain/kotlin/annotation/Annotations.kt @@ -1,8 +1,8 @@ package dev.kord.common.annotation +import kotlin.RequiresOptIn.Level.ERROR import kotlin.RequiresOptIn.Level.WARNING import kotlin.annotation.AnnotationRetention.BINARY -import kotlin.annotation.AnnotationRetention.RUNTIME import kotlin.annotation.AnnotationTarget.* /** [DslMarker] for Kord DSLs. */ @@ -80,3 +80,12 @@ public annotation class KordUnsafe @Retention(BINARY) @Target(CLASS, ANNOTATION_CLASS, PROPERTY, CONSTRUCTOR, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER, TYPEALIAS) public annotation class DeprecatedSinceKord(val version: String) + +/** + * Marks an API for internal use only. + */ +@MustBeDocumented +@RequiresOptIn("This Api is intended for internal use only", level = ERROR) +@Retention(BINARY) +@Target(CLASS, PROPERTY, FUNCTION, TYPEALIAS) +public annotation class KordInternal diff --git a/common/src/commonMain/kotlin/http/HttpEngine.kt b/common/src/commonMain/kotlin/http/HttpEngine.kt new file mode 100644 index 000000000000..b723790693fe --- /dev/null +++ b/common/src/commonMain/kotlin/http/HttpEngine.kt @@ -0,0 +1,7 @@ +package dev.kord.common.http + +import dev.kord.common.annotation.KordInternal +import io.ktor.client.engine.* + +@KordInternal +public expect object HttpEngine : HttpClientEngineFactory diff --git a/common/src/commonTest/kotlin/file.kt b/common/src/commonTest/kotlin/file.kt index fc61460974ff..7f0b71174f99 100644 --- a/common/src/commonTest/kotlin/file.kt +++ b/common/src/commonTest/kotlin/file.kt @@ -1,3 +1,5 @@ package dev.kord.common -expect suspend fun readFile(prefix: String, name: String): String +import dev.kord.test.file +suspend fun readFile(prefix: String, name: String): String = + file("common", "json/$prefix/$name.json") diff --git a/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt b/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt index 84e080fcc791..c4184d549111 100644 --- a/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt +++ b/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt @@ -2,12 +2,12 @@ package serialization import dev.kord.common.serialization.InstantInEpochMillisecondsSerializer import dev.kord.common.serialization.InstantInEpochSecondsSerializer +import dev.kord.test.IgnoreOnJs import kotlinx.datetime.Instant import kotlinx.serialization.KSerializer import kotlinx.serialization.SerializationException import kotlinx.serialization.json.Json import kotlin.js.JsName -import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith @@ -70,7 +70,7 @@ abstract class InstantSerializerTest( } -@Ignore // currently can't pass +@IgnoreOnJs // currently can't pass class InstantInEpochMillisecondsSerializerTest : InstantSerializerTest( json = "796514689159", instant = Instant.fromEpochMilliseconds(796514689159), diff --git a/common/src/jsMain/kotlin/dev/kord/common/Platform.kt b/common/src/jsMain/kotlin/dev/kord/common/Platform.kt new file mode 100644 index 000000000000..75916fbeb457 --- /dev/null +++ b/common/src/jsMain/kotlin/dev/kord/common/Platform.kt @@ -0,0 +1,13 @@ +package dev.kord.common + +public actual object Platform { + public actual val IS_JVM: Boolean = false + public actual val IS_NODE: Boolean + get() = js( + "typeof process !== 'undefined' && process.versions != null && process.versions.node != null" + ) as Boolean + public actual val IS_BROWSER: Boolean + get() = js( + "typeof window !== 'undefined' && typeof window.document !== 'undefined' || typeof self !== 'undefined' && typeof self.location !== 'undefined'" + ) as Boolean +} diff --git a/common/src/jsMain/kotlin/dev/kord/common/http/HttpEngine.kt b/common/src/jsMain/kotlin/dev/kord/common/http/HttpEngine.kt new file mode 100644 index 000000000000..6b8553d499a7 --- /dev/null +++ b/common/src/jsMain/kotlin/dev/kord/common/http/HttpEngine.kt @@ -0,0 +1,5 @@ +package dev.kord.common.http + +import io.ktor.client.engine.js.* + +public actual typealias HttpEngine = Js diff --git a/common/src/jsTest/kotlin/file.kt b/common/src/jsTest/kotlin/file.kt deleted file mode 100644 index 4ea496e94b85..000000000000 --- a/common/src/jsTest/kotlin/file.kt +++ /dev/null @@ -1,10 +0,0 @@ -package dev.kord.common - -import js.core.get -import node.buffer.BufferEncoding -import node.process.process -import node.fs.readFile as nodeReadFile - -actual suspend fun readFile(prefix: String, name: String): String = - nodeReadFile("${process.env["PROJECT_ROOT"]}/common/src/commonTest/resources/json/$prefix/$name.json") - .toString(BufferEncoding.utf8) diff --git a/common/src/jvmMain/kotlin/Color.kt b/common/src/jvmMain/kotlin/Color.kt index 735306d43732..be091030b16d 100644 --- a/common/src/jvmMain/kotlin/Color.kt +++ b/common/src/jvmMain/kotlin/Color.kt @@ -1,5 +1,4 @@ -@file:JvmName("ColorJvm" -) +@file:JvmName("ColorJvm") package dev.kord.common import java.awt.Color as AwtColor diff --git a/common/src/jvmMain/kotlin/Platform.kt b/common/src/jvmMain/kotlin/Platform.kt new file mode 100644 index 000000000000..20ce8f8b9bd3 --- /dev/null +++ b/common/src/jvmMain/kotlin/Platform.kt @@ -0,0 +1,7 @@ +package dev.kord.common + +public actual object Platform { + public actual val IS_JVM: Boolean = true + public actual val IS_NODE: Boolean = false + public actual val IS_BROWSER: Boolean = false +} diff --git a/common/src/jvmMain/kotlin/http/HttpEngine.kt b/common/src/jvmMain/kotlin/http/HttpEngine.kt new file mode 100644 index 000000000000..f3877cb3840a --- /dev/null +++ b/common/src/jvmMain/kotlin/http/HttpEngine.kt @@ -0,0 +1,6 @@ +package dev.kord.common.http + +import io.ktor.client.engine.* +import io.ktor.client.engine.cio.* + +public actual object HttpEngine : HttpClientEngineFactory by CIO diff --git a/common/src/jvmTest/kotlin/file.kt b/common/src/jvmTest/kotlin/file.kt deleted file mode 100644 index 3bee4f5efbf6..000000000000 --- a/common/src/jvmTest/kotlin/file.kt +++ /dev/null @@ -1,4 +0,0 @@ -package dev.kord.common - -actual suspend inline fun readFile(prefix: String, name: String): String = - ClassLoader.getSystemResource("json/$prefix/$name.json")!!.readText() diff --git a/core-voice/build.gradle.kts b/core-voice/build.gradle.kts new file mode 100644 index 000000000000..356fca4c82b8 --- /dev/null +++ b/core-voice/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + `kord-module` + `kord-publishing` +} + +dependencies { + api(projects.core) + api(projects.voice) +} diff --git a/core/voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehavior.kt b/core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehavior.kt similarity index 100% rename from core/voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehavior.kt rename to core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehavior.kt diff --git a/core/build.gradle.kts b/core/build.gradle.kts index acddb513a9aa..f5153b8b177b 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,40 +1,26 @@ plugins { - java - `kord-module` - `kord-sampled-module` + `kord-multiplatform-module` `kord-publishing` } -val voice: SourceSet by sourceSets.creating -val voiceApi: Configuration by configurations.getting +kotlin { + sourceSets { + commonMain { + dependencies { + compileOnly(projects.kspAnnotations) + api(projects.common) + api(projects.rest) + api(projects.gateway) -configurations { - getByName("voiceImplementation") { - extendsFrom(implementation.get()) - } -} - -dependencies { - api(projects.common) - api(projects.rest) - api(projects.gateway) - voiceApi(projects.core) - voiceApi(projects.voice) - - api(libs.kord.cache.api) - api(libs.kord.cache.map) - - samplesImplementation(libs.slf4j.simple) - - testImplementation(libs.bundles.test.implementation) - testRuntimeOnly(libs.bundles.test.runtime) -} + api(libs.kord.cache.api) + api(libs.kord.cache.map) + } + } -java { - registerFeature("voice") { - usingSourceSet(voice) - withJavadocJar() - withSourcesJar() - capability("dev.kord", "core-voice", version as String) + jvmTest { + dependencies { + implementation(libs.mockk) + } + } } } diff --git a/core/src/commonMain/kotlin/builder/kord/KordBuilderUtil.kt b/core/src/commonMain/kotlin/builder/kord/KordBuilderUtil.kt index e8c393a872e0..c82addcef11e 100644 --- a/core/src/commonMain/kotlin/builder/kord/KordBuilderUtil.kt +++ b/core/src/commonMain/kotlin/builder/kord/KordBuilderUtil.kt @@ -1,7 +1,7 @@ package dev.kord.core.builder.kord import dev.kord.common.entity.Snowflake -import dev.kord.rest.request.HttpEngine +import dev.kord.common.http.HttpEngine import io.ktor.client.* import io.ktor.client.plugins.contentnegotiation.* import io.ktor.client.plugins.websocket.* diff --git a/gateway/src/commonMain/kotlin/DefaultGatewayBuilder.kt b/gateway/src/commonMain/kotlin/DefaultGatewayBuilder.kt index 624f5ca4242c..bc3d45fa351d 100644 --- a/gateway/src/commonMain/kotlin/DefaultGatewayBuilder.kt +++ b/gateway/src/commonMain/kotlin/DefaultGatewayBuilder.kt @@ -1,6 +1,7 @@ package dev.kord.gateway import dev.kord.common.KordConfiguration +import dev.kord.common.http.HttpEngine import dev.kord.common.ratelimit.IntervalRateLimiter import dev.kord.common.ratelimit.RateLimiter import dev.kord.gateway.ratelimit.IdentifyRateLimiter diff --git a/gateway/src/commonMain/kotlin/HttpEngine.kt b/gateway/src/commonMain/kotlin/HttpEngine.kt deleted file mode 100644 index 8f5f4e200dd1..000000000000 --- a/gateway/src/commonMain/kotlin/HttpEngine.kt +++ /dev/null @@ -1,5 +0,0 @@ -package dev.kord.gateway - -import io.ktor.client.engine.* - -internal expect object HttpEngine : HttpClientEngineFactory diff --git a/gateway/src/commonTest/kotlin/Platform.kt b/gateway/src/commonTest/kotlin/Platform.kt deleted file mode 100644 index 68fd8dad98ee..000000000000 --- a/gateway/src/commonTest/kotlin/Platform.kt +++ /dev/null @@ -1,5 +0,0 @@ -package dev.kord.gateway - -internal expect fun getEnv(name: String): String? - -internal expect suspend fun readFile(prefix: String, name: String): String diff --git a/gateway/src/commonTest/kotlin/gateway/DefaultGatewayTest.kt b/gateway/src/commonTest/kotlin/gateway/DefaultGatewayTest.kt index 964c6803382d..830f2994635f 100644 --- a/gateway/src/commonTest/kotlin/gateway/DefaultGatewayTest.kt +++ b/gateway/src/commonTest/kotlin/gateway/DefaultGatewayTest.kt @@ -6,6 +6,7 @@ import dev.kord.common.entity.PresenceStatus import dev.kord.common.ratelimit.IntervalRateLimiter import dev.kord.gateway.* import dev.kord.gateway.retry.LinearRetry +import dev.kord.test.getEnv import io.ktor.client.* import io.ktor.client.plugins.contentnegotiation.* import io.ktor.client.plugins.websocket.* diff --git a/gateway/src/commonTest/kotlin/json/RegressionTests.kt b/gateway/src/commonTest/kotlin/json/RegressionTests.kt index f023e1e56b36..48a41704d203 100644 --- a/gateway/src/commonTest/kotlin/json/RegressionTests.kt +++ b/gateway/src/commonTest/kotlin/json/RegressionTests.kt @@ -2,7 +2,6 @@ package json import dev.kord.gateway.Event import dev.kord.gateway.Reconnect -import dev.kord.gateway.readFile import kotlinx.coroutines.test.runTest import kotlinx.serialization.json.Json import kotlin.js.JsName diff --git a/gateway/src/commonTest/kotlin/json/Util.kt b/gateway/src/commonTest/kotlin/json/Util.kt index dbdc90e3c5f9..ed480dfc730d 100644 --- a/gateway/src/commonTest/kotlin/json/Util.kt +++ b/gateway/src/commonTest/kotlin/json/Util.kt @@ -1,7 +1,10 @@ package json +import dev.kord.test.file import kotlin.test.assertEquals +suspend fun readFile(prefix: String, name: String) = file("gateway", "json/$prefix/$name.jspon") + infix fun T.shouldBe(that: T) { assertEquals(that, this) } diff --git a/gateway/src/jsMain/kotlin/dev/kord/gateway/HttpEngine.kt b/gateway/src/jsMain/kotlin/dev/kord/gateway/HttpEngine.kt deleted file mode 100644 index 65e588d50386..000000000000 --- a/gateway/src/jsMain/kotlin/dev/kord/gateway/HttpEngine.kt +++ /dev/null @@ -1,7 +0,0 @@ -package dev.kord.gateway - -import io.ktor.client.engine.* -import io.ktor.client.engine.js.* - -internal actual object HttpEngine : HttpClientEngineFactory by Js - diff --git a/gateway/src/jsTest/kotlin/dev/kord/gateway/Platform.kt b/gateway/src/jsTest/kotlin/dev/kord/gateway/Platform.kt deleted file mode 100644 index e8cc8e43bd91..000000000000 --- a/gateway/src/jsTest/kotlin/dev/kord/gateway/Platform.kt +++ /dev/null @@ -1,11 +0,0 @@ -package dev.kord.gateway - -import js.core.get -import node.buffer.BufferEncoding -import node.process.process - -internal actual fun getEnv(name: String) = process.env[name] - -actual suspend fun readFile(prefix: String, name: String): String = - node.fs.readFile("${process.env["PROJECT_ROOT"]}/gateway/src/commonTest/resources/json/$prefix/$name.json") - .toString(BufferEncoding.utf8) diff --git a/gateway/src/jvmMain/kotlin/dev/kord/gateway/HttpEngine.kt b/gateway/src/jvmMain/kotlin/dev/kord/gateway/HttpEngine.kt deleted file mode 100644 index 4f33f4a89be8..000000000000 --- a/gateway/src/jvmMain/kotlin/dev/kord/gateway/HttpEngine.kt +++ /dev/null @@ -1,6 +0,0 @@ -package dev.kord.gateway - -import io.ktor.client.engine.* -import io.ktor.client.engine.cio.* - -internal actual object HttpEngine : HttpClientEngineFactory by CIO diff --git a/gateway/src/jvmTest/kotlin/dev/kord/gateway/Platform.kt b/gateway/src/jvmTest/kotlin/dev/kord/gateway/Platform.kt deleted file mode 100644 index c590b965ee90..000000000000 --- a/gateway/src/jvmTest/kotlin/dev/kord/gateway/Platform.kt +++ /dev/null @@ -1,6 +0,0 @@ -package dev.kord.gateway - -internal actual fun getEnv(name: String): String? = System.getenv(name) - -internal actual suspend fun readFile(prefix: String, name: String): String = - ClassLoader.getSystemResource("json/$prefix/$name.json").readText() diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6c5cef251009..ae997ccdd019 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,8 +6,8 @@ ktor = "2.2.4" # https://github.com/ktorio/ktor kotlinx-coroutines = "1.6.4" # https://github.com/Kotlin/kotlinx.coroutines kotlinx-serialization = "1.5.0" # https://github.com/Kotlin/kotlinx.serialization kotlinx-datetime = "0.4.0" # https://github.com/Kotlin/kotlinx-datetime -kotlin-logging = "3.0.5" # https://github.com/oshai/kotlin-logging -kord-cache = { strictly = "[0.3.0, 0.4.0[", prefer = "latest.release" } +kotlin-logging = "3.0.5" # https://github.com/MicroUtils/kotlin-logging +kord-cache = "0.4.0" stately = "2.0.0-rc1" # code generation diff --git a/rest/build.gradle.kts b/rest/build.gradle.kts index e38930ce2006..b555bd2bee3d 100644 --- a/rest/build.gradle.kts +++ b/rest/build.gradle.kts @@ -25,7 +25,7 @@ kotlin { commonTest { dependencies { - implementation(libs.bundles.test.common) + implementation(projects.testKit) implementation(libs.ktor.client.mock) } } @@ -36,23 +36,11 @@ kotlin { } } - jsTest { - dependencies { - implementation(libs.bundles.test.js) - } - } jvmMain { dependencies { api(libs.ktor.client.cio) } } - - jvmTest { - dependencies { - runtimeOnly(libs.bundles.test.runtime) - implementation(libs.kotlin.test.junit5) - } - } } } diff --git a/rest/src/commonMain/kotlin/request/HttpEngine.kt b/rest/src/commonMain/kotlin/request/HttpEngine.kt deleted file mode 100644 index 4808a37cc883..000000000000 --- a/rest/src/commonMain/kotlin/request/HttpEngine.kt +++ /dev/null @@ -1,5 +0,0 @@ -package dev.kord.rest.request - -import io.ktor.client.engine.* - -internal expect object HttpEngine : HttpClientEngineFactory diff --git a/rest/src/commonMain/kotlin/request/KtorRequestHandler.kt b/rest/src/commonMain/kotlin/request/KtorRequestHandler.kt index 5ca8f01b8a57..3ed22ac5e35f 100644 --- a/rest/src/commonMain/kotlin/request/KtorRequestHandler.kt +++ b/rest/src/commonMain/kotlin/request/KtorRequestHandler.kt @@ -1,5 +1,6 @@ package dev.kord.rest.request +import dev.kord.common.http.HttpEngine import dev.kord.rest.json.response.DiscordErrorResponse import dev.kord.rest.ratelimit.* import dev.kord.rest.route.optional diff --git a/rest/src/commonTest/kotlin/json/Util.kt b/rest/src/commonTest/kotlin/json/Util.kt index 50bd760c501f..dd6f1420ef56 100644 --- a/rest/src/commonTest/kotlin/json/Util.kt +++ b/rest/src/commonTest/kotlin/json/Util.kt @@ -1,6 +1,8 @@ package dev.kord.rest.json import io.ktor.utils.io.* +import dev.kord.test.file as platformFile +import dev.kord.test.readFile as platformReadFile -internal expect suspend fun file(name: String): String -internal expect suspend fun readFile(name: String): ByteReadChannel +internal suspend fun file(name: String): String = platformFile("rest", "json/$name.json") +internal suspend fun readFile(name: String): ByteReadChannel = platformReadFile("rest", name) diff --git a/rest/src/jsMain/kotlin/dev/kord/rest/request/HttpEngine.kt b/rest/src/jsMain/kotlin/dev/kord/rest/request/HttpEngine.kt deleted file mode 100644 index 4f859e5db0ff..000000000000 --- a/rest/src/jsMain/kotlin/dev/kord/rest/request/HttpEngine.kt +++ /dev/null @@ -1,6 +0,0 @@ -package dev.kord.rest.request - -import io.ktor.client.engine.* -import io.ktor.client.engine.js.* - -internal actual object HttpEngine : HttpClientEngineFactory by Js diff --git a/rest/src/jsTest/kotlin/dev/kord/rest/json/Utils.kt b/rest/src/jsTest/kotlin/dev/kord/rest/json/Utils.kt deleted file mode 100644 index 356dfffef368..000000000000 --- a/rest/src/jsTest/kotlin/dev/kord/rest/json/Utils.kt +++ /dev/null @@ -1,23 +0,0 @@ -package dev.kord.rest.json - -import io.ktor.utils.io.* -import js.core.get -import js.core.toList -import node.buffer.Buffer -import node.buffer.BufferEncoding -import node.process.process -import node.fs.readFile as nodeReadFile - -internal actual suspend fun file(name: String): String = - nodeReadFile("${process.env["PROJECT_ROOT"]}/rest/src/commonTest/resources/json/$name.json") - .toString(BufferEncoding.utf8) - -internal actual suspend fun readFile(name: String): ByteReadChannel { - val buffer = nodeReadFile("${process.env["PROJECT_ROOT"]}/rest/src/commonTest/resources/$name") - - return ByteReadChannel(buffer.toByteArray()) -} - -private fun Buffer.toByteArray() = values().toList() - .map(Int::toByte) - .toByteArray() diff --git a/rest/src/jvmMain/kotlin/dev/kord/rest/request/HttpEngine.kt b/rest/src/jvmMain/kotlin/dev/kord/rest/request/HttpEngine.kt deleted file mode 100644 index 34ef3bdde016..000000000000 --- a/rest/src/jvmMain/kotlin/dev/kord/rest/request/HttpEngine.kt +++ /dev/null @@ -1,6 +0,0 @@ -package dev.kord.rest.request - -import io.ktor.client.engine.* -import io.ktor.client.engine.cio.* - -internal actual object HttpEngine : HttpClientEngineFactory by CIO diff --git a/rest/src/jvmTest/kotlin/dev/kord/rest/json/Utils.kt b/rest/src/jvmTest/kotlin/dev/kord/rest/json/Utils.kt deleted file mode 100644 index a0e52f58579b..000000000000 --- a/rest/src/jvmTest/kotlin/dev/kord/rest/json/Utils.kt +++ /dev/null @@ -1,8 +0,0 @@ -package dev.kord.rest.json - -import io.ktor.utils.io.* -import io.ktor.utils.io.jvm.javaio.* - -internal actual suspend fun file(name: String): String = ClassLoader.getSystemResource("json/$name.json")!!.readText() -internal actual suspend fun readFile(name: String): ByteReadChannel = - ClassLoader.getSystemResourceAsStream(name)!!.toByteReadChannel() diff --git a/rest/src/jvmTest/kotlin/dev/kord/rest/request/StackTraceRecoveryTest.kt b/rest/src/jvmTest/kotlin/dev/kord/rest/request/StackTraceRecoveryTest.kt deleted file mode 100644 index d11141077df6..000000000000 --- a/rest/src/jvmTest/kotlin/dev/kord/rest/request/StackTraceRecoveryTest.kt +++ /dev/null @@ -1,55 +0,0 @@ -package dev.kord.rest.request - -import dev.kord.rest.json.response.GatewayResponse -import dev.kord.rest.route.Route -import io.ktor.client.* -import io.ktor.client.engine.mock.* -import io.ktor.http.* -import io.ktor.util.* -import io.ktor.utils.io.* -import kotlinx.coroutines.test.runTest -import kotlin.test.Test -import kotlin.test.assertEquals - -class StackTraceRecoveryTest { - - @Test - fun `test stack trace recovery`() = runTest { - val mockEngine = MockEngine { - respond( - content = ByteReadChannel.Empty, - status = HttpStatusCode.NotFound - ) - } - - val client = HttpClient(mockEngine) - val handler = KtorRequestHandler(client = client, token = "") - .withStackTraceRecovery() - - val request = JsonRequest( - Route.GatewayGet, // The mock engine will 404 for any request, so we just use an endpoint without params - emptyMap(), - StringValues.Empty, - StringValues.Empty, - null - ) - - val stackTrace = Thread.currentThread().stackTrace[1] // [0]: java.lang.Thread.getStackTrace(Thread.java) - try { - handler.handle(request) - } catch (e: Throwable) { - e.printStackTrace() - - val recovered = e.suppressedExceptions.first { it is RecoveredStackTrace } - recovered.printStackTrace() - - // at request.StackTraceRecoveryTest$test stack trace recovery$1.invokeSuspend(StackTraceRecoveryTest.kt:39) - with(recovered.stackTrace.first()) { - assertEquals(stackTrace.className, className) - assertEquals(stackTrace.fileName, fileName) - assertEquals(stackTrace.lineNumber + 2, lineNumber) // +2 because capture is two lines deeper - assertEquals(stackTrace.methodName, methodName) - } - } - } -} diff --git a/samples/build.gradle.kts b/samples/build.gradle.kts new file mode 100644 index 000000000000..42ffcec709b4 --- /dev/null +++ b/samples/build.gradle.kts @@ -0,0 +1,23 @@ +plugins { + `kord-internal-multiplatform-module` +} + +kotlin { + js { + binaries.executable() + } + + sourceSets { + commonMain { + dependencies { + implementation(projects.core) + } + } + + jvmMain { + dependencies { + runtimeOnly(libs.slf4j.simple) + } + } + } +} diff --git a/core/src/samples/kotlin/PingBot.kt b/samples/src/commonMain/kotlin/dev/kord/core/PingBot.kt similarity index 91% rename from core/src/samples/kotlin/PingBot.kt rename to samples/src/commonMain/kotlin/dev/kord/core/PingBot.kt index 8569d9e8b4aa..84454f9b636a 100644 --- a/core/src/samples/kotlin/PingBot.kt +++ b/samples/src/commonMain/kotlin/dev/kord/core/PingBot.kt @@ -1,6 +1,6 @@ -import dev.kord.core.Kord +package dev.kord.core + import dev.kord.core.event.message.MessageCreateEvent -import dev.kord.core.on import dev.kord.gateway.Intent import dev.kord.gateway.PrivilegedIntent diff --git a/samples/src/commonMain/kotlin/dev/kord/gateway/GatewayExample.kt b/samples/src/commonMain/kotlin/dev/kord/gateway/GatewayExample.kt new file mode 100644 index 000000000000..3d323ab72b7c --- /dev/null +++ b/samples/src/commonMain/kotlin/dev/kord/gateway/GatewayExample.kt @@ -0,0 +1,50 @@ +package dev.kord.gateway + +import dev.kord.common.entity.PresenceStatus +import dev.kord.common.ratelimit.IntervalRateLimiter +import dev.kord.gateway.retry.LinearRetry +import io.ktor.client.* +import io.ktor.client.plugins.contentnegotiation.* +import io.ktor.client.plugins.websocket.* +import io.ktor.serialization.kotlinx.json.* +import kotlinx.coroutines.flow.filterIsInstance +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach +import kotlin.time.Duration.Companion.seconds +import kotlin.time.ExperimentalTime + +@OptIn(ExperimentalTime::class) +suspend fun main(args: Array) { + val token = args.firstOrNull() ?: error("expected a token") + + val gateway = DefaultGateway { + reconnectRetry = LinearRetry(2.seconds, 20.seconds, 10) + sendRateLimiter = IntervalRateLimiter(limit = 120, interval = 60.seconds) + } + + gateway.events.filterIsInstance().onEach { + val words = it.message.content.split(' ') + when (words.firstOrNull()) { + "!close" -> gateway.stop() + "!detach" -> gateway.detach() + "!status" -> when (words.getOrNull(1)) { + "playing" -> gateway.editPresence { + status = PresenceStatus.Online + afk = false + playing("Kord") + } + } + + "!ping" -> gateway.editPresence { + status = PresenceStatus.Online + afk = false + listening("a ${gateway.ping.value?.inWholeMilliseconds} ms ping") + } + } + }.launchIn(gateway) + + gateway.start(token) { + @OptIn(PrivilegedIntent::class) + intents = Intents.all + } +} diff --git a/rest/src/samples/kotlin/RestExample.kt b/samples/src/commonMain/kotlin/dev/kord/rest/RestExample.kt similarity index 100% rename from rest/src/samples/kotlin/RestExample.kt rename to samples/src/commonMain/kotlin/dev/kord/rest/RestExample.kt diff --git a/settings.gradle.kts b/settings.gradle.kts index 08ea1eb4d203..dbcf85e10a88 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -13,7 +13,9 @@ include( "ksp-processors", "rest", "voice", - "js-test" + "core-voice", + "test-kit", + "samples" ) enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") diff --git a/test-kit/build.gradle.kts b/test-kit/build.gradle.kts new file mode 100644 index 000000000000..af0f02d4485f --- /dev/null +++ b/test-kit/build.gradle.kts @@ -0,0 +1,29 @@ +plugins { + `kord-internal-multiplatform-module` +} + +kotlin { + sourceSets { + commonMain { + dependencies { + compileOnly(projects.kspAnnotations) + api(libs.bundles.test.common) + api(libs.ktor.utils) + api(projects.common) + } + } + + jsMain { + dependencies { + api(libs.bundles.test.js) + } + } + + jvmMain { + dependencies { + api(libs.bundles.test.runtime) + api(libs.kotlin.test.junit5) + } + } + } +} diff --git a/test-kit/src/commonMain/kotlin/dev/kord/test/Annotations.kt b/test-kit/src/commonMain/kotlin/dev/kord/test/Annotations.kt new file mode 100644 index 000000000000..d7c5d089758f --- /dev/null +++ b/test-kit/src/commonMain/kotlin/dev/kord/test/Annotations.kt @@ -0,0 +1,19 @@ +@file:OptIn(ExperimentalMultiplatform::class) + +package dev.kord.test + +import kotlin.annotation.AnnotationTarget.CLASS + +/** + * Ignores this Test on JS platforms. + */ +@Target(AnnotationTarget.FUNCTION, CLASS) +@OptionalExpectation +expect annotation class IgnoreOnJs() + +/** + * Ignores this test on JVM. + */ +@Target(AnnotationTarget.FUNCTION, CLASS) +@OptionalExpectation +expect annotation class IgnoreOnJvm() diff --git a/test-kit/src/commonMain/kotlin/dev/kord/test/Platfrom.kt b/test-kit/src/commonMain/kotlin/dev/kord/test/Platfrom.kt new file mode 100644 index 000000000000..00f7f92ee664 --- /dev/null +++ b/test-kit/src/commonMain/kotlin/dev/kord/test/Platfrom.kt @@ -0,0 +1,7 @@ +package dev.kord.test + +import io.ktor.utils.io.* + +expect fun getEnv(name: String): String? +expect suspend fun file(project: String, path: String): String +expect suspend fun readFile(project: String, path: String): ByteReadChannel diff --git a/test-kit/src/jsMain/kotlin/dev/kord/test/IgnoreOnJs.kt b/test-kit/src/jsMain/kotlin/dev/kord/test/IgnoreOnJs.kt new file mode 100644 index 000000000000..59d75c64b7ed --- /dev/null +++ b/test-kit/src/jsMain/kotlin/dev/kord/test/IgnoreOnJs.kt @@ -0,0 +1,5 @@ +package dev.kord.test + +import kotlin.test.Ignore + +actual typealias IgnoreOnJs = Ignore diff --git a/test-kit/src/jsMain/kotlin/dev/kord/test/Platform.kt b/test-kit/src/jsMain/kotlin/dev/kord/test/Platform.kt new file mode 100644 index 000000000000..10d430ac9bd0 --- /dev/null +++ b/test-kit/src/jsMain/kotlin/dev/kord/test/Platform.kt @@ -0,0 +1,14 @@ +package dev.kord.test + +import dev.kord.common.Platform +import io.ktor.utils.io.* +import js.core.get +import node.process.process + +actual fun getEnv(name: String) = process.env[name] + +actual suspend fun file(project: String, path: String): String = + if (Platform.IS_NODE) nodeFile(project, path) else TODO("Browser JS is not supported yet") + +actual suspend fun readFile(project: String, path: String): ByteReadChannel = + if (Platform.IS_NODE) nodeReadFile(project, path) else TODO("Browser JS is not supported yet") diff --git a/test-kit/src/jsMain/kotlin/dev/kord/test/Platform.node.kt b/test-kit/src/jsMain/kotlin/dev/kord/test/Platform.node.kt new file mode 100644 index 000000000000..e0e4426a2add --- /dev/null +++ b/test-kit/src/jsMain/kotlin/dev/kord/test/Platform.node.kt @@ -0,0 +1,22 @@ +package dev.kord.test + +import io.ktor.utils.io.* +import js.core.get +import js.core.toList +import node.buffer.Buffer +import node.buffer.BufferEncoding +import node.process.process + +internal suspend fun nodeFile(project: String, path: String): String = + node.fs.readFile("${process.env["PROJECT_ROOT"]}/$project/src/commonTest/resources/$path") + .toString(BufferEncoding.utf8) + +internal suspend fun nodeReadFile(project: String, path: String): ByteReadChannel { + val buffer = node.fs.readFile("${process.env["PROJECT_ROOT"]}/$project/src/commonTest/resources/$path") + + return ByteReadChannel(buffer.toByteArray()) +} + +private fun Buffer.toByteArray() = values().toList() + .map(Int::toByte) + .toByteArray() diff --git a/test-kit/src/jvmMain/kotlin/dev/kord/test/IgnoreOnJvm.kt b/test-kit/src/jvmMain/kotlin/dev/kord/test/IgnoreOnJvm.kt new file mode 100644 index 000000000000..b324faa889ff --- /dev/null +++ b/test-kit/src/jvmMain/kotlin/dev/kord/test/IgnoreOnJvm.kt @@ -0,0 +1,5 @@ +package dev.kord.test + +import org.junit.jupiter.api.Disabled + +actual typealias IgnoreOnJvm = Disabled diff --git a/test-kit/src/jvmMain/kotlin/dev/kord/test/Platform.kt b/test-kit/src/jvmMain/kotlin/dev/kord/test/Platform.kt new file mode 100644 index 000000000000..5345e9ddc97e --- /dev/null +++ b/test-kit/src/jvmMain/kotlin/dev/kord/test/Platform.kt @@ -0,0 +1,9 @@ +package dev.kord.test + +import io.ktor.utils.io.* +import io.ktor.utils.io.jvm.javaio.* + +actual fun getEnv(name: String) = System.getenv(name) +actual suspend fun file(project: String, path: String): String = ClassLoader.getSystemResource(path).readText() +actual suspend fun readFile(project: String, path: String): ByteReadChannel = + ClassLoader.getSystemResourceAsStream(path)!!.toByteReadChannel() From e1088bede0c8bb4496e023eac7155929723d6b7d Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Mar 2023 12:35:17 +0100 Subject: [PATCH 025/136] Update KSP generated files --- .../common/entity/AutoModerationActionType.kt | 4 +- .../dev/kord/common/entity/ChannelType.kt | 9 +++- .../dev/kord/common/entity/ForumLayoutType.kt | 0 .../dev/kord/common/entity/GuildFeature.kt | 49 ++++++++++++++++--- .../dev/kord/common/entity/MessageType.kt | 4 ++ .../dev/kord/common/entity/SortOrderType.kt | 0 6 files changed, 57 insertions(+), 9 deletions(-) rename common/build/generated/ksp/{main => metadata/commonMain}/kotlin/dev/kord/common/entity/ForumLayoutType.kt (100%) rename common/build/generated/ksp/{main => metadata/commonMain}/kotlin/dev/kord/common/entity/SortOrderType.kt (100%) diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationActionType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationActionType.kt index f3266b09da72..2dd057cf911e 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationActionType.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/AutoModerationActionType.kt @@ -51,7 +51,9 @@ public sealed class AutoModerationActionType( ) : AutoModerationActionType(value) /** - * Blocks the content of a message according to the rule. + * Blocks a member's message and prevents it from being posted. + * + * A custom explanation can be specified and shown to members whenever their message is blocked. */ public object BlockMessage : AutoModerationActionType(1) diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelType.kt index 0e2264191961..04a3e6b1db63 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelType.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ChannelType.kt @@ -86,7 +86,7 @@ public sealed class ChannelType( public object PublicNewsThread : ChannelType(10) /** - * A temporary sub-channel within a [GuildText] channel. + * A temporary sub-channel within a [GuildText] or [GuildForum] channel. */ public object PublicGuildThread : ChannelType(11) @@ -109,6 +109,11 @@ public sealed class ChannelType( */ public object GuildDirectory : ChannelType(14) + /** + * A channel that can only contain threads. + */ + public object GuildForum : ChannelType(15) + internal object Serializer : KSerializer { public override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("dev.kord.common.entity.ChannelType", PrimitiveKind.INT) @@ -128,6 +133,7 @@ public sealed class ChannelType( 12 -> PrivateThread 13 -> GuildStageVoice 14 -> GuildDirectory + 15 -> GuildForum else -> Unknown(value) } } @@ -149,6 +155,7 @@ public sealed class ChannelType( PrivateThread, GuildStageVoice, GuildDirectory, + GuildForum, ) } diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ForumLayoutType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ForumLayoutType.kt similarity index 100% rename from common/build/generated/ksp/main/kotlin/dev/kord/common/entity/ForumLayoutType.kt rename to common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ForumLayoutType.kt diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildFeature.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildFeature.kt index 3c48544959e6..d7a1d11427b0 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildFeature.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildFeature.kt @@ -10,6 +10,7 @@ import kotlin.Deprecated import kotlin.DeprecationLevel import kotlin.Int import kotlin.LazyThreadSafetyMode.PUBLICATION +import kotlin.ReplaceWith import kotlin.String import kotlin.Suppress import kotlin.collections.List @@ -81,6 +82,16 @@ public sealed class GuildFeature( */ public object Community : GuildFeature("COMMUNITY") + /** + * Guild has enabled monetization. + */ + public object CreatorMonetizableProvisional : GuildFeature("CREATOR_MONETIZABLE_PROVISIONAL") + + /** + * Guild has enabled the role subscription promo page. + */ + public object CreatorStorePage : GuildFeature("CREATOR_STORE_PAGE") + /** * Guild has been set as a support server on the App Directory. */ @@ -111,11 +122,6 @@ public sealed class GuildFeature( */ public object MemberVerificationGateEnabled : GuildFeature("MEMBER_VERIFICATION_GATE_ENABLED") - /** - * Guild has enabled monetization. - */ - public object MonetizationEnabled : GuildFeature("MONETIZATION_ENABLED") - /** * Guild has increased custom sticker slots. */ @@ -141,6 +147,17 @@ public sealed class GuildFeature( */ public object RoleIcons : GuildFeature("ROLE_ICONS") + /** + * Guild has role subscriptions that can be purchased. + */ + public object RoleSubscriptionsAvailableForPurchase : + GuildFeature("ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE") + + /** + * Guild has enabled role subscriptions. + */ + public object RoleSubscriptionsEnabled : GuildFeature("ROLE_SUBSCRIPTIONS_ENABLED") + /** * Guild has enabled ticketed events. */ @@ -178,6 +195,16 @@ public sealed class GuildFeature( ) public object Commerce : GuildFeature("COMMERCE") + /** + * Guild has enabled monetization. + */ + @Deprecated( + message = "Replaced by CreatorMonetizableProvisional.", + replaceWith = ReplaceWith(expression = "GuildFeature.CreatorMonetizableProvisional", imports + = arrayOf("dev.kord.common.entitiy.GuildFeature")), + ) + public object MonetizationEnabled : GuildFeature("MONETIZATION_ENABLED") + /** * Guild has access to create private threads */ @@ -223,19 +250,23 @@ public sealed class GuildFeature( "BANNER" -> Banner "COMMERCE" -> @Suppress("DEPRECATION_ERROR") Commerce "COMMUNITY" -> Community + "CREATOR_MONETIZABLE_PROVISIONAL" -> CreatorMonetizableProvisional + "CREATOR_STORE_PAGE" -> CreatorStorePage "DEVELOPER_SUPPORT_SERVER" -> DeveloperSupportServer "DISCOVERABLE" -> Discoverable "FEATURABLE" -> Featurable "INVITES_DISABLED" -> InvitesDisabled "INVITE_SPLASH" -> InviteSplash "MEMBER_VERIFICATION_GATE_ENABLED" -> MemberVerificationGateEnabled - "MONETIZATION_ENABLED" -> MonetizationEnabled + "MONETIZATION_ENABLED" -> @Suppress("DEPRECATION") MonetizationEnabled "MORE_STICKERS" -> MoreStickers "NEWS" -> News "PARTNERED" -> Partnered "PREVIEW_ENABLED" -> PreviewEnabled "PRIVATE_THREADS" -> @Suppress("DEPRECATION") PrivateThreads "ROLE_ICONS" -> RoleIcons + "ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE" -> RoleSubscriptionsAvailableForPurchase + "ROLE_SUBSCRIPTIONS_ENABLED" -> RoleSubscriptionsEnabled "SEVEN_DAY_THREAD_ARCHIVE" -> @Suppress("DEPRECATION_ERROR") SevenDayThreadArchive "THREE_DAY_THREAD_ARCHIVE" -> @Suppress("DEPRECATION_ERROR") ThreeDayThreadArchive "TICKETED_EVENTS_ENABLED" -> TicketedEventsEnabled @@ -260,19 +291,23 @@ public sealed class GuildFeature( Banner, @Suppress("DEPRECATION_ERROR") Commerce, Community, + CreatorMonetizableProvisional, + CreatorStorePage, DeveloperSupportServer, Discoverable, Featurable, InvitesDisabled, InviteSplash, MemberVerificationGateEnabled, - MonetizationEnabled, + @Suppress("DEPRECATION") MonetizationEnabled, MoreStickers, News, Partnered, PreviewEnabled, @Suppress("DEPRECATION") PrivateThreads, RoleIcons, + RoleSubscriptionsAvailableForPurchase, + RoleSubscriptionsEnabled, @Suppress("DEPRECATION_ERROR") SevenDayThreadArchive, @Suppress("DEPRECATION_ERROR") ThreeDayThreadArchive, TicketedEventsEnabled, diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageType.kt index 204caac5b45c..64f973848123 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageType.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageType.kt @@ -99,6 +99,8 @@ public sealed class MessageType( public object AutoModerationAction : MessageType(24) + public object RoleSubscriptionPurchase : MessageType(25) + public object InteractionPremiumUpsell : MessageType(26) public object StageStart : MessageType(27) @@ -198,6 +200,7 @@ public sealed class MessageType( 22 -> GuildInviteReminder 23 -> ContextMenuCommand 24 -> AutoModerationAction + 25 -> RoleSubscriptionPurchase 26 -> InteractionPremiumUpsell 27 -> StageStart 28 -> StageEnd @@ -238,6 +241,7 @@ public sealed class MessageType( GuildInviteReminder, ContextMenuCommand, AutoModerationAction, + RoleSubscriptionPurchase, InteractionPremiumUpsell, StageStart, StageEnd, diff --git a/common/build/generated/ksp/main/kotlin/dev/kord/common/entity/SortOrderType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/SortOrderType.kt similarity index 100% rename from common/build/generated/ksp/main/kotlin/dev/kord/common/entity/SortOrderType.kt rename to common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/SortOrderType.kt From 39e955c6f1ad54310f16878d980cee9a1a8a03fe Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Mar 2023 12:35:48 +0100 Subject: [PATCH 026/136] Add qualified import for @JvmName in DiscordChannel.kt --- common/src/commonMain/kotlin/entity/DiscordChannel.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/common/src/commonMain/kotlin/entity/DiscordChannel.kt b/common/src/commonMain/kotlin/entity/DiscordChannel.kt index 8315021d321d..cebfee562112 100644 --- a/common/src/commonMain/kotlin/entity/DiscordChannel.kt +++ b/common/src/commonMain/kotlin/entity/DiscordChannel.kt @@ -99,6 +99,7 @@ import kotlin.DeprecationLevel.HIDDEN import kotlin.LazyThreadSafetyMode.PUBLICATION import kotlin.contracts.InvocationKind import kotlin.contracts.contract +import kotlin.jvm.JvmName import kotlin.time.Duration import kotlin.time.Duration.Companion.minutes From 50fb779b78e6cde5d30f8c12d0f9556a5195c73a Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Mar 2023 12:36:22 +0100 Subject: [PATCH 027/136] Type-alias to JDK for BigInteger and ConcurrentHashMap --- .../src/main/kotlin/kord-multiplatform-module.gradle.kts | 9 +++++++++ common/build.gradle.kts | 8 +++++++- common/src/commonMain/kotlin/ConcurrentHashMap.kt | 9 +++++++++ common/src/commonMain/kotlin/DiscordBitSet.kt | 9 +++++---- common/src/jvmMain/kotlin/ConcurrentHashMap.kt | 7 +++++++ common/src/jvmMain/kotlin/DiscordBitSet.kt | 7 +++++++ common/src/nonJvm/kotlin/ConcurrentHashMap.kt | 7 +++++++ common/src/nonJvm/kotlin/DiscordBitSet.kt | 9 +++++++++ core/src/commonMain/kotlin/cache/KordCache.kt | 6 +++--- .../commonMain/kotlin/ratelimit/AbstractRateLimiter.kt | 6 +++--- 10 files changed, 66 insertions(+), 11 deletions(-) create mode 100644 common/src/commonMain/kotlin/ConcurrentHashMap.kt create mode 100644 common/src/jvmMain/kotlin/ConcurrentHashMap.kt create mode 100644 common/src/jvmMain/kotlin/DiscordBitSet.kt create mode 100644 common/src/nonJvm/kotlin/ConcurrentHashMap.kt create mode 100644 common/src/nonJvm/kotlin/DiscordBitSet.kt diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index e43d1e3b6333..ce9e75948067 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -57,6 +57,10 @@ kotlin { kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") } + val nonJvm by creating { + dependsOn(commonMain.get()) + } + targets.forEach { val safeName = if(it.name == "metadata") "common" else it.name findByName("${safeName}Test")?.apply { @@ -64,6 +68,11 @@ kotlin { implementation(project(":test-kit")) } } + if (safeName != "jvm" && safeName != "common") { + findByName("${safeName}Main")?.apply { + dependsOn(nonJvm) + } + } } } } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index dd7227fe65a7..f705aad199a3 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -15,7 +15,6 @@ kotlin { api(libs.kotlinx.serialization.json) api(libs.kotlinx.datetime) api(libs.kotlin.logging) - api(libs.bignum) // Replacement for java.io api(libs.ktor.utils) api(libs.ktor.client.core) @@ -30,6 +29,13 @@ kotlin { api(libs.ktor.client.cio) } } + nonJvm { + dependencies { + api(libs.bignum) + + api(libs.bundles.stately) + } + } jsMain { dependencies { api(libs.ktor.client.js) diff --git a/common/src/commonMain/kotlin/ConcurrentHashMap.kt b/common/src/commonMain/kotlin/ConcurrentHashMap.kt new file mode 100644 index 000000000000..773e8d2981c6 --- /dev/null +++ b/common/src/commonMain/kotlin/ConcurrentHashMap.kt @@ -0,0 +1,9 @@ +package dev.kord.common + +import dev.kord.common.annotation.KordInternal + +/** + * Platform agnostic implementation of ConcurrentHashMap. + */ +@KordInternal +public expect class ConcurrentHashMap() : MutableMap diff --git a/common/src/commonMain/kotlin/DiscordBitSet.kt b/common/src/commonMain/kotlin/DiscordBitSet.kt index cccfb631e998..6bd593683388 100644 --- a/common/src/commonMain/kotlin/DiscordBitSet.kt +++ b/common/src/commonMain/kotlin/DiscordBitSet.kt @@ -1,7 +1,5 @@ package dev.kord.common -import com.ionspin.kotlin.bignum.integer.BigInteger -import com.ionspin.kotlin.bignum.integer.Sign import io.ktor.utils.io.bits.* import io.ktor.utils.io.core.* import io.ktor.utils.io.core.internal.* @@ -22,6 +20,9 @@ private const val WIDTH = Long.SIZE_BITS @Suppress("FunctionName") public fun EmptyBitSet(): DiscordBitSet = DiscordBitSet() +internal expect fun formatIntegerFromByteArray(data: ByteArray): String +internal expect fun parseIntegerToByteArray(value: String): ByteArray + @Serializable(with = DiscordBitSetSerializer::class) public class DiscordBitSet(internal var data: LongArray) { // data is in little-endian order @@ -33,7 +34,7 @@ public class DiscordBitSet(internal var data: LongArray) { // data is in little- // need to convert from little-endian data to big-endian expected by BigInteger return withBuffer(data.size * Long.SIZE_BYTES) { writeFully(data.reversedArray()) - BigInteger.fromByteArray(readBytes(), Sign.POSITIVE).toString() + formatIntegerFromByteArray(readBytes()) } } @@ -133,7 +134,7 @@ public fun DiscordBitSet(value: String): DiscordBitSet { return DiscordBitSet(longArrayOf(value.toULong().toLong())) } - val bytes = BigInteger.parseString(value, 10).toByteArray() + val bytes = parseIntegerToByteArray(value) val longSize = (bytes.size / Long.SIZE_BYTES) + 1 val destination = LongArray(longSize) diff --git a/common/src/jvmMain/kotlin/ConcurrentHashMap.kt b/common/src/jvmMain/kotlin/ConcurrentHashMap.kt new file mode 100644 index 000000000000..f2884470e98e --- /dev/null +++ b/common/src/jvmMain/kotlin/ConcurrentHashMap.kt @@ -0,0 +1,7 @@ +package dev.kord.common + +import dev.kord.common.annotation.KordInternal +import java.util.concurrent.ConcurrentHashMap as JavaConcurrentHashMap + +@KordInternal +public actual typealias ConcurrentHashMap = JavaConcurrentHashMap diff --git a/common/src/jvmMain/kotlin/DiscordBitSet.kt b/common/src/jvmMain/kotlin/DiscordBitSet.kt new file mode 100644 index 000000000000..4cd044fd298b --- /dev/null +++ b/common/src/jvmMain/kotlin/DiscordBitSet.kt @@ -0,0 +1,7 @@ +@file:JvmName("DiscordBitSetJvm") +package dev.kord.common + +import java.math.BigInteger + +internal actual fun formatIntegerFromByteArray(data: ByteArray): String = BigInteger(data).toString() +internal actual fun parseIntegerToByteArray(value: String): ByteArray = BigInteger(value).toByteArray() diff --git a/common/src/nonJvm/kotlin/ConcurrentHashMap.kt b/common/src/nonJvm/kotlin/ConcurrentHashMap.kt new file mode 100644 index 000000000000..5791f8f91ecc --- /dev/null +++ b/common/src/nonJvm/kotlin/ConcurrentHashMap.kt @@ -0,0 +1,7 @@ +package dev.kord.common + +import co.touchlab.stately.collections.ConcurrentMutableMap +import dev.kord.common.annotation.KordInternal + +@KordInternal +public actual typealias ConcurrentHashMap = ConcurrentMutableMap diff --git a/common/src/nonJvm/kotlin/DiscordBitSet.kt b/common/src/nonJvm/kotlin/DiscordBitSet.kt new file mode 100644 index 000000000000..65b5199c124b --- /dev/null +++ b/common/src/nonJvm/kotlin/DiscordBitSet.kt @@ -0,0 +1,9 @@ +package dev.kord.common + +import com.ionspin.kotlin.bignum.integer.BigInteger +import com.ionspin.kotlin.bignum.integer.Sign + +internal actual fun formatIntegerFromByteArray(data: ByteArray): String = + BigInteger.fromByteArray(data, Sign.POSITIVE).toString() + +internal actual fun parseIntegerToByteArray(value: String): ByteArray = BigInteger.parseString(value).toByteArray() diff --git a/core/src/commonMain/kotlin/cache/KordCache.kt b/core/src/commonMain/kotlin/cache/KordCache.kt index 8a129b1e9667..e0e304d7ec99 100644 --- a/core/src/commonMain/kotlin/cache/KordCache.kt +++ b/core/src/commonMain/kotlin/cache/KordCache.kt @@ -1,6 +1,5 @@ package dev.kord.core.cache -import co.touchlab.stately.collections.ConcurrentMutableMap import dev.kord.cache.api.DataCache import dev.kord.cache.api.DataEntryCache import dev.kord.cache.api.data.DataDescription @@ -8,6 +7,7 @@ import dev.kord.cache.api.delegate.DelegatingDataCache import dev.kord.cache.api.delegate.EntrySupplier import dev.kord.cache.map.MapLikeCollection import dev.kord.cache.map.internal.MapEntryCache +import dev.kord.common.ConcurrentHashMap import dev.kord.common.entity.Snowflake import dev.kord.core.cache.data.* @@ -16,10 +16,10 @@ public typealias Generator = (cache: DataCache, description: DataDescripti public class KordCacheBuilder { /** - * The default behavior for all types not explicitly configured, by default a [ConcurrentMutableMap] is supplied. + * The default behavior for all types not explicitly configured, by default a [ConcurrentHashMap] is supplied. */ public var defaultGenerator: Generator = { cache, description -> - MapEntryCache(cache, description, MapLikeCollection.concurrentHashMap()) + MapEntryCache(cache, description, MapLikeCollection.concurrentHashMap()) } private val descriptionGenerators: MutableMap, Generator<*, *>> = mutableMapOf() diff --git a/rest/src/commonMain/kotlin/ratelimit/AbstractRateLimiter.kt b/rest/src/commonMain/kotlin/ratelimit/AbstractRateLimiter.kt index 2afe10e8f122..d42d7bbcdbc5 100644 --- a/rest/src/commonMain/kotlin/ratelimit/AbstractRateLimiter.kt +++ b/rest/src/commonMain/kotlin/ratelimit/AbstractRateLimiter.kt @@ -1,6 +1,6 @@ package dev.kord.rest.ratelimit -import co.touchlab.stately.collections.ConcurrentMutableMap +import dev.kord.common.ConcurrentHashMap import dev.kord.common.ratelimit.IntervalRateLimiter import dev.kord.rest.request.Request import dev.kord.rest.request.RequestIdentifier @@ -19,8 +19,8 @@ public abstract class AbstractRateLimiter internal constructor(public val clock: internal val autoBanRateLimiter = IntervalRateLimiter(limit = 25000, interval = 10.minutes) private val globalSuspensionPoint = atomic(Reset(clock.now())) - internal val buckets = ConcurrentMutableMap() - internal val routeBuckets = ConcurrentMutableMap>() + internal val buckets = ConcurrentHashMap() + internal val routeBuckets = ConcurrentHashMap>() internal val BucketKey.bucket get() = buckets.getOrPut(this) { Bucket(this) } internal val Request<*, *>.buckets get() = routeBuckets[identifier].orEmpty().map { it.bucket } From f061a8cb05a3b39997b966fb2110f87a3aff8a48 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Mar 2023 12:40:20 +0100 Subject: [PATCH 028/136] Remove remaining JVM function in common --- .../kotlin/builder/message/modify/MessageModifyBuilder.kt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/rest/src/commonMain/kotlin/builder/message/modify/MessageModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/message/modify/MessageModifyBuilder.kt index b1eb09744022..1fa4ce0b6153 100644 --- a/rest/src/commonMain/kotlin/builder/message/modify/MessageModifyBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/modify/MessageModifyBuilder.kt @@ -44,13 +44,6 @@ public sealed interface MessageModifyBuilder { */ public var suppressEmbeds: Boolean? - - /** - * Adds a file with the given [path] to the attachments. - */ - public suspend fun addFile(path: Path): NamedFile = - addFile(path.fileName.toString(), ChannelProvider { path.readChannel() }) - /** * Adds a file with the [name] and [contentProvider] to the attachments. */ From 74b9ce8391596052ae478aa243029f98bc3ef0f4 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Mar 2023 12:41:27 +0100 Subject: [PATCH 029/136] Dump api --- core-voice/api/core-voice.api | 4 ++++ core/api/core.api | 22 +++++++++++++++------- rest/api/rest.api | 2 -- 3 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 core-voice/api/core-voice.api diff --git a/core-voice/api/core-voice.api b/core-voice/api/core-voice.api new file mode 100644 index 000000000000..a899627b1a37 --- /dev/null +++ b/core-voice/api/core-voice.api @@ -0,0 +1,4 @@ +public final class dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorJvm { + public static final fun connect (Ldev/kord/core/behavior/channel/BaseVoiceChannelBehavior;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + diff --git a/core/api/core.api b/core/api/core.api index 2a7ef8298710..abcda831d613 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -2081,15 +2081,21 @@ public final class dev/kord/core/builder/components/ButtonBuilderExtensionsKt { public static final fun emoji (Ldev/kord/rest/builder/component/ButtonBuilder;Ldev/kord/core/entity/ReactionEmoji$Unicode;)V } -public final class dev/kord/core/builder/kord/KordBuilder { +public final class dev/kord/core/builder/kord/KordBuilder : dev/kord/core/builder/kord/KordBuilderBase { public fun (Ljava/lang/String;)V - public final fun build (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public fun build (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getEnableShutdownHook ()Z + public final fun setEnableShutdownHook (Z)V +} + +public abstract class dev/kord/core/builder/kord/KordBuilderBase { + public fun build (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + protected final fun buildBase (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun cache (Lkotlin/jvm/functions/Function2;)V public final fun gateways (Lkotlin/jvm/functions/Function2;)V public final fun getApplicationId ()Ldev/kord/common/entity/Snowflake; public final fun getDefaultDispatcher ()Lkotlinx/coroutines/CoroutineDispatcher; public final fun getDefaultStrategy ()Ldev/kord/core/supplier/EntitySupplyStrategy; - public final fun getEnableShutdownHook ()Z public final fun getEventFlow ()Lkotlinx/coroutines/flow/MutableSharedFlow; public final fun getGatewayEventInterceptor ()Ldev/kord/core/gateway/handler/GatewayEventInterceptor; public final fun getHttpClient ()Lio/ktor/client/HttpClient; @@ -2099,7 +2105,6 @@ public final class dev/kord/core/builder/kord/KordBuilder { public final fun setApplicationId (Ldev/kord/common/entity/Snowflake;)V public final fun setDefaultDispatcher (Lkotlinx/coroutines/CoroutineDispatcher;)V public final fun setDefaultStrategy (Ldev/kord/core/supplier/EntitySupplyStrategy;)V - public final fun setEnableShutdownHook (Z)V public final fun setEventFlow (Lkotlinx/coroutines/flow/MutableSharedFlow;)V public final fun setGatewayEventInterceptor (Ldev/kord/core/gateway/handler/GatewayEventInterceptor;)V public final fun setHttpClient (Lio/ktor/client/HttpClient;)V @@ -2181,8 +2186,6 @@ public final class dev/kord/core/cache/KordCacheBuilder { public final fun forDescription (Ldev/kord/cache/api/data/DataDescription;Lkotlin/jvm/functions/Function2;)V public final fun getDefaultGenerator ()Lkotlin/jvm/functions/Function2; public final fun guilds (Lkotlin/jvm/functions/Function2;)V - public final fun lruCache (I)Lkotlin/jvm/functions/Function2; - public static synthetic fun lruCache$default (Ldev/kord/core/cache/KordCacheBuilder;IILjava/lang/Object;)Lkotlin/jvm/functions/Function2; public final fun members (Lkotlin/jvm/functions/Function2;)V public final fun messages (Lkotlin/jvm/functions/Function2;)V public final fun none ()Lkotlin/jvm/functions/Function2; @@ -2195,6 +2198,11 @@ public final class dev/kord/core/cache/KordCacheBuilder { public final fun webhooks (Lkotlin/jvm/functions/Function2;)V } +public final class dev/kord/core/cache/KordCacheBuilderJvm { + public static final fun lruCache (Ldev/kord/core/cache/KordCacheBuilder;I)Lkotlin/jvm/functions/Function2; + public static synthetic fun lruCache$default (Ldev/kord/core/cache/KordCacheBuilder;IILjava/lang/Object;)Lkotlin/jvm/functions/Function2; +} + public final class dev/kord/core/cache/QueryKt { public static final fun booleanEq (Ldev/kord/cache/api/QueryBuilder;Lkotlin/reflect/KProperty1;Ljava/lang/Boolean;)V public static final fun idEq (Ldev/kord/cache/api/QueryBuilder;Lkotlin/reflect/KProperty1;Ldev/kord/common/entity/Snowflake;)V @@ -6127,7 +6135,7 @@ public final class dev/kord/core/entity/Guild : dev/kord/core/behavior/GuildBeha public final fun getOwnerId ()Ldev/kord/common/entity/Snowflake; public final fun getOwnerOrNull (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun getPermissions ()Ldev/kord/common/entity/Permissions; - public final fun getPreferredLocale ()Ljava/util/Locale; + public final fun getPreferredLocale ()Ldev/kord/common/Locale; public final fun getPremiumProgressBarEnabled ()Z public final fun getPremiumSubscriptionCount ()Ljava/lang/Integer; public final fun getPremiumTier ()Ldev/kord/common/entity/PremiumTier; diff --git a/rest/api/rest.api b/rest/api/rest.api index e8f0aee4dc4f..f4c6fee32552 100644 --- a/rest/api/rest.api +++ b/rest/api/rest.api @@ -1929,8 +1929,6 @@ public final class dev/kord/rest/builder/message/create/FollowupMessageCreateBui public final class dev/kord/rest/builder/message/create/ForumMessageCreateBuilder : dev/kord/rest/builder/RequestBuilder, dev/kord/rest/builder/message/create/MessageCreateBuilder { public fun ()V public fun addFile (Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; - public fun addFile (Ljava/lang/String;Ljava/io/InputStream;)Ldev/kord/rest/NamedFile; - public fun addFile (Ljava/nio/file/Path;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun getAllowedMentions ()Ldev/kord/rest/builder/message/AllowedMentionsBuilder; public fun getComponents ()Ljava/util/List; public fun getContent ()Ljava/lang/String; From e30bcebf3818830a5b35d5184bf226adff0f44e7 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Mar 2023 12:53:52 +0100 Subject: [PATCH 030/136] Clarify comment on hash function --- core/src/commonMain/kotlin/Util.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/commonMain/kotlin/Util.kt b/core/src/commonMain/kotlin/Util.kt index 3e1ab0894397..827510177165 100644 --- a/core/src/commonMain/kotlin/Util.kt +++ b/core/src/commonMain/kotlin/Util.kt @@ -477,5 +477,5 @@ public fun Intents.IntentsBuilder.enableEvent(event: KClass): Unit = else -> Unit } -// Replacement of hash +// Replacement of Objects.hash internal fun hash(vararg values: Any?) = values.contentHashCode() From 8badb69a09b3f11f4435346f3e07e0d6fe0e4a78 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Mar 2023 12:54:23 +0100 Subject: [PATCH 031/136] Fix compilation error --- samples/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/build.gradle.kts b/samples/build.gradle.kts index 42ffcec709b4..8f7e5910c85c 100644 --- a/samples/build.gradle.kts +++ b/samples/build.gradle.kts @@ -11,6 +11,7 @@ kotlin { commonMain { dependencies { implementation(projects.core) + compileOnly(projects.kspAnnotations) } } From 22d4bf01dc91ddfc9a12d94567bfc645ae239677 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Mar 2023 12:54:51 +0100 Subject: [PATCH 032/136] Fix compilation issues with Integration.kt --- core/src/commonMain/kotlin/entity/Integration.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/commonMain/kotlin/entity/Integration.kt b/core/src/commonMain/kotlin/entity/Integration.kt index 8facaf2cc94b..182b8a6fe803 100644 --- a/core/src/commonMain/kotlin/entity/Integration.kt +++ b/core/src/commonMain/kotlin/entity/Integration.kt @@ -10,15 +10,17 @@ import dev.kord.core.behavior.RoleBehavior import dev.kord.core.behavior.UserBehavior import dev.kord.core.cache.data.IntegrationData import dev.kord.core.exception.EntityNotFoundException +import dev.kord.core.hash import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.rest.builder.integration.IntegrationModifyBuilder import dev.kord.rest.request.RestRequestException import kotlinx.datetime.Instant -import java.util.* import kotlin.DeprecationLevel.HIDDEN import kotlin.contracts.InvocationKind import kotlin.contracts.contract +import kotlin.js.JsName +import kotlin.jvm.JvmName import kotlin.time.Duration /** @@ -52,6 +54,7 @@ public class Integration( get() = data.enabled @Deprecated("Binary compatibility, was non-nullable before. Keep for some releases.", level = HIDDEN) + @JsName("_isSyncing") // binary compatibility with js doesn't matter as this is the first JS release public fun isSyncing(): Boolean = isSyncing!! /** @@ -171,7 +174,7 @@ public class Integration( override fun withStrategy(strategy: EntitySupplyStrategy<*>): Integration = Integration(data, kord, strategy.supply(kord)) - override fun hashCode(): Int = Objects.hash(id) + override fun hashCode(): Int = hash(id) override fun equals(other: Any?): Boolean = when (other) { is Integration -> other.id == id && other.guildId == guildId From e54a49f9d603fc7c68348c15c35d16c70f71fe30 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Mar 2023 12:55:08 +0100 Subject: [PATCH 033/136] Fix gateway tests --- gateway/src/commonTest/kotlin/json/Util.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/src/commonTest/kotlin/json/Util.kt b/gateway/src/commonTest/kotlin/json/Util.kt index ed480dfc730d..525affb86125 100644 --- a/gateway/src/commonTest/kotlin/json/Util.kt +++ b/gateway/src/commonTest/kotlin/json/Util.kt @@ -3,7 +3,7 @@ package json import dev.kord.test.file import kotlin.test.assertEquals -suspend fun readFile(prefix: String, name: String) = file("gateway", "json/$prefix/$name.jspon") +suspend fun readFile(prefix: String, name: String) = file("gateway", "json/$prefix/$name.json") infix fun T.shouldBe(that: T) { assertEquals(that, this) From f021146170629749931331e1ddd7324f5b4365b1 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Mar 2023 16:24:46 +0100 Subject: [PATCH 034/136] Move some more core tests to common --- CHANGELOG.md | 2 +- buildSrc/src/main/kotlin/Compiler.kt | 20 ++++++ buildSrc/src/main/kotlin/TestKit.kt | 15 +++++ ...d-internal-multiplatform-module.gradle.kts | 3 + .../kord-multiplatform-module.gradle.kts | 32 ++-------- core/api/core.api | 6 ++ core/build.gradle.kts | 7 +++ core/live-tests/build.gradle.kts | 21 +++++++ .../src/commonTest}/kotlin/KordTest.kt | 13 ++-- .../src/commonTest}/kotlin/StrategyTest.kt | 33 +++++----- .../src/commonTest/kotlin/TestToken.kt | 3 + .../kotlin/regression/CacheMissRegression.kt | 21 ++++--- .../kotlin/builder/kord/KordBuilderUtil.kt | 8 ++- .../kotlin/cache/DataCacheExtensions.kt | 6 +- core/src/commonTest/kotlin/RandomIds.kt | 9 +++ .../kotlin/UtilKtTest.kt | 15 +++-- .../kotlin/cache/data/ComponentDataTest.kt | 2 + .../kotlin/gateway/MasterGatewayTest.kt | 8 ++- .../kotlin/live/AbstractLiveEntityTest.kt | 62 ++++++++----------- .../kotlin/live/LiveGuildTest.kt | 50 +++++++++++---- .../kotlin/live/LiveKordEntityTest.kt | 40 +++++++----- .../kotlin/live/LiveMemberTest.kt | 41 ++++++------ .../kotlin/live/LiveMessageTest.kt | 59 +++++++++--------- .../kotlin/live/LiveRoleTest.kt | 32 +++++----- .../kotlin/live/LiveUserTest.kt | 26 +++----- .../kotlin/live/channel/LiveCategoryTest.kt | 26 +++----- .../kotlin/live/channel/LiveChannelTest.kt | 27 ++++---- .../kotlin/live/channel/LiveDmChannelTest.kt | 26 +++----- .../live/channel/LiveGuildChannelTest.kt | 26 +++----- .../kotlin/live/channel/LiveGuildTextTest.kt | 26 +++----- .../live/channel/LiveVoiceChannelTest.kt | 26 +++----- .../kotlin/performance/KordEventDropTest.kt | 52 +++++++++------- .../kotlin/regression/ReactionEmojiTest.kt | 2 + .../supplier/CacheEntitySupplierTest.kt | 9 +-- .../kotlin/equality/BehaviorEqualityTest.kt | 3 +- .../kotlin/equality/ChannelEqualityTest.kt | 6 +- .../kotlin/equality/EntityEqualityTest.kt | 9 +-- .../equality/GuildEntityEqualityTest.kt | 1 + settings.gradle.kts | 3 +- 39 files changed, 410 insertions(+), 366 deletions(-) create mode 100644 buildSrc/src/main/kotlin/TestKit.kt create mode 100644 core/live-tests/build.gradle.kts rename core/{src/jvmTest => live-tests/src/commonTest}/kotlin/KordTest.kt (54%) rename core/{src/jvmTest => live-tests/src/commonTest}/kotlin/StrategyTest.kt (56%) create mode 100644 core/live-tests/src/commonTest/kotlin/TestToken.kt rename core/{src/jvmTest => live-tests/src/commonTest}/kotlin/regression/CacheMissRegression.kt (92%) create mode 100644 core/src/commonTest/kotlin/RandomIds.kt rename core/src/{jvmTest => commonTest}/kotlin/UtilKtTest.kt (83%) rename core/src/{jvmTest => commonTest}/kotlin/cache/data/ComponentDataTest.kt (93%) rename core/src/{jvmTest => commonTest}/kotlin/gateway/MasterGatewayTest.kt (93%) rename core/src/{jvmTest => commonTest}/kotlin/live/AbstractLiveEntityTest.kt (75%) rename core/src/{jvmTest => commonTest}/kotlin/live/LiveGuildTest.kt (96%) rename core/src/{jvmTest => commonTest}/kotlin/live/LiveKordEntityTest.kt (86%) rename core/src/{jvmTest => commonTest}/kotlin/live/LiveMemberTest.kt (88%) rename core/src/{jvmTest => commonTest}/kotlin/live/LiveMessageTest.kt (91%) rename core/src/{jvmTest => commonTest}/kotlin/live/LiveRoleTest.kt (87%) rename core/src/{jvmTest => commonTest}/kotlin/live/LiveUserTest.kt (70%) rename core/src/{jvmTest => commonTest}/kotlin/live/channel/LiveCategoryTest.kt (72%) rename core/src/{jvmTest => commonTest}/kotlin/live/channel/LiveChannelTest.kt (88%) rename core/src/{jvmTest => commonTest}/kotlin/live/channel/LiveDmChannelTest.kt (71%) rename core/src/{jvmTest => commonTest}/kotlin/live/channel/LiveGuildChannelTest.kt (77%) rename core/src/{jvmTest => commonTest}/kotlin/live/channel/LiveGuildTextTest.kt (77%) rename core/src/{jvmTest => commonTest}/kotlin/live/channel/LiveVoiceChannelTest.kt (72%) rename core/src/{jvmTest => commonTest}/kotlin/performance/KordEventDropTest.kt (77%) rename core/src/{jvmTest => commonTest}/kotlin/regression/ReactionEmojiTest.kt (88%) rename core/src/{jvmTest => commonTest}/kotlin/supplier/CacheEntitySupplierTest.kt (91%) diff --git a/CHANGELOG.md b/CHANGELOG.md index e490471ada3e..6bf2e9eb53d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1041,7 +1041,7 @@ exist. #74 * `Kord#gateway` is now a `MasterGateway`, exposing all sharded gateways #65 * `core` Events now expose their shard index as well as the `Gateway` they were spawned from. #65 * `DisconnectEvent` and `Close` have been extended with more detailed implementations #65 -* `Gateway` now accepts a `PresenceBuilder` to configure its original presence. #72 +* `Gateway` now accepts a `PresenceBuilder` to applyKordSourceSetOptions its original presence. #72 * Rest Discord API version can now be configured by setting the `com.gitlab.kordlib.rest.version` system property, `v6` by default. * `DefaultGateway` now supports zlib compression and enables it by default. diff --git a/buildSrc/src/main/kotlin/Compiler.kt b/buildSrc/src/main/kotlin/Compiler.kt index 444bf1b2bc24..384dbd2c349e 100644 --- a/buildSrc/src/main/kotlin/Compiler.kt +++ b/buildSrc/src/main/kotlin/Compiler.kt @@ -1,4 +1,6 @@ +import org.gradle.api.NamedDomainObjectContainer import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet object OptIns { const val time = "kotlin.time.ExperimentalTime" @@ -32,3 +34,21 @@ fun KotlinCommonCompilerOptions.applyKordCompilerOptions() { allWarningsAsErrors.set(false) freeCompilerArgs.add(CompilerArguments.progressive) } + +fun NamedDomainObjectContainer.applyKordSourceSetOptions() { + all { + languageSettings { + if ("Test" in name) { + optIn(OptIns.coroutines) + } + optIn(OptIns.kordInternal) + listOf( + OptIns.time, + OptIns.contracts, + OptIns.kordPreview, + OptIns.kordExperimental, + OptIns.kordVoice, + ).forEach(::optIn) + } + } +} diff --git a/buildSrc/src/main/kotlin/TestKit.kt b/buildSrc/src/main/kotlin/TestKit.kt new file mode 100644 index 000000000000..1098b84cbee5 --- /dev/null +++ b/buildSrc/src/main/kotlin/TestKit.kt @@ -0,0 +1,15 @@ +import org.gradle.api.NamedDomainObjectContainer +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet +import org.jetbrains.kotlin.gradle.plugin.KotlinTarget + +val KotlinTarget.safeName: String get() = if (name == "metadata") "common" else name + +fun NamedDomainObjectContainer.addTestKit(targets: Iterable) { + targets.forEach { + findByName("${it.safeName}Test")?.apply { + dependencies { + implementation(project(":test-kit")) + } + } + } +} diff --git a/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts index 53be19854869..603f4a4348a7 100644 --- a/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts @@ -13,6 +13,9 @@ kotlin { } jvmToolchain(Jvm.target) + sourceSets { + applyKordSourceSetOptions() + } targets { all { compilations.all { diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index ce9e75948067..b42a52684f83 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -32,26 +32,7 @@ kotlin { } sourceSets { - all { - languageSettings { - if ("Test" in name) { - optIn(OptIns.coroutines) - } - optIn(OptIns.kordInternal) - listOf( - OptIns.time, - OptIns.contracts, - OptIns.kordPreview, - OptIns.kordExperimental, - OptIns.kordVoice, - ).forEach(::optIn) - } - - repositories { - // until Dokka 1.8.0 is released and we no longer need dev builds, see https://github.com/kordlib/kord/pull/755 - maven("https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev") - } - } + applyKordSourceSetOptions() commonMain { // mark ksp src dir kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") @@ -61,15 +42,10 @@ kotlin { dependsOn(commonMain.get()) } + addTestKit(targets) targets.forEach { - val safeName = if(it.name == "metadata") "common" else it.name - findByName("${safeName}Test")?.apply { - dependencies { - implementation(project(":test-kit")) - } - } - if (safeName != "jvm" && safeName != "common") { - findByName("${safeName}Main")?.apply { + if (it.safeName != "jvm" && it.safeName != "common") { + findByName("${it.safeName}Main")?.apply { dependsOn(nonJvm) } } diff --git a/core/api/core.api b/core/api/core.api index abcda831d613..c005850023ea 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -2117,6 +2117,11 @@ public final class dev/kord/core/builder/kord/KordBuilderKt { public static synthetic fun invoke$default (Ldev/kord/gateway/DefaultGateway$Companion;Ldev/kord/core/ClientResources;Ldev/kord/gateway/retry/Retry;ILjava/lang/Object;)Ldev/kord/gateway/DefaultGateway; } +public final class dev/kord/core/builder/kord/KordBuilderUtilKt { + public static final fun configure (Lio/ktor/client/HttpClient;)Lio/ktor/client/HttpClient; + public static final fun getBotIdFromToken (Ljava/lang/String;)Ldev/kord/common/entity/Snowflake; +} + public final class dev/kord/core/builder/kord/KordProxyBuilder : dev/kord/core/builder/kord/RestOnlyBuilder { public fun (Ldev/kord/common/entity/Snowflake;)V public fun getApplicationId ()Ldev/kord/common/entity/Snowflake; @@ -2165,6 +2170,7 @@ public final class dev/kord/core/cache/CachingGateway : dev/kord/cache/api/DataC public final class dev/kord/core/cache/DataCacheExtensionsKt { public static final fun createView (Ldev/kord/cache/api/DataCache;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun registerKordData (Ldev/kord/cache/api/DataCache;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } public final class dev/kord/core/cache/DataCacheView : dev/kord/cache/api/DataCache { diff --git a/core/build.gradle.kts b/core/build.gradle.kts index f5153b8b177b..0be975fe78fe 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -17,6 +17,13 @@ kotlin { } } + commonTest { + dependencies { + // The plugin should add this automatically, but it doesn't + compileOnly(libs.kotlinx.atomicfu) + } + } + jvmTest { dependencies { implementation(libs.mockk) diff --git a/core/live-tests/build.gradle.kts b/core/live-tests/build.gradle.kts new file mode 100644 index 000000000000..d9127713159d --- /dev/null +++ b/core/live-tests/build.gradle.kts @@ -0,0 +1,21 @@ +plugins { + `kord-internal-multiplatform-module` +} + +kotlin { + sourceSets { + commonMain { + dependencies { + implementation(projects.core) + implementation(projects.kspAnnotations) + } + } + addTestKit(targets) + } +} + +tasks { + withType { + enabled = !System.getenv("KORD_TEST_TOKEN").isNullOrBlank() + } +} diff --git a/core/src/jvmTest/kotlin/KordTest.kt b/core/live-tests/src/commonTest/kotlin/KordTest.kt similarity index 54% rename from core/src/jvmTest/kotlin/KordTest.kt rename to core/live-tests/src/commonTest/kotlin/KordTest.kt index a1f93cded382..4a3f82ecff84 100644 --- a/core/src/jvmTest/kotlin/KordTest.kt +++ b/core/live-tests/src/commonTest/kotlin/KordTest.kt @@ -1,17 +1,16 @@ import dev.kord.core.Kord import dev.kord.core.event.gateway.ReadyEvent import dev.kord.core.on -import kotlinx.coroutines.runBlocking -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable +import kotlinx.coroutines.test.runTest +import kotlin.js.JsName +import kotlin.test.Test import kotlin.test.assertEquals -@EnabledIfEnvironmentVariable(named = "KORD_TEST_TOKEN", matches = ".+") internal class KordTest { - @Test - fun `Kord life cycle is correctly ended on shutdown`() = runBlocking { - val kord = Kord.restOnly(System.getenv("KORD_TEST_TOKEN")) + @JsName("test1") + fun `Kord life cycle is correctly ended on shutdown`() = runTest { + val kord = Kord.restOnly(testToken) val job = kord.on {} kord.shutdown() assertEquals(false, job.isActive) diff --git a/core/src/jvmTest/kotlin/StrategyTest.kt b/core/live-tests/src/commonTest/kotlin/StrategyTest.kt similarity index 56% rename from core/src/jvmTest/kotlin/StrategyTest.kt rename to core/live-tests/src/commonTest/kotlin/StrategyTest.kt index 2175d45597ba..01a30953f544 100644 --- a/core/src/jvmTest/kotlin/StrategyTest.kt +++ b/core/live-tests/src/commonTest/kotlin/StrategyTest.kt @@ -1,27 +1,22 @@ import dev.kord.cache.api.put import dev.kord.core.Kord import dev.kord.core.supplier.EntitySupplyStrategy -import kotlinx.coroutines.runBlocking -import org.junit.jupiter.api.* -import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertNull - -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@EnabledIfEnvironmentVariable(named = "KORD_TEST_TOKEN", matches = ".+") +import kotlinx.coroutines.test.runTest +import kotlin.js.JsName +import kotlin.test.* + class StrategyTest { lateinit var kord: Kord - @BeforeAll - fun setup() = runBlocking { - kord = Kord(System.getenv("KORD_TEST_TOKEN")) + @BeforeTest + fun setup() = runTest { + kord = Kord(testToken) } @Test - @Order(1) - fun `rest only`() = runBlocking { + @JsName("test1") + fun `rest only`() = runTest { val fromRest = kord.with(EntitySupplyStrategy.rest).getSelfOrNull() val inCache = kord.with(EntitySupplyStrategy.cache).getSelfOrNull() assertNull(inCache) @@ -29,16 +24,16 @@ class StrategyTest { } @Test - @Order(3) - fun `cache only`() = runBlocking { + @JsName("test2") + fun `cache only`() = runTest { val inCache = kord.with(EntitySupplyStrategy.cache).getSelfOrNull() assertNotNull(inCache) } @Test - @Order(2) - fun `cache falls back to rest`() = runBlocking { + @JsName("test3") + fun `cache falls back to rest`() = runTest { val cache = kord.with(EntitySupplyStrategy.cache) val inCache = cache.getSelfOrNull() @@ -51,4 +46,4 @@ class StrategyTest { assertEquals(self, cache.getSelf()) } -} \ No newline at end of file +} diff --git a/core/live-tests/src/commonTest/kotlin/TestToken.kt b/core/live-tests/src/commonTest/kotlin/TestToken.kt new file mode 100644 index 000000000000..66fa24e474f7 --- /dev/null +++ b/core/live-tests/src/commonTest/kotlin/TestToken.kt @@ -0,0 +1,3 @@ +import dev.kord.test.getEnv + +val testToken = getEnv("KORD_TEST_TOKEN") ?: error("KORD_TEST_TOKEN is not defined") diff --git a/core/src/jvmTest/kotlin/regression/CacheMissRegression.kt b/core/live-tests/src/commonTest/kotlin/regression/CacheMissRegression.kt similarity index 92% rename from core/src/jvmTest/kotlin/regression/CacheMissRegression.kt rename to core/live-tests/src/commonTest/kotlin/regression/CacheMissRegression.kt index eba4327ae36a..7185030f52f2 100644 --- a/core/src/jvmTest/kotlin/regression/CacheMissRegression.kt +++ b/core/live-tests/src/commonTest/kotlin/regression/CacheMissRegression.kt @@ -6,8 +6,8 @@ import dev.kord.common.entity.ChannelType import dev.kord.common.entity.Snowflake import dev.kord.core.ClientResources import dev.kord.core.Kord -import dev.kord.core.builder.kord.configure import dev.kord.core.builder.kord.getBotIdFromToken +import dev.kord.core.builder.kord.configure import dev.kord.core.cache.data.ChannelData import dev.kord.core.cache.registerKordData import dev.kord.core.gateway.DefaultMasterGateway @@ -37,16 +37,16 @@ import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.runTest import kotlinx.serialization.SerializationStrategy import kotlinx.serialization.json.Json -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable +import testToken import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext +import kotlin.js.JsName import kotlin.test.BeforeTest +import kotlin.test.Test +import kotlin.test.assertFailsWith import kotlin.time.Duration @@ -116,13 +116,12 @@ class CrashingHandler(val client: HttpClient, override val token: String) : Requ } } -@EnabledIfEnvironmentVariable(named = "KORD_TEST_TOKEN", matches = ".+") class CacheMissingRegressions { lateinit var kord: Kord @BeforeTest fun setup() = runTest { //TODO, move this over to entity supplier tests instead, eventually. - val token = System.getenv("KORD_TEST_TOKEN") + val token = testToken val resources = ClientResources( token, getBotIdFromToken(token), @@ -145,18 +144,20 @@ class CacheMissingRegressions { @Test + @JsName("test1") fun `if data not in cache explode`() { val id = 5uL - assertThrows { - runBlocking { + assertFailsWith { + runTest { kord.getChannel(Snowflake(id)) } } } @Test + @JsName("test2") fun `if data in cache don't fetch from rest`() { - runBlocking { + runTest { val id = Snowflake(5uL) kord.cache.put(ChannelData(id, ChannelType.GuildText)) diff --git a/core/src/commonMain/kotlin/builder/kord/KordBuilderUtil.kt b/core/src/commonMain/kotlin/builder/kord/KordBuilderUtil.kt index c82addcef11e..a6cf63e2b7dd 100644 --- a/core/src/commonMain/kotlin/builder/kord/KordBuilderUtil.kt +++ b/core/src/commonMain/kotlin/builder/kord/KordBuilderUtil.kt @@ -1,5 +1,6 @@ package dev.kord.core.builder.kord +import dev.kord.common.annotation.KordInternal import dev.kord.common.entity.Snowflake import dev.kord.common.http.HttpEngine import io.ktor.client.* @@ -18,7 +19,8 @@ internal fun HttpClientConfig<*>.defaultConfig() { install(WebSockets) } -internal fun HttpClient?.configure(): HttpClient { +@KordInternal +public fun HttpClient?.configure(): HttpClient { if (this != null) return this.config { defaultConfig() } @@ -38,8 +40,8 @@ internal fun HttpClient?.configure(): HttpClient { } } - -internal fun getBotIdFromToken(token: String) = try { +@KordInternal +public fun getBotIdFromToken(token: String): Snowflake = try { Snowflake(token.substringBefore('.').decodeBase64String()) } catch (exception: IllegalArgumentException) { throw IllegalArgumentException("Malformed bot token: '$token'. Make sure that your token is correct.") diff --git a/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt b/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt index 0ebc3deba6a5..dc14b3812b64 100644 --- a/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt +++ b/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt @@ -2,12 +2,14 @@ package dev.kord.core.cache import dev.kord.cache.api.DataCache import dev.kord.cache.api.query +import dev.kord.common.annotation.KordInternal import dev.kord.core.cache.data.* /** * Registers all Kord data classes for this cache */ -internal suspend fun DataCache.registerKordData() = register( +@KordInternal +public suspend fun DataCache.registerKordData(): Unit = register( RoleData.description, ChannelData.description, GuildData.description, @@ -52,4 +54,4 @@ internal suspend fun DataCache.removeKordData() { * Creates a [DataCacheView] for this view, only removing elements that were added * directly to this instance. */ -public suspend fun DataCache.createView(): DataCacheView = DataCacheView(this) +public fun DataCache.createView(): DataCacheView = DataCacheView(this) diff --git a/core/src/commonTest/kotlin/RandomIds.kt b/core/src/commonTest/kotlin/RandomIds.kt new file mode 100644 index 000000000000..0cfab39b24ee --- /dev/null +++ b/core/src/commonTest/kotlin/RandomIds.kt @@ -0,0 +1,9 @@ +import dev.kord.common.entity.Snowflake +import kotlin.random.Random +import kotlin.random.nextULong + +val ids = generateSequence { + Random.nextULong(Snowflake.validValues) // limit to valid range to guarantee distinct generated Snowflakes +}.distinct().iterator() + +fun randomId() = Snowflake(ids.next()) diff --git a/core/src/jvmTest/kotlin/UtilKtTest.kt b/core/src/commonTest/kotlin/UtilKtTest.kt similarity index 83% rename from core/src/jvmTest/kotlin/UtilKtTest.kt rename to core/src/commonTest/kotlin/UtilKtTest.kt index d6880199f814..fc5b51a8e3cc 100644 --- a/core/src/jvmTest/kotlin/UtilKtTest.kt +++ b/core/src/commonTest/kotlin/UtilKtTest.kt @@ -1,14 +1,16 @@ -package dev.kord.core - import dev.kord.common.entity.Snowflake +import dev.kord.core.paginateBackwards +import dev.kord.core.paginateForwards import kotlinx.coroutines.flow.count import kotlinx.coroutines.test.runTest -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test +import kotlin.js.JsName +import kotlin.test.Test +import kotlin.test.assertEquals internal class UtilKtTest { @Test + @JsName("test1") fun `paginate forwards selects the right id`() = runTest { val flow = paginateForwards(start = Snowflake(0u), batchSize = 100, idSelector = { it }) { @@ -23,10 +25,11 @@ internal class UtilKtTest { } } - Assertions.assertEquals(1000, flow.count()) + assertEquals(1000, flow.count()) } @Test + @JsName("test2") fun `paginate backwards selects the right id`() = runTest { val flow = paginateBackwards(start = Snowflake(1000u), batchSize = 100, idSelector = { it }) { @@ -41,7 +44,7 @@ internal class UtilKtTest { } } - Assertions.assertEquals(1000, flow.count()) + assertEquals(1000, flow.count()) } } diff --git a/core/src/jvmTest/kotlin/cache/data/ComponentDataTest.kt b/core/src/commonTest/kotlin/cache/data/ComponentDataTest.kt similarity index 93% rename from core/src/jvmTest/kotlin/cache/data/ComponentDataTest.kt rename to core/src/commonTest/kotlin/cache/data/ComponentDataTest.kt index 0441ec8f81dc..b4cc0b322237 100644 --- a/core/src/jvmTest/kotlin/cache/data/ComponentDataTest.kt +++ b/core/src/commonTest/kotlin/cache/data/ComponentDataTest.kt @@ -5,12 +5,14 @@ import dev.kord.core.cache.data.ChatComponentData import dev.kord.core.cache.data.ComponentData import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json +import kotlin.js.JsName import kotlin.test.Test import kotlin.test.assertEquals class ComponentDataTest { @Test + @JsName("test1") fun `polymorphic ComponentData can be serialized`() { val type = ComponentType.ActionRow val data: ComponentData = ChatComponentData(type) diff --git a/core/src/jvmTest/kotlin/gateway/MasterGatewayTest.kt b/core/src/commonTest/kotlin/gateway/MasterGatewayTest.kt similarity index 93% rename from core/src/jvmTest/kotlin/gateway/MasterGatewayTest.kt rename to core/src/commonTest/kotlin/gateway/MasterGatewayTest.kt index 7a01a7a6c503..2b0cf66b1456 100644 --- a/core/src/jvmTest/kotlin/gateway/MasterGatewayTest.kt +++ b/core/src/commonTest/kotlin/gateway/MasterGatewayTest.kt @@ -8,16 +8,18 @@ import dev.kord.gateway.GatewayConfiguration import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharedFlow -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext +import kotlin.js.JsName +import kotlin.test.Test +import kotlin.test.assertEquals import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds internal class DefaultMasterGatewayTest { @Test + @JsName("test1") fun `Gateway takes ping of single child`() { val dummy = DummyGateway() val ping = 150.milliseconds @@ -32,6 +34,7 @@ internal class DefaultMasterGatewayTest { } @Test + @JsName("test2") fun `Gateway takes ping average of multiple children`() { val dummy1 = DummyGateway() val dummy2 = DummyGateway() @@ -49,6 +52,7 @@ internal class DefaultMasterGatewayTest { } @Test + @JsName("test3") fun `Gateway returns null ping when no gateway pings`(){ val dummy = DummyGateway() diff --git a/core/src/jvmTest/kotlin/live/AbstractLiveEntityTest.kt b/core/src/commonTest/kotlin/live/AbstractLiveEntityTest.kt similarity index 75% rename from core/src/jvmTest/kotlin/live/AbstractLiveEntityTest.kt rename to core/src/commonTest/kotlin/live/AbstractLiveEntityTest.kt index aaf66060e47c..9b043da677ac 100644 --- a/core/src/jvmTest/kotlin/live/AbstractLiveEntityTest.kt +++ b/core/src/commonTest/kotlin/live/AbstractLiveEntityTest.kt @@ -15,24 +15,20 @@ import dev.kord.gateway.GatewayConfiguration import dev.kord.gateway.builder.Shards import dev.kord.rest.request.KtorRequestHandler import dev.kord.rest.service.RestClient -import equality.randomId import io.ktor.client.* +import kotlinx.atomicfu.atomic import kotlinx.coroutines.* +import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow -import org.junit.jupiter.api.AfterAll -import org.junit.jupiter.api.BeforeAll -import java.util.concurrent.CountDownLatch -import java.util.concurrent.TimeUnit -import java.util.concurrent.atomic.AtomicInteger +import kotlinx.coroutines.test.runTest +import randomId import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext -import kotlin.test.AfterTest -import kotlin.test.assertEquals -import kotlin.test.assertFalse -import kotlin.test.assertTrue +import kotlin.test.* import kotlin.time.Duration +import kotlin.time.Duration.Companion.milliseconds abstract class AbstractLiveEntityTest { @@ -56,20 +52,19 @@ abstract class AbstractLiveEntityTest { override suspend fun stop() {} } - class CounterAtomicLatch(count: Int) { + class CounterAtomicLatch() { + private val channel = Channel() - private val countdown = CountDownLatch(count) - val latchCount get() = countdown.count + private val received = atomic(0) + val atomicCount by received - private val counter = AtomicInteger(0) - val atomicCount get() = counter.get() - - fun count() { - counter.incrementAndGet() - countdown.countDown() + suspend fun count() { + channel.send(Unit) } - fun await(timeout: Long, unit: TimeUnit) = countdown.await(timeout, unit) + suspend fun await(duration: Duration) = withTimeout(duration) { + for(unit in channel) { received.incrementAndGet() } + } } private lateinit var gateway: GatewayMock @@ -80,27 +75,23 @@ abstract class AbstractLiveEntityTest { lateinit var live: LIVE - @BeforeAll - open fun onBeforeAll() = runBlocking { + @BeforeTest + open fun onBeforeAll() = runTest { kord = createKord() guildId = randomId() } - @AfterAll - open fun onAfterAll() = runBlocking { + @AfterTest + open fun onAfterAll() = runTest { + if (::live.isInitialized && live.isActive) { + live.shutDown() + } if (kord.isActive) { kord.logout() kord.shutdown() } } - @AfterTest - open fun onAfter() { - if (this::live.isInitialized && live.isActive) { - live.shutDown() - } - } - protected open fun createKord(): Kord { gateway = GatewayMock() return Kord( @@ -117,15 +108,14 @@ abstract class AbstractLiveEntityTest { protected inline fun countdownContext( expectedCount: Int, - waitMs: Long = 5000, + wait: Duration = 5000.milliseconds, crossinline action: suspend CounterAtomicLatch.() -> Unit - ) = runBlocking { - val counter = CounterAtomicLatch(expectedCount) + ) = runTest { + val counter = CounterAtomicLatch() action(counter) - counter.await(waitMs, TimeUnit.MILLISECONDS) - assertEquals(0, counter.latchCount) + counter.await(wait) assertEquals(expectedCount, counter.atomicCount) } diff --git a/core/src/jvmTest/kotlin/live/LiveGuildTest.kt b/core/src/commonTest/kotlin/live/LiveGuildTest.kt similarity index 96% rename from core/src/jvmTest/kotlin/live/LiveGuildTest.kt rename to core/src/commonTest/kotlin/live/LiveGuildTest.kt index d798db21a7f8..2d262e5b92e6 100644 --- a/core/src/jvmTest/kotlin/live/LiveGuildTest.kt +++ b/core/src/commonTest/kotlin/live/LiveGuildTest.kt @@ -10,27 +10,23 @@ import dev.kord.core.event.guild.GuildDeleteEvent import dev.kord.core.live.* import dev.kord.core.live.exception.LiveCancellationException import dev.kord.gateway.* -import equality.randomId import kotlinx.coroutines.job -import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.test.runTest import kotlinx.datetime.Instant import kotlinx.serialization.json.JsonObject -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.TestInstance -import org.junit.jupiter.api.Timeout -import java.util.concurrent.TimeUnit +import randomId +import kotlin.js.JsName import kotlin.test.BeforeTest +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.time.Duration.Companion.seconds -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@Timeout(value = 5, unit = TimeUnit.SECONDS) -@Disabled +@Ignore class LiveGuildTest : AbstractLiveEntityTest() { @BeforeTest - fun onBefore() = runBlocking { + fun onBefore() = runTest { live = LiveGuild( Guild( kord = kord, @@ -58,6 +54,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test1") fun `Check onEmojisUpdate is called when event is received`() { countdownContext(1) { live.onEmojisUpdate { @@ -78,6 +75,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test2") fun `Check onIntegrationsUpdate is called when event is received`() { countdownContext(1) { live.onIntegrationsUpdate { @@ -97,6 +95,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test3") fun `Check onBanAdd is called when event is received`() { countdownContext(1) { live.onBanAdd { @@ -122,6 +121,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test4") fun `Check onBanRemove is called when event is received`() { countdownContext(1) { live.onBanRemove { @@ -147,6 +147,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test5") fun `Check onPresenceUpdate is called when event is received`() { countdownContext(1) { live.onPresenceUpdate { @@ -173,6 +174,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test6") fun `Check onVoiceServerUpdate is called when event is received`() { countdownContext(1) { live.onVoiceServerUpdate { @@ -194,6 +196,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test7") fun `Check onVoiceStateUpdate is called when event is received`() { countdownContext(1) { live.onVoiceStateUpdate { @@ -223,6 +226,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test8") fun `Check onWebhookUpdate is called when event is received`() { countdownContext(1) { live.onWebhookUpdate { @@ -243,6 +247,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test9") fun `Check onRoleCreate is called when event is received`() { countdownContext(1) { live.onRoleCreate { @@ -274,6 +279,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test10") fun `Check onRoleUpdate is called when event is received`() { countdownContext(1) { live.onRoleUpdate { @@ -305,6 +311,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test11") fun `Check onRoleDelete is called when event is received`() { countdownContext(1) { live.onRoleDelete { @@ -325,6 +332,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test12") fun `Check onMemberJoin is called when event is received`() { countdownContext(1) { live.onMemberJoin { @@ -356,6 +364,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test13") fun `Check onMemberUpdate is called when event is received`() { countdownContext(1) { live.onMemberUpdate { @@ -383,6 +392,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test14") fun `Check onMemberLeave is called when event is received`() { countdownContext(1) { live.onMemberLeave { @@ -408,6 +418,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test15") fun `Check onReactionAdd is called when event is received`() { countdownContext(1) { val emojiExpected = ReactionEmoji.Unicode("\uD83D\uDC28") @@ -433,6 +444,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test16") fun `Check onReactionAdd with specific reaction is called when event is received`() { countdownContext(1) { val emojiExpected = ReactionEmoji.Unicode("\uD83D\uDC28") @@ -462,6 +474,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test17") fun `Check onReactionRemove is called when event is received`() { countdownContext(1) { val emojiExpected = ReactionEmoji.Unicode("\uD83D\uDC28") @@ -488,6 +501,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test18") fun `Check onReactionRemove with specific reaction is called when event is received`() { countdownContext(1) { val emojiExpected = ReactionEmoji.Unicode("\uD83D\uDC28") @@ -517,6 +531,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test19") fun `Check onReactionRemoveAll is called when event is received`() { countdownContext(1) { live.onReactionRemoveAll { @@ -538,6 +553,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test20") fun `Check onMessageCreate is called when event is received`() { countdownContext(1) { live.onMessageCreate { @@ -576,6 +592,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test21") fun `Check onMessageUpdate is called when event is received`() { countdownContext(1) { live.onMessageUpdate { @@ -597,6 +614,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test22") fun `Check onMessageDelete is called when event is received`() { countdownContext(1) { live.onMessageDelete { @@ -618,6 +636,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test23") fun `Check onChannelCreate is called when event is received`() { countdownContext(1) { live.onChannelCreate { @@ -639,6 +658,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test24") fun `Check onChannelUpdate is called when event is received`() { countdownContext(1) { live.onChannelUpdate { @@ -660,6 +680,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test25") fun `Check onChannelDelete is called when event is received`() { countdownContext(1) { live.onChannelDelete { @@ -681,6 +702,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test26") fun `Check onGuildCreate is called when event is received`() { countdownContext(1) { live.onGuildCreate { @@ -725,6 +747,7 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test + @JsName("test27") fun `Check onGuildUpdate is called when event is received`() { countdownContext(1) { live.onGuildUpdate { @@ -769,13 +792,16 @@ class LiveGuildTest : AbstractLiveEntityTest() { } @Test - fun `Check if live entity is completed when event the guild delete event is received`() { + @JsName("test28") + fun `Check if live entity is completed when event the guild delete event is received`() { countdownContext(1) { live.coroutineContext.job.invokeOnCompletion { it as LiveCancellationException val event = it.event as GuildDeleteEvent assertEquals(guildId, event.guildId) - count() + runTest { + count() + } } sendEventValidAndRandomIdCheckLiveActive(guildId) { diff --git a/core/src/jvmTest/kotlin/live/LiveKordEntityTest.kt b/core/src/commonTest/kotlin/live/LiveKordEntityTest.kt similarity index 86% rename from core/src/jvmTest/kotlin/live/LiveKordEntityTest.kt rename to core/src/commonTest/kotlin/live/LiveKordEntityTest.kt index f7bc726ad425..5e4fcc3de330 100644 --- a/core/src/jvmTest/kotlin/live/LiveKordEntityTest.kt +++ b/core/src/commonTest/kotlin/live/LiveKordEntityTest.kt @@ -13,24 +13,20 @@ import dev.kord.core.live.on import dev.kord.gateway.GuildBanAdd import dev.kord.gateway.GuildDelete import dev.kord.gateway.MessageReactionAdd -import equality.randomId import kotlinx.coroutines.* -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.TestInstance -import org.junit.jupiter.api.Timeout -import java.util.concurrent.TimeUnit +import kotlinx.coroutines.test.runTest +import randomId +import kotlin.js.JsName import kotlin.test.* +import kotlin.time.Duration.Companion.milliseconds -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@Timeout(value = 5, unit = TimeUnit.SECONDS) -@Disabled +@Ignore class LiveKordEntityTest : AbstractLiveEntityTest() { companion object { private const val REASON_SHUTDOWN = "The live entity mock is shut down" } - @Disabled inner class LiveEntityMock(kord: Kord) : AbstractLiveKordEntity(kord) { @@ -45,9 +41,11 @@ class LiveKordEntityTest : AbstractLiveEntityTest counter?.count() - is ReactionAddEvent -> shutDown(LiveCancellationException(event, REASON_SHUTDOWN)) + runTest { + when (event) { + is BanAddEvent -> counter?.count() + is ReactionAddEvent -> shutDown(LiveCancellationException(event, REASON_SHUTDOWN)) + } } } } @@ -58,6 +56,7 @@ class LiveKordEntityTest : AbstractLiveEntityTest { } assertTrue(job.isActive) @@ -75,18 +75,22 @@ class LiveKordEntityTest : AbstractLiveEntityTest { error("Never called") } diff --git a/core/src/jvmTest/kotlin/live/LiveMemberTest.kt b/core/src/commonTest/kotlin/live/LiveMemberTest.kt similarity index 88% rename from core/src/jvmTest/kotlin/live/LiveMemberTest.kt rename to core/src/commonTest/kotlin/live/LiveMemberTest.kt index bcb9fb5c2a59..fd9b304c573b 100644 --- a/core/src/jvmTest/kotlin/live/LiveMemberTest.kt +++ b/core/src/commonTest/kotlin/live/LiveMemberTest.kt @@ -15,34 +15,23 @@ import dev.kord.gateway.GuildBanAdd import dev.kord.gateway.GuildDelete import dev.kord.gateway.GuildMemberRemove import dev.kord.gateway.GuildMemberUpdate -import equality.randomId import kotlinx.coroutines.job -import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.test.runTest import kotlinx.datetime.Instant -import org.junit.jupiter.api.BeforeAll -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.TestInstance -import org.junit.jupiter.api.Timeout -import java.util.concurrent.TimeUnit +import randomId +import kotlin.js.JsName import kotlin.test.BeforeTest +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@Timeout(value = 5, unit = TimeUnit.SECONDS) -@Disabled +@Ignore class LiveMemberTest : AbstractLiveEntityTest() { - private lateinit var userId: Snowflake - - @BeforeAll - override fun onBeforeAll() { - super.onBeforeAll() - userId = randomId() - } + private val userId: Snowflake = randomId() @BeforeTest - fun onBefore() = runBlocking { + fun onBefore() = runTest { live = LiveMember( Member( kord = kord, @@ -64,6 +53,7 @@ class LiveMemberTest : AbstractLiveEntityTest() { } @Test + @JsName("test1") fun `Check onUpdate is called when event is received`() { countdownContext(1) { live.onUpdate { @@ -91,13 +81,16 @@ class LiveMemberTest : AbstractLiveEntityTest() { } @Test + @JsName("test2") fun `Check onLeave is called when event is received`() { countdownContext(1) { live.coroutineContext.job.invokeOnCompletion { it as LiveCancellationException val event = it.event as MemberLeaveEvent assertEquals(userId, event.user.id) - count() + runTest { + count() + } } sendEventValidAndRandomIdCheckLiveActive(userId) { @@ -118,13 +111,16 @@ class LiveMemberTest : AbstractLiveEntityTest() { } @Test + @JsName("test3") fun `Check if live entity is completed when the member is banned`() { countdownContext(1) { live.coroutineContext.job.invokeOnCompletion { it as LiveCancellationException val event = it.event as BanAddEvent assertEquals(userId, event.user.id) - count() + runTest { + count() + } } sendEventValidAndRandomIdCheckLiveActive(userId) { @@ -145,13 +141,16 @@ class LiveMemberTest : AbstractLiveEntityTest() { } @Test + @JsName("test4") fun `Check if live entity is completed when the guild is deleted`() { countdownContext(1) { live.coroutineContext.job.invokeOnCompletion { it as LiveCancellationException val event = it.event as GuildDeleteEvent assertEquals(guildId, event.guildId) - count() + runTest { + count() + } } sendEventValidAndRandomIdCheckLiveActive(guildId) { diff --git a/core/src/jvmTest/kotlin/live/LiveMessageTest.kt b/core/src/commonTest/kotlin/live/LiveMessageTest.kt similarity index 91% rename from core/src/jvmTest/kotlin/live/LiveMessageTest.kt rename to core/src/commonTest/kotlin/live/LiveMessageTest.kt index 0637cf7cc94d..8857d0a206d2 100644 --- a/core/src/jvmTest/kotlin/live/LiveMessageTest.kt +++ b/core/src/commonTest/kotlin/live/LiveMessageTest.kt @@ -12,38 +12,23 @@ import dev.kord.core.event.message.MessageDeleteEvent import dev.kord.core.live.* import dev.kord.core.live.exception.LiveCancellationException import dev.kord.gateway.* -import equality.randomId +import randomId import kotlinx.coroutines.job -import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.test.runTest import kotlinx.datetime.Instant -import org.junit.jupiter.api.BeforeAll -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.TestInstance -import org.junit.jupiter.api.Timeout -import java.util.concurrent.TimeUnit -import kotlin.test.BeforeTest -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertTrue - -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@Timeout(value = 5, unit = TimeUnit.SECONDS) -@Disabled +import kotlin.js.JsName +import kotlin.test.* + +@Ignore class LiveMessageTest : AbstractLiveEntityTest() { - private lateinit var messageId: Snowflake + private val messageId: Snowflake = randomId() - private lateinit var channelId: Snowflake + private val channelId: Snowflake = randomId() - @BeforeAll - override fun onBeforeAll() { - super.onBeforeAll() - messageId = randomId() - channelId = randomId() - } @BeforeTest - fun onBefore() = runBlocking { + fun onBefore() = runTest { live = LiveMessage( guildId = guildId, message = Message( @@ -72,6 +57,7 @@ class LiveMessageTest : AbstractLiveEntityTest() { } @Test + @JsName("test1") fun `Check onReactionAdd is called when event is received`() { countdownContext(1) { val emojiExpected = ReactionEmoji.Unicode("\uD83D\uDC28") @@ -97,6 +83,7 @@ class LiveMessageTest : AbstractLiveEntityTest() { } @Test + @JsName("test2") fun `Check onReactionAdd with specific reaction is called when event is received`() { countdownContext(1) { val emojiExpected = ReactionEmoji.Unicode("\uD83D\uDC28") @@ -125,6 +112,7 @@ class LiveMessageTest : AbstractLiveEntityTest() { } @Test + @JsName("test3") fun `Check onReactionRemove is called when event is received`() { countdownContext(1) { val emojiExpected = ReactionEmoji.Unicode("\uD83D\uDC28") @@ -150,6 +138,7 @@ class LiveMessageTest : AbstractLiveEntityTest() { } @Test + @JsName("test4") fun `Check onReactionRemove with specific reaction is called when event is received`() { countdownContext(1) { val emojiExpected = ReactionEmoji.Unicode("\uD83D\uDC28") @@ -178,6 +167,7 @@ class LiveMessageTest : AbstractLiveEntityTest() { } @Test + @JsName("test5") fun `Check onReactionRemoveAll is called when event is received`() { countdownContext(1) { live.onReactionRemoveAll { @@ -198,6 +188,7 @@ class LiveMessageTest : AbstractLiveEntityTest() { } @Test + @JsName("test6") fun `Check onUpdate is called when event is received`() { countdownContext(1) { live.onUpdate { @@ -218,13 +209,16 @@ class LiveMessageTest : AbstractLiveEntityTest() { } @Test + @JsName("test7") fun `Check if live entity is completed when event the message delete event is received`() { countdownContext(1) { live.coroutineContext.job.invokeOnCompletion { it as LiveCancellationException val event = it.event as MessageDeleteEvent assertEquals(messageId, event.messageId) - count() + runTest { + count() + } } sendEventValidAndRandomIdCheckLiveActive(messageId) { @@ -240,13 +234,16 @@ class LiveMessageTest : AbstractLiveEntityTest() { } @Test + @JsName("test8") fun `Check if live entity is completed when event the bulk delete event is received`() { countdownContext(1) { live.coroutineContext.job.invokeOnCompletion { it as LiveCancellationException val event = it.event as MessageBulkDeleteEvent assertTrue { messageId in event.messageIds } - count() + runTest { + count() + } } sendEventValidAndRandomIdCheckLiveActive(messageId) { @@ -262,13 +259,16 @@ class LiveMessageTest : AbstractLiveEntityTest() { } @Test + @JsName("test9") fun `Check if live entity is completed when event the channel delete event is received`() { countdownContext(1) { live.coroutineContext.job.invokeOnCompletion { it as LiveCancellationException val event = it.event as ChannelDeleteEvent assertEquals(channelId, event.channel.id) - count() + runTest { + count() + } } sendEventValidAndRandomIdCheckLiveActive(channelId) { @@ -284,13 +284,16 @@ class LiveMessageTest : AbstractLiveEntityTest() { } @Test + @JsName("test10") fun `Check if live entity is completed when event the guild delete event is received`() { countdownContext(1) { live.coroutineContext.job.invokeOnCompletion { it as LiveCancellationException val event = it.event as GuildDeleteEvent assertEquals(guildId, event.guildId) - count() + runTest { + count() + } } sendEventValidAndRandomIdCheckLiveActive(guildId) { diff --git a/core/src/jvmTest/kotlin/live/LiveRoleTest.kt b/core/src/commonTest/kotlin/live/LiveRoleTest.kt similarity index 87% rename from core/src/jvmTest/kotlin/live/LiveRoleTest.kt rename to core/src/commonTest/kotlin/live/LiveRoleTest.kt index bdbec2e4cf6a..a7c0ab282a98 100644 --- a/core/src/jvmTest/kotlin/live/LiveRoleTest.kt +++ b/core/src/commonTest/kotlin/live/LiveRoleTest.kt @@ -12,29 +12,20 @@ import dev.kord.core.live.onUpdate import dev.kord.gateway.GuildDelete import dev.kord.gateway.GuildRoleDelete import dev.kord.gateway.GuildRoleUpdate -import equality.randomId import kotlinx.coroutines.job -import org.junit.jupiter.api.BeforeAll -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.TestInstance -import org.junit.jupiter.api.Timeout -import java.util.concurrent.TimeUnit +import kotlinx.coroutines.test.runTest +import randomId +import kotlin.js.JsName import kotlin.test.BeforeTest +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@Timeout(value = 5, unit = TimeUnit.SECONDS) -@Disabled +@Ignore class LiveRoleTest : AbstractLiveEntityTest() { - private lateinit var roleId: Snowflake + private val roleId: Snowflake = randomId() - @BeforeAll - override fun onBeforeAll() { - super.onBeforeAll() - roleId = randomId() - } @BeforeTest fun onBefore() { @@ -59,6 +50,7 @@ class LiveRoleTest : AbstractLiveEntityTest() { } @Test + @JsName("test1") fun `Check onUpdate is called when event is received`() { countdownContext(1) { live.onUpdate { @@ -90,13 +82,16 @@ class LiveRoleTest : AbstractLiveEntityTest() { } @Test + @JsName("test2") fun `Check if live entity is completed when the role is deleted`() { countdownContext(1) { live.coroutineContext.job.invokeOnCompletion { it as LiveCancellationException val event = it.event as RoleDeleteEvent assertEquals(roleId, event.roleId) - count() + runTest { + count() + } } sendEventValidAndRandomIdCheckLiveActive(roleId) { @@ -112,13 +107,16 @@ class LiveRoleTest : AbstractLiveEntityTest() { } @Test + @JsName("test3") fun `Check if live entity is completed when the guild is deleted`() { countdownContext(1) { live.coroutineContext.job.invokeOnCompletion { it as LiveCancellationException val event = it.event as GuildDeleteEvent assertEquals(guildId, event.guildId) - count() + runTest { + count() + } } sendEventValidAndRandomIdCheckLiveActive(guildId) { diff --git a/core/src/jvmTest/kotlin/live/LiveUserTest.kt b/core/src/commonTest/kotlin/live/LiveUserTest.kt similarity index 70% rename from core/src/jvmTest/kotlin/live/LiveUserTest.kt rename to core/src/commonTest/kotlin/live/LiveUserTest.kt index a204922b8054..f25b6dd1acc8 100644 --- a/core/src/jvmTest/kotlin/live/LiveUserTest.kt +++ b/core/src/commonTest/kotlin/live/LiveUserTest.kt @@ -7,32 +7,21 @@ import dev.kord.core.entity.User import dev.kord.core.live.LiveUser import dev.kord.core.live.onUpdate import dev.kord.gateway.UserUpdate -import equality.randomId -import kotlinx.coroutines.runBlocking -import org.junit.jupiter.api.BeforeAll -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.TestInstance -import org.junit.jupiter.api.Timeout -import java.util.concurrent.TimeUnit +import kotlinx.coroutines.test.runTest +import randomId +import kotlin.js.JsName import kotlin.test.BeforeTest +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@Timeout(value = 5, unit = TimeUnit.SECONDS) -@Disabled +@Ignore class LiveUserTest : AbstractLiveEntityTest() { - private lateinit var userId: Snowflake - - @BeforeAll - override fun onBeforeAll() { - super.onBeforeAll() - userId = randomId() - } + private val userId: Snowflake = randomId() @BeforeTest - fun onBefore() = runBlocking { + fun onBefore() = runTest { live = LiveUser( user = User( kord = kord, @@ -46,6 +35,7 @@ class LiveUserTest : AbstractLiveEntityTest() { } @Test + @JsName("test1") fun `Check onUpdate is called when event is received`() { countdownContext(1) { live.onUpdate { diff --git a/core/src/jvmTest/kotlin/live/channel/LiveCategoryTest.kt b/core/src/commonTest/kotlin/live/channel/LiveCategoryTest.kt similarity index 72% rename from core/src/jvmTest/kotlin/live/channel/LiveCategoryTest.kt rename to core/src/commonTest/kotlin/live/channel/LiveCategoryTest.kt index a082dc863803..7029509dabb9 100644 --- a/core/src/jvmTest/kotlin/live/channel/LiveCategoryTest.kt +++ b/core/src/commonTest/kotlin/live/channel/LiveCategoryTest.kt @@ -9,32 +9,21 @@ import dev.kord.core.entity.channel.Category import dev.kord.core.live.channel.LiveCategory import dev.kord.core.live.channel.onUpdate import dev.kord.gateway.ChannelUpdate -import equality.randomId -import kotlinx.coroutines.runBlocking -import org.junit.jupiter.api.BeforeAll -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.TestInstance -import org.junit.jupiter.api.Timeout -import java.util.concurrent.TimeUnit +import kotlinx.coroutines.test.runTest +import randomId +import kotlin.js.JsName import kotlin.test.BeforeTest +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@Timeout(value = 5, unit = TimeUnit.SECONDS) -@Disabled +@Ignore class LiveCategoryTest : LiveChannelTest() { - override lateinit var channelId: Snowflake - - @BeforeAll - override fun onBeforeAll() { - super.onBeforeAll() - channelId = randomId() - } + override val channelId: Snowflake = randomId() @BeforeTest - fun onBefore() = runBlocking { + fun onBefore() = runTest { live = LiveCategory( Category( kord = kord, @@ -48,6 +37,7 @@ class LiveCategoryTest : LiveChannelTest() { } @Test + @JsName("testOnUpdate") fun `Check onUpdate is called when event is received`() { countdownContext(1) { live.onUpdate { diff --git a/core/src/jvmTest/kotlin/live/channel/LiveChannelTest.kt b/core/src/commonTest/kotlin/live/channel/LiveChannelTest.kt similarity index 88% rename from core/src/jvmTest/kotlin/live/channel/LiveChannelTest.kt rename to core/src/commonTest/kotlin/live/channel/LiveChannelTest.kt index ecb006668ffd..9a0975f4fd40 100644 --- a/core/src/jvmTest/kotlin/live/channel/LiveChannelTest.kt +++ b/core/src/commonTest/kotlin/live/channel/LiveChannelTest.kt @@ -12,27 +12,24 @@ import dev.kord.core.live.channel.* import dev.kord.core.live.exception.LiveCancellationException import dev.kord.gateway.ChannelDelete import dev.kord.gateway.GuildDelete -import equality.randomId import kotlinx.coroutines.job -import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.test.runTest import live.AbstractLiveEntityTest -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.TestInstance -import org.junit.jupiter.api.Timeout -import java.util.concurrent.TimeUnit +import randomId +import kotlin.js.JsName import kotlin.reflect.KClass +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@Timeout(value = 5, unit = TimeUnit.SECONDS) -@Disabled +@Ignore abstract class LiveChannelTest : AbstractLiveEntityTest() { protected abstract val channelId: Snowflake @Test - fun `Check type of live entity corresponds to the channel type`() = runBlocking { + @JsName("test41") + fun `Check type of live entity corresponds to the channel type`() = runTest { val data = ChannelData( id = randomId(), type = ChannelType.DM @@ -49,13 +46,16 @@ abstract class LiveChannelTest : AbstractLiveEntityTest : AbstractLiveEntityTest() { - override lateinit var channelId: Snowflake - - @BeforeAll - override fun onBeforeAll() { - super.onBeforeAll() - channelId = randomId() - } + override val channelId: Snowflake = randomId() @BeforeTest - fun onBefore() = runBlocking { + fun onBefore() = runTest { live = LiveDmChannel( DmChannel( kord = kord, @@ -48,6 +37,7 @@ class LiveDmChannelTest : LiveChannelTest() { } @Test + @JsName("test31") fun `Check onUpdate is called when event is received`() { countdownContext(1) { live.onUpdate { diff --git a/core/src/jvmTest/kotlin/live/channel/LiveGuildChannelTest.kt b/core/src/commonTest/kotlin/live/channel/LiveGuildChannelTest.kt similarity index 77% rename from core/src/jvmTest/kotlin/live/channel/LiveGuildChannelTest.kt rename to core/src/commonTest/kotlin/live/channel/LiveGuildChannelTest.kt index 6235f15d2da4..2f0d2e18ea10 100644 --- a/core/src/jvmTest/kotlin/live/channel/LiveGuildChannelTest.kt +++ b/core/src/commonTest/kotlin/live/channel/LiveGuildChannelTest.kt @@ -12,20 +12,15 @@ import dev.kord.core.live.channel.onUpdate import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.gateway.ChannelUpdate -import equality.randomId -import kotlinx.coroutines.runBlocking -import org.junit.jupiter.api.BeforeAll -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.TestInstance -import org.junit.jupiter.api.Timeout -import java.util.concurrent.TimeUnit +import kotlinx.coroutines.test.runTest +import randomId +import kotlin.js.JsName import kotlin.test.BeforeTest +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@Timeout(value = 5, unit = TimeUnit.SECONDS) -@Disabled +@Ignore class LiveGuildChannelTest : LiveChannelTest() { inner class GuildChannelMock( @@ -38,16 +33,10 @@ class LiveGuildChannelTest : LiveChannelTest() { } } - override lateinit var channelId: Snowflake - - @BeforeAll - override fun onBeforeAll() { - super.onBeforeAll() - channelId = randomId() - } + override val channelId: Snowflake = randomId() @BeforeTest - fun onBefore() = runBlocking { + fun onBefore() = runTest { live = LiveGuildChannel( GuildChannelMock( kord = kord, @@ -61,6 +50,7 @@ class LiveGuildChannelTest : LiveChannelTest() { } @Test + @JsName("test11") fun `Check onUpdate is called when event is received`() { countdownContext(1) { live.onUpdate { diff --git a/core/src/jvmTest/kotlin/live/channel/LiveGuildTextTest.kt b/core/src/commonTest/kotlin/live/channel/LiveGuildTextTest.kt similarity index 77% rename from core/src/jvmTest/kotlin/live/channel/LiveGuildTextTest.kt rename to core/src/commonTest/kotlin/live/channel/LiveGuildTextTest.kt index cb384ce02b2e..a584d5bec08d 100644 --- a/core/src/jvmTest/kotlin/live/channel/LiveGuildTextTest.kt +++ b/core/src/commonTest/kotlin/live/channel/LiveGuildTextTest.kt @@ -12,20 +12,15 @@ import dev.kord.core.live.channel.onUpdate import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.gateway.ChannelUpdate -import equality.randomId -import kotlinx.coroutines.runBlocking -import org.junit.jupiter.api.BeforeAll -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.TestInstance -import org.junit.jupiter.api.Timeout -import java.util.concurrent.TimeUnit +import kotlinx.coroutines.test.runTest +import randomId +import kotlin.js.JsName import kotlin.test.BeforeTest +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@Timeout(value = 5, unit = TimeUnit.SECONDS) -@Disabled +@Ignore class LiveGuildTextTest : LiveChannelTest() { inner class GuildChannelMock( @@ -38,16 +33,10 @@ class LiveGuildTextTest : LiveChannelTest() { } } - override lateinit var channelId: Snowflake - - @BeforeAll - override fun onBeforeAll() { - super.onBeforeAll() - channelId = randomId() - } + override val channelId: Snowflake = randomId() @BeforeTest - fun onBefore() = runBlocking { + fun onBefore() = runTest { live = LiveGuildChannel( GuildChannelMock( kord = kord, @@ -61,6 +50,7 @@ class LiveGuildTextTest : LiveChannelTest() { } @Test + @JsName("testOnUpdate") fun `Check onUpdate is called when event is received`() { countdownContext(1) { live.onUpdate { diff --git a/core/src/jvmTest/kotlin/live/channel/LiveVoiceChannelTest.kt b/core/src/commonTest/kotlin/live/channel/LiveVoiceChannelTest.kt similarity index 72% rename from core/src/jvmTest/kotlin/live/channel/LiveVoiceChannelTest.kt rename to core/src/commonTest/kotlin/live/channel/LiveVoiceChannelTest.kt index 993e50e4c541..1f94737cf30a 100644 --- a/core/src/jvmTest/kotlin/live/channel/LiveVoiceChannelTest.kt +++ b/core/src/commonTest/kotlin/live/channel/LiveVoiceChannelTest.kt @@ -9,32 +9,21 @@ import dev.kord.core.entity.channel.VoiceChannel import dev.kord.core.live.channel.LiveVoiceChannel import dev.kord.core.live.channel.onUpdate import dev.kord.gateway.ChannelUpdate -import equality.randomId -import kotlinx.coroutines.runBlocking -import org.junit.jupiter.api.BeforeAll -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.TestInstance -import org.junit.jupiter.api.Timeout -import java.util.concurrent.TimeUnit +import kotlinx.coroutines.test.runTest +import randomId +import kotlin.js.JsName import kotlin.test.BeforeTest +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@Timeout(value = 5, unit = TimeUnit.SECONDS) -@Disabled +@Ignore class LiveVoiceChannelTest : LiveChannelTest() { - override lateinit var channelId: Snowflake - - @BeforeAll - override fun onBeforeAll() { - super.onBeforeAll() - channelId = randomId() - } + override val channelId: Snowflake = randomId() @BeforeTest - fun onBefore() = runBlocking { + fun onBefore() = runTest { live = LiveVoiceChannel( VoiceChannel( kord = kord, @@ -48,6 +37,7 @@ class LiveVoiceChannelTest : LiveChannelTest() { } @Test + @JsName("test21") fun `Check onUpdate is called when event is received`() { countdownContext(1) { live.onUpdate { diff --git a/core/src/jvmTest/kotlin/performance/KordEventDropTest.kt b/core/src/commonTest/kotlin/performance/KordEventDropTest.kt similarity index 77% rename from core/src/jvmTest/kotlin/performance/KordEventDropTest.kt rename to core/src/commonTest/kotlin/performance/KordEventDropTest.kt index 6d35fe457ba1..7ca650e9ad70 100644 --- a/core/src/jvmTest/kotlin/performance/KordEventDropTest.kt +++ b/core/src/commonTest/kotlin/performance/KordEventDropTest.kt @@ -1,10 +1,9 @@ -package dev.kord.core.performance +package performance import dev.kord.cache.api.DataCache import dev.kord.common.entity.* import dev.kord.core.ClientResources import dev.kord.core.Kord -import dev.kord.core.event.guild.GuildCreateEvent import dev.kord.core.gateway.DefaultMasterGateway import dev.kord.core.gateway.handler.DefaultGatewayEventInterceptor import dev.kord.core.on @@ -14,18 +13,16 @@ import dev.kord.gateway.builder.Shards import dev.kord.rest.request.KtorRequestHandler import dev.kord.rest.service.RestClient import io.ktor.client.* -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.* +import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow -import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.withTimeout +import kotlinx.coroutines.test.runTest import kotlinx.datetime.Clock -import java.util.concurrent.CountDownLatch -import java.util.concurrent.atomic.AtomicInteger import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext +import kotlin.js.JsName import kotlin.test.Test import kotlin.test.assertEquals import kotlin.time.Duration @@ -52,7 +49,14 @@ class KordEventDropTest { } val kord = Kord( - resources = ClientResources("token", Snowflake(0u), Shards(1), maxConcurrency = 1, HttpClient(), EntitySupplyStrategy.cache), + resources = ClientResources( + "token", + Snowflake(0u), + Shards(1), + maxConcurrency = 1, + HttpClient(), + EntitySupplyStrategy.cache + ), cache = DataCache.none(), DefaultMasterGateway(mapOf(0 to SpammyGateway)), RestClient(KtorRequestHandler("token", clock = Clock.System)), @@ -63,7 +67,8 @@ class KordEventDropTest { ) @Test - fun `hammering the gateway does not drop core events`() = runBlocking { + @JsName("test1") + fun `hammering the gateway does not drop core events`() = runTest { val amount = 1_000 val event = GuildCreate( @@ -97,21 +102,24 @@ class KordEventDropTest { ), 0 ) - val counter = AtomicInteger(0) - val countdown = CountDownLatch(amount) - kord.on { - counter.incrementAndGet() - countdown.countDown() + val channel = Channel() + kord.on { + channel.send(Unit) } - repeat(amount) { - SpammyGateway.events.emit(event) + launch { + repeat(amount) { SpammyGateway.events.emit(event) } } - - withTimeout(1.minutes.inWholeMilliseconds) { - countdown.await() + var received = 0 + withContext(Dispatchers.Default) { + withTimeout(1.minutes) { + for (unit in channel) { + if (++received == amount) { + channel.close() + } + } + } } - assertEquals(amount, counter.get()) + assertEquals(amount, received) } - } diff --git a/core/src/jvmTest/kotlin/regression/ReactionEmojiTest.kt b/core/src/commonTest/kotlin/regression/ReactionEmojiTest.kt similarity index 88% rename from core/src/jvmTest/kotlin/regression/ReactionEmojiTest.kt rename to core/src/commonTest/kotlin/regression/ReactionEmojiTest.kt index a32d940a0d3a..4d1434b28ebe 100644 --- a/core/src/jvmTest/kotlin/regression/ReactionEmojiTest.kt +++ b/core/src/commonTest/kotlin/regression/ReactionEmojiTest.kt @@ -2,11 +2,13 @@ package regression import dev.kord.common.entity.Snowflake import dev.kord.core.entity.ReactionEmoji +import kotlin.js.JsName import kotlin.test.Test class ReactionEmojiTest { @Test + @JsName("test1") fun `getting the id of a reaction emoji doesn't cause a castException`() { val emoji = ReactionEmoji.Custom(Snowflake(0u), "test", false) emoji.id diff --git a/core/src/jvmTest/kotlin/supplier/CacheEntitySupplierTest.kt b/core/src/commonTest/kotlin/supplier/CacheEntitySupplierTest.kt similarity index 91% rename from core/src/jvmTest/kotlin/supplier/CacheEntitySupplierTest.kt rename to core/src/commonTest/kotlin/supplier/CacheEntitySupplierTest.kt index c609bb23ac41..c3f315096391 100644 --- a/core/src/jvmTest/kotlin/supplier/CacheEntitySupplierTest.kt +++ b/core/src/commonTest/kotlin/supplier/CacheEntitySupplierTest.kt @@ -16,14 +16,16 @@ import io.ktor.client.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.toList -import kotlinx.coroutines.runBlocking -import org.junit.jupiter.api.Test +import kotlinx.coroutines.test.runTest +import kotlin.js.JsName +import kotlin.test.Test internal class CacheEntitySupplierTest { @Test @OptIn(KordUnsafe::class) - fun `cache does not throw when accessing unregistered entities`(): Unit = runBlocking { + @JsName("test1") + fun `cache does not throw when accessing unregistered entities`() = runTest { val kord = Kord( ClientResources("", Snowflake(0u), Shards(0), maxConcurrency = 1, HttpClient(), EntitySupplyStrategy.cache), KordCacheBuilder().build(), @@ -37,5 +39,4 @@ internal class CacheEntitySupplierTest { kord.unsafe.guild(Snowflake(0u)).regions.toList() } - } diff --git a/core/src/jvmTest/kotlin/equality/BehaviorEqualityTest.kt b/core/src/jvmTest/kotlin/equality/BehaviorEqualityTest.kt index ea568cdbc415..d0f1ffbd964e 100644 --- a/core/src/jvmTest/kotlin/equality/BehaviorEqualityTest.kt +++ b/core/src/jvmTest/kotlin/equality/BehaviorEqualityTest.kt @@ -1,6 +1,7 @@ package equality import dev.kord.core.entity.KordEntity +import randomId import kotlin.test.Test import kotlin.test.assertEquals @@ -24,4 +25,4 @@ interface BehaviorEqualityTest : EntityEqualityTest { assertEquals(behavior, entity) } -} \ No newline at end of file +} diff --git a/core/src/jvmTest/kotlin/equality/ChannelEqualityTest.kt b/core/src/jvmTest/kotlin/equality/ChannelEqualityTest.kt index abbc4aca40cd..d6b85a04a3dc 100644 --- a/core/src/jvmTest/kotlin/equality/ChannelEqualityTest.kt +++ b/core/src/jvmTest/kotlin/equality/ChannelEqualityTest.kt @@ -4,11 +4,13 @@ import dev.kord.common.entity.Snowflake import dev.kord.core.behavior.channel.ChannelBehavior import dev.kord.core.entity.KordEntity import mockKord +import randomId +import kotlin.test.Test import kotlin.test.assertEquals interface ChannelEqualityTest : EntityEqualityTest { - @kotlin.test.Test + @Test fun `Channel is equal to Channel with the same id`() { val id = randomId() val kord = mockKord() @@ -24,4 +26,4 @@ interface ChannelEqualityTest : EntityEqualityTest { } } -} \ No newline at end of file +} diff --git a/core/src/jvmTest/kotlin/equality/EntityEqualityTest.kt b/core/src/jvmTest/kotlin/equality/EntityEqualityTest.kt index 64d8ab36faf3..956c3197b100 100644 --- a/core/src/jvmTest/kotlin/equality/EntityEqualityTest.kt +++ b/core/src/jvmTest/kotlin/equality/EntityEqualityTest.kt @@ -2,18 +2,11 @@ package equality import dev.kord.common.entity.Snowflake import dev.kord.core.entity.KordEntity -import kotlin.random.Random -import kotlin.random.nextULong +import randomId import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotEquals -val ids = generateSequence { - Random.nextULong(Snowflake.validValues) // limit to valid range to guarantee distinct generated Snowflakes -}.distinct().iterator() - -fun randomId() = Snowflake(ids.next()) - interface EntityEqualityTest { fun newEntity(id: Snowflake): T diff --git a/core/src/jvmTest/kotlin/equality/GuildEntityEqualityTest.kt b/core/src/jvmTest/kotlin/equality/GuildEntityEqualityTest.kt index 702e662f044e..0f4e950ab4db 100644 --- a/core/src/jvmTest/kotlin/equality/GuildEntityEqualityTest.kt +++ b/core/src/jvmTest/kotlin/equality/GuildEntityEqualityTest.kt @@ -2,6 +2,7 @@ package equality import dev.kord.common.entity.Snowflake import dev.kord.core.entity.KordEntity +import randomId import kotlin.test.Test import kotlin.test.assertNotEquals diff --git a/settings.gradle.kts b/settings.gradle.kts index dbcf85e10a88..c93362a4d1aa 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -15,7 +15,8 @@ include( "voice", "core-voice", "test-kit", - "samples" + "samples", + "core:live-tests" ) enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") From dc1eb18216eda94ab655a9bff699565798da8e3d Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sat, 25 Mar 2023 22:42:07 +0100 Subject: [PATCH 035/136] Upgrade to new cache version --- build.gradle.kts | 1 - core/api/core.api | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index bfe1c7cfc034..c6dab6323252 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,6 @@ plugins { allprojects { repositories { mavenCentral() - mavenLocal() } } diff --git a/core/api/core.api b/core/api/core.api index c005850023ea..7f1e03e3a89f 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -2169,7 +2169,7 @@ public final class dev/kord/core/cache/CachingGateway : dev/kord/cache/api/DataC } public final class dev/kord/core/cache/DataCacheExtensionsKt { - public static final fun createView (Ldev/kord/cache/api/DataCache;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun createView (Ldev/kord/cache/api/DataCache;)Ldev/kord/core/cache/DataCacheView; public static final fun registerKordData (Ldev/kord/cache/api/DataCache;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } From 526216a4c99871e97a798a3035a34102a5c3470a Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sun, 26 Mar 2023 16:09:45 +0200 Subject: [PATCH 036/136] Ignore EventDropTest on JS --- core/src/commonTest/kotlin/performance/KordEventDropTest.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/commonTest/kotlin/performance/KordEventDropTest.kt b/core/src/commonTest/kotlin/performance/KordEventDropTest.kt index 7ca650e9ad70..67e8530b02ce 100644 --- a/core/src/commonTest/kotlin/performance/KordEventDropTest.kt +++ b/core/src/commonTest/kotlin/performance/KordEventDropTest.kt @@ -12,6 +12,7 @@ import dev.kord.gateway.* import dev.kord.gateway.builder.Shards import dev.kord.rest.request.KtorRequestHandler import dev.kord.rest.service.RestClient +import dev.kord.test.IgnoreOnJs import io.ktor.client.* import kotlinx.coroutines.* import kotlinx.coroutines.channels.Channel @@ -68,6 +69,7 @@ class KordEventDropTest { @Test @JsName("test1") + @IgnoreOnJs // currently this doesn't work on JS for some reason fun `hammering the gateway does not drop core events`() = runTest { val amount = 1_000 From 9a213521fab6683a361582b8fa0ca3a82687721a Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sun, 26 Mar 2023 17:47:20 +0200 Subject: [PATCH 037/136] Fix live tests failing --- .../src/commonTest/kotlin/KordTest.kt | 1 - .../src/commonTest/kotlin/StrategyTest.kt | 39 +++++++++-------- .../src/commonTest/kotlin/TestToken.kt | 39 +++++++++++++++++ .../kotlin/regression/CacheMissRegression.kt | 43 +++++-------------- 4 files changed, 69 insertions(+), 53 deletions(-) diff --git a/core/live-tests/src/commonTest/kotlin/KordTest.kt b/core/live-tests/src/commonTest/kotlin/KordTest.kt index 4a3f82ecff84..d3943a744942 100644 --- a/core/live-tests/src/commonTest/kotlin/KordTest.kt +++ b/core/live-tests/src/commonTest/kotlin/KordTest.kt @@ -14,6 +14,5 @@ internal class KordTest { val job = kord.on {} kord.shutdown() assertEquals(false, job.isActive) - } } diff --git a/core/live-tests/src/commonTest/kotlin/StrategyTest.kt b/core/live-tests/src/commonTest/kotlin/StrategyTest.kt index 01a30953f544..9d3131760ed3 100644 --- a/core/live-tests/src/commonTest/kotlin/StrategyTest.kt +++ b/core/live-tests/src/commonTest/kotlin/StrategyTest.kt @@ -9,41 +9,42 @@ class StrategyTest { lateinit var kord: Kord - @BeforeTest - fun setup() = runTest { - kord = Kord(testToken) - } - @Test @JsName("test1") fun `rest only`() = runTest { - val fromRest = kord.with(EntitySupplyStrategy.rest).getSelfOrNull() - val inCache = kord.with(EntitySupplyStrategy.cache).getSelfOrNull() - assertNull(inCache) - assertNotNull(fromRest) + withKord { kord -> + val fromRest = kord.with(EntitySupplyStrategy.rest).getSelfOrNull() + val inCache = kord.with(EntitySupplyStrategy.cache).getSelfOrNull() + assertNull(inCache) + assertNotNull(fromRest) + } } @Test @JsName("test2") fun `cache only`() = runTest { - - val inCache = kord.with(EntitySupplyStrategy.cache).getSelfOrNull() - assertNotNull(inCache) + withKord { kord -> + kord.cache.put(kord.getSelf().data) + val inCache = kord.with(EntitySupplyStrategy.cache).getSelfOrNull() + assertNotNull(inCache) + } } @Test @JsName("test3") fun `cache falls back to rest`() = runTest { - val cache = kord.with(EntitySupplyStrategy.cache) - val inCache = cache.getSelfOrNull() + withKord { kord -> + val cache = kord.with(EntitySupplyStrategy.cache) + val inCache = cache.getSelfOrNull() - assertNull(inCache) + assertNull(inCache) - val self = kord.getSelf() - assertNotNull(self) - kord.cache.put(self.data) + val self = kord.getSelf() + assertNotNull(self) + kord.cache.put(self.data) - assertEquals(self, cache.getSelf()) + assertEquals(self, cache.getSelf()) + } } } diff --git a/core/live-tests/src/commonTest/kotlin/TestToken.kt b/core/live-tests/src/commonTest/kotlin/TestToken.kt index 66fa24e474f7..b37a10568bf9 100644 --- a/core/live-tests/src/commonTest/kotlin/TestToken.kt +++ b/core/live-tests/src/commonTest/kotlin/TestToken.kt @@ -1,3 +1,42 @@ +import dev.kord.cache.map.MapDataCache +import dev.kord.core.ClientResources +import dev.kord.core.Kord +import dev.kord.core.builder.kord.configure +import dev.kord.core.builder.kord.getBotIdFromToken +import dev.kord.core.cache.registerKordData +import dev.kord.core.gateway.DefaultMasterGateway +import dev.kord.core.gateway.handler.DefaultGatewayEventInterceptor +import dev.kord.core.supplier.EntitySupplyStrategy +import dev.kord.gateway.builder.Shards +import dev.kord.rest.service.RestClient import dev.kord.test.getEnv +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.MutableSharedFlow +import regression.CrashingHandler +import regression.FakeGateway val testToken = getEnv("KORD_TEST_TOKEN") ?: error("KORD_TEST_TOKEN is not defined") + +suspend inline fun withKord(block: (kord: Kord) -> Unit) { + val token = testToken + val resources = ClientResources( + token, + getBotIdFromToken(token), + Shards(1), + maxConcurrency = 1, + null.configure(), + EntitySupplyStrategy.cacheWithRestFallback, + ) + val kord = Kord( + resources, + MapDataCache().also { it.registerKordData() }, + DefaultMasterGateway(mapOf(0 to FakeGateway)), + RestClient(CrashingHandler(resources.httpClient, resources.token)), + getBotIdFromToken(token), + MutableSharedFlow(extraBufferCapacity = Int.MAX_VALUE), + Dispatchers.Default, + DefaultGatewayEventInterceptor(), + ) + block(kord) + kord.shutdown() +} diff --git a/core/live-tests/src/commonTest/kotlin/regression/CacheMissRegression.kt b/core/live-tests/src/commonTest/kotlin/regression/CacheMissRegression.kt index 7185030f52f2..f51a95243f06 100644 --- a/core/live-tests/src/commonTest/kotlin/regression/CacheMissRegression.kt +++ b/core/live-tests/src/commonTest/kotlin/regression/CacheMissRegression.kt @@ -41,6 +41,7 @@ import kotlinx.coroutines.test.runTest import kotlinx.serialization.SerializationStrategy import kotlinx.serialization.json.Json import testToken +import withKord import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext import kotlin.js.JsName @@ -117,52 +118,28 @@ class CrashingHandler(val client: HttpClient, override val token: String) : Requ } class CacheMissingRegressions { - lateinit var kord: Kord - - @BeforeTest - fun setup() = runTest { //TODO, move this over to entity supplier tests instead, eventually. - val token = testToken - val resources = ClientResources( - token, - getBotIdFromToken(token), - Shards(1), - maxConcurrency = 1, - null.configure(), - EntitySupplyStrategy.cacheWithRestFallback, - ) - kord = Kord( - resources, - MapDataCache().also { it.registerKordData() }, - DefaultMasterGateway(mapOf(0 to FakeGateway)), - RestClient(CrashingHandler(resources.httpClient, resources.token)), - getBotIdFromToken(token), - MutableSharedFlow(extraBufferCapacity = Int.MAX_VALUE), - Dispatchers.Default, - DefaultGatewayEventInterceptor(), - ) - } - @Test @JsName("test1") - fun `if data not in cache explode`() { - val id = 5uL - assertFailsWith { - runTest { - kord.getChannel(Snowflake(id)) + fun `if data not in cache explode`() = runTest { + withKord { kord -> + val id = 5uL + assertFailsWith { + runTest { + kord.getChannel(Snowflake(id)) + } } } } @Test @JsName("test2") - fun `if data in cache don't fetch from rest`() { - runTest { + fun `if data in cache don't fetch from rest`() = runTest { + withKord { kord -> val id = Snowflake(5uL) kord.cache.put(ChannelData(id, ChannelType.GuildText)) kord.getChannel(id) } } - } From a63b62e3fce72aa1a57425c54e824345160cae7a Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sun, 26 Mar 2023 21:00:38 +0200 Subject: [PATCH 038/136] Fix live tests failing --- .../src/main/kotlin/kord-publishing.gradle.kts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts index 6bff04ef271e..68d5069a4710 100644 --- a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts @@ -5,14 +5,15 @@ plugins { signing } -if(tasks.findByName("dokkaHtml") != null) { - val dokkaJar by tasks.registering(Jar::class) { - group = JavaBasePlugin.DOCUMENTATION_GROUP - description = "Assembles Kotlin docs with Dokka" - archiveClassifier.set("javadoc") - from(tasks.getByName("dokkaHtml")) - } - publishing.publications.withType { +fun MavenPublication.addDokkaIfNeeded() { + if (tasks.findByName("dokkaHtml") != null) { + val platform = name.substringAfterLast('-') + val dokkaJar = tasks.register("${platform}DokkaJar", Jar::class) { + dependsOn("dokkaHtml") + archiveClassifier.set("javadoc") + destinationDirectory.set(buildDir.resolve(platform)) + from(tasks.getByName("dokkaHtml")) + } artifact(dokkaJar) } } @@ -20,6 +21,7 @@ if(tasks.findByName("dokkaHtml") != null) { publishing { publications { withType { + addDokkaIfNeeded() groupId = Library.group artifactId = "kord-${artifactId}" version = Library.version From 8970371dc072302e1719fa1549f9a0de7d1b201a Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sun, 26 Mar 2023 21:36:49 +0200 Subject: [PATCH 039/136] Fix task dependency --- .../kord-multiplatform-module.gradle.kts | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index b42a52684f83..7ee512dd3ff9 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -70,30 +70,32 @@ tasks { } } - configureDokka { - dependsOnKspKotlin("kspCommonMainKotlinMetadata") + afterEvaluate { + configureDokka { + dependsOnKspKotlin("kspCommonMainKotlinMetadata") - dokkaSourceSets { - val map = asMap + dokkaSourceSets { + val map = asMap - if (map.containsKey("jsMain")) { - named("jsMain") { - displayName.set("JS") + if (map.containsKey("jsMain")) { + named("jsMain") { + displayName.set("JS") + } } - } - if (map.containsKey("jvmMain")) { - named("jvmMain") { - displayName.set("JVM") + if (map.containsKey("jvmMain")) { + named("jvmMain") { + displayName.set("JVM") + } } - } - if (map.containsKey("commonMain")) { - named("jvmMain") { - displayName.set("Common") + if (map.containsKey("commonMain")) { + named("jvmMain") { + displayName.set("Common") + } } } - } + } } } From 255aaecffe452c9a7342d343cb23ea0a2dc6beb7 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sun, 26 Mar 2023 22:01:13 +0200 Subject: [PATCH 040/136] [ci skip] Fix duplicated publication --- .../main/kotlin/kord-publishing.gradle.kts | 16 +++--- .../dev/kord/common/entity/ButtonStyle.kt | 4 +- .../dev/kord/common/entity/ComponentType.kt | 5 +- .../dev/kord/common/entity/GuildFeature.kt | 52 +++-------------- .../entity/GuildScheduledEventStatus.kt | 4 +- .../entity/IntegrationExpireBehavior.kt | 4 +- .../kord/common/entity/MessageStickerType.kt | 2 +- .../dev/kord/common/entity/MessageType.kt | 57 +------------------ .../dev/kord/common/entity/PresenceStatus.kt | 4 +- .../kord/common/entity/ScheduledEntityType.kt | 4 +- .../entity/StageInstancePrivacyLevel.kt | 4 +- .../kord/common/entity/TeamMembershipState.kt | 4 +- .../behavior/channel/NewsChannelBehavior.kt | 1 + .../behavior/channel/TextChannelBehavior.kt | 1 + .../kotlin/builder/kord/KordBuilder.kt | 1 + .../src/commonMain/kotlin/DefaultGateway.kt | 5 -- rest/api/rest.api | 12 ++-- .../message/create/MessageCreateBuilder.kt | 19 ------- 18 files changed, 44 insertions(+), 155 deletions(-) diff --git a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts index 68d5069a4710..65f0fd7d3d7d 100644 --- a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts @@ -60,16 +60,16 @@ publishing { url.set(Library.projectUrl) } } + } - if (!isJitPack) { - repositories { - maven { - url = uri(if (Library.isSnapshot) Repo.snapshotsUrl else Repo.releasesUrl) + if (!isJitPack) { + repositories { + maven { + url = uri(if (Library.isSnapshot) Repo.snapshotsUrl else Repo.releasesUrl) - credentials { - username = System.getenv("NEXUS_USER") - password = System.getenv("NEXUS_PASSWORD") - } + credentials { + username = System.getenv("NEXUS_USER") + password = System.getenv("NEXUS_PASSWORD") } } } diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ButtonStyle.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ButtonStyle.kt index 2af04b4c42b4..1e61d640d012 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ButtonStyle.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ButtonStyle.kt @@ -96,14 +96,14 @@ public sealed class ButtonStyle( } @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Use 'ButtonStyle.serializer()' instead.", replaceWith = ReplaceWith(expression = "ButtonStyle.serializer()", imports = arrayOf("dev.kord.common.entity.ButtonStyle")), ) public object Serializer : KSerializer by NewSerializer { @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Use 'ButtonStyle.serializer()' instead.", replaceWith = ReplaceWith(expression = "ButtonStyle.serializer()", imports = arrayOf("dev.kord.common.entity.ButtonStyle")), diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ComponentType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ComponentType.kt index 70be45d6cb37..b1640f27c92a 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ComponentType.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ComponentType.kt @@ -95,6 +95,7 @@ public sealed class ComponentType( * A select menu for picking from choices. */ @Deprecated( + level = DeprecationLevel.ERROR, message = "Renamed by discord", replaceWith = ReplaceWith(expression = "StringSelect", imports = arrayOf("dev.kord.common.entity.ComponentType.StringSelect")), @@ -122,14 +123,14 @@ public sealed class ComponentType( } @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Use 'ComponentType.serializer()' instead.", replaceWith = ReplaceWith(expression = "ComponentType.serializer()", imports = arrayOf("dev.kord.common.entity.ComponentType")), ) public object Serializer : KSerializer by NewSerializer { @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Use 'ComponentType.serializer()' instead.", replaceWith = ReplaceWith(expression = "ComponentType.serializer()", imports = arrayOf("dev.kord.common.entity.ComponentType")), diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildFeature.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildFeature.kt index d7a1d11427b0..0bc82d268fba 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildFeature.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildFeature.kt @@ -183,22 +183,11 @@ public sealed class GuildFeature( */ public object WelcomeScreenEnabled : GuildFeature("WELCOME_SCREEN_ENABLED") - /** - * Guild has access to use commerce features (i.e. create store channels). - * - * @suppress - */ - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = - "Discord no longer offers the ability to purchase a license to sell PC games on Discord and store channels were removed on March 10, 2022. See https://support-dev.discord.com/hc/en-us/articles/6309018858647-Self-serve-Game-Selling-Deprecation for more information.", - ) - public object Commerce : GuildFeature("COMMERCE") - /** * Guild has enabled monetization. */ @Deprecated( + level = DeprecationLevel.ERROR, message = "Replaced by CreatorMonetizableProvisional.", replaceWith = ReplaceWith(expression = "GuildFeature.CreatorMonetizableProvisional", imports = arrayOf("dev.kord.common.entitiy.GuildFeature")), @@ -208,30 +197,11 @@ public sealed class GuildFeature( /** * Guild has access to create private threads */ - @Deprecated(message = "Creating a private thread no longer requires the server to be boosted.") - public object PrivateThreads : GuildFeature("PRIVATE_THREADS") - - /** - * Guild has access to the seven day archive time for threads. - * - * @suppress - */ @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Thread archive durations are no longer boost locked.", + level = DeprecationLevel.ERROR, + message = "Creating a private thread no longer requires the server to be boosted.", ) - public object SevenDayThreadArchive : GuildFeature("SEVEN_DAY_THREAD_ARCHIVE") - - /** - * Guild has access to the three-day archive time for threads. - * - * @suppress - */ - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Thread archive durations are no longer boost locked.", - ) - public object ThreeDayThreadArchive : GuildFeature("THREE_DAY_THREAD_ARCHIVE") + public object PrivateThreads : GuildFeature("PRIVATE_THREADS") internal object Serializer : KSerializer { public override val descriptor: SerialDescriptor = @@ -248,7 +218,6 @@ public sealed class GuildFeature( "APPLICATION_COMMAND_PERMISSIONS_V2" -> ApplicationCommandPermissionsV2 "AUTO_MODERATION" -> AutoModeration "BANNER" -> Banner - "COMMERCE" -> @Suppress("DEPRECATION_ERROR") Commerce "COMMUNITY" -> Community "CREATOR_MONETIZABLE_PROVISIONAL" -> CreatorMonetizableProvisional "CREATOR_STORE_PAGE" -> CreatorStorePage @@ -258,17 +227,15 @@ public sealed class GuildFeature( "INVITES_DISABLED" -> InvitesDisabled "INVITE_SPLASH" -> InviteSplash "MEMBER_VERIFICATION_GATE_ENABLED" -> MemberVerificationGateEnabled - "MONETIZATION_ENABLED" -> @Suppress("DEPRECATION") MonetizationEnabled + "MONETIZATION_ENABLED" -> @Suppress("DEPRECATION_ERROR") MonetizationEnabled "MORE_STICKERS" -> MoreStickers "NEWS" -> News "PARTNERED" -> Partnered "PREVIEW_ENABLED" -> PreviewEnabled - "PRIVATE_THREADS" -> @Suppress("DEPRECATION") PrivateThreads + "PRIVATE_THREADS" -> @Suppress("DEPRECATION_ERROR") PrivateThreads "ROLE_ICONS" -> RoleIcons "ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE" -> RoleSubscriptionsAvailableForPurchase "ROLE_SUBSCRIPTIONS_ENABLED" -> RoleSubscriptionsEnabled - "SEVEN_DAY_THREAD_ARCHIVE" -> @Suppress("DEPRECATION_ERROR") SevenDayThreadArchive - "THREE_DAY_THREAD_ARCHIVE" -> @Suppress("DEPRECATION_ERROR") ThreeDayThreadArchive "TICKETED_EVENTS_ENABLED" -> TicketedEventsEnabled "VANITY_URL" -> VanityUrl "VERIFIED" -> Verified @@ -289,7 +256,6 @@ public sealed class GuildFeature( ApplicationCommandPermissionsV2, AutoModeration, Banner, - @Suppress("DEPRECATION_ERROR") Commerce, Community, CreatorMonetizableProvisional, CreatorStorePage, @@ -299,17 +265,15 @@ public sealed class GuildFeature( InvitesDisabled, InviteSplash, MemberVerificationGateEnabled, - @Suppress("DEPRECATION") MonetizationEnabled, + @Suppress("DEPRECATION_ERROR") MonetizationEnabled, MoreStickers, News, Partnered, PreviewEnabled, - @Suppress("DEPRECATION") PrivateThreads, + @Suppress("DEPRECATION_ERROR") PrivateThreads, RoleIcons, RoleSubscriptionsAvailableForPurchase, RoleSubscriptionsEnabled, - @Suppress("DEPRECATION_ERROR") SevenDayThreadArchive, - @Suppress("DEPRECATION_ERROR") ThreeDayThreadArchive, TicketedEventsEnabled, VanityUrl, Verified, diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildScheduledEventStatus.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildScheduledEventStatus.kt index 73e7473d93bf..bc70863d26ff 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildScheduledEventStatus.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/GuildScheduledEventStatus.kt @@ -78,14 +78,14 @@ public sealed class GuildScheduledEventStatus( } @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Use 'GuildScheduledEventStatus.serializer()' instead.", replaceWith = ReplaceWith(expression = "GuildScheduledEventStatus.serializer()", imports = arrayOf("dev.kord.common.entity.GuildScheduledEventStatus")), ) public object Serializer : KSerializer by NewSerializer { @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Use 'GuildScheduledEventStatus.serializer()' instead.", replaceWith = ReplaceWith(expression = "GuildScheduledEventStatus.serializer()", imports = arrayOf("dev.kord.common.entity.GuildScheduledEventStatus")), diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/IntegrationExpireBehavior.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/IntegrationExpireBehavior.kt index 401753d3b492..be12f6c672e9 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/IntegrationExpireBehavior.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/IntegrationExpireBehavior.kt @@ -72,14 +72,14 @@ public sealed class IntegrationExpireBehavior( } @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Use 'IntegrationExpireBehavior.serializer()' instead.", replaceWith = ReplaceWith(expression = "IntegrationExpireBehavior.serializer()", imports = arrayOf("dev.kord.common.entity.IntegrationExpireBehavior")), ) public object Serializer : KSerializer by NewSerializer { @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Use 'IntegrationExpireBehavior.serializer()' instead.", replaceWith = ReplaceWith(expression = "IntegrationExpireBehavior.serializer()", imports = arrayOf("dev.kord.common.entity.IntegrationExpireBehavior")), diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageStickerType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageStickerType.kt index 7fe0dfdade5d..e641439efbfc 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageStickerType.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageStickerType.kt @@ -91,7 +91,7 @@ public sealed class MessageStickerType( @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Renamed to 'entries'.", replaceWith = ReplaceWith(expression = "this.entries", imports = arrayOf()), ) diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageType.kt index 64f973848123..4cbc5066bae5 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageType.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/MessageType.kt @@ -113,61 +113,6 @@ public sealed class MessageType( public object GuildApplicationPremiumSubscription : MessageType(32) - /** - * @suppress - */ - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Renamed to 'UserJoin'.", - replaceWith = ReplaceWith(expression = "UserJoin", imports = - arrayOf("dev.kord.common.entity.MessageType.UserJoin")), - ) - public object GuildMemberJoin : MessageType(7) - - /** - * @suppress - */ - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Renamed to 'GuildBoost'.", - replaceWith = ReplaceWith(expression = "GuildBoost", imports = - arrayOf("dev.kord.common.entity.MessageType.GuildBoost")), - ) - public object UserPremiumGuildSubscription : MessageType(8) - - /** - * @suppress - */ - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Renamed to 'GuildBoostTier1'.", - replaceWith = ReplaceWith(expression = "GuildBoostTier1", imports = - arrayOf("dev.kord.common.entity.MessageType.GuildBoostTier1")), - ) - public object UserPremiumGuildSubscriptionTierOne : MessageType(9) - - /** - * @suppress - */ - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Renamed to 'GuildBoostTier2'.", - replaceWith = ReplaceWith(expression = "GuildBoostTier2", imports = - arrayOf("dev.kord.common.entity.MessageType.GuildBoostTier2")), - ) - public object UserPremiumGuildSubscriptionTwo : MessageType(10) - - /** - * @suppress - */ - @Deprecated( - level = DeprecationLevel.HIDDEN, - message = "Renamed to 'GuildBoostTier3'.", - replaceWith = ReplaceWith(expression = "GuildBoostTier3", imports = - arrayOf("dev.kord.common.entity.MessageType.GuildBoostTier3")), - ) - public object UserPremiumGuildSubscriptionThree : MessageType(11) - internal object Serializer : KSerializer { public override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("dev.kord.common.entity.MessageType", PrimitiveKind.INT) @@ -253,7 +198,7 @@ public sealed class MessageType( @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Renamed to 'entries'.", replaceWith = ReplaceWith(expression = "this.entries", imports = arrayOf()), ) diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/PresenceStatus.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/PresenceStatus.kt index 941954c578de..0883027dbe3b 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/PresenceStatus.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/PresenceStatus.kt @@ -96,14 +96,14 @@ public sealed class PresenceStatus( } @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Use 'PresenceStatus.serializer()' instead.", replaceWith = ReplaceWith(expression = "PresenceStatus.serializer()", imports = arrayOf("dev.kord.common.entity.PresenceStatus")), ) public object StatusSerializer : KSerializer by Serializer { @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Use 'PresenceStatus.serializer()' instead.", replaceWith = ReplaceWith(expression = "PresenceStatus.serializer()", imports = arrayOf("dev.kord.common.entity.PresenceStatus")), diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ScheduledEntityType.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ScheduledEntityType.kt index 9f56df8ae1b2..7103621e6889 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ScheduledEntityType.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/ScheduledEntityType.kt @@ -74,14 +74,14 @@ public sealed class ScheduledEntityType( } @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Use 'ScheduledEntityType.serializer()' instead.", replaceWith = ReplaceWith(expression = "ScheduledEntityType.serializer()", imports = arrayOf("dev.kord.common.entity.ScheduledEntityType")), ) public object Serializer : KSerializer by NewSerializer { @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Use 'ScheduledEntityType.serializer()' instead.", replaceWith = ReplaceWith(expression = "ScheduledEntityType.serializer()", imports = arrayOf("dev.kord.common.entity.ScheduledEntityType")), diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/StageInstancePrivacyLevel.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/StageInstancePrivacyLevel.kt index e6511fdd1c24..b90dad5dc8ed 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/StageInstancePrivacyLevel.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/StageInstancePrivacyLevel.kt @@ -79,14 +79,14 @@ public sealed class StageInstancePrivacyLevel( } @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Use 'StageInstancePrivacyLevel.serializer()' instead.", replaceWith = ReplaceWith(expression = "StageInstancePrivacyLevel.serializer()", imports = arrayOf("dev.kord.common.entity.StageInstancePrivacyLevel")), ) public object Serializer : KSerializer by NewSerializer { @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Use 'StageInstancePrivacyLevel.serializer()' instead.", replaceWith = ReplaceWith(expression = "StageInstancePrivacyLevel.serializer()", imports = arrayOf("dev.kord.common.entity.StageInstancePrivacyLevel")), diff --git a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/TeamMembershipState.kt b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/TeamMembershipState.kt index 4bf0d827782b..9d0d97d68f90 100644 --- a/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/TeamMembershipState.kt +++ b/common/build/generated/ksp/metadata/commonMain/kotlin/dev/kord/common/entity/TeamMembershipState.kt @@ -71,14 +71,14 @@ public sealed class TeamMembershipState( } @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Use 'TeamMembershipState.serializer()' instead.", replaceWith = ReplaceWith(expression = "TeamMembershipState.serializer()", imports = arrayOf("dev.kord.common.entity.TeamMembershipState")), ) public object TeamMembershipStateSerializer : KSerializer by Serializer { @Deprecated( - level = DeprecationLevel.ERROR, + level = DeprecationLevel.HIDDEN, message = "Use 'TeamMembershipState.serializer()' instead.", replaceWith = ReplaceWith(expression = "TeamMembershipState.serializer()", imports = arrayOf("dev.kord.common.entity.TeamMembershipState")), diff --git a/core/src/commonMain/kotlin/behavior/channel/NewsChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/NewsChannelBehavior.kt index cc5b7bd3e84e..3efed3886a38 100644 --- a/core/src/commonMain/kotlin/behavior/channel/NewsChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/NewsChannelBehavior.kt @@ -27,6 +27,7 @@ import kotlinx.coroutines.flow.filterIsInstance import kotlinx.datetime.Instant import kotlin.DeprecationLevel.WARNING import dev.kord.core.hash +import kotlin.DeprecationLevel.ERROR import kotlin.contracts.InvocationKind import kotlin.contracts.contract diff --git a/core/src/commonMain/kotlin/behavior/channel/TextChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/TextChannelBehavior.kt index b36e9184388e..9f0adb47e6c2 100644 --- a/core/src/commonMain/kotlin/behavior/channel/TextChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/TextChannelBehavior.kt @@ -25,6 +25,7 @@ import kotlinx.coroutines.flow.filterIsInstance import kotlinx.datetime.Instant import kotlin.DeprecationLevel.WARNING import dev.kord.core.hash +import kotlin.DeprecationLevel.ERROR import kotlin.contracts.InvocationKind import kotlin.contracts.contract diff --git a/core/src/commonMain/kotlin/builder/kord/KordBuilder.kt b/core/src/commonMain/kotlin/builder/kord/KordBuilder.kt index 224544929bc8..93abacf1b3b3 100644 --- a/core/src/commonMain/kotlin/builder/kord/KordBuilder.kt +++ b/core/src/commonMain/kotlin/builder/kord/KordBuilder.kt @@ -39,6 +39,7 @@ import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.serialization.json.Json import mu.KotlinLogging import kotlin.DeprecationLevel.ERROR +import kotlin.DeprecationLevel.HIDDEN import kotlin.contracts.InvocationKind import kotlin.contracts.contract import kotlin.time.Duration.Companion.seconds diff --git a/gateway/src/commonMain/kotlin/DefaultGateway.kt b/gateway/src/commonMain/kotlin/DefaultGateway.kt index a0d4b54dfb27..d820f4e2fb42 100644 --- a/gateway/src/commonMain/kotlin/DefaultGateway.kt +++ b/gateway/src/commonMain/kotlin/DefaultGateway.kt @@ -25,14 +25,9 @@ import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import kotlinx.serialization.json.Json import mu.KotlinLogging -import java.io.ByteArrayOutputStream -import java.util.zip.Inflater -import java.util.zip.InflaterOutputStream -import kotlin.DeprecationLevel.HIDDEN import kotlin.contracts.InvocationKind import kotlin.contracts.contract import kotlin.coroutines.CoroutineContext -import kotlin.jvm.JvmName import kotlin.time.Duration private val defaultGatewayLogger = KotlinLogging.logger { } diff --git a/rest/api/rest.api b/rest/api/rest.api index f4c6fee32552..04184fde7268 100644 --- a/rest/api/rest.api +++ b/rest/api/rest.api @@ -352,10 +352,10 @@ public final class dev/kord/rest/builder/automoderation/UntypedAutoModerationRul public final class dev/kord/rest/builder/ban/BanCreateBuilder : dev/kord/rest/builder/AuditRequestBuilder { public fun ()V public final fun getDeleteMessageDuration-FghU774 ()Lkotlin/time/Duration; - public final fun getDeleteMessagesDays ()Ljava/lang/Integer; + public final synthetic fun getDeleteMessagesDays ()Ljava/lang/Integer; public fun getReason ()Ljava/lang/String; public final fun setDeleteMessageDuration-BwNAW2A (Lkotlin/time/Duration;)V - public final fun setDeleteMessagesDays (Ljava/lang/Integer;)V + public final synthetic fun setDeleteMessagesDays (Ljava/lang/Integer;)V public fun setReason (Ljava/lang/String;)V public fun toRequest ()Ldev/kord/rest/json/request/GuildBanCreateRequest; public synthetic fun toRequest ()Ljava/lang/Object; @@ -990,7 +990,7 @@ public final class dev/kord/rest/builder/component/UserSelectBuilder : dev/kord/ public final class dev/kord/rest/builder/guild/CurrentVoiceStateModifyBuilder : dev/kord/rest/builder/RequestBuilder { public fun ()V - public fun (Ldev/kord/common/entity/Snowflake;)V + public synthetic fun (Ldev/kord/common/entity/Snowflake;)V public final fun getChannelId ()Ldev/kord/common/entity/Snowflake; public final fun getRequestToSpeakTimestamp ()Lkotlinx/datetime/Instant; public final fun getSuppress ()Ljava/lang/Boolean; @@ -3699,8 +3699,8 @@ public final class dev/kord/rest/json/request/GuildBanCreateRequest { public static synthetic fun copy$default (Ldev/kord/rest/json/request/GuildBanCreateRequest;Ldev/kord/common/entity/optional/Optional;Ldev/kord/common/entity/optional/OptionalInt;Ldev/kord/common/entity/optional/Optional;ILjava/lang/Object;)Ldev/kord/rest/json/request/GuildBanCreateRequest; public fun equals (Ljava/lang/Object;)Z public final fun getDeleteMessageSeconds ()Ldev/kord/common/entity/optional/Optional; - public final fun getDeleteMessagesDays ()Ldev/kord/common/entity/optional/OptionalInt; - public final fun getReason ()Ldev/kord/common/entity/optional/Optional; + public final synthetic fun getDeleteMessagesDays ()Ldev/kord/common/entity/optional/OptionalInt; + public final synthetic fun getReason ()Ldev/kord/common/entity/optional/Optional; public fun hashCode ()I public fun toString ()Ljava/lang/String; public static final fun write$Self (Ldev/kord/rest/json/request/GuildBanCreateRequest;Lkotlinx/serialization/encoding/CompositeEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;)V @@ -7156,7 +7156,7 @@ public final class dev/kord/rest/service/GuildServiceKt { public static synthetic fun createScheduledEvent$default (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Ldev/kord/common/entity/GuildScheduledEventPrivacyLevel;Lkotlinx/datetime/Instant;Ldev/kord/common/entity/ScheduledEntityType;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public static final fun createTextChannel (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun createVoiceChannel (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static final fun modifyCurrentVoiceState (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final synthetic fun modifyCurrentVoiceState (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun modifyCurrentVoiceState (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun modifyGuildWelcomeScreen (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun modifyScheduledEvent (Ldev/kord/rest/service/GuildService;Ldev/kord/common/entity/Snowflake;Ldev/kord/common/entity/Snowflake;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; diff --git a/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt index 3bfc3eef4e05..529268f595e0 100644 --- a/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt @@ -71,25 +71,6 @@ public sealed interface MessageCreateBuilder { */ public var suppressNotifications: Boolean? - /** - * Adds a file with the [name] and [content] to the attachments. - * - * @suppress - */ - @Deprecated( - "Use lazy ChannelProvider instead of InputStream. You should also make sure that the stream/channel is only " + - "opened inside the block of the ChannelProvider because it could otherwise be read multiple times " + - "(which isn't allowed).", - ReplaceWith( - "addFile(name, ChannelProvider { content.toByteReadChannel() })", - "io.ktor.client.request.forms.ChannelProvider", - "io.ktor.utils.io.jvm.javaio.toByteReadChannel", - ), - level = ERROR, - ) - public fun addFile(name: String, content: InputStream): NamedFile = - addFile(name, ChannelProvider { content.toByteReadChannel() }) - /** * Adds a file with the [name] and [contentProvider] to the attachments. */ From 79de31e627c735e53b8fe793fda4b42a5af2eaa4 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sun, 26 Mar 2023 22:30:56 +0200 Subject: [PATCH 041/136] Trigger CI From 9eaaaa5e44b6416bd74b6bf96c6669ec0d1f7f96 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 27 Mar 2023 09:05:26 +0200 Subject: [PATCH 042/136] Apply some requested changes --- .gitignore | 3 --- CHANGELOG.md | 2 +- build.gradle.kts | 6 ----- buildSrc/src/main/kotlin/Compiler.kt | 13 ++++++++++ .../src/main/kotlin/kord-module.gradle.kts | 6 +---- .../kord-multiplatform-module.gradle.kts | 25 ++----------------- .../main/kotlin/kord-publishing.gradle.kts | 21 ++++++---------- common/build.gradle.kts | 9 ++----- common/src/commonMain/kotlin/Color.kt | 2 ++ .../kotlin/entity/DiscordActivity.kt | 3 +-- .../commonTest/kotlin/entity/SnowflakeTest.kt | 10 -------- common/src/jvmMain/kotlin/Color.kt | 1 - .../jvmTest/kotlin/entity/SnowflakeTest.kt | 18 +++++++++++++ core/build.gradle.kts | 7 ------ gateway/build.gradle.kts | 3 --- rest/build.gradle.kts | 5 ---- 16 files changed, 47 insertions(+), 87 deletions(-) create mode 100644 common/src/jvmTest/kotlin/entity/SnowflakeTest.kt diff --git a/.gitignore b/.gitignore index 4635b15ea70d..e46f4d6a2cc7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,3 @@ out/ !**/build/generated/ # re-exclude BuildConfigGenerated.kt common/build/generated/source/buildConfig/main/main/dev/kord/common/BuildConfigGenerated.kt - -# Schlaubi's js testing project -js-test/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bf2e9eb53d0..e490471ada3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1041,7 +1041,7 @@ exist. #74 * `Kord#gateway` is now a `MasterGateway`, exposing all sharded gateways #65 * `core` Events now expose their shard index as well as the `Gateway` they were spawned from. #65 * `DisconnectEvent` and `Close` have been extended with more detailed implementations #65 -* `Gateway` now accepts a `PresenceBuilder` to applyKordSourceSetOptions its original presence. #72 +* `Gateway` now accepts a `PresenceBuilder` to configure its original presence. #72 * Rest Discord API version can now be configured by setting the `com.gitlab.kordlib.rest.version` system property, `v6` by default. * `DefaultGateway` now supports zlib compression and enables it by default. diff --git a/build.gradle.kts b/build.gradle.kts index c6dab6323252..f15881c2309d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,11 +2,5 @@ plugins { org.jetbrains.dokka // for dokkaHtmlMultiModule task } -allprojects { - repositories { - mavenCentral() - } -} - group = Library.group version = Library.version diff --git a/buildSrc/src/main/kotlin/Compiler.kt b/buildSrc/src/main/kotlin/Compiler.kt index 384dbd2c349e..1bbff57cd3f0 100644 --- a/buildSrc/src/main/kotlin/Compiler.kt +++ b/buildSrc/src/main/kotlin/Compiler.kt @@ -1,4 +1,9 @@ +import kotlinx.atomicfu.plugin.gradle.AtomicFUPluginExtension import org.gradle.api.NamedDomainObjectContainer +import org.gradle.api.Project +import org.gradle.api.artifacts.VersionCatalogsExtension +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.getByType import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet @@ -52,3 +57,11 @@ fun NamedDomainObjectContainer.applyKordSourceSetOptions() { } } } + +fun Project.configureAtomicFU() { + // https://github.com/Kotlin/kotlinx-atomicfu/issues/210 + configure { + val libs = extensions.getByType().named("libs") + dependenciesVersion = libs.findVersion("kotlinx-atomicfu").get().requiredVersion + } +} diff --git a/buildSrc/src/main/kotlin/kord-module.gradle.kts b/buildSrc/src/main/kotlin/kord-module.gradle.kts index 5f090aa34b98..4a3654293e8b 100644 --- a/buildSrc/src/main/kotlin/kord-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-module.gradle.kts @@ -31,11 +31,7 @@ kotlin { } } -// https://github.com/Kotlin/kotlinx-atomicfu/issues/210 -atomicfu { - val libs = extensions.getByType().named("libs") - dependenciesVersion = libs.findVersion("kotlinx-atomicfu").get().requiredVersion -} +configureAtomicFU() tasks { withType { diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index 7ee512dd3ff9..33e5b56de404 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -53,6 +53,8 @@ kotlin { } } +configureAtomicFU() + tasks { getByName("jvmTest") { useJUnitPlatform() @@ -73,29 +75,6 @@ tasks { afterEvaluate { configureDokka { dependsOnKspKotlin("kspCommonMainKotlinMetadata") - - dokkaSourceSets { - val map = asMap - - if (map.containsKey("jsMain")) { - named("jsMain") { - displayName.set("JS") - } - } - - if (map.containsKey("jvmMain")) { - named("jvmMain") { - displayName.set("JVM") - } - } - - if (map.containsKey("commonMain")) { - named("jvmMain") { - displayName.set("Common") - } - } - } - } } } diff --git a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts index 65f0fd7d3d7d..964fad0190e7 100644 --- a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts @@ -5,23 +5,16 @@ plugins { signing } -fun MavenPublication.addDokkaIfNeeded() { - if (tasks.findByName("dokkaHtml") != null) { - val platform = name.substringAfterLast('-') - val dokkaJar = tasks.register("${platform}DokkaJar", Jar::class) { - dependsOn("dokkaHtml") - archiveClassifier.set("javadoc") - destinationDirectory.set(buildDir.resolve(platform)) - from(tasks.getByName("dokkaHtml")) - } - artifact(dokkaJar) - } -} - publishing { publications { withType { - addDokkaIfNeeded() + val platform = name.substringAfterLast('-') + val dokkaJar = tasks.register("${platform}DokkaJar", Jar::class) { + archiveClassifier.set("javadoc") + destinationDirectory.set(buildDir.resolve(platform)) + from(tasks.getByName("dokkaHtml")) + } + artifact(dokkaJar) groupId = Library.group artifactId = "kord-${artifactId}" version = Library.version diff --git a/common/build.gradle.kts b/common/build.gradle.kts index f705aad199a3..920f8234e320 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -2,8 +2,6 @@ plugins { `kord-multiplatform-module` `kord-publishing` - `kotlinx-atomicfu` - `kotlinx-serialization` alias(libs.plugins.buildconfig) } @@ -20,8 +18,6 @@ kotlin { api(libs.ktor.client.core) compileOnly(projects.kspAnnotations) - // The plugin should add this automatically, but it doesn't - compileOnly(libs.kotlinx.atomicfu) } } jvmMain { @@ -31,9 +27,8 @@ kotlin { } nonJvm { dependencies { - api(libs.bignum) - - api(libs.bundles.stately) + implementation(libs.bignum) + implementation(libs.bundles.stately) } } jsMain { diff --git a/common/src/commonMain/kotlin/Color.kt b/common/src/commonMain/kotlin/Color.kt index fbc6fa790919..4052f9c25a98 100644 --- a/common/src/commonMain/kotlin/Color.kt +++ b/common/src/commonMain/kotlin/Color.kt @@ -1,3 +1,4 @@ +@file:JvmName("ColorCommon") package dev.kord.common import kotlinx.serialization.KSerializer @@ -7,6 +8,7 @@ import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder +import kotlin.jvm.JvmName @Serializable(with = Color.Serializer::class) diff --git a/common/src/commonMain/kotlin/entity/DiscordActivity.kt b/common/src/commonMain/kotlin/entity/DiscordActivity.kt index 407ad6f9ed0e..dd1dd521d966 100644 --- a/common/src/commonMain/kotlin/entity/DiscordActivity.kt +++ b/common/src/commonMain/kotlin/entity/DiscordActivity.kt @@ -197,8 +197,7 @@ public sealed class ActivityType(public val code: Int) { @Deprecated("Binary compatibility", level = HIDDEN) @JvmField public val Listening: ActivityType = Listening @Deprecated("Binary compatibility", level = HIDDEN) @JvmField public val Watching: ActivityType = Watching @Deprecated("Binary compatibility", level = HIDDEN) @JvmField public val Custom: ActivityType = Custom - @Deprecated("Binary compatibility", level = HIDDEN) @JvmField - public val Competing: ActivityType = Competing + @Deprecated("Binary compatibility", level = HIDDEN) @JvmField public val Competing: ActivityType = Competing // @formatter:on /** @suppress */ diff --git a/common/src/commonTest/kotlin/entity/SnowflakeTest.kt b/common/src/commonTest/kotlin/entity/SnowflakeTest.kt index 2ad05062d6b7..5cc6a36c08e2 100644 --- a/common/src/commonTest/kotlin/entity/SnowflakeTest.kt +++ b/common/src/commonTest/kotlin/entity/SnowflakeTest.kt @@ -129,14 +129,4 @@ class SnowflakeTest { assertEquals(0, compare(c, f)) } } - - @Test - @JsName("test13") - fun `Snowflake's natural order works with SortedSets`() { - val a = Snowflake(0b0_00000_00000_000000000000_u) - val b = Snowflake(0b0_00000_00000_000000000001_u) - val c = Snowflake(0b1_00000_00000_000000000000_u) - assertEquals(2, setOf(a, b).size) - assertEquals(2, setOf(a, c).size) - } } diff --git a/common/src/jvmMain/kotlin/Color.kt b/common/src/jvmMain/kotlin/Color.kt index be091030b16d..4365fe39e493 100644 --- a/common/src/jvmMain/kotlin/Color.kt +++ b/common/src/jvmMain/kotlin/Color.kt @@ -1,4 +1,3 @@ -@file:JvmName("ColorJvm") package dev.kord.common import java.awt.Color as AwtColor diff --git a/common/src/jvmTest/kotlin/entity/SnowflakeTest.kt b/common/src/jvmTest/kotlin/entity/SnowflakeTest.kt new file mode 100644 index 000000000000..5455e680d633 --- /dev/null +++ b/common/src/jvmTest/kotlin/entity/SnowflakeTest.kt @@ -0,0 +1,18 @@ +@file:JvmName("SnowflakeTestJvm") + +package entity + +import dev.kord.common.entity.Snowflake +import org.junit.jupiter.api.Test +import kotlin.test.assertEquals + +class SnowflakeTest { + @Test + fun `Snowflake's natural order works with SortedSets`() { + val a = Snowflake(0b0_00000_00000_000000000000_u) + val b = Snowflake(0b0_00000_00000_000000000001_u) + val c = Snowflake(0b1_00000_00000_000000000000_u) + assertEquals(2, sortedSetOf(a, b).size) + assertEquals(2, sortedSetOf(a, c).size) + } +} diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 0be975fe78fe..f5153b8b177b 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -17,13 +17,6 @@ kotlin { } } - commonTest { - dependencies { - // The plugin should add this automatically, but it doesn't - compileOnly(libs.kotlinx.atomicfu) - } - } - jvmTest { dependencies { implementation(libs.mockk) diff --git a/gateway/build.gradle.kts b/gateway/build.gradle.kts index 5b71cfa416e1..d6d5ad13c390 100644 --- a/gateway/build.gradle.kts +++ b/gateway/build.gradle.kts @@ -15,9 +15,6 @@ kotlin { api(libs.ktor.client.core) api(libs.kotlinx.coroutines.core) api(libs.ktor.client.websockets) - - // The plugin should add this automatically, but it doesn't - compileOnly(libs.kotlinx.atomicfu) } } diff --git a/rest/build.gradle.kts b/rest/build.gradle.kts index b555bd2bee3d..51619503d499 100644 --- a/rest/build.gradle.kts +++ b/rest/build.gradle.kts @@ -15,11 +15,7 @@ kotlin { api(libs.bundles.ktor.client.serialization) api(libs.ktor.client.core) - api(libs.bundles.stately) compileOnly(projects.kspAnnotations) - - // The plugin should add this automatically, but it doesn't - compileOnly(libs.kotlinx.atomicfu) } } @@ -36,7 +32,6 @@ kotlin { } } - jvmMain { dependencies { api(libs.ktor.client.cio) From 0b4569e3b2a231076d6e3bbc97f818974e701188 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 27 Mar 2023 09:24:39 +0200 Subject: [PATCH 043/136] Fix dokkaHtmlMultiModule task --- core/live-tests/build.gradle.kts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/live-tests/build.gradle.kts b/core/live-tests/build.gradle.kts index d9127713159d..823d474a414c 100644 --- a/core/live-tests/build.gradle.kts +++ b/core/live-tests/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.dokka.gradle.DokkaTaskPartial + plugins { `kord-internal-multiplatform-module` } @@ -18,4 +20,9 @@ tasks { withType { enabled = !System.getenv("KORD_TEST_TOKEN").isNullOrBlank() } + + // Replace this once proper project isolation support is there + task("dokkaHtmlPartial") { + enabled = false + } } From 78b9500ac9d903dd5a6f9249583a839ef713d2ae Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 27 Mar 2023 09:27:58 +0200 Subject: [PATCH 044/136] Apply suggestions from code review Co-authored-by: Lukellmann <47486203+Lukellmann@users.noreply.github.com> --- buildSrc/src/main/kotlin/Documentation.kt | 2 +- common/src/commonTest/kotlin/json/PermissionsTest.kt | 2 +- common/src/jvmMain/kotlin/Platform.kt | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/buildSrc/src/main/kotlin/Documentation.kt b/buildSrc/src/main/kotlin/Documentation.kt index 2dab4c5eec0e..6bbb687664b1 100644 --- a/buildSrc/src/main/kotlin/Documentation.kt +++ b/buildSrc/src/main/kotlin/Documentation.kt @@ -17,7 +17,7 @@ fun TaskContainer.configureDokka(additionalConfiguration: AbstractDokkaLeafTask. jdkVersion.set(Jvm.target) val baseRemoteUrl = - "https://github.com/kordlib/kord/blob/${Library.commitHashOrDefault("0.8.x")}/${project.name}" + "https://github.com/kordlib/kord/blob/${Library.commitHashOrDefault("0.9.x")}/${project.name}" sourceLink { localDirectory.set(project.file("src/main/kotlin")) diff --git a/common/src/commonTest/kotlin/json/PermissionsTest.kt b/common/src/commonTest/kotlin/json/PermissionsTest.kt index 7d6eafe681de..ce73e1ade9d3 100644 --- a/common/src/commonTest/kotlin/json/PermissionsTest.kt +++ b/common/src/commonTest/kotlin/json/PermissionsTest.kt @@ -40,7 +40,7 @@ class PermissionsTest { } val actual = Json.decodeFromJsonElement(DiscordRole.serializer(), expected) assertEquals( - actual.permissions.code.value, "123456789876543000000000000", + "123456789876543000000000000", actual.permissions.code.value, "1234567898765430000000000 was expected but ${actual.permissions.code.value} was found" ) diff --git a/common/src/jvmMain/kotlin/Platform.kt b/common/src/jvmMain/kotlin/Platform.kt index 20ce8f8b9bd3..fefb5e165114 100644 --- a/common/src/jvmMain/kotlin/Platform.kt +++ b/common/src/jvmMain/kotlin/Platform.kt @@ -1,7 +1,7 @@ package dev.kord.common public actual object Platform { - public actual val IS_JVM: Boolean = true - public actual val IS_NODE: Boolean = false - public actual val IS_BROWSER: Boolean = false + public actual const val IS_JVM: Boolean = true + public actual const val IS_NODE: Boolean = false + public actual const val IS_BROWSER: Boolean = false } From 1e6c4606b9bd5810cd2c94762f82f36b59e2d044 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 27 Mar 2023 09:28:45 +0200 Subject: [PATCH 045/136] Update gradle/libs.versions.toml Co-authored-by: Lukellmann <47486203+Lukellmann@users.noreply.github.com> --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ae997ccdd019..630f71f61e7c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,7 +6,7 @@ ktor = "2.2.4" # https://github.com/ktorio/ktor kotlinx-coroutines = "1.6.4" # https://github.com/Kotlin/kotlinx.coroutines kotlinx-serialization = "1.5.0" # https://github.com/Kotlin/kotlinx.serialization kotlinx-datetime = "0.4.0" # https://github.com/Kotlin/kotlinx-datetime -kotlin-logging = "3.0.5" # https://github.com/MicroUtils/kotlin-logging +kotlin-logging = "3.0.5" # https://github.com/oshai/kotlin-logging kord-cache = "0.4.0" stately = "2.0.0-rc1" From 24fe65ab09d0f148c9dc2459de7e7da6d0d1fc71 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 27 Mar 2023 09:26:16 +0200 Subject: [PATCH 046/136] No longer apply compiler options to internal module --- .../kotlin/kord-internal-multiplatform-module.gradle.kts | 7 ------- core/live-tests/build.gradle.kts | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts index 603f4a4348a7..2e777b44d2c6 100644 --- a/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts @@ -16,11 +16,4 @@ kotlin { sourceSets { applyKordSourceSetOptions() } - targets { - all { - compilations.all { - compilerOptions.options.applyKordCompilerOptions() - } - } - } } diff --git a/core/live-tests/build.gradle.kts b/core/live-tests/build.gradle.kts index 823d474a414c..f450e2f9ce75 100644 --- a/core/live-tests/build.gradle.kts +++ b/core/live-tests/build.gradle.kts @@ -14,6 +14,13 @@ kotlin { } addTestKit(targets) } + targets { + all { + compilations.all { + compilerOptions.options.applyKordCompilerOptions() + } + } + } } tasks { From 62f88ddfa986b76ade4052fb22c315364a4fe812 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 27 Mar 2023 09:26:46 +0200 Subject: [PATCH 047/136] Remove outdated link --- buildSrc/src/main/kotlin/Documentation.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/Documentation.kt b/buildSrc/src/main/kotlin/Documentation.kt index 6bbb687664b1..180abbb67842 100644 --- a/buildSrc/src/main/kotlin/Documentation.kt +++ b/buildSrc/src/main/kotlin/Documentation.kt @@ -5,8 +5,6 @@ import java.net.URL fun TaskContainer.configureDokka(additionalConfiguration: AbstractDokkaLeafTask.() -> Unit = {}) { withType().configureEach { - // see https://kotlin.github.io/dokka//user_guide/gradle/usage/#configuration-options - // include documentation generated by ksp dependsOnKspKotlin() From 00c7f623195a8760aa3b8698ad3331a1ee2a963b Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 27 Mar 2023 09:30:17 +0200 Subject: [PATCH 048/136] Use more explicit names for integer formatting --- common/src/commonMain/kotlin/DiscordBitSet.kt | 8 ++++---- common/src/jvmMain/kotlin/DiscordBitSet.kt | 4 ++-- common/src/nonJvm/kotlin/DiscordBitSet.kt | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/src/commonMain/kotlin/DiscordBitSet.kt b/common/src/commonMain/kotlin/DiscordBitSet.kt index 6bd593683388..2ef5c9dcbab9 100644 --- a/common/src/commonMain/kotlin/DiscordBitSet.kt +++ b/common/src/commonMain/kotlin/DiscordBitSet.kt @@ -20,8 +20,8 @@ private const val WIDTH = Long.SIZE_BITS @Suppress("FunctionName") public fun EmptyBitSet(): DiscordBitSet = DiscordBitSet() -internal expect fun formatIntegerFromByteArray(data: ByteArray): String -internal expect fun parseIntegerToByteArray(value: String): ByteArray +internal expect fun formatBigEndianIntegerFromByteArray(data: ByteArray): String +internal expect fun parseBigEndianIntegerToByteArray(value: String): ByteArray @Serializable(with = DiscordBitSetSerializer::class) public class DiscordBitSet(internal var data: LongArray) { // data is in little-endian order @@ -34,7 +34,7 @@ public class DiscordBitSet(internal var data: LongArray) { // data is in little- // need to convert from little-endian data to big-endian expected by BigInteger return withBuffer(data.size * Long.SIZE_BYTES) { writeFully(data.reversedArray()) - formatIntegerFromByteArray(readBytes()) + formatBigEndianIntegerFromByteArray(readBytes()) } } @@ -134,7 +134,7 @@ public fun DiscordBitSet(value: String): DiscordBitSet { return DiscordBitSet(longArrayOf(value.toULong().toLong())) } - val bytes = parseIntegerToByteArray(value) + val bytes = parseBigEndianIntegerToByteArray(value) val longSize = (bytes.size / Long.SIZE_BYTES) + 1 val destination = LongArray(longSize) diff --git a/common/src/jvmMain/kotlin/DiscordBitSet.kt b/common/src/jvmMain/kotlin/DiscordBitSet.kt index 4cd044fd298b..f87e5a25a702 100644 --- a/common/src/jvmMain/kotlin/DiscordBitSet.kt +++ b/common/src/jvmMain/kotlin/DiscordBitSet.kt @@ -3,5 +3,5 @@ package dev.kord.common import java.math.BigInteger -internal actual fun formatIntegerFromByteArray(data: ByteArray): String = BigInteger(data).toString() -internal actual fun parseIntegerToByteArray(value: String): ByteArray = BigInteger(value).toByteArray() +internal actual fun formatBigEndianIntegerFromByteArray(data: ByteArray): String = BigInteger(data).toString() +internal actual fun parseBigEndianIntegerToByteArray(value: String): ByteArray = BigInteger(value).toByteArray() diff --git a/common/src/nonJvm/kotlin/DiscordBitSet.kt b/common/src/nonJvm/kotlin/DiscordBitSet.kt index 65b5199c124b..91cb3880ef29 100644 --- a/common/src/nonJvm/kotlin/DiscordBitSet.kt +++ b/common/src/nonJvm/kotlin/DiscordBitSet.kt @@ -3,7 +3,7 @@ package dev.kord.common import com.ionspin.kotlin.bignum.integer.BigInteger import com.ionspin.kotlin.bignum.integer.Sign -internal actual fun formatIntegerFromByteArray(data: ByteArray): String = +internal actual fun formatBigEndianIntegerFromByteArray(data: ByteArray): String = BigInteger.fromByteArray(data, Sign.POSITIVE).toString() -internal actual fun parseIntegerToByteArray(value: String): ByteArray = BigInteger.parseString(value).toByteArray() +internal actual fun parseBigEndianIntegerToByteArray(value: String): ByteArray = BigInteger.parseString(value).toByteArray() From 0e9306c8af9d64b31a972a270fbc52cd89f0b2d0 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 27 Mar 2023 09:31:36 +0200 Subject: [PATCH 049/136] Revert formatting --- common/src/commonMain/kotlin/entity/AuditLog.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/common/src/commonMain/kotlin/entity/AuditLog.kt b/common/src/commonMain/kotlin/entity/AuditLog.kt index 50b1c8561be6..b125a21e02fe 100644 --- a/common/src/commonMain/kotlin/entity/AuditLog.kt +++ b/common/src/commonMain/kotlin/entity/AuditLog.kt @@ -39,11 +39,7 @@ Entry("IntegrationDelete", intValue = 82, kDoc = "App was removed from server."), Entry("StageInstanceCreate", intValue = 83, kDoc = "Stage instance was created (stage channel becomes live)."), Entry("StageInstanceUpdate", intValue = 84, kDoc = "Stage instance details were updated."), - Entry( - "StageInstanceDelete", - intValue = 85, - kDoc = "Stage instance was deleted (stage channel no longer live)." - ), + Entry("StageInstanceDelete", intValue = 85, kDoc = "Stage instance was deleted (stage channel no longer live)."), Entry("StickerCreate", intValue = 90, kDoc = "Sticker was created."), Entry("StickerUpdate", intValue = 91, kDoc = "Sticker details were updated."), Entry("StickerDelete", intValue = 92, kDoc = "Sticker was deleted."), From 1592e0f6ac1b7fcd2825329b186f2be04a94d69b Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 27 Mar 2023 09:54:27 +0200 Subject: [PATCH 050/136] Some fixes - Fix dokka tasks - No longer apply sourceSet options on internal modules - Rename Snowflake and color classes - Add mavenCentral() to root project --- build.gradle.kts | 4 ++++ buildSrc/src/main/kotlin/Documentation.kt | 8 ++++---- .../kord-internal-multiplatform-module.gradle.kts | 8 ++++++-- common/api/common.api | 8 ++++---- common/src/jvmTest/kotlin/entity/SnowflakeTest.kt | 4 +--- core/build.gradle.kts | 6 ++++++ core/live-tests/build.gradle.kts | 15 ++------------- 7 files changed, 27 insertions(+), 26 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f15881c2309d..8113ee632f63 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,3 +4,7 @@ plugins { group = Library.group version = Library.version + +repositories { + mavenCentral() +} diff --git a/buildSrc/src/main/kotlin/Documentation.kt b/buildSrc/src/main/kotlin/Documentation.kt index 180abbb67842..df005113ea1b 100644 --- a/buildSrc/src/main/kotlin/Documentation.kt +++ b/buildSrc/src/main/kotlin/Documentation.kt @@ -18,8 +18,8 @@ fun TaskContainer.configureDokka(additionalConfiguration: AbstractDokkaLeafTask. "https://github.com/kordlib/kord/blob/${Library.commitHashOrDefault("0.9.x")}/${project.name}" sourceLink { - localDirectory.set(project.file("src/main/kotlin")) - remoteUrl.set(URL("$baseRemoteUrl/src/main/kotlin")) + localDirectory.set(project.file("src/${name}Main/kotlin")) + remoteUrl.set(URL("$baseRemoteUrl/src/${name}Main/kotlin")) remoteLineSuffix.set("#L") } @@ -27,8 +27,8 @@ fun TaskContainer.configureDokka(additionalConfiguration: AbstractDokkaLeafTask. suppressGeneratedFiles.set(false) sourceLink { // will fail if dir doesn't exist -> always create it, won't harm if not needed - localDirectory.set(project.file("build/generated/ksp/main/kotlin").apply { mkdirs() }) - remoteUrl.set(URL("$baseRemoteUrl/build/generated/ksp/main/kotlin")) + localDirectory.set(project.file("build/generated/ksp/metadata/commonMain/kotlin").apply { mkdirs() }) + remoteUrl.set(URL("$baseRemoteUrl/build/generated/ksp/metadata/commonMain/kotlin")) remoteLineSuffix.set("#L") } diff --git a/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts index 2e777b44d2c6..53be19854869 100644 --- a/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts @@ -13,7 +13,11 @@ kotlin { } jvmToolchain(Jvm.target) - sourceSets { - applyKordSourceSetOptions() + targets { + all { + compilations.all { + compilerOptions.options.applyKordCompilerOptions() + } + } } } diff --git a/common/api/common.api b/common/api/common.api index c470d1120255..b0423525d437 100644 --- a/common/api/common.api +++ b/common/api/common.api @@ -15,7 +15,7 @@ public final class dev/kord/common/Color$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } -public final class dev/kord/common/ColorJvm { +public final class dev/kord/common/ColorKt { public static final fun getKColor (Ljava/awt/Color;)Ldev/kord/common/Color; } @@ -166,9 +166,9 @@ public final class dev/kord/common/LocaleKt { public final class dev/kord/common/Platform { public static final field INSTANCE Ldev/kord/common/Platform; - public final fun getIS_BROWSER ()Z - public final fun getIS_JVM ()Z - public final fun getIS_NODE ()Z + public static final field IS_BROWSER Z + public static final field IS_JVM Z + public static final field IS_NODE Z } public abstract interface annotation class dev/kord/common/annotation/DeprecatedSinceKord : java/lang/annotation/Annotation { diff --git a/common/src/jvmTest/kotlin/entity/SnowflakeTest.kt b/common/src/jvmTest/kotlin/entity/SnowflakeTest.kt index 5455e680d633..0fc43f5005ed 100644 --- a/common/src/jvmTest/kotlin/entity/SnowflakeTest.kt +++ b/common/src/jvmTest/kotlin/entity/SnowflakeTest.kt @@ -1,12 +1,10 @@ -@file:JvmName("SnowflakeTestJvm") - package entity import dev.kord.common.entity.Snowflake import org.junit.jupiter.api.Test import kotlin.test.assertEquals -class SnowflakeTest { +class SnowflakeTestJvm { @Test fun `Snowflake's natural order works with SortedSets`() { val a = Snowflake(0b0_00000_00000_000000000000_u) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index f5153b8b177b..d03ac0897d20 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -24,3 +24,9 @@ kotlin { } } } + +tasks { + dokkaHtmlMultiModule { + enabled = false + } +} diff --git a/core/live-tests/build.gradle.kts b/core/live-tests/build.gradle.kts index f450e2f9ce75..b59592b5f9c6 100644 --- a/core/live-tests/build.gradle.kts +++ b/core/live-tests/build.gradle.kts @@ -1,5 +1,3 @@ -import org.jetbrains.dokka.gradle.DokkaTaskPartial - plugins { `kord-internal-multiplatform-module` } @@ -14,12 +12,8 @@ kotlin { } addTestKit(targets) } - targets { - all { - compilations.all { - compilerOptions.options.applyKordCompilerOptions() - } - } + sourceSets { + applyKordSourceSetOptions() } } @@ -27,9 +21,4 @@ tasks { withType { enabled = !System.getenv("KORD_TEST_TOKEN").isNullOrBlank() } - - // Replace this once proper project isolation support is there - task("dokkaHtmlPartial") { - enabled = false - } } From 1fc42c0870cef372e43ecd17abfba49246f6fff2 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 27 Mar 2023 09:55:58 +0200 Subject: [PATCH 051/136] Fix formatting --- common/src/nonJvm/kotlin/DiscordBitSet.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/nonJvm/kotlin/DiscordBitSet.kt b/common/src/nonJvm/kotlin/DiscordBitSet.kt index 91cb3880ef29..2f0e8d430353 100644 --- a/common/src/nonJvm/kotlin/DiscordBitSet.kt +++ b/common/src/nonJvm/kotlin/DiscordBitSet.kt @@ -6,4 +6,5 @@ import com.ionspin.kotlin.bignum.integer.Sign internal actual fun formatBigEndianIntegerFromByteArray(data: ByteArray): String = BigInteger.fromByteArray(data, Sign.POSITIVE).toString() -internal actual fun parseBigEndianIntegerToByteArray(value: String): ByteArray = BigInteger.parseString(value).toByteArray() +internal actual fun parseBigEndianIntegerToByteArray(value: String): ByteArray = + BigInteger.parseString(value).toByteArray() From e25309246a9f3a75391fd9096cddb7b3dfc40141 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Mon, 27 Mar 2023 10:13:05 +0200 Subject: [PATCH 052/136] [ci skip] clarify why allWarningsAsErrors is disabled --- buildSrc/src/main/kotlin/Compiler.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/buildSrc/src/main/kotlin/Compiler.kt b/buildSrc/src/main/kotlin/Compiler.kt index 1bbff57cd3f0..89f4b82f2506 100644 --- a/buildSrc/src/main/kotlin/Compiler.kt +++ b/buildSrc/src/main/kotlin/Compiler.kt @@ -36,6 +36,7 @@ object Jvm { } fun KotlinCommonCompilerOptions.applyKordCompilerOptions() { + // TODO: Enable again once https://youtrack.jetbrains.com/issue/KT-51110 is fixed allWarningsAsErrors.set(false) freeCompilerArgs.add(CompilerArguments.progressive) } From 1762cb0b387defe691e6e62fa77a839a1c778a66 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 27 Mar 2023 22:57:34 +0200 Subject: [PATCH 053/136] Some small changes --- build.gradle.kts | 6 +-- buildSrc/src/main/kotlin/Compiler.kt | 43 ++++++------------- buildSrc/src/main/kotlin/Documentation.kt | 18 ++------ .../src/main/kotlin/kord-module.gradle.kts | 12 +----- .../kord-multiplatform-module.gradle.kts | 2 +- common/src/commonMain/kotlin/DiscordBitSet.kt | 8 ++-- common/src/jvmMain/kotlin/DiscordBitSet.kt | 4 +- common/src/nonJvm/kotlin/DiscordBitSet.kt | 4 +- core/live-tests/build.gradle.kts | 2 +- 9 files changed, 29 insertions(+), 70 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8113ee632f63..a1cd46774e82 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,9 +2,9 @@ plugins { org.jetbrains.dokka // for dokkaHtmlMultiModule task } -group = Library.group -version = Library.version - repositories { mavenCentral() } + +group = Library.group +version = Library.version diff --git a/buildSrc/src/main/kotlin/Compiler.kt b/buildSrc/src/main/kotlin/Compiler.kt index 89f4b82f2506..fefa694e20c7 100644 --- a/buildSrc/src/main/kotlin/Compiler.kt +++ b/buildSrc/src/main/kotlin/Compiler.kt @@ -8,28 +8,18 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet object OptIns { - const val time = "kotlin.time.ExperimentalTime" - const val contracts = "kotlin.contracts.ExperimentalContracts" const val coroutines = "kotlinx.coroutines.ExperimentalCoroutinesApi" - - const val kordInternal = "dev.kord.common.annotation.KordInternal" - const val kordPreview = "dev.kord.common.annotation.KordPreview" - const val kordExperimental = "dev.kord.common.annotation.KordExperimental" - const val kordVoice = "dev.kord.common.annotation.KordVoice" } -object CompilerArguments { - val time = OptIns.time.asOptIn() - val contracts = OptIns.contracts.asOptIn() - - val kordPreview = OptIns.kordPreview.asOptIn() - val kordExperimental = OptIns.kordExperimental.asOptIn() - val kordVoice = OptIns.kordVoice.asOptIn() - - const val progressive = "-progressive" -} +val kordOptIns = listOf( + "kotlin.time.ExperimentalTime", + "kotlin.contracts.ExperimentalContracts", -private fun String.asOptIn() = "-opt-in=$this" + "dev.kord.common.annotation.KordInternal", + "dev.kord.common.annotation.KordPreview", + "dev.kord.common.annotation.KordExperimental", + "dev.kord.common.annotation.KordVoice", +) object Jvm { const val target = 8 @@ -38,23 +28,14 @@ object Jvm { fun KotlinCommonCompilerOptions.applyKordCompilerOptions() { // TODO: Enable again once https://youtrack.jetbrains.com/issue/KT-51110 is fixed allWarningsAsErrors.set(false) - freeCompilerArgs.add(CompilerArguments.progressive) + freeCompilerArgs.add("-progressive") } -fun NamedDomainObjectContainer.applyKordSourceSetOptions() { +fun NamedDomainObjectContainer.applyKordOptIns() { all { languageSettings { - if ("Test" in name) { - optIn(OptIns.coroutines) - } - optIn(OptIns.kordInternal) - listOf( - OptIns.time, - OptIns.contracts, - OptIns.kordPreview, - OptIns.kordExperimental, - OptIns.kordVoice, - ).forEach(::optIn) + if ("Test" in name) optIn(OptIns.coroutines) + kordOptIns.forEach(::optIn) } } } diff --git a/buildSrc/src/main/kotlin/Documentation.kt b/buildSrc/src/main/kotlin/Documentation.kt index df005113ea1b..e275d00b54c1 100644 --- a/buildSrc/src/main/kotlin/Documentation.kt +++ b/buildSrc/src/main/kotlin/Documentation.kt @@ -5,8 +5,6 @@ import java.net.URL fun TaskContainer.configureDokka(additionalConfiguration: AbstractDokkaLeafTask.() -> Unit = {}) { withType().configureEach { - // include documentation generated by ksp - dependsOnKspKotlin() failOnWarning.set(true) @@ -14,21 +12,11 @@ fun TaskContainer.configureDokka(additionalConfiguration: AbstractDokkaLeafTask. jdkVersion.set(Jvm.target) - val baseRemoteUrl = - "https://github.com/kordlib/kord/blob/${Library.commitHashOrDefault("0.9.x")}/${project.name}" - - sourceLink { - localDirectory.set(project.file("src/${name}Main/kotlin")) - remoteUrl.set(URL("$baseRemoteUrl/src/${name}Main/kotlin")) - remoteLineSuffix.set("#L") - } - - // config for files generated by ksp suppressGeneratedFiles.set(false) + sourceLink { - // will fail if dir doesn't exist -> always create it, won't harm if not needed - localDirectory.set(project.file("build/generated/ksp/metadata/commonMain/kotlin").apply { mkdirs() }) - remoteUrl.set(URL("$baseRemoteUrl/build/generated/ksp/metadata/commonMain/kotlin")) + localDirectory.set(project.projectDir) + remoteUrl.set(URL("https://github.com/kordlib/kord/blob/${Library.commitHashOrDefault("0.9.x")}/${project.name}")) remoteLineSuffix.set("#L") } diff --git a/buildSrc/src/main/kotlin/kord-module.gradle.kts b/buildSrc/src/main/kotlin/kord-module.gradle.kts index 4a3654293e8b..6224eae5dbbd 100644 --- a/buildSrc/src/main/kotlin/kord-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-module.gradle.kts @@ -1,7 +1,4 @@ -import com.google.devtools.ksp.gradle.KspTask -import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import java.net.URL plugins { org.jetbrains.kotlin.jvm @@ -37,14 +34,7 @@ tasks { withType { compilerOptions { applyKordCompilerOptions() - freeCompilerArgs.addAll( - CompilerArguments.time, - CompilerArguments.contracts, - - CompilerArguments.kordPreview, - CompilerArguments.kordExperimental, - CompilerArguments.kordVoice, - ) + freeCompilerArgs.addAll(kordOptIns.map { "-opt-in=$it" }) } } diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index 33e5b56de404..50305406db1a 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -32,7 +32,7 @@ kotlin { } sourceSets { - applyKordSourceSetOptions() + applyKordOptIns() commonMain { // mark ksp src dir kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") diff --git a/common/src/commonMain/kotlin/DiscordBitSet.kt b/common/src/commonMain/kotlin/DiscordBitSet.kt index 2ef5c9dcbab9..92ce485a56a5 100644 --- a/common/src/commonMain/kotlin/DiscordBitSet.kt +++ b/common/src/commonMain/kotlin/DiscordBitSet.kt @@ -20,8 +20,8 @@ private const val WIDTH = Long.SIZE_BITS @Suppress("FunctionName") public fun EmptyBitSet(): DiscordBitSet = DiscordBitSet() -internal expect fun formatBigEndianIntegerFromByteArray(data: ByteArray): String -internal expect fun parseBigEndianIntegerToByteArray(value: String): ByteArray +internal expect fun formatIntegerFromBigEndianByteArray(data: ByteArray): String +internal expect fun parseIntegerToBigEndianByteArray(value: String): ByteArray @Serializable(with = DiscordBitSetSerializer::class) public class DiscordBitSet(internal var data: LongArray) { // data is in little-endian order @@ -34,7 +34,7 @@ public class DiscordBitSet(internal var data: LongArray) { // data is in little- // need to convert from little-endian data to big-endian expected by BigInteger return withBuffer(data.size * Long.SIZE_BYTES) { writeFully(data.reversedArray()) - formatBigEndianIntegerFromByteArray(readBytes()) + formatIntegerFromBigEndianByteArray(readBytes()) } } @@ -134,7 +134,7 @@ public fun DiscordBitSet(value: String): DiscordBitSet { return DiscordBitSet(longArrayOf(value.toULong().toLong())) } - val bytes = parseBigEndianIntegerToByteArray(value) + val bytes = parseIntegerToBigEndianByteArray(value) val longSize = (bytes.size / Long.SIZE_BYTES) + 1 val destination = LongArray(longSize) diff --git a/common/src/jvmMain/kotlin/DiscordBitSet.kt b/common/src/jvmMain/kotlin/DiscordBitSet.kt index f87e5a25a702..6f33883ca12a 100644 --- a/common/src/jvmMain/kotlin/DiscordBitSet.kt +++ b/common/src/jvmMain/kotlin/DiscordBitSet.kt @@ -3,5 +3,5 @@ package dev.kord.common import java.math.BigInteger -internal actual fun formatBigEndianIntegerFromByteArray(data: ByteArray): String = BigInteger(data).toString() -internal actual fun parseBigEndianIntegerToByteArray(value: String): ByteArray = BigInteger(value).toByteArray() +internal actual fun formatIntegerFromBigEndianByteArray(data: ByteArray): String = BigInteger(data).toString() +internal actual fun parseIntegerToBigEndianByteArray(value: String): ByteArray = BigInteger(value).toByteArray() diff --git a/common/src/nonJvm/kotlin/DiscordBitSet.kt b/common/src/nonJvm/kotlin/DiscordBitSet.kt index 2f0e8d430353..1eaae15bfe71 100644 --- a/common/src/nonJvm/kotlin/DiscordBitSet.kt +++ b/common/src/nonJvm/kotlin/DiscordBitSet.kt @@ -3,8 +3,8 @@ package dev.kord.common import com.ionspin.kotlin.bignum.integer.BigInteger import com.ionspin.kotlin.bignum.integer.Sign -internal actual fun formatBigEndianIntegerFromByteArray(data: ByteArray): String = +internal actual fun formatIntegerFromBigEndianByteArray(data: ByteArray): String = BigInteger.fromByteArray(data, Sign.POSITIVE).toString() -internal actual fun parseBigEndianIntegerToByteArray(value: String): ByteArray = +internal actual fun parseIntegerToBigEndianByteArray(value: String): ByteArray = BigInteger.parseString(value).toByteArray() diff --git a/core/live-tests/build.gradle.kts b/core/live-tests/build.gradle.kts index b59592b5f9c6..cd731baa2b82 100644 --- a/core/live-tests/build.gradle.kts +++ b/core/live-tests/build.gradle.kts @@ -13,7 +13,7 @@ kotlin { addTestKit(targets) } sourceSets { - applyKordSourceSetOptions() + applyKordOptIns() } } From 7991bd6d5c10b4082707f581dc5ac714f310c5d0 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 27 Mar 2023 23:08:05 +0200 Subject: [PATCH 054/136] No need for @JvmName --- common/src/commonMain/kotlin/Color.kt | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/common/src/commonMain/kotlin/Color.kt b/common/src/commonMain/kotlin/Color.kt index 4052f9c25a98..b7fed9e74852 100644 --- a/common/src/commonMain/kotlin/Color.kt +++ b/common/src/commonMain/kotlin/Color.kt @@ -1,4 +1,3 @@ -@file:JvmName("ColorCommon") package dev.kord.common import kotlinx.serialization.KSerializer @@ -8,7 +7,6 @@ import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -import kotlin.jvm.JvmName @Serializable(with = Color.Serializer::class) @@ -38,6 +36,17 @@ public class Color(rgb: Int) { public companion object { private const val MIN_COLOR = 0 private const val MAX_COLOR = 0xFFFFFF + + private fun rgb(red: Int, green: Int, blue: Int): Int { + require(red in 0..255) { "Red should be in range of 0..255 but was $red" } + require(green in 0..255) { "Green should be in range of 0..255 but was $green" } + require(blue in 0..255) { "Blue should be in range of 0..255 but was $blue" } + + + return red and 0xFF shl 16 or + (green and 0xFF shl 8) or + (blue and 0xFF) shl 0 + } } internal object Serializer : KSerializer { @@ -51,15 +60,3 @@ public class Color(rgb: Int) { } } } - -private fun rgb(red: Int, green: Int, blue: Int): Int { - require(red in 0..255) { "Red should be in range of 0..255 but was $red" } - require(green in 0..255) { "Green should be in range of 0..255 but was $green" } - require(blue in 0..255) { "Blue should be in range of 0..255 but was $blue" } - - - return red and 0xFF shl 16 or - (green and 0xFF shl 8) or - (blue and 0xFF) shl 0 -} - From 89ffc2f3f885421d4775fec01b72be0dddf300e9 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 27 Mar 2023 23:44:56 +0200 Subject: [PATCH 055/136] Some more changes --- common/src/commonMain/kotlin/entity/AuditLog.kt | 7 +------ common/src/commonMain/kotlin/entity/Interactions.kt | 1 - .../commonMain/kotlin/entity/optional/OptionalSnowflake.kt | 1 - .../commonMain/kotlin/serialization/InstantSerializers.kt | 1 + common/src/jsMain/kotlin/dev/kord/common/Platform.kt | 3 +++ .../src/jsMain/kotlin/dev/kord/common/http/HttpEngine.kt | 2 ++ common/src/jvmMain/kotlin/Platform.kt | 3 +++ common/src/jvmMain/kotlin/http/HttpEngine.kt | 2 ++ core-voice/api/core-voice.api | 2 +- ...elBehavior.kt => BaseVoiceChannelBehaviorExtensions.kt} | 2 -- test-kit/src/jsMain/kotlin/dev/kord/test/Platform.kt | 3 +++ 11 files changed, 16 insertions(+), 11 deletions(-) rename core-voice/src/main/kotlin/dev/kord/core/behavior/channel/{BaseVoiceChannelBehavior.kt => BaseVoiceChannelBehaviorExtensions.kt} (96%) diff --git a/common/src/commonMain/kotlin/entity/AuditLog.kt b/common/src/commonMain/kotlin/entity/AuditLog.kt index b125a21e02fe..dce82c8c9751 100644 --- a/common/src/commonMain/kotlin/entity/AuditLog.kt +++ b/common/src/commonMain/kotlin/entity/AuditLog.kt @@ -55,11 +55,7 @@ Entry("AutoModerationRuleDelete", intValue = 142, kDoc = "Auto Moderation rule was deleted."), Entry("AutoModerationBlockMessage", intValue = 143, kDoc = "Message was blocked by Auto Moderation."), Entry("AutoModerationFlagToChannel", intValue = 144, kDoc = "Message was flagged by Auto Moderation."), - Entry( - "AutoModerationUserCommunicationDisabled", - intValue = 145, - kDoc = "Member was timed out by Auto Moderation." - ), + Entry("AutoModerationUserCommunicationDisabled", intValue = 145, kDoc = "Member was timed out by Auto Moderation."), ], ) @@ -206,7 +202,6 @@ public data class AuditLogChange( index, AuditLogChangeKey.Serializer(Unit.serializer()) ) - CompositeDecoder.DECODE_DONE -> break else -> throw SerializationException("unknown index: $index") } diff --git a/common/src/commonMain/kotlin/entity/Interactions.kt b/common/src/commonMain/kotlin/entity/Interactions.kt index 37bce30a1c6f..21fab94936ee 100644 --- a/common/src/commonMain/kotlin/entity/Interactions.kt +++ b/common/src/commonMain/kotlin/entity/Interactions.kt @@ -92,7 +92,6 @@ import kotlinx.serialization.descriptors.* import kotlinx.serialization.encoding.* import kotlinx.serialization.json.* import kotlin.DeprecationLevel.ERROR -import kotlin.jvm.JvmName @Serializable public data class DiscordApplicationCommand( diff --git a/common/src/commonMain/kotlin/entity/optional/OptionalSnowflake.kt b/common/src/commonMain/kotlin/entity/optional/OptionalSnowflake.kt index 9baaba7b41d0..f8fbbdb9ef9b 100644 --- a/common/src/commonMain/kotlin/entity/optional/OptionalSnowflake.kt +++ b/common/src/commonMain/kotlin/entity/optional/OptionalSnowflake.kt @@ -7,7 +7,6 @@ import kotlinx.serialization.builtins.serializer import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -import kotlin.js.JsName import kotlin.jvm.JvmName /** diff --git a/common/src/commonMain/kotlin/serialization/InstantSerializers.kt b/common/src/commonMain/kotlin/serialization/InstantSerializers.kt index 31b1213e8860..12fe03a99238 100644 --- a/common/src/commonMain/kotlin/serialization/InstantSerializers.kt +++ b/common/src/commonMain/kotlin/serialization/InstantSerializers.kt @@ -2,6 +2,7 @@ package dev.kord.common.serialization import kotlinx.datetime.Instant import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable import kotlinx.serialization.SerializationException import kotlinx.serialization.descriptors.PrimitiveKind import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor diff --git a/common/src/jsMain/kotlin/dev/kord/common/Platform.kt b/common/src/jsMain/kotlin/dev/kord/common/Platform.kt index 75916fbeb457..8285c9e52b32 100644 --- a/common/src/jsMain/kotlin/dev/kord/common/Platform.kt +++ b/common/src/jsMain/kotlin/dev/kord/common/Platform.kt @@ -1,5 +1,8 @@ package dev.kord.common +import dev.kord.common.annotation.KordInternal + +@KordInternal public actual object Platform { public actual val IS_JVM: Boolean = false public actual val IS_NODE: Boolean diff --git a/common/src/jsMain/kotlin/dev/kord/common/http/HttpEngine.kt b/common/src/jsMain/kotlin/dev/kord/common/http/HttpEngine.kt index 6b8553d499a7..67f7ed245579 100644 --- a/common/src/jsMain/kotlin/dev/kord/common/http/HttpEngine.kt +++ b/common/src/jsMain/kotlin/dev/kord/common/http/HttpEngine.kt @@ -1,5 +1,7 @@ package dev.kord.common.http +import dev.kord.common.annotation.KordInternal import io.ktor.client.engine.js.* +@KordInternal public actual typealias HttpEngine = Js diff --git a/common/src/jvmMain/kotlin/Platform.kt b/common/src/jvmMain/kotlin/Platform.kt index fefb5e165114..8fe26557559d 100644 --- a/common/src/jvmMain/kotlin/Platform.kt +++ b/common/src/jvmMain/kotlin/Platform.kt @@ -1,5 +1,8 @@ package dev.kord.common +import dev.kord.common.annotation.KordInternal + +@KordInternal public actual object Platform { public actual const val IS_JVM: Boolean = true public actual const val IS_NODE: Boolean = false diff --git a/common/src/jvmMain/kotlin/http/HttpEngine.kt b/common/src/jvmMain/kotlin/http/HttpEngine.kt index f3877cb3840a..bc68406ee48c 100644 --- a/common/src/jvmMain/kotlin/http/HttpEngine.kt +++ b/common/src/jvmMain/kotlin/http/HttpEngine.kt @@ -1,6 +1,8 @@ package dev.kord.common.http +import dev.kord.common.annotation.KordInternal import io.ktor.client.engine.* import io.ktor.client.engine.cio.* +@KordInternal public actual object HttpEngine : HttpClientEngineFactory by CIO diff --git a/core-voice/api/core-voice.api b/core-voice/api/core-voice.api index a899627b1a37..4985d62d6741 100644 --- a/core-voice/api/core-voice.api +++ b/core-voice/api/core-voice.api @@ -1,4 +1,4 @@ -public final class dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorJvm { +public final class dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorExtensionsKt { public static final fun connect (Ldev/kord/core/behavior/channel/BaseVoiceChannelBehavior;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } diff --git a/core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehavior.kt b/core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorExtensions.kt similarity index 96% rename from core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehavior.kt rename to core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorExtensions.kt index 948c979020a2..b7abef77dea7 100644 --- a/core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehavior.kt +++ b/core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorExtensions.kt @@ -1,5 +1,3 @@ -@file:JvmName("BaseVoiceChannelBehaviorJvm") - package dev.kord.core.behavior.channel import dev.kord.common.annotation.KordVoice diff --git a/test-kit/src/jsMain/kotlin/dev/kord/test/Platform.kt b/test-kit/src/jsMain/kotlin/dev/kord/test/Platform.kt index 10d430ac9bd0..758fdcd58b4b 100644 --- a/test-kit/src/jsMain/kotlin/dev/kord/test/Platform.kt +++ b/test-kit/src/jsMain/kotlin/dev/kord/test/Platform.kt @@ -1,6 +1,9 @@ +@file:OptIn(KordInternal::class) + package dev.kord.test import dev.kord.common.Platform +import dev.kord.common.annotation.KordInternal import io.ktor.utils.io.* import js.core.get import node.process.process From f6609ee6c92df90b479cde418f8fa1b8dc4fcd3e Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Tue, 28 Mar 2023 09:27:22 +0200 Subject: [PATCH 056/136] Also publish kspAnnotations for js target --- common/build.gradle.kts | 2 ++ core/build.gradle.kts | 1 - gateway/build.gradle.kts | 1 - ksp-annotations/build.gradle.kts | 2 ++ rest/build.gradle.kts | 1 - samples/build.gradle.kts | 1 - test-kit/build.gradle.kts | 1 - 7 files changed, 4 insertions(+), 5 deletions(-) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 920f8234e320..8dbdee8f8759 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -34,6 +34,8 @@ kotlin { jsMain { dependencies { api(libs.ktor.client.js) + // When targeting K/JS needs to be present at compile time for users + api(projects.kspAnnotations) } } } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index d03ac0897d20..9714d8d8f5a9 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -7,7 +7,6 @@ kotlin { sourceSets { commonMain { dependencies { - compileOnly(projects.kspAnnotations) api(projects.common) api(projects.rest) api(projects.gateway) diff --git a/gateway/build.gradle.kts b/gateway/build.gradle.kts index d6d5ad13c390..e3614818e0dc 100644 --- a/gateway/build.gradle.kts +++ b/gateway/build.gradle.kts @@ -9,7 +9,6 @@ kotlin { commonMain { dependencies { api(projects.common) - compileOnly(projects.kspAnnotations) api(libs.bundles.ktor.client.serialization) api(libs.ktor.client.core) diff --git a/ksp-annotations/build.gradle.kts b/ksp-annotations/build.gradle.kts index aaacf04f2c4f..bdc0f024093d 100644 --- a/ksp-annotations/build.gradle.kts +++ b/ksp-annotations/build.gradle.kts @@ -1,3 +1,5 @@ plugins { `kord-internal-multiplatform-module` + org.jetbrains.dokka + `kord-publishing` } diff --git a/rest/build.gradle.kts b/rest/build.gradle.kts index 51619503d499..33fd8e56c314 100644 --- a/rest/build.gradle.kts +++ b/rest/build.gradle.kts @@ -15,7 +15,6 @@ kotlin { api(libs.bundles.ktor.client.serialization) api(libs.ktor.client.core) - compileOnly(projects.kspAnnotations) } } diff --git a/samples/build.gradle.kts b/samples/build.gradle.kts index 8f7e5910c85c..42ffcec709b4 100644 --- a/samples/build.gradle.kts +++ b/samples/build.gradle.kts @@ -11,7 +11,6 @@ kotlin { commonMain { dependencies { implementation(projects.core) - compileOnly(projects.kspAnnotations) } } diff --git a/test-kit/build.gradle.kts b/test-kit/build.gradle.kts index af0f02d4485f..7cfcc632d6fc 100644 --- a/test-kit/build.gradle.kts +++ b/test-kit/build.gradle.kts @@ -6,7 +6,6 @@ kotlin { sourceSets { commonMain { dependencies { - compileOnly(projects.kspAnnotations) api(libs.bundles.test.common) api(libs.ktor.utils) api(projects.common) From 132daa54a4b719c7cee9605caca63c9663facd9d Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Thu, 30 Mar 2023 12:01:50 +0200 Subject: [PATCH 057/136] Remove no longer needed @ObsoleteCoroutinesApi annotations --- gateway/src/commonMain/kotlin/Ticker.kt | 1 - gateway/src/commonMain/kotlin/handler/HeartbeatHandler.kt | 4 +--- voice/src/main/kotlin/gateway/Ticker.kt | 3 +-- voice/src/main/kotlin/gateway/handler/HeartbeatHandler.kt | 2 -- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/gateway/src/commonMain/kotlin/Ticker.kt b/gateway/src/commonMain/kotlin/Ticker.kt index 419ef97c6a1b..608118ccf2b3 100644 --- a/gateway/src/commonMain/kotlin/Ticker.kt +++ b/gateway/src/commonMain/kotlin/Ticker.kt @@ -17,7 +17,6 @@ private val logger = KotlinLogging.logger { } * * @param dispatcher The dispatchers the events will be fired on. */ -@ObsoleteCoroutinesApi public class Ticker(private val dispatcher: CoroutineDispatcher = Dispatchers.Default) : CoroutineScope { diff --git a/gateway/src/commonMain/kotlin/handler/HeartbeatHandler.kt b/gateway/src/commonMain/kotlin/handler/HeartbeatHandler.kt index 6e85bcdef94a..e363e982e3db 100644 --- a/gateway/src/commonMain/kotlin/handler/HeartbeatHandler.kt +++ b/gateway/src/commonMain/kotlin/handler/HeartbeatHandler.kt @@ -3,13 +3,11 @@ package dev.kord.gateway.handler import dev.kord.gateway.* import kotlinx.atomicfu.atomic import kotlinx.atomicfu.update -import kotlinx.coroutines.ObsoleteCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlin.time.Duration import kotlin.time.TimeMark import kotlin.time.TimeSource -@OptIn(ObsoleteCoroutinesApi::class) internal class HeartbeatHandler( flow: Flow, private val send: suspend (Command) -> Unit, @@ -67,4 +65,4 @@ internal class HeartbeatHandler( private fun setPossibleZombie() { possibleZombie.update { true } } -} \ No newline at end of file +} diff --git a/voice/src/main/kotlin/gateway/Ticker.kt b/voice/src/main/kotlin/gateway/Ticker.kt index 59d6e292f67a..770e206b2fa0 100644 --- a/voice/src/main/kotlin/gateway/Ticker.kt +++ b/voice/src/main/kotlin/gateway/Ticker.kt @@ -5,7 +5,6 @@ import kotlinx.coroutines.* /** * A reusable fixed rate ticker. */ -@ObsoleteCoroutinesApi internal class Ticker { // we only want one of these private var tickerJob: Job? = null @@ -23,4 +22,4 @@ internal class Ticker { fun stop() { tickerJob?.cancel() } -} \ No newline at end of file +} diff --git a/voice/src/main/kotlin/gateway/handler/HeartbeatHandler.kt b/voice/src/main/kotlin/gateway/handler/HeartbeatHandler.kt index b443e2c26b7a..f41c5ae470ff 100644 --- a/voice/src/main/kotlin/gateway/handler/HeartbeatHandler.kt +++ b/voice/src/main/kotlin/gateway/handler/HeartbeatHandler.kt @@ -2,7 +2,6 @@ package dev.kord.voice.gateway.handler import dev.kord.voice.gateway.* import kotlinx.atomicfu.atomic -import kotlinx.coroutines.ObsoleteCoroutinesApi import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.launch @@ -10,7 +9,6 @@ import kotlin.time.Duration import kotlin.time.TimeMark import kotlin.time.TimeSource -@OptIn(ObsoleteCoroutinesApi::class) internal class HeartbeatHandler( flow: Flow, private val send: suspend (Command) -> Unit, From d5d3580b8e17cf95dbcffc6a91ada50d03a19214 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Wed, 29 Mar 2023 19:28:49 +0200 Subject: [PATCH 058/136] oops --- .../commonTest/kotlin/serialization/InstantSerializersTests.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt b/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt index c4184d549111..0a266ede13fa 100644 --- a/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt +++ b/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt @@ -63,7 +63,7 @@ abstract class InstantSerializerTest( } @Test - @JsName("testtest6") + @JsName("test6") fun `past Instant can be deserialized`() { assertEquals(expected = mirroredInstant, actual = deserialize("-$json")) } From a5f641cd77bd4134cb3844a9a2b411d72de3d988 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Thu, 30 Mar 2023 18:34:45 +0200 Subject: [PATCH 059/136] preserve class name --- core-voice/api/core-voice.api | 2 +- .../core/behavior/channel/BaseVoiceChannelBehaviorExtensions.kt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core-voice/api/core-voice.api b/core-voice/api/core-voice.api index 4985d62d6741..62ddd5c6aa67 100644 --- a/core-voice/api/core-voice.api +++ b/core-voice/api/core-voice.api @@ -1,4 +1,4 @@ -public final class dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorExtensionsKt { +public final class dev/kord/core/behavior/channel/VoiceBaseVoiceChannelBehaviorKt { public static final fun connect (Ldev/kord/core/behavior/channel/BaseVoiceChannelBehavior;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } diff --git a/core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorExtensions.kt b/core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorExtensions.kt index b7abef77dea7..7448b979c68f 100644 --- a/core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorExtensions.kt +++ b/core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorExtensions.kt @@ -1,3 +1,5 @@ +@file:JvmName("VoiceBaseVoiceChannelBehaviorKt") // preserve old name for binary compatibility + package dev.kord.core.behavior.channel import dev.kord.common.annotation.KordVoice From dd4ed4818e922aa50e3b2db147b2c99802db480b Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Thu, 30 Mar 2023 18:35:40 +0200 Subject: [PATCH 060/136] unused imports --- core/src/commonMain/kotlin/behavior/MemberBehavior.kt | 1 - .../commonMain/kotlin/behavior/channel/NewsChannelBehavior.kt | 1 - .../commonMain/kotlin/behavior/channel/TextChannelBehavior.kt | 1 - .../kotlin/behavior/channel/TopGuildMessageChannelBehavior.kt | 4 ---- 4 files changed, 7 deletions(-) diff --git a/core/src/commonMain/kotlin/behavior/MemberBehavior.kt b/core/src/commonMain/kotlin/behavior/MemberBehavior.kt index b27cdbd1bab2..341825bf4fbe 100644 --- a/core/src/commonMain/kotlin/behavior/MemberBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/MemberBehavior.kt @@ -17,7 +17,6 @@ import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.rest.builder.ban.BanCreateBuilder import dev.kord.rest.builder.member.MemberModifyBuilder import dev.kord.rest.request.RestRequestException -import dev.kord.core.hash import kotlin.contracts.InvocationKind import kotlin.contracts.contract diff --git a/core/src/commonMain/kotlin/behavior/channel/NewsChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/NewsChannelBehavior.kt index 3efed3886a38..8c8bdf030cf3 100644 --- a/core/src/commonMain/kotlin/behavior/channel/NewsChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/NewsChannelBehavior.kt @@ -25,7 +25,6 @@ import dev.kord.rest.service.patchNewsChannel import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.filterIsInstance import kotlinx.datetime.Instant -import kotlin.DeprecationLevel.WARNING import dev.kord.core.hash import kotlin.DeprecationLevel.ERROR import kotlin.contracts.InvocationKind diff --git a/core/src/commonMain/kotlin/behavior/channel/TextChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/TextChannelBehavior.kt index 9f0adb47e6c2..49e6cfab04f0 100644 --- a/core/src/commonMain/kotlin/behavior/channel/TextChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/TextChannelBehavior.kt @@ -23,7 +23,6 @@ import dev.kord.rest.service.patchTextChannel import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.filterIsInstance import kotlinx.datetime.Instant -import kotlin.DeprecationLevel.WARNING import dev.kord.core.hash import kotlin.DeprecationLevel.ERROR import kotlin.contracts.InvocationKind diff --git a/core/src/commonMain/kotlin/behavior/channel/TopGuildMessageChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/TopGuildMessageChannelBehavior.kt index 4028beeb5213..106b2173185b 100644 --- a/core/src/commonMain/kotlin/behavior/channel/TopGuildMessageChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/TopGuildMessageChannelBehavior.kt @@ -10,10 +10,6 @@ import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.rest.builder.webhook.WebhookCreateBuilder import kotlin.DeprecationLevel.HIDDEN -import dev.kord.rest.request.RestRequestException -import dev.kord.rest.service.RestClient -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow import dev.kord.core.hash import kotlin.contracts.InvocationKind import kotlin.contracts.contract From 50f04060207098f104a5979ed38a54b8ec869709 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Thu, 30 Mar 2023 18:36:30 +0200 Subject: [PATCH 061/136] links to javadoc --- common/src/commonMain/kotlin/entity/Snowflake.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/common/src/commonMain/kotlin/entity/Snowflake.kt b/common/src/commonMain/kotlin/entity/Snowflake.kt index ba5a7bffbf47..07a1f2a06ab0 100644 --- a/common/src/commonMain/kotlin/entity/Snowflake.kt +++ b/common/src/commonMain/kotlin/entity/Snowflake.kt @@ -138,7 +138,7 @@ public class Snowflake : Comparable { * * The comparison is based first on the value of the [timestamp], then on the value of the [workerId], then on the * value of the [processId] and finally on the value of the [increment]. It is *consistent with equals*, as defined - * by [Comparable][java.lang.Comparable]. + * by [Comparable](https://docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html). */ override fun compareTo(other: Snowflake): Int { // the layout of Snowflake values from MSB to LSB is timestamp, workerId, processId, increment, @@ -175,9 +175,10 @@ public class Snowflake : Comparable { * [processId] and [increment] are not taken into account. * * Note: this comparator imposes an ordering that is *inconsistent with equals*, as defined by - * [Comparator][java.util.Comparator]. It therefore shouldn't be used to order a - * [SortedSet][java.util.SortedSet] or [SortedMap][java.util.SortedMap]. This is because `TimestampComparator` - * only compares the first 42 bits of the ULong [value] (comparing the timestamp), whereas + * [Comparator](https://docs.oracle.com/javase/8/docs/api/java/util/Comparator.html). It therefore shouldn't be + * used to order a [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) or + * [SortedMap](https://docs.oracle.com/javase/8/docs/api/java/util/SortedMap.html). This is because + * `TimestampComparator` only compares the first 42 bits of the ULong [value] (comparing the timestamp), whereas * [equals][Snowflake.equals] compares all the bits of the [value]. `TimestampComparator` can return `0` even if * [equals][Snowflake.equals] returns `false`, but [equals][Snowflake.equals] only returns `true` if * `TimestampComparator` returns `0`. From 210032b62449807f95b9fb1871f5cd469d94d2d5 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Thu, 30 Mar 2023 19:35:47 +0200 Subject: [PATCH 062/136] Rename files --- common/src/commonMain/kotlin/DiscordBitSet.kt | 3 --- .../jvmMain/kotlin/{DiscordBitSet.kt => DiscordBitSetJvm.kt} | 1 - core/api/core.api | 2 +- .../jvmMain/kotlin/dev/kord/core/cache/KordCacheBuilder.kt | 2 -- .../kord/gateway/{DefaultGateway.kt => DefaultGatewayJvm.kt} | 1 - rest/api/rest.api | 4 ++-- .../{MessageCreateBuilder.kt => MessageCreateBuilderJvm.kt} | 2 -- .../{MessageModifyBuilder.kt => MessageModifyBuilderJvm.kt} | 2 -- 8 files changed, 3 insertions(+), 14 deletions(-) rename common/src/jvmMain/kotlin/{DiscordBitSet.kt => DiscordBitSetJvm.kt} (89%) rename gateway/src/jvmMain/kotlin/dev/kord/gateway/{DefaultGateway.kt => DefaultGatewayJvm.kt} (86%) rename rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/{MessageCreateBuilder.kt => MessageCreateBuilderJvm.kt} (89%) rename rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/{MessageModifyBuilder.kt => MessageModifyBuilderJvm.kt} (89%) diff --git a/common/src/commonMain/kotlin/DiscordBitSet.kt b/common/src/commonMain/kotlin/DiscordBitSet.kt index 92ce485a56a5..8c604548db55 100644 --- a/common/src/commonMain/kotlin/DiscordBitSet.kt +++ b/common/src/commonMain/kotlin/DiscordBitSet.kt @@ -1,9 +1,6 @@ package dev.kord.common -import io.ktor.utils.io.bits.* import io.ktor.utils.io.core.* -import io.ktor.utils.io.core.internal.* -import io.ktor.utils.io.pool.* import kotlinx.serialization.KSerializer import kotlinx.serialization.Serializable import kotlinx.serialization.descriptors.PrimitiveKind diff --git a/common/src/jvmMain/kotlin/DiscordBitSet.kt b/common/src/jvmMain/kotlin/DiscordBitSetJvm.kt similarity index 89% rename from common/src/jvmMain/kotlin/DiscordBitSet.kt rename to common/src/jvmMain/kotlin/DiscordBitSetJvm.kt index 6f33883ca12a..002c7491b1aa 100644 --- a/common/src/jvmMain/kotlin/DiscordBitSet.kt +++ b/common/src/jvmMain/kotlin/DiscordBitSetJvm.kt @@ -1,4 +1,3 @@ -@file:JvmName("DiscordBitSetJvm") package dev.kord.common import java.math.BigInteger diff --git a/core/api/core.api b/core/api/core.api index 7f1e03e3a89f..a6e2ab46197c 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -2204,7 +2204,7 @@ public final class dev/kord/core/cache/KordCacheBuilder { public final fun webhooks (Lkotlin/jvm/functions/Function2;)V } -public final class dev/kord/core/cache/KordCacheBuilderJvm { +public final class dev/kord/core/cache/KordCacheBuilderKt { public static final fun lruCache (Ldev/kord/core/cache/KordCacheBuilder;I)Lkotlin/jvm/functions/Function2; public static synthetic fun lruCache$default (Ldev/kord/core/cache/KordCacheBuilder;IILjava/lang/Object;)Lkotlin/jvm/functions/Function2; } diff --git a/core/src/jvmMain/kotlin/dev/kord/core/cache/KordCacheBuilder.kt b/core/src/jvmMain/kotlin/dev/kord/core/cache/KordCacheBuilder.kt index eed914958f24..97dcaa6f7cb8 100644 --- a/core/src/jvmMain/kotlin/dev/kord/core/cache/KordCacheBuilder.kt +++ b/core/src/jvmMain/kotlin/dev/kord/core/cache/KordCacheBuilder.kt @@ -1,5 +1,3 @@ -@file:JvmName("KordCacheBuilderJvm") - package dev.kord.core.cache import dev.kord.cache.api.DataEntryCache diff --git a/gateway/src/jvmMain/kotlin/dev/kord/gateway/DefaultGateway.kt b/gateway/src/jvmMain/kotlin/dev/kord/gateway/DefaultGatewayJvm.kt similarity index 86% rename from gateway/src/jvmMain/kotlin/dev/kord/gateway/DefaultGateway.kt rename to gateway/src/jvmMain/kotlin/dev/kord/gateway/DefaultGatewayJvm.kt index 9077eba296ef..4394c82a8313 100644 --- a/gateway/src/jvmMain/kotlin/dev/kord/gateway/DefaultGateway.kt +++ b/gateway/src/jvmMain/kotlin/dev/kord/gateway/DefaultGatewayJvm.kt @@ -1,4 +1,3 @@ -@file:JvmName("DefaultGatewayJvm") package dev.kord.gateway import java.nio.channels.UnresolvedAddressException diff --git a/rest/api/rest.api b/rest/api/rest.api index 04184fde7268..8e24fbb01e1d 100644 --- a/rest/api/rest.api +++ b/rest/api/rest.api @@ -1997,7 +1997,7 @@ public final class dev/kord/rest/builder/message/create/MessageCreateBuilder$Def public static fun addFile (Ldev/kord/rest/builder/message/create/MessageCreateBuilder;Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; } -public final class dev/kord/rest/builder/message/create/MessageCreateBuilderJvm { +public final class dev/kord/rest/builder/message/create/MessageCreateBuilderJvmKt { public static final fun addFile (Ldev/kord/rest/builder/message/create/MessageCreateBuilder;Ljava/nio/file/Path;)Ldev/kord/rest/NamedFile; } @@ -2160,7 +2160,7 @@ public final class dev/kord/rest/builder/message/modify/MessageModifyBuilder$Def public static fun addFile (Ldev/kord/rest/builder/message/modify/MessageModifyBuilder;Ljava/lang/String;Lio/ktor/client/request/forms/ChannelProvider;)Ldev/kord/rest/NamedFile; } -public final class dev/kord/rest/builder/message/modify/MessageModifyBuilderJvm { +public final class dev/kord/rest/builder/message/modify/MessageModifyBuilderJvmKt { public static final fun addFile (Ldev/kord/rest/builder/message/modify/MessageModifyBuilder;Ljava/nio/file/Path;)Ldev/kord/rest/NamedFile; } diff --git a/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/MessageCreateBuilder.kt b/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/MessageCreateBuilderJvm.kt similarity index 89% rename from rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/MessageCreateBuilder.kt rename to rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/MessageCreateBuilderJvm.kt index 62065431c6bb..4ac22022c303 100644 --- a/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/MessageCreateBuilder.kt +++ b/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/MessageCreateBuilderJvm.kt @@ -1,4 +1,3 @@ -@file:JvmName("MessageCreateBuilderJvm") package dev.kord.rest.builder.message.create import dev.kord.rest.NamedFile @@ -6,7 +5,6 @@ import io.ktor.client.request.forms.* import io.ktor.util.cio.* import java.nio.file.Path - /** * Adds a file with the given [path] to the attachments. */ diff --git a/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/MessageModifyBuilder.kt b/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/MessageModifyBuilderJvm.kt similarity index 89% rename from rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/MessageModifyBuilder.kt rename to rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/MessageModifyBuilderJvm.kt index 9b6bf6ef7aaa..ea279a114317 100644 --- a/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/MessageModifyBuilder.kt +++ b/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/MessageModifyBuilderJvm.kt @@ -1,5 +1,3 @@ -@file:JvmName("MessageModifyBuilderJvm") - package dev.kord.rest.builder.message.modify import dev.kord.rest.NamedFile From 631600f002696a0964334fdb6b973ab474dbd80b Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Thu, 30 Mar 2023 19:37:59 +0200 Subject: [PATCH 063/136] Wrong old name for VoiceBaseVoiceChannelBehavior --- core-voice/api/core-voice.api | 2 +- .../core/behavior/channel/BaseVoiceChannelBehaviorExtensions.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core-voice/api/core-voice.api b/core-voice/api/core-voice.api index 62ddd5c6aa67..fde1322aa8fe 100644 --- a/core-voice/api/core-voice.api +++ b/core-voice/api/core-voice.api @@ -1,4 +1,4 @@ -public final class dev/kord/core/behavior/channel/VoiceBaseVoiceChannelBehaviorKt { +public final class dev/kord/core/behavior/channel/VoiceBaseVoiceChannelBehavior { public static final fun connect (Ldev/kord/core/behavior/channel/BaseVoiceChannelBehavior;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } diff --git a/core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorExtensions.kt b/core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorExtensions.kt index 7448b979c68f..1d576ef984e0 100644 --- a/core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorExtensions.kt +++ b/core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorExtensions.kt @@ -1,4 +1,4 @@ -@file:JvmName("VoiceBaseVoiceChannelBehaviorKt") // preserve old name for binary compatibility +@file:JvmName("VoiceBaseVoiceChannelBehavior") // preserve old name for binary compatibility package dev.kord.core.behavior.channel From 78b00ad0488d5bb57464fb40080b212b55692846 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Thu, 30 Mar 2023 19:43:42 +0200 Subject: [PATCH 064/136] Use FQNs instead of import aliases --- .../src/commonMain/kotlin/annotation/Annotations.kt | 2 +- common/src/jvmMain/kotlin/Color.kt | 4 +--- common/src/jvmMain/kotlin/ConcurrentHashMap.kt | 3 +-- common/src/jvmMain/kotlin/Locale.kt | 12 ++++-------- .../src/jvmMain/kotlin/dev/kord/gateway/Inflater.kt | 3 +-- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/common/src/commonMain/kotlin/annotation/Annotations.kt b/common/src/commonMain/kotlin/annotation/Annotations.kt index 37684ff7b704..3e9fc57065ce 100644 --- a/common/src/commonMain/kotlin/annotation/Annotations.kt +++ b/common/src/commonMain/kotlin/annotation/Annotations.kt @@ -85,7 +85,7 @@ public annotation class DeprecatedSinceKord(val version: String) * Marks an API for internal use only. */ @MustBeDocumented -@RequiresOptIn("This Api is intended for internal use only", level = ERROR) +@RequiresOptIn("This API is intended for internal use only", level = ERROR) @Retention(BINARY) @Target(CLASS, PROPERTY, FUNCTION, TYPEALIAS) public annotation class KordInternal diff --git a/common/src/jvmMain/kotlin/Color.kt b/common/src/jvmMain/kotlin/Color.kt index 4365fe39e493..228ac673f2df 100644 --- a/common/src/jvmMain/kotlin/Color.kt +++ b/common/src/jvmMain/kotlin/Color.kt @@ -1,5 +1,3 @@ package dev.kord.common -import java.awt.Color as AwtColor - -public val AwtColor.kColor: Color get() = Color(rgb) +public val java.awt.Color.kColor: Color get() = Color(rgb) diff --git a/common/src/jvmMain/kotlin/ConcurrentHashMap.kt b/common/src/jvmMain/kotlin/ConcurrentHashMap.kt index f2884470e98e..33efe6d2faed 100644 --- a/common/src/jvmMain/kotlin/ConcurrentHashMap.kt +++ b/common/src/jvmMain/kotlin/ConcurrentHashMap.kt @@ -1,7 +1,6 @@ package dev.kord.common import dev.kord.common.annotation.KordInternal -import java.util.concurrent.ConcurrentHashMap as JavaConcurrentHashMap @KordInternal -public actual typealias ConcurrentHashMap = JavaConcurrentHashMap +public actual typealias ConcurrentHashMap = java.util.concurrent.ConcurrentHashMap diff --git a/common/src/jvmMain/kotlin/Locale.kt b/common/src/jvmMain/kotlin/Locale.kt index fae8d46c84a1..ee1b63c35c8a 100644 --- a/common/src/jvmMain/kotlin/Locale.kt +++ b/common/src/jvmMain/kotlin/Locale.kt @@ -1,15 +1,11 @@ package dev.kord.common -import java.util.Locale as JLocale - - /** - * Converts this into a [JLocale]. + * Converts this [dev.kord.common.Locale] into a [java.util.Locale]. */ -public fun Locale.asJavaLocale(): JLocale = JLocale(language, country ?: "") +public fun Locale.asJavaLocale(): java.util.Locale = java.util.Locale(language, country ?: "") /** - * Converts this into a [Locale]. + * Converts this [java.util.Locale] into a [dev.kord.common.Locale]. */ -public val JLocale.kLocale: Locale - get() = Locale(language, country.ifBlank { null }) +public val java.util.Locale.kLocale: Locale get() = Locale(language, country.ifBlank { null }) diff --git a/gateway/src/jvmMain/kotlin/dev/kord/gateway/Inflater.kt b/gateway/src/jvmMain/kotlin/dev/kord/gateway/Inflater.kt index 307f75d9684e..19a20d07dd70 100644 --- a/gateway/src/jvmMain/kotlin/dev/kord/gateway/Inflater.kt +++ b/gateway/src/jvmMain/kotlin/dev/kord/gateway/Inflater.kt @@ -3,10 +3,9 @@ package dev.kord.gateway import io.ktor.websocket.* import java.io.ByteArrayOutputStream import java.util.zip.InflaterOutputStream -import java.util.zip.Inflater as JvmInflater internal actual class Inflater { - private val delegate = JvmInflater() + private val delegate = java.util.zip.Inflater() actual suspend fun Frame.inflateData(): String { val outputStream = ByteArrayOutputStream() From 93f3ffd5ec114480963ab6d8db772e999b095bbb Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Thu, 30 Mar 2023 19:49:15 +0200 Subject: [PATCH 065/136] Omit common root package from directory structure Also moved tests to right packages. --- common/src/commonTest/kotlin/BitSetTests.kt | 4 ++-- common/src/commonTest/kotlin/LocaleTest.kt | 1 - .../commonTest/kotlin/entity/SnowflakeTest.kt | 3 +-- .../src/commonTest/kotlin/json/ChannelTest.kt | 2 +- common/src/commonTest/kotlin/json/EmojiTest.kt | 2 +- common/src/commonTest/kotlin/json/GuildTest.kt | 2 +- .../commonTest/kotlin/json/InteractionTest.kt | 2 +- .../src/commonTest/kotlin/json/MessageTest.kt | 2 +- .../commonTest/kotlin/json/PermissionsTest.kt | 2 +- common/src/commonTest/kotlin/json/UserTest.kt | 2 +- common/src/commonTest/kotlin/json/Util.kt | 2 +- .../commonTest/kotlin/json/VoiceStateTest.kt | 2 +- .../AbstractIntervalRateLimiterTest.kt | 1 - .../serialization/DurationSerializersTests.kt | 3 +-- .../serialization/InstantSerializersTests.kt | 4 +--- .../kotlin/{dev/kord/common => }/Platform.kt | 0 .../{dev/kord/common => }/http/HttpEngine.kt | 0 .../kotlin/{ColorTests.kt => ColorTestsJvm.kt} | 5 +++-- .../{SnowflakeTest.kt => SnowflakeTestJvm.kt} | 3 +-- .../BaseVoiceChannelBehaviorExtensions.kt | 0 .../src/commonTest/kotlin/KordTest.kt | 4 ++-- .../src/commonTest/kotlin/StrategyTest.kt | 8 ++++++-- .../src/commonTest/kotlin/TestToken.kt | 8 ++++---- .../kotlin/regression/CacheMissRegression.kt | 18 ++---------------- core/src/commonTest/kotlin/RandomIds.kt | 2 ++ core/src/commonTest/kotlin/UtilKtTest.kt | 4 ++-- .../kotlin/cache/data/ComponentDataTest.kt | 4 +--- .../kotlin/gateway/MasterGatewayTest.kt | 3 +-- .../kotlin/live/AbstractLiveEntityTest.kt | 5 ++--- .../commonTest/kotlin/live/LiveGuildTest.kt | 5 ++--- .../kotlin/live/LiveKordEntityTest.kt | 10 +++++----- .../commonTest/kotlin/live/LiveMemberTest.kt | 6 ++---- .../commonTest/kotlin/live/LiveMessageTest.kt | 5 ++--- .../src/commonTest/kotlin/live/LiveRoleTest.kt | 6 ++---- .../src/commonTest/kotlin/live/LiveUserTest.kt | 6 ++---- .../kotlin/live/channel/LiveCategoryTest.kt | 6 ++---- .../kotlin/live/channel/LiveChannelTest.kt | 7 +++---- .../kotlin/live/channel/LiveDmChannelTest.kt | 6 ++---- .../live/channel/LiveGuildChannelTest.kt | 6 ++---- .../kotlin/live/channel/LiveGuildTextTest.kt | 6 ++---- .../live/channel/LiveVoiceChannelTest.kt | 6 ++---- .../kotlin/performance/KordEventDropTest.kt | 2 +- .../kotlin/regression/ReactionEmojiTest.kt | 2 +- .../kotlin/supplier/CacheEntitySupplierTest.kt | 3 +-- .../kord/core/builder/kord => }/KordBuilder.kt | 0 .../kord/core => }/builder/kord/KordBuilder.kt | 0 .../kord/core => }/cache/KordCacheBuilder.kt | 0 .../jvmTest/kotlin/{Util.kt => MockKord.kt} | 5 +++-- .../kotlin/behavior/GuildBehaviorTest.kt | 6 +++--- .../kotlin/behavior/MemberBehaviorTest.kt | 6 +++--- .../kotlin/behavior/MessageBehaviorTest.kt | 4 ++-- .../kotlin/behavior/RoleBehaviorTest.kt | 4 ++-- .../kotlin/behavior/UserBehaviorTest.kt | 6 +++--- .../kotlin/behavior/WebhookBehaviorTest.kt | 6 +++--- .../behavior/channel/CategoryBehaviorTest.kt | 6 +++--- .../behavior/channel/ChannelBehaviorTest.kt | 6 +++--- .../channel/GuildChannelBehaviorTest.kt | 6 +++--- .../channel/GuildMessageChannelBehaviorTest.kt | 6 +++--- .../channel/MessageChannelBehaviorTest.kt | 6 +++--- .../channel/NewsChannelBehaviorTest.kt | 6 +++--- .../channel/TextChannelBehaviorTest.kt | 6 +++--- .../channel/VoiceChannelBehaviorTest.kt | 6 +++--- .../jvmTest/kotlin/entity/ApplicationTest.kt | 7 +++---- .../jvmTest/kotlin/entity/AttachmentTest.kt | 4 ++-- .../jvmTest/kotlin/entity/GuildEmojiTest.kt | 6 +++--- core/src/jvmTest/kotlin/entity/GuildTest.kt | 8 ++++---- .../jvmTest/kotlin/entity/IntegrationTest.kt | 6 +++--- core/src/jvmTest/kotlin/entity/MemberTest.kt | 6 +++--- core/src/jvmTest/kotlin/entity/MessageTest.kt | 8 ++++---- core/src/jvmTest/kotlin/entity/RoleTest.kt | 8 ++++---- core/src/jvmTest/kotlin/entity/UserTest.kt | 8 ++++---- core/src/jvmTest/kotlin/entity/WebhookTest.kt | 8 ++++---- .../kotlin/entity/channel/CategoryTest.kt | 6 +++--- .../kotlin/entity/channel/DmChannelTest.kt | 6 +++--- .../kotlin/entity/channel/NewsChannelTest.kt | 6 +++--- .../kotlin/entity/channel/TextChannelTest.kt | 6 +++--- .../kotlin/entity/channel/VoiceChannelTest.kt | 6 +++--- .../kotlin/equality/BehaviorEqualityTest.kt | 4 ++-- .../kotlin/equality/ChannelEqualityTest.kt | 6 +++--- .../kotlin/equality/EntityEqualityTest.kt | 4 ++-- .../equality/GuildChannelEqualityTest.kt | 4 ++-- .../kotlin/equality/GuildEntityEqualityTest.kt | 4 ++-- .../kotlin/interaction/CommandTypesTest.kt | 12 +++++++----- core/src/jvmTest/kotlin/rest/RestTest.kt | 2 +- .../kotlin/{gateway => }/DefaultGatewayTest.kt | 0 .../src/commonTest/kotlin/json/CommandTest.kt | 4 ++-- .../commonTest/kotlin/json/RegressionTests.kt | 2 +- .../kotlin/json/SerializationTest.kt | 2 +- .../commonTest/kotlin/json/SnowflakeTest.kt | 2 +- gateway/src/commonTest/kotlin/json/Util.kt | 2 +- .../ratelimit/IdentifyRateLimiterTest.kt | 3 +-- .../{helper => retry}/LinearRetryTest.kt | 3 +-- .../{dev/kord/gateway => }/DefaultGateway.kt | 0 .../kotlin/{dev/kord/gateway => }/Inflater.kt | 0 .../kord/gateway => }/internal/JsInflater.kt | 0 .../kord/gateway => }/DefaultGatewayJvm.kt | 0 .../kotlin/{dev/kord/gateway => }/Inflater.kt | 0 .../kotlin/builder/EmojiModifyBuilderTest.kt | 2 ++ .../rest/request => }/RecoveredStackTrace.kt | 0 .../message/create/MessageCreateBuilderJvm.kt | 0 .../message/modify/MessageModifyBuilderJvm.kt | 0 .../rest => }/request/RecoveredStackTrace.kt | 0 .../kord/rest => }/request/RequestBuilder.kt | 0 .../kotlin/{dev/kord => }/core/PingBot.kt | 0 .../{dev/kord => }/gateway/GatewayExample.kt | 0 .../kotlin/{dev/kord => }/rest/RestExample.kt | 0 .../kotlin/{dev/kord/test => }/Annotations.kt | 0 .../kotlin/{dev/kord/test => }/Platfrom.kt | 0 .../kotlin/{dev/kord/test => }/IgnoreOnJs.kt | 0 .../kotlin/{dev/kord/test => }/Platform.kt | 0 .../{dev/kord/test => }/Platform.node.kt | 0 .../kotlin/{dev/kord/test => }/IgnoreOnJvm.kt | 0 .../kotlin/{dev/kord/test => }/Platform.kt | 0 113 files changed, 192 insertions(+), 228 deletions(-) rename common/src/jsMain/kotlin/{dev/kord/common => }/Platform.kt (100%) rename common/src/jsMain/kotlin/{dev/kord/common => }/http/HttpEngine.kt (100%) rename common/src/jvmTest/kotlin/{ColorTests.kt => ColorTestsJvm.kt} (85%) rename common/src/jvmTest/kotlin/entity/{SnowflakeTest.kt => SnowflakeTestJvm.kt} (88%) rename core-voice/src/main/kotlin/{dev/kord/core/behavior/channel => }/BaseVoiceChannelBehaviorExtensions.kt (100%) rename core/src/jsMain/kotlin/{dev/kord/core/builder/kord => }/KordBuilder.kt (100%) rename core/src/jvmMain/kotlin/{dev/kord/core => }/builder/kord/KordBuilder.kt (100%) rename core/src/jvmMain/kotlin/{dev/kord/core => }/cache/KordCacheBuilder.kt (100%) rename core/src/jvmTest/kotlin/{Util.kt => MockKord.kt} (93%) rename gateway/src/commonTest/kotlin/{gateway => }/DefaultGatewayTest.kt (100%) rename gateway/src/commonTest/kotlin/{helper => retry}/LinearRetryTest.kt (95%) rename gateway/src/jsMain/kotlin/{dev/kord/gateway => }/DefaultGateway.kt (100%) rename gateway/src/jsMain/kotlin/{dev/kord/gateway => }/Inflater.kt (100%) rename gateway/src/jsMain/kotlin/{dev/kord/gateway => }/internal/JsInflater.kt (100%) rename gateway/src/jvmMain/kotlin/{dev/kord/gateway => }/DefaultGatewayJvm.kt (100%) rename gateway/src/jvmMain/kotlin/{dev/kord/gateway => }/Inflater.kt (100%) rename rest/src/jsMain/kotlin/{dev/kord/rest/request => }/RecoveredStackTrace.kt (100%) rename rest/src/jvmMain/kotlin/{dev/kord/rest => }/builder/message/create/MessageCreateBuilderJvm.kt (100%) rename rest/src/jvmMain/kotlin/{dev/kord/rest => }/builder/message/modify/MessageModifyBuilderJvm.kt (100%) rename rest/src/jvmMain/kotlin/{dev/kord/rest => }/request/RecoveredStackTrace.kt (100%) rename rest/src/jvmMain/kotlin/{dev/kord/rest => }/request/RequestBuilder.kt (100%) rename samples/src/commonMain/kotlin/{dev/kord => }/core/PingBot.kt (100%) rename samples/src/commonMain/kotlin/{dev/kord => }/gateway/GatewayExample.kt (100%) rename samples/src/commonMain/kotlin/{dev/kord => }/rest/RestExample.kt (100%) rename test-kit/src/commonMain/kotlin/{dev/kord/test => }/Annotations.kt (100%) rename test-kit/src/commonMain/kotlin/{dev/kord/test => }/Platfrom.kt (100%) rename test-kit/src/jsMain/kotlin/{dev/kord/test => }/IgnoreOnJs.kt (100%) rename test-kit/src/jsMain/kotlin/{dev/kord/test => }/Platform.kt (100%) rename test-kit/src/jsMain/kotlin/{dev/kord/test => }/Platform.node.kt (100%) rename test-kit/src/jvmMain/kotlin/{dev/kord/test => }/IgnoreOnJvm.kt (100%) rename test-kit/src/jvmMain/kotlin/{dev/kord/test => }/Platform.kt (100%) diff --git a/common/src/commonTest/kotlin/BitSetTests.kt b/common/src/commonTest/kotlin/BitSetTests.kt index c827b5c20f8e..0360bdfdf600 100644 --- a/common/src/commonTest/kotlin/BitSetTests.kt +++ b/common/src/commonTest/kotlin/BitSetTests.kt @@ -1,5 +1,5 @@ -import dev.kord.common.DiscordBitSet -import dev.kord.common.EmptyBitSet +package dev.kord.common + import kotlin.js.JsName import kotlin.test.* diff --git a/common/src/commonTest/kotlin/LocaleTest.kt b/common/src/commonTest/kotlin/LocaleTest.kt index f5a779a521dc..3130f7f8516a 100644 --- a/common/src/commonTest/kotlin/LocaleTest.kt +++ b/common/src/commonTest/kotlin/LocaleTest.kt @@ -1,6 +1,5 @@ package dev.kord.common -import dev.kord.common.Locale import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json diff --git a/common/src/commonTest/kotlin/entity/SnowflakeTest.kt b/common/src/commonTest/kotlin/entity/SnowflakeTest.kt index 5cc6a36c08e2..6a52cfdc51af 100644 --- a/common/src/commonTest/kotlin/entity/SnowflakeTest.kt +++ b/common/src/commonTest/kotlin/entity/SnowflakeTest.kt @@ -1,6 +1,5 @@ -package entity +package dev.kord.common.entity -import dev.kord.common.entity.Snowflake import kotlinx.datetime.Clock import kotlinx.datetime.Instant import kotlin.js.JsName diff --git a/common/src/commonTest/kotlin/json/ChannelTest.kt b/common/src/commonTest/kotlin/json/ChannelTest.kt index 9d031cda1d17..9153fbd5d252 100644 --- a/common/src/commonTest/kotlin/json/ChannelTest.kt +++ b/common/src/commonTest/kotlin/json/ChannelTest.kt @@ -1,4 +1,4 @@ -package json +package dev.kord.common.json import dev.kord.common.entity.DiscordChannel import dev.kord.common.entity.optional.value diff --git a/common/src/commonTest/kotlin/json/EmojiTest.kt b/common/src/commonTest/kotlin/json/EmojiTest.kt index 879f6b9a63c4..3cca7f47aaf2 100644 --- a/common/src/commonTest/kotlin/json/EmojiTest.kt +++ b/common/src/commonTest/kotlin/json/EmojiTest.kt @@ -1,4 +1,4 @@ -package json +package dev.kord.common.json import dev.kord.common.entity.DiscordEmoji import dev.kord.common.entity.Snowflake diff --git a/common/src/commonTest/kotlin/json/GuildTest.kt b/common/src/commonTest/kotlin/json/GuildTest.kt index d2eedc02004d..d74d43977f83 100644 --- a/common/src/commonTest/kotlin/json/GuildTest.kt +++ b/common/src/commonTest/kotlin/json/GuildTest.kt @@ -1,4 +1,4 @@ -package json +package dev.kord.common.json import dev.kord.common.entity.* import dev.kord.common.readFile diff --git a/common/src/commonTest/kotlin/json/InteractionTest.kt b/common/src/commonTest/kotlin/json/InteractionTest.kt index c345d736c5a6..1f27899a6646 100644 --- a/common/src/commonTest/kotlin/json/InteractionTest.kt +++ b/common/src/commonTest/kotlin/json/InteractionTest.kt @@ -1,4 +1,4 @@ -package json +package dev.kord.common.json import dev.kord.common.entity.* import dev.kord.common.entity.optional.orEmpty diff --git a/common/src/commonTest/kotlin/json/MessageTest.kt b/common/src/commonTest/kotlin/json/MessageTest.kt index c4376382af00..5fea99400e97 100644 --- a/common/src/commonTest/kotlin/json/MessageTest.kt +++ b/common/src/commonTest/kotlin/json/MessageTest.kt @@ -1,4 +1,4 @@ -package json +package dev.kord.common.json import dev.kord.common.entity.* import dev.kord.common.readFile diff --git a/common/src/commonTest/kotlin/json/PermissionsTest.kt b/common/src/commonTest/kotlin/json/PermissionsTest.kt index ce73e1ade9d3..e1dc29845dc1 100644 --- a/common/src/commonTest/kotlin/json/PermissionsTest.kt +++ b/common/src/commonTest/kotlin/json/PermissionsTest.kt @@ -1,4 +1,4 @@ -package json +package dev.kord.common.json import dev.kord.common.DiscordBitSet import dev.kord.common.entity.* diff --git a/common/src/commonTest/kotlin/json/UserTest.kt b/common/src/commonTest/kotlin/json/UserTest.kt index b10bfeba9bab..a5c9c3e2d821 100644 --- a/common/src/commonTest/kotlin/json/UserTest.kt +++ b/common/src/commonTest/kotlin/json/UserTest.kt @@ -1,4 +1,4 @@ -package json +package dev.kord.common.json import dev.kord.common.entity.DiscordUser import dev.kord.common.entity.UserFlags diff --git a/common/src/commonTest/kotlin/json/Util.kt b/common/src/commonTest/kotlin/json/Util.kt index 24f8df2c6c34..a44194e5f60d 100644 --- a/common/src/commonTest/kotlin/json/Util.kt +++ b/common/src/commonTest/kotlin/json/Util.kt @@ -1,4 +1,4 @@ -package json +package dev.kord.common.json import dev.kord.common.entity.* import dev.kord.common.entity.optional.* diff --git a/common/src/commonTest/kotlin/json/VoiceStateTest.kt b/common/src/commonTest/kotlin/json/VoiceStateTest.kt index b7a917c53095..1d73de02faf5 100644 --- a/common/src/commonTest/kotlin/json/VoiceStateTest.kt +++ b/common/src/commonTest/kotlin/json/VoiceStateTest.kt @@ -1,4 +1,4 @@ -package json +package dev.kord.common.json import dev.kord.common.entity.DiscordVoiceState import dev.kord.common.readFile diff --git a/common/src/commonTest/kotlin/ratelimit/AbstractIntervalRateLimiterTest.kt b/common/src/commonTest/kotlin/ratelimit/AbstractIntervalRateLimiterTest.kt index 7038bd99a919..2a47a2cf7324 100644 --- a/common/src/commonTest/kotlin/ratelimit/AbstractIntervalRateLimiterTest.kt +++ b/common/src/commonTest/kotlin/ratelimit/AbstractIntervalRateLimiterTest.kt @@ -1,6 +1,5 @@ package dev.kord.common.ratelimit -import dev.kord.common.ratelimit.IntervalRateLimiter import kotlinx.coroutines.test.currentTime import kotlinx.coroutines.test.runTest import kotlin.js.JsName diff --git a/common/src/commonTest/kotlin/serialization/DurationSerializersTests.kt b/common/src/commonTest/kotlin/serialization/DurationSerializersTests.kt index 31d673a79401..5a5e5761bdbc 100644 --- a/common/src/commonTest/kotlin/serialization/DurationSerializersTests.kt +++ b/common/src/commonTest/kotlin/serialization/DurationSerializersTests.kt @@ -1,6 +1,5 @@ -package serialization +package dev.kord.common.serialization -import dev.kord.common.serialization.* import kotlinx.serialization.SerializationException import kotlinx.serialization.json.Json import kotlin.js.JsName diff --git a/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt b/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt index 0a266ede13fa..70ccbd59d53a 100644 --- a/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt +++ b/common/src/commonTest/kotlin/serialization/InstantSerializersTests.kt @@ -1,7 +1,5 @@ -package serialization +package dev.kord.common.serialization -import dev.kord.common.serialization.InstantInEpochMillisecondsSerializer -import dev.kord.common.serialization.InstantInEpochSecondsSerializer import dev.kord.test.IgnoreOnJs import kotlinx.datetime.Instant import kotlinx.serialization.KSerializer diff --git a/common/src/jsMain/kotlin/dev/kord/common/Platform.kt b/common/src/jsMain/kotlin/Platform.kt similarity index 100% rename from common/src/jsMain/kotlin/dev/kord/common/Platform.kt rename to common/src/jsMain/kotlin/Platform.kt diff --git a/common/src/jsMain/kotlin/dev/kord/common/http/HttpEngine.kt b/common/src/jsMain/kotlin/http/HttpEngine.kt similarity index 100% rename from common/src/jsMain/kotlin/dev/kord/common/http/HttpEngine.kt rename to common/src/jsMain/kotlin/http/HttpEngine.kt diff --git a/common/src/jvmTest/kotlin/ColorTests.kt b/common/src/jvmTest/kotlin/ColorTestsJvm.kt similarity index 85% rename from common/src/jvmTest/kotlin/ColorTests.kt rename to common/src/jvmTest/kotlin/ColorTestsJvm.kt index 387bb1e338a9..c5e15b31c54c 100644 --- a/common/src/jvmTest/kotlin/ColorTests.kt +++ b/common/src/jvmTest/kotlin/ColorTestsJvm.kt @@ -1,9 +1,10 @@ -import dev.kord.common.kColor +package dev.kord.common + import kotlin.test.assertEquals import kotlin.test.Test -class ColorTests { +class ColorTestsJvm { @Test fun `java to kColor conversion`() { val color = java.awt.Color.decode("#DBD0B4").kColor diff --git a/common/src/jvmTest/kotlin/entity/SnowflakeTest.kt b/common/src/jvmTest/kotlin/entity/SnowflakeTestJvm.kt similarity index 88% rename from common/src/jvmTest/kotlin/entity/SnowflakeTest.kt rename to common/src/jvmTest/kotlin/entity/SnowflakeTestJvm.kt index 0fc43f5005ed..604c0a72d558 100644 --- a/common/src/jvmTest/kotlin/entity/SnowflakeTest.kt +++ b/common/src/jvmTest/kotlin/entity/SnowflakeTestJvm.kt @@ -1,6 +1,5 @@ -package entity +package dev.kord.common.entity -import dev.kord.common.entity.Snowflake import org.junit.jupiter.api.Test import kotlin.test.assertEquals diff --git a/core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorExtensions.kt b/core-voice/src/main/kotlin/BaseVoiceChannelBehaviorExtensions.kt similarity index 100% rename from core-voice/src/main/kotlin/dev/kord/core/behavior/channel/BaseVoiceChannelBehaviorExtensions.kt rename to core-voice/src/main/kotlin/BaseVoiceChannelBehaviorExtensions.kt diff --git a/core/live-tests/src/commonTest/kotlin/KordTest.kt b/core/live-tests/src/commonTest/kotlin/KordTest.kt index d3943a744942..c23f1e25ddca 100644 --- a/core/live-tests/src/commonTest/kotlin/KordTest.kt +++ b/core/live-tests/src/commonTest/kotlin/KordTest.kt @@ -1,6 +1,6 @@ -import dev.kord.core.Kord +package dev.kord.core + import dev.kord.core.event.gateway.ReadyEvent -import dev.kord.core.on import kotlinx.coroutines.test.runTest import kotlin.js.JsName import kotlin.test.Test diff --git a/core/live-tests/src/commonTest/kotlin/StrategyTest.kt b/core/live-tests/src/commonTest/kotlin/StrategyTest.kt index 9d3131760ed3..33dd1a28e9b2 100644 --- a/core/live-tests/src/commonTest/kotlin/StrategyTest.kt +++ b/core/live-tests/src/commonTest/kotlin/StrategyTest.kt @@ -1,9 +1,13 @@ +package dev.kord.core + import dev.kord.cache.api.put -import dev.kord.core.Kord import dev.kord.core.supplier.EntitySupplyStrategy import kotlinx.coroutines.test.runTest import kotlin.js.JsName -import kotlin.test.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertNotNull +import kotlin.test.assertNull class StrategyTest { diff --git a/core/live-tests/src/commonTest/kotlin/TestToken.kt b/core/live-tests/src/commonTest/kotlin/TestToken.kt index b37a10568bf9..3634fddf977e 100644 --- a/core/live-tests/src/commonTest/kotlin/TestToken.kt +++ b/core/live-tests/src/commonTest/kotlin/TestToken.kt @@ -1,19 +1,19 @@ +package dev.kord.core + import dev.kord.cache.map.MapDataCache -import dev.kord.core.ClientResources -import dev.kord.core.Kord import dev.kord.core.builder.kord.configure import dev.kord.core.builder.kord.getBotIdFromToken import dev.kord.core.cache.registerKordData import dev.kord.core.gateway.DefaultMasterGateway import dev.kord.core.gateway.handler.DefaultGatewayEventInterceptor +import dev.kord.core.regression.CrashingHandler +import dev.kord.core.regression.FakeGateway import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.gateway.builder.Shards import dev.kord.rest.service.RestClient import dev.kord.test.getEnv import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableSharedFlow -import regression.CrashingHandler -import regression.FakeGateway val testToken = getEnv("KORD_TEST_TOKEN") ?: error("KORD_TEST_TOKEN is not defined") diff --git a/core/live-tests/src/commonTest/kotlin/regression/CacheMissRegression.kt b/core/live-tests/src/commonTest/kotlin/regression/CacheMissRegression.kt index f51a95243f06..50bb6822f7a2 100644 --- a/core/live-tests/src/commonTest/kotlin/regression/CacheMissRegression.kt +++ b/core/live-tests/src/commonTest/kotlin/regression/CacheMissRegression.kt @@ -1,29 +1,19 @@ -package regression +package dev.kord.core.regression import dev.kord.cache.api.put -import dev.kord.cache.map.MapDataCache import dev.kord.common.entity.ChannelType import dev.kord.common.entity.Snowflake -import dev.kord.core.ClientResources -import dev.kord.core.Kord -import dev.kord.core.builder.kord.getBotIdFromToken -import dev.kord.core.builder.kord.configure import dev.kord.core.cache.data.ChannelData -import dev.kord.core.cache.registerKordData -import dev.kord.core.gateway.DefaultMasterGateway -import dev.kord.core.gateway.handler.DefaultGatewayEventInterceptor -import dev.kord.core.supplier.EntitySupplyStrategy +import dev.kord.core.withKord import dev.kord.gateway.Command import dev.kord.gateway.Event import dev.kord.gateway.Gateway import dev.kord.gateway.GatewayConfiguration -import dev.kord.gateway.builder.Shards import dev.kord.rest.request.JsonRequest import dev.kord.rest.request.MultipartRequest import dev.kord.rest.request.Request import dev.kord.rest.request.RequestHandler import dev.kord.rest.route.Route -import dev.kord.rest.service.RestClient import io.ktor.client.* import io.ktor.client.request.* import io.ktor.client.request.forms.* @@ -31,7 +21,6 @@ import io.ktor.client.statement.* import io.ktor.content.* import io.ktor.http.* import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -40,12 +29,9 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.test.runTest import kotlinx.serialization.SerializationStrategy import kotlinx.serialization.json.Json -import testToken -import withKord import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext import kotlin.js.JsName -import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertFailsWith import kotlin.time.Duration diff --git a/core/src/commonTest/kotlin/RandomIds.kt b/core/src/commonTest/kotlin/RandomIds.kt index 0cfab39b24ee..9c49fe8c956a 100644 --- a/core/src/commonTest/kotlin/RandomIds.kt +++ b/core/src/commonTest/kotlin/RandomIds.kt @@ -1,3 +1,5 @@ +package dev.kord.core + import dev.kord.common.entity.Snowflake import kotlin.random.Random import kotlin.random.nextULong diff --git a/core/src/commonTest/kotlin/UtilKtTest.kt b/core/src/commonTest/kotlin/UtilKtTest.kt index fc5b51a8e3cc..e276e55e2005 100644 --- a/core/src/commonTest/kotlin/UtilKtTest.kt +++ b/core/src/commonTest/kotlin/UtilKtTest.kt @@ -1,6 +1,6 @@ +package dev.kord.core + import dev.kord.common.entity.Snowflake -import dev.kord.core.paginateBackwards -import dev.kord.core.paginateForwards import kotlinx.coroutines.flow.count import kotlinx.coroutines.test.runTest import kotlin.js.JsName diff --git a/core/src/commonTest/kotlin/cache/data/ComponentDataTest.kt b/core/src/commonTest/kotlin/cache/data/ComponentDataTest.kt index b4cc0b322237..ec9b840f8843 100644 --- a/core/src/commonTest/kotlin/cache/data/ComponentDataTest.kt +++ b/core/src/commonTest/kotlin/cache/data/ComponentDataTest.kt @@ -1,8 +1,6 @@ -package cache.data +package dev.kord.core.cache.data import dev.kord.common.entity.ComponentType -import dev.kord.core.cache.data.ChatComponentData -import dev.kord.core.cache.data.ComponentData import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import kotlin.js.JsName diff --git a/core/src/commonTest/kotlin/gateway/MasterGatewayTest.kt b/core/src/commonTest/kotlin/gateway/MasterGatewayTest.kt index 2b0cf66b1456..ed4e3f5405bc 100644 --- a/core/src/commonTest/kotlin/gateway/MasterGatewayTest.kt +++ b/core/src/commonTest/kotlin/gateway/MasterGatewayTest.kt @@ -1,6 +1,5 @@ -package gateway +package dev.kord.core.gateway -import dev.kord.core.gateway.DefaultMasterGateway import dev.kord.gateway.Command import dev.kord.gateway.Event import dev.kord.gateway.Gateway diff --git a/core/src/commonTest/kotlin/live/AbstractLiveEntityTest.kt b/core/src/commonTest/kotlin/live/AbstractLiveEntityTest.kt index 9b043da677ac..2df59fe02e12 100644 --- a/core/src/commonTest/kotlin/live/AbstractLiveEntityTest.kt +++ b/core/src/commonTest/kotlin/live/AbstractLiveEntityTest.kt @@ -1,4 +1,4 @@ -package live +package dev.kord.core.live import dev.kord.cache.api.DataCache import dev.kord.common.entity.Snowflake @@ -6,7 +6,7 @@ import dev.kord.core.ClientResources import dev.kord.core.Kord import dev.kord.core.gateway.DefaultMasterGateway import dev.kord.core.gateway.handler.DefaultGatewayEventInterceptor -import dev.kord.core.live.AbstractLiveKordEntity +import dev.kord.core.randomId import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.gateway.Command import dev.kord.gateway.Event @@ -23,7 +23,6 @@ import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.test.runTest -import randomId import kotlin.coroutines.CoroutineContext import kotlin.coroutines.EmptyCoroutineContext import kotlin.test.* diff --git a/core/src/commonTest/kotlin/live/LiveGuildTest.kt b/core/src/commonTest/kotlin/live/LiveGuildTest.kt index 2d262e5b92e6..1c53cacd1a97 100644 --- a/core/src/commonTest/kotlin/live/LiveGuildTest.kt +++ b/core/src/commonTest/kotlin/live/LiveGuildTest.kt @@ -1,4 +1,4 @@ -package live +package dev.kord.core.live import dev.kord.common.entity.* import dev.kord.common.entity.optional.Optional @@ -7,14 +7,13 @@ import dev.kord.core.cache.data.GuildData import dev.kord.core.entity.Guild import dev.kord.core.entity.ReactionEmoji import dev.kord.core.event.guild.GuildDeleteEvent -import dev.kord.core.live.* import dev.kord.core.live.exception.LiveCancellationException +import dev.kord.core.randomId import dev.kord.gateway.* import kotlinx.coroutines.job import kotlinx.coroutines.test.runTest import kotlinx.datetime.Instant import kotlinx.serialization.json.JsonObject -import randomId import kotlin.js.JsName import kotlin.test.BeforeTest import kotlin.test.Ignore diff --git a/core/src/commonTest/kotlin/live/LiveKordEntityTest.kt b/core/src/commonTest/kotlin/live/LiveKordEntityTest.kt index 5e4fcc3de330..69d84a05a029 100644 --- a/core/src/commonTest/kotlin/live/LiveKordEntityTest.kt +++ b/core/src/commonTest/kotlin/live/LiveKordEntityTest.kt @@ -1,4 +1,4 @@ -package live +package dev.kord.core.live import dev.kord.common.entity.* import dev.kord.core.Kord @@ -7,15 +7,15 @@ import dev.kord.core.event.Event import dev.kord.core.event.guild.BanAddEvent import dev.kord.core.event.guild.GuildDeleteEvent import dev.kord.core.event.message.ReactionAddEvent -import dev.kord.core.live.AbstractLiveKordEntity import dev.kord.core.live.exception.LiveCancellationException -import dev.kord.core.live.on +import dev.kord.core.randomId import dev.kord.gateway.GuildBanAdd import dev.kord.gateway.GuildDelete import dev.kord.gateway.MessageReactionAdd -import kotlinx.coroutines.* +import kotlinx.coroutines.delay +import kotlinx.coroutines.isActive +import kotlinx.coroutines.job import kotlinx.coroutines.test.runTest -import randomId import kotlin.js.JsName import kotlin.test.* import kotlin.time.Duration.Companion.milliseconds diff --git a/core/src/commonTest/kotlin/live/LiveMemberTest.kt b/core/src/commonTest/kotlin/live/LiveMemberTest.kt index fd9b304c573b..5eabcb348989 100644 --- a/core/src/commonTest/kotlin/live/LiveMemberTest.kt +++ b/core/src/commonTest/kotlin/live/LiveMemberTest.kt @@ -1,4 +1,4 @@ -package live +package dev.kord.core.live import dev.kord.common.entity.* import dev.kord.common.entity.optional.Optional @@ -8,9 +8,8 @@ import dev.kord.core.entity.Member import dev.kord.core.event.guild.BanAddEvent import dev.kord.core.event.guild.GuildDeleteEvent import dev.kord.core.event.guild.MemberLeaveEvent -import dev.kord.core.live.LiveMember import dev.kord.core.live.exception.LiveCancellationException -import dev.kord.core.live.onUpdate +import dev.kord.core.randomId import dev.kord.gateway.GuildBanAdd import dev.kord.gateway.GuildDelete import dev.kord.gateway.GuildMemberRemove @@ -18,7 +17,6 @@ import dev.kord.gateway.GuildMemberUpdate import kotlinx.coroutines.job import kotlinx.coroutines.test.runTest import kotlinx.datetime.Instant -import randomId import kotlin.js.JsName import kotlin.test.BeforeTest import kotlin.test.Ignore diff --git a/core/src/commonTest/kotlin/live/LiveMessageTest.kt b/core/src/commonTest/kotlin/live/LiveMessageTest.kt index 8857d0a206d2..02b1b92bea8b 100644 --- a/core/src/commonTest/kotlin/live/LiveMessageTest.kt +++ b/core/src/commonTest/kotlin/live/LiveMessageTest.kt @@ -1,4 +1,4 @@ -package live +package dev.kord.core.live import dev.kord.common.entity.* import dev.kord.core.cache.data.MessageData @@ -9,10 +9,9 @@ import dev.kord.core.event.channel.ChannelDeleteEvent import dev.kord.core.event.guild.GuildDeleteEvent import dev.kord.core.event.message.MessageBulkDeleteEvent import dev.kord.core.event.message.MessageDeleteEvent -import dev.kord.core.live.* import dev.kord.core.live.exception.LiveCancellationException +import dev.kord.core.randomId import dev.kord.gateway.* -import randomId import kotlinx.coroutines.job import kotlinx.coroutines.test.runTest import kotlinx.datetime.Instant diff --git a/core/src/commonTest/kotlin/live/LiveRoleTest.kt b/core/src/commonTest/kotlin/live/LiveRoleTest.kt index a7c0ab282a98..3f19e64bf214 100644 --- a/core/src/commonTest/kotlin/live/LiveRoleTest.kt +++ b/core/src/commonTest/kotlin/live/LiveRoleTest.kt @@ -1,4 +1,4 @@ -package live +package dev.kord.core.live import dev.kord.common.entity.* import dev.kord.common.entity.optional.Optional @@ -6,15 +6,13 @@ import dev.kord.core.cache.data.RoleData import dev.kord.core.entity.Role import dev.kord.core.event.guild.GuildDeleteEvent import dev.kord.core.event.role.RoleDeleteEvent -import dev.kord.core.live.LiveRole import dev.kord.core.live.exception.LiveCancellationException -import dev.kord.core.live.onUpdate +import dev.kord.core.randomId import dev.kord.gateway.GuildDelete import dev.kord.gateway.GuildRoleDelete import dev.kord.gateway.GuildRoleUpdate import kotlinx.coroutines.job import kotlinx.coroutines.test.runTest -import randomId import kotlin.js.JsName import kotlin.test.BeforeTest import kotlin.test.Ignore diff --git a/core/src/commonTest/kotlin/live/LiveUserTest.kt b/core/src/commonTest/kotlin/live/LiveUserTest.kt index f25b6dd1acc8..4783c4bc4130 100644 --- a/core/src/commonTest/kotlin/live/LiveUserTest.kt +++ b/core/src/commonTest/kotlin/live/LiveUserTest.kt @@ -1,14 +1,12 @@ -package live +package dev.kord.core.live import dev.kord.common.entity.DiscordUser import dev.kord.common.entity.Snowflake import dev.kord.core.cache.data.UserData import dev.kord.core.entity.User -import dev.kord.core.live.LiveUser -import dev.kord.core.live.onUpdate +import dev.kord.core.randomId import dev.kord.gateway.UserUpdate import kotlinx.coroutines.test.runTest -import randomId import kotlin.js.JsName import kotlin.test.BeforeTest import kotlin.test.Ignore diff --git a/core/src/commonTest/kotlin/live/channel/LiveCategoryTest.kt b/core/src/commonTest/kotlin/live/channel/LiveCategoryTest.kt index 7029509dabb9..afbb9036f769 100644 --- a/core/src/commonTest/kotlin/live/channel/LiveCategoryTest.kt +++ b/core/src/commonTest/kotlin/live/channel/LiveCategoryTest.kt @@ -1,4 +1,4 @@ -package live.channel +package dev.kord.core.live.channel import dev.kord.common.entity.ChannelType import dev.kord.common.entity.DiscordChannel @@ -6,11 +6,9 @@ import dev.kord.common.entity.Snowflake import dev.kord.common.entity.optional.optionalSnowflake import dev.kord.core.cache.data.ChannelData import dev.kord.core.entity.channel.Category -import dev.kord.core.live.channel.LiveCategory -import dev.kord.core.live.channel.onUpdate +import dev.kord.core.randomId import dev.kord.gateway.ChannelUpdate import kotlinx.coroutines.test.runTest -import randomId import kotlin.js.JsName import kotlin.test.BeforeTest import kotlin.test.Ignore diff --git a/core/src/commonTest/kotlin/live/channel/LiveChannelTest.kt b/core/src/commonTest/kotlin/live/channel/LiveChannelTest.kt index 9a0975f4fd40..2fc1e617b045 100644 --- a/core/src/commonTest/kotlin/live/channel/LiveChannelTest.kt +++ b/core/src/commonTest/kotlin/live/channel/LiveChannelTest.kt @@ -1,4 +1,4 @@ -package live.channel +package dev.kord.core.live.channel import dev.kord.common.entity.ChannelType import dev.kord.common.entity.DiscordChannel @@ -8,14 +8,13 @@ import dev.kord.core.cache.data.ChannelData import dev.kord.core.entity.channel.* import dev.kord.core.event.channel.ChannelDeleteEvent import dev.kord.core.event.guild.GuildDeleteEvent -import dev.kord.core.live.channel.* +import dev.kord.core.live.AbstractLiveEntityTest import dev.kord.core.live.exception.LiveCancellationException +import dev.kord.core.randomId import dev.kord.gateway.ChannelDelete import dev.kord.gateway.GuildDelete import kotlinx.coroutines.job import kotlinx.coroutines.test.runTest -import live.AbstractLiveEntityTest -import randomId import kotlin.js.JsName import kotlin.reflect.KClass import kotlin.test.Ignore diff --git a/core/src/commonTest/kotlin/live/channel/LiveDmChannelTest.kt b/core/src/commonTest/kotlin/live/channel/LiveDmChannelTest.kt index 5dbdc7afb3eb..746d0953d9d4 100644 --- a/core/src/commonTest/kotlin/live/channel/LiveDmChannelTest.kt +++ b/core/src/commonTest/kotlin/live/channel/LiveDmChannelTest.kt @@ -1,4 +1,4 @@ -package live.channel +package dev.kord.core.live.channel import dev.kord.common.entity.ChannelType import dev.kord.common.entity.DiscordChannel @@ -6,11 +6,9 @@ import dev.kord.common.entity.Snowflake import dev.kord.common.entity.optional.optionalSnowflake import dev.kord.core.cache.data.ChannelData import dev.kord.core.entity.channel.DmChannel -import dev.kord.core.live.channel.LiveDmChannel -import dev.kord.core.live.channel.onUpdate +import dev.kord.core.randomId import dev.kord.gateway.ChannelUpdate import kotlinx.coroutines.test.runTest -import randomId import kotlin.js.JsName import kotlin.test.BeforeTest import kotlin.test.Ignore diff --git a/core/src/commonTest/kotlin/live/channel/LiveGuildChannelTest.kt b/core/src/commonTest/kotlin/live/channel/LiveGuildChannelTest.kt index 2f0d2e18ea10..1fe0e03905bc 100644 --- a/core/src/commonTest/kotlin/live/channel/LiveGuildChannelTest.kt +++ b/core/src/commonTest/kotlin/live/channel/LiveGuildChannelTest.kt @@ -1,4 +1,4 @@ -package live.channel +package dev.kord.core.live.channel import dev.kord.common.entity.ChannelType import dev.kord.common.entity.DiscordChannel @@ -7,13 +7,11 @@ import dev.kord.common.entity.optional.optionalSnowflake import dev.kord.core.Kord import dev.kord.core.cache.data.ChannelData import dev.kord.core.entity.channel.TopGuildMessageChannel -import dev.kord.core.live.channel.LiveGuildChannel -import dev.kord.core.live.channel.onUpdate +import dev.kord.core.randomId import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.gateway.ChannelUpdate import kotlinx.coroutines.test.runTest -import randomId import kotlin.js.JsName import kotlin.test.BeforeTest import kotlin.test.Ignore diff --git a/core/src/commonTest/kotlin/live/channel/LiveGuildTextTest.kt b/core/src/commonTest/kotlin/live/channel/LiveGuildTextTest.kt index a584d5bec08d..5d34889f54c0 100644 --- a/core/src/commonTest/kotlin/live/channel/LiveGuildTextTest.kt +++ b/core/src/commonTest/kotlin/live/channel/LiveGuildTextTest.kt @@ -1,4 +1,4 @@ -package live.channel +package dev.kord.core.live.channel import dev.kord.common.entity.ChannelType import dev.kord.common.entity.DiscordChannel @@ -7,13 +7,11 @@ import dev.kord.common.entity.optional.optionalSnowflake import dev.kord.core.Kord import dev.kord.core.cache.data.ChannelData import dev.kord.core.entity.channel.TopGuildChannel -import dev.kord.core.live.channel.LiveGuildChannel -import dev.kord.core.live.channel.onUpdate +import dev.kord.core.randomId import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.gateway.ChannelUpdate import kotlinx.coroutines.test.runTest -import randomId import kotlin.js.JsName import kotlin.test.BeforeTest import kotlin.test.Ignore diff --git a/core/src/commonTest/kotlin/live/channel/LiveVoiceChannelTest.kt b/core/src/commonTest/kotlin/live/channel/LiveVoiceChannelTest.kt index 1f94737cf30a..72b2913edc59 100644 --- a/core/src/commonTest/kotlin/live/channel/LiveVoiceChannelTest.kt +++ b/core/src/commonTest/kotlin/live/channel/LiveVoiceChannelTest.kt @@ -1,4 +1,4 @@ -package live.channel +package dev.kord.core.live.channel import dev.kord.common.entity.ChannelType import dev.kord.common.entity.DiscordChannel @@ -6,11 +6,9 @@ import dev.kord.common.entity.Snowflake import dev.kord.common.entity.optional.optionalSnowflake import dev.kord.core.cache.data.ChannelData import dev.kord.core.entity.channel.VoiceChannel -import dev.kord.core.live.channel.LiveVoiceChannel -import dev.kord.core.live.channel.onUpdate +import dev.kord.core.randomId import dev.kord.gateway.ChannelUpdate import kotlinx.coroutines.test.runTest -import randomId import kotlin.js.JsName import kotlin.test.BeforeTest import kotlin.test.Ignore diff --git a/core/src/commonTest/kotlin/performance/KordEventDropTest.kt b/core/src/commonTest/kotlin/performance/KordEventDropTest.kt index 67e8530b02ce..76a8ab111454 100644 --- a/core/src/commonTest/kotlin/performance/KordEventDropTest.kt +++ b/core/src/commonTest/kotlin/performance/KordEventDropTest.kt @@ -1,4 +1,4 @@ -package performance +package dev.kord.core.performance import dev.kord.cache.api.DataCache import dev.kord.common.entity.* diff --git a/core/src/commonTest/kotlin/regression/ReactionEmojiTest.kt b/core/src/commonTest/kotlin/regression/ReactionEmojiTest.kt index 4d1434b28ebe..c1c1c52f0b91 100644 --- a/core/src/commonTest/kotlin/regression/ReactionEmojiTest.kt +++ b/core/src/commonTest/kotlin/regression/ReactionEmojiTest.kt @@ -1,4 +1,4 @@ -package regression +package dev.kord.core.regression import dev.kord.common.entity.Snowflake import dev.kord.core.entity.ReactionEmoji diff --git a/core/src/commonTest/kotlin/supplier/CacheEntitySupplierTest.kt b/core/src/commonTest/kotlin/supplier/CacheEntitySupplierTest.kt index c3f315096391..5b54c6ffe540 100644 --- a/core/src/commonTest/kotlin/supplier/CacheEntitySupplierTest.kt +++ b/core/src/commonTest/kotlin/supplier/CacheEntitySupplierTest.kt @@ -1,4 +1,4 @@ -package supplier +package dev.kord.core.supplier import dev.kord.common.annotation.KordUnsafe import dev.kord.common.entity.Snowflake @@ -7,7 +7,6 @@ import dev.kord.core.Kord import dev.kord.core.cache.KordCacheBuilder import dev.kord.core.gateway.DefaultMasterGateway import dev.kord.core.gateway.handler.DefaultGatewayEventInterceptor -import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.gateway.Gateway import dev.kord.gateway.builder.Shards import dev.kord.rest.request.KtorRequestHandler diff --git a/core/src/jsMain/kotlin/dev/kord/core/builder/kord/KordBuilder.kt b/core/src/jsMain/kotlin/KordBuilder.kt similarity index 100% rename from core/src/jsMain/kotlin/dev/kord/core/builder/kord/KordBuilder.kt rename to core/src/jsMain/kotlin/KordBuilder.kt diff --git a/core/src/jvmMain/kotlin/dev/kord/core/builder/kord/KordBuilder.kt b/core/src/jvmMain/kotlin/builder/kord/KordBuilder.kt similarity index 100% rename from core/src/jvmMain/kotlin/dev/kord/core/builder/kord/KordBuilder.kt rename to core/src/jvmMain/kotlin/builder/kord/KordBuilder.kt diff --git a/core/src/jvmMain/kotlin/dev/kord/core/cache/KordCacheBuilder.kt b/core/src/jvmMain/kotlin/cache/KordCacheBuilder.kt similarity index 100% rename from core/src/jvmMain/kotlin/dev/kord/core/cache/KordCacheBuilder.kt rename to core/src/jvmMain/kotlin/cache/KordCacheBuilder.kt diff --git a/core/src/jvmTest/kotlin/Util.kt b/core/src/jvmTest/kotlin/MockKord.kt similarity index 93% rename from core/src/jvmTest/kotlin/Util.kt rename to core/src/jvmTest/kotlin/MockKord.kt index 108c9d99c1e2..caa1081fb399 100644 --- a/core/src/jvmTest/kotlin/Util.kt +++ b/core/src/jvmTest/kotlin/MockKord.kt @@ -1,4 +1,5 @@ -import dev.kord.core.Kord +package dev.kord.core + import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import io.mockk.every @@ -16,4 +17,4 @@ fun mockKord(): Kord = every { defaultStrategy } returns strategy } every { defaultSupplier } returns supplier - } \ No newline at end of file + } diff --git a/core/src/jvmTest/kotlin/behavior/GuildBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/GuildBehaviorTest.kt index 7b08eaa398f8..b53ec1d494e5 100644 --- a/core/src/jvmTest/kotlin/behavior/GuildBehaviorTest.kt +++ b/core/src/jvmTest/kotlin/behavior/GuildBehaviorTest.kt @@ -1,9 +1,9 @@ package dev.kord.core.behavior -import equality.EntityEqualityTest -import mockKord +import dev.kord.core.equality.EntityEqualityTest +import dev.kord.core.mockKord internal class GuildBehaviorTest: EntityEqualityTest by EntityEqualityTest({ val kord = mockKord() GuildBehavior(it, kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/behavior/MemberBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/MemberBehaviorTest.kt index bf5560613b08..372d8ad13ae5 100644 --- a/core/src/jvmTest/kotlin/behavior/MemberBehaviorTest.kt +++ b/core/src/jvmTest/kotlin/behavior/MemberBehaviorTest.kt @@ -1,9 +1,9 @@ package dev.kord.core.behavior -import equality.GuildEntityEqualityTest -import mockKord +import dev.kord.core.equality.GuildEntityEqualityTest +import dev.kord.core.mockKord internal class MemberBehaviorTest : GuildEntityEqualityTest by GuildEntityEqualityTest({ id, guildId -> val kord = mockKord() MemberBehavior(guildId = guildId, id = id, kord = kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/behavior/MessageBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/MessageBehaviorTest.kt index ec969a237df7..6bb2cd6a1779 100644 --- a/core/src/jvmTest/kotlin/behavior/MessageBehaviorTest.kt +++ b/core/src/jvmTest/kotlin/behavior/MessageBehaviorTest.kt @@ -1,8 +1,8 @@ package dev.kord.core.behavior import dev.kord.common.entity.Snowflake -import equality.EntityEqualityTest -import mockKord +import dev.kord.core.equality.EntityEqualityTest +import dev.kord.core.mockKord internal class MessageBehaviorTest : EntityEqualityTest by EntityEqualityTest({ val kord = mockKord() diff --git a/core/src/jvmTest/kotlin/behavior/RoleBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/RoleBehaviorTest.kt index 08d1f328b8dd..7ee910d59728 100644 --- a/core/src/jvmTest/kotlin/behavior/RoleBehaviorTest.kt +++ b/core/src/jvmTest/kotlin/behavior/RoleBehaviorTest.kt @@ -1,8 +1,8 @@ package dev.kord.core.behavior import dev.kord.common.entity.Snowflake -import equality.GuildEntityEqualityTest -import mockKord +import dev.kord.core.equality.GuildEntityEqualityTest +import dev.kord.core.mockKord import org.junit.jupiter.api.Test import kotlin.test.assertEquals diff --git a/core/src/jvmTest/kotlin/behavior/UserBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/UserBehaviorTest.kt index 0d0385d439d6..2f49a7df24f9 100644 --- a/core/src/jvmTest/kotlin/behavior/UserBehaviorTest.kt +++ b/core/src/jvmTest/kotlin/behavior/UserBehaviorTest.kt @@ -1,9 +1,9 @@ package dev.kord.core.behavior -import equality.EntityEqualityTest -import mockKord +import dev.kord.core.equality.EntityEqualityTest +import dev.kord.core.mockKord internal class UserBehaviorTest : EntityEqualityTest by EntityEqualityTest({ val kord = mockKord() UserBehavior(it, kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/behavior/WebhookBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/WebhookBehaviorTest.kt index d7f9735f8f8a..6f252f3bb0f9 100644 --- a/core/src/jvmTest/kotlin/behavior/WebhookBehaviorTest.kt +++ b/core/src/jvmTest/kotlin/behavior/WebhookBehaviorTest.kt @@ -1,9 +1,9 @@ package dev.kord.core.behavior -import equality.EntityEqualityTest -import mockKord +import dev.kord.core.equality.EntityEqualityTest +import dev.kord.core.mockKord internal class WebhookBehaviorTest : EntityEqualityTest by EntityEqualityTest({ val kord = mockKord() WebhookBehavior(it, kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/behavior/channel/CategoryBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/channel/CategoryBehaviorTest.kt index 35a718cef4da..1e7fb7664233 100644 --- a/core/src/jvmTest/kotlin/behavior/channel/CategoryBehaviorTest.kt +++ b/core/src/jvmTest/kotlin/behavior/channel/CategoryBehaviorTest.kt @@ -1,10 +1,10 @@ package dev.kord.core.behavior.channel -import equality.GuildChannelEqualityTest -import mockKord +import dev.kord.core.equality.GuildChannelEqualityTest +import dev.kord.core.mockKord @Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") internal class CategoryBehaviorTest : GuildChannelEqualityTest by GuildChannelEqualityTest({ id, guildId -> val kord = mockKord() CategoryBehavior(id = id, guildId = guildId, kord = kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/behavior/channel/ChannelBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/channel/ChannelBehaviorTest.kt index 6c96164e114d..7bb991b8a14e 100644 --- a/core/src/jvmTest/kotlin/behavior/channel/ChannelBehaviorTest.kt +++ b/core/src/jvmTest/kotlin/behavior/channel/ChannelBehaviorTest.kt @@ -1,10 +1,10 @@ package dev.kord.core.behavior.channel -import equality.ChannelEqualityTest -import mockKord +import dev.kord.core.equality.ChannelEqualityTest +import dev.kord.core.mockKord @Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") internal class ChannelBehaviorTest : ChannelEqualityTest by ChannelEqualityTest({ id -> val kord = mockKord() ChannelBehavior(id = id, kord = kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/behavior/channel/GuildChannelBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/channel/GuildChannelBehaviorTest.kt index 6b79846e0e71..652d7293045d 100644 --- a/core/src/jvmTest/kotlin/behavior/channel/GuildChannelBehaviorTest.kt +++ b/core/src/jvmTest/kotlin/behavior/channel/GuildChannelBehaviorTest.kt @@ -1,10 +1,10 @@ package dev.kord.core.behavior.channel -import equality.GuildChannelEqualityTest -import mockKord +import dev.kord.core.equality.GuildChannelEqualityTest +import dev.kord.core.mockKord @Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") internal class GuildChannelBehaviorTest : GuildChannelEqualityTest by GuildChannelEqualityTest({ id, guildId -> val kord = mockKord() TopGuildChannelBehavior(id = id, guildId = guildId, kord = kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/behavior/channel/GuildMessageChannelBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/channel/GuildMessageChannelBehaviorTest.kt index f9e27d5613df..26a7bb1c9839 100644 --- a/core/src/jvmTest/kotlin/behavior/channel/GuildMessageChannelBehaviorTest.kt +++ b/core/src/jvmTest/kotlin/behavior/channel/GuildMessageChannelBehaviorTest.kt @@ -1,10 +1,10 @@ package dev.kord.core.behavior.channel -import equality.GuildChannelEqualityTest -import mockKord +import dev.kord.core.equality.GuildChannelEqualityTest +import dev.kord.core.mockKord @Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") internal class GuildMessageChannelBehaviorTest : GuildChannelEqualityTest by GuildChannelEqualityTest({ id, guildId -> val kord = mockKord() TopGuildMessageChannelBehavior(id = id, guildId = guildId, kord = kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/behavior/channel/MessageChannelBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/channel/MessageChannelBehaviorTest.kt index 66be7a6f275e..93bd39ffddb0 100644 --- a/core/src/jvmTest/kotlin/behavior/channel/MessageChannelBehaviorTest.kt +++ b/core/src/jvmTest/kotlin/behavior/channel/MessageChannelBehaviorTest.kt @@ -1,10 +1,10 @@ package dev.kord.core.behavior.channel -import equality.ChannelEqualityTest -import mockKord +import dev.kord.core.equality.ChannelEqualityTest +import dev.kord.core.mockKord @Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") internal class MessageChannelBehaviorTest : ChannelEqualityTest by ChannelEqualityTest({ id -> val kord = mockKord() MessageChannelBehavior(id = id, kord = kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/behavior/channel/NewsChannelBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/channel/NewsChannelBehaviorTest.kt index d81b4bd31b8e..4f7265ac10cf 100644 --- a/core/src/jvmTest/kotlin/behavior/channel/NewsChannelBehaviorTest.kt +++ b/core/src/jvmTest/kotlin/behavior/channel/NewsChannelBehaviorTest.kt @@ -1,10 +1,10 @@ package dev.kord.core.behavior.channel -import equality.GuildChannelEqualityTest -import mockKord +import dev.kord.core.equality.GuildChannelEqualityTest +import dev.kord.core.mockKord @Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") internal class NewsChannelBehaviorTest : GuildChannelEqualityTest by GuildChannelEqualityTest({ id, guildId -> val kord = mockKord() NewsChannelBehavior(id = id, guildId = guildId, kord = kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/behavior/channel/TextChannelBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/channel/TextChannelBehaviorTest.kt index f15b0b561c5d..7422915dbed8 100644 --- a/core/src/jvmTest/kotlin/behavior/channel/TextChannelBehaviorTest.kt +++ b/core/src/jvmTest/kotlin/behavior/channel/TextChannelBehaviorTest.kt @@ -1,10 +1,10 @@ package dev.kord.core.behavior.channel -import equality.GuildChannelEqualityTest -import mockKord +import dev.kord.core.equality.GuildChannelEqualityTest +import dev.kord.core.mockKord @Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") internal class TextChannelBehaviorTest : GuildChannelEqualityTest by GuildChannelEqualityTest({ id, guildId -> val kord = mockKord() TextChannelBehavior(id = id, guildId = guildId, kord = kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/behavior/channel/VoiceChannelBehaviorTest.kt b/core/src/jvmTest/kotlin/behavior/channel/VoiceChannelBehaviorTest.kt index cb8fd2f61269..43c2359d6a80 100644 --- a/core/src/jvmTest/kotlin/behavior/channel/VoiceChannelBehaviorTest.kt +++ b/core/src/jvmTest/kotlin/behavior/channel/VoiceChannelBehaviorTest.kt @@ -1,10 +1,10 @@ package dev.kord.core.behavior.channel -import equality.GuildChannelEqualityTest -import mockKord +import dev.kord.core.equality.GuildChannelEqualityTest +import dev.kord.core.mockKord @Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") internal class VoiceChannelBehaviorTest : GuildChannelEqualityTest by GuildChannelEqualityTest({ id, guildId -> val kord = mockKord() VoiceChannelBehavior(id = id, guildId = guildId, kord = kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/entity/ApplicationTest.kt b/core/src/jvmTest/kotlin/entity/ApplicationTest.kt index 55497b6fd1c6..b707b1ead7c3 100644 --- a/core/src/jvmTest/kotlin/entity/ApplicationTest.kt +++ b/core/src/jvmTest/kotlin/entity/ApplicationTest.kt @@ -1,11 +1,10 @@ -package entity +package dev.kord.core.entity import dev.kord.core.cache.data.ApplicationData -import dev.kord.core.entity.Application -import equality.EntityEqualityTest +import dev.kord.core.equality.EntityEqualityTest +import dev.kord.core.mockKord import io.mockk.every import io.mockk.mockk -import mockKord internal class ApplicationTest : EntityEqualityTest by EntityEqualityTest({ val kord = mockKord() diff --git a/core/src/jvmTest/kotlin/entity/AttachmentTest.kt b/core/src/jvmTest/kotlin/entity/AttachmentTest.kt index c4fb62adac69..d228444074e3 100644 --- a/core/src/jvmTest/kotlin/entity/AttachmentTest.kt +++ b/core/src/jvmTest/kotlin/entity/AttachmentTest.kt @@ -1,10 +1,10 @@ package dev.kord.core.entity import dev.kord.core.cache.data.AttachmentData -import equality.EntityEqualityTest +import dev.kord.core.equality.EntityEqualityTest +import dev.kord.core.mockKord import io.mockk.every import io.mockk.mockk -import mockKord internal class AttachmentTest : EntityEqualityTest by EntityEqualityTest({ val kord = mockKord() diff --git a/core/src/jvmTest/kotlin/entity/GuildEmojiTest.kt b/core/src/jvmTest/kotlin/entity/GuildEmojiTest.kt index 6a7b997c58bf..77e021a89cd6 100644 --- a/core/src/jvmTest/kotlin/entity/GuildEmojiTest.kt +++ b/core/src/jvmTest/kotlin/entity/GuildEmojiTest.kt @@ -1,10 +1,10 @@ package dev.kord.core.entity import dev.kord.core.cache.data.EmojiData -import equality.GuildEntityEqualityTest +import dev.kord.core.equality.GuildEntityEqualityTest +import dev.kord.core.mockKord import io.mockk.every import io.mockk.mockk -import mockKord internal class GuildEmojiTest : GuildEntityEqualityTest by GuildEntityEqualityTest({ id, guildId -> val kord = mockKord() @@ -12,4 +12,4 @@ internal class GuildEmojiTest : GuildEntityEqualityTest by GuildEnti every { data.id } returns id every { data.guildId } returns guildId GuildEmoji(data, kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/entity/GuildTest.kt b/core/src/jvmTest/kotlin/entity/GuildTest.kt index 03fa31e04b31..bcb9637033ac 100644 --- a/core/src/jvmTest/kotlin/entity/GuildTest.kt +++ b/core/src/jvmTest/kotlin/entity/GuildTest.kt @@ -2,11 +2,11 @@ package dev.kord.core.entity import dev.kord.core.behavior.GuildBehavior import dev.kord.core.cache.data.GuildData -import equality.BehaviorEqualityTest -import equality.EntityEqualityTest +import dev.kord.core.equality.BehaviorEqualityTest +import dev.kord.core.equality.EntityEqualityTest +import dev.kord.core.mockKord import io.mockk.every import io.mockk.mockk -import mockKord internal class GuildTest: EntityEqualityTest by EntityEqualityTest({ val kord = mockKord() @@ -15,4 +15,4 @@ internal class GuildTest: EntityEqualityTest by EntityEqualityTest({ Guild(data, kord) }), BehaviorEqualityTest { override fun Guild.behavior(): KordEntity = GuildBehavior(id, kord) -} \ No newline at end of file +} diff --git a/core/src/jvmTest/kotlin/entity/IntegrationTest.kt b/core/src/jvmTest/kotlin/entity/IntegrationTest.kt index ae5a0a1f9e30..37dd58a08626 100644 --- a/core/src/jvmTest/kotlin/entity/IntegrationTest.kt +++ b/core/src/jvmTest/kotlin/entity/IntegrationTest.kt @@ -1,10 +1,10 @@ package dev.kord.core.entity import dev.kord.core.cache.data.IntegrationData -import equality.GuildEntityEqualityTest +import dev.kord.core.equality.GuildEntityEqualityTest import io.mockk.every import io.mockk.mockk -import mockKord +import dev.kord.core.mockKord internal class IntegrationTest : GuildEntityEqualityTest by GuildEntityEqualityTest ({ id, guildId -> val kord = mockKord() @@ -12,4 +12,4 @@ internal class IntegrationTest : GuildEntityEqualityTest by GuildEn every { data.id } returns id every { data.guildId } returns guildId Integration(data, kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/entity/MemberTest.kt b/core/src/jvmTest/kotlin/entity/MemberTest.kt index 4b14d0917cab..6fff9f80dbd4 100644 --- a/core/src/jvmTest/kotlin/entity/MemberTest.kt +++ b/core/src/jvmTest/kotlin/entity/MemberTest.kt @@ -4,11 +4,11 @@ import dev.kord.common.entity.Snowflake import dev.kord.core.behavior.MemberBehavior import dev.kord.core.cache.data.MemberData import dev.kord.core.cache.data.UserData -import equality.BehaviorEqualityTest -import equality.GuildEntityEqualityTest +import dev.kord.core.equality.BehaviorEqualityTest +import dev.kord.core.equality.GuildEntityEqualityTest import io.mockk.every import io.mockk.mockk -import mockKord +import dev.kord.core.mockKord import org.junit.jupiter.api.Test import kotlin.test.assertEquals diff --git a/core/src/jvmTest/kotlin/entity/MessageTest.kt b/core/src/jvmTest/kotlin/entity/MessageTest.kt index 5ea9f3af7094..203bb63a84f9 100644 --- a/core/src/jvmTest/kotlin/entity/MessageTest.kt +++ b/core/src/jvmTest/kotlin/entity/MessageTest.kt @@ -2,11 +2,11 @@ package dev.kord.core.entity import dev.kord.core.behavior.MessageBehavior import dev.kord.core.cache.data.MessageData -import equality.BehaviorEqualityTest -import equality.EntityEqualityTest +import dev.kord.core.equality.BehaviorEqualityTest +import dev.kord.core.equality.EntityEqualityTest +import dev.kord.core.mockKord import io.mockk.every import io.mockk.mockk -import mockKord internal class MessageTest : EntityEqualityTest by EntityEqualityTest({ val kord = mockKord() @@ -16,4 +16,4 @@ internal class MessageTest : EntityEqualityTest by EntityEqualityTest({ Message(data, kord) }), BehaviorEqualityTest { override fun Message.behavior(): KordEntity = MessageBehavior(messageId = id, channelId = id, kord = kord) -} \ No newline at end of file +} diff --git a/core/src/jvmTest/kotlin/entity/RoleTest.kt b/core/src/jvmTest/kotlin/entity/RoleTest.kt index ee3dcc6df5ab..f18c08de0a8a 100644 --- a/core/src/jvmTest/kotlin/entity/RoleTest.kt +++ b/core/src/jvmTest/kotlin/entity/RoleTest.kt @@ -3,11 +3,11 @@ package dev.kord.core.entity import dev.kord.common.entity.optional.Optional import dev.kord.core.behavior.RoleBehavior import dev.kord.core.cache.data.RoleData -import equality.BehaviorEqualityTest -import equality.GuildEntityEqualityTest +import dev.kord.core.equality.BehaviorEqualityTest +import dev.kord.core.equality.GuildEntityEqualityTest +import dev.kord.core.mockKord import io.mockk.every import io.mockk.mockk -import mockKord internal class RoleTest : GuildEntityEqualityTest by GuildEntityEqualityTest({ id, guildId -> val kord = mockKord() @@ -19,4 +19,4 @@ internal class RoleTest : GuildEntityEqualityTest by GuildEntityEqualityTe Role(data, kord) }), BehaviorEqualityTest { override fun Role.behavior(): KordEntity = RoleBehavior(guildId = guildId, id = id, kord = kord) -} \ No newline at end of file +} diff --git a/core/src/jvmTest/kotlin/entity/UserTest.kt b/core/src/jvmTest/kotlin/entity/UserTest.kt index 4b53357739e5..27f74cfab2c2 100644 --- a/core/src/jvmTest/kotlin/entity/UserTest.kt +++ b/core/src/jvmTest/kotlin/entity/UserTest.kt @@ -2,11 +2,11 @@ package dev.kord.core.entity import dev.kord.core.behavior.UserBehavior import dev.kord.core.cache.data.UserData -import equality.BehaviorEqualityTest -import equality.EntityEqualityTest +import dev.kord.core.equality.BehaviorEqualityTest +import dev.kord.core.equality.EntityEqualityTest +import dev.kord.core.mockKord import io.mockk.every import io.mockk.mockk -import mockKord internal class UserTest : EntityEqualityTest by EntityEqualityTest({ val kord = mockKord() @@ -15,4 +15,4 @@ internal class UserTest : EntityEqualityTest by EntityEqualityTest({ User(data, kord) }), BehaviorEqualityTest { override fun User.behavior(): KordEntity = UserBehavior(id = id, kord = kord) -} \ No newline at end of file +} diff --git a/core/src/jvmTest/kotlin/entity/WebhookTest.kt b/core/src/jvmTest/kotlin/entity/WebhookTest.kt index 076bc5d051e8..3b16ee317d3b 100644 --- a/core/src/jvmTest/kotlin/entity/WebhookTest.kt +++ b/core/src/jvmTest/kotlin/entity/WebhookTest.kt @@ -2,11 +2,11 @@ package dev.kord.core.entity import dev.kord.core.behavior.WebhookBehavior import dev.kord.core.cache.data.WebhookData -import equality.BehaviorEqualityTest -import equality.EntityEqualityTest +import dev.kord.core.equality.BehaviorEqualityTest +import dev.kord.core.equality.EntityEqualityTest +import dev.kord.core.mockKord import io.mockk.every import io.mockk.mockk -import mockKord internal class WebhookTest : EntityEqualityTest by EntityEqualityTest({ val kord = mockKord() @@ -15,4 +15,4 @@ internal class WebhookTest : EntityEqualityTest by EntityEqualityTest({ Webhook(data, kord) }), BehaviorEqualityTest { override fun Webhook.behavior(): KordEntity = WebhookBehavior(id = id, kord = kord) -} \ No newline at end of file +} diff --git a/core/src/jvmTest/kotlin/entity/channel/CategoryTest.kt b/core/src/jvmTest/kotlin/entity/channel/CategoryTest.kt index 79d612a62d9f..d31ba0f5d54a 100644 --- a/core/src/jvmTest/kotlin/entity/channel/CategoryTest.kt +++ b/core/src/jvmTest/kotlin/entity/channel/CategoryTest.kt @@ -3,8 +3,8 @@ package dev.kord.core.entity.channel import dev.kord.common.entity.ChannelType import dev.kord.common.entity.optional.optionalSnowflake import dev.kord.core.cache.data.ChannelData -import equality.GuildChannelEqualityTest -import mockKord +import dev.kord.core.equality.GuildChannelEqualityTest +import dev.kord.core.mockKord @Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") internal class CategoryTest : GuildChannelEqualityTest by GuildChannelEqualityTest ({ id, guildId -> @@ -12,4 +12,4 @@ internal class CategoryTest : GuildChannelEqualityTest by GuildChannel Category(ChannelData(id, guildId = guildId.optionalSnowflake(), type = ChannelType.GuildCategory), kord) }) { -} \ No newline at end of file +} diff --git a/core/src/jvmTest/kotlin/entity/channel/DmChannelTest.kt b/core/src/jvmTest/kotlin/entity/channel/DmChannelTest.kt index d184b87a131a..39276dc0a733 100644 --- a/core/src/jvmTest/kotlin/entity/channel/DmChannelTest.kt +++ b/core/src/jvmTest/kotlin/entity/channel/DmChannelTest.kt @@ -2,10 +2,10 @@ package dev.kord.core.entity.channel import dev.kord.common.entity.ChannelType import dev.kord.core.cache.data.ChannelData -import equality.ChannelEqualityTest -import mockKord +import dev.kord.core.equality.ChannelEqualityTest +import dev.kord.core.mockKord internal class DmChannelTest: ChannelEqualityTest by ChannelEqualityTest ({ id -> val kord = mockKord() DmChannel(ChannelData(id, type = ChannelType.DM), kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/entity/channel/NewsChannelTest.kt b/core/src/jvmTest/kotlin/entity/channel/NewsChannelTest.kt index 9ac4d6b80206..ee9d7b06b25b 100644 --- a/core/src/jvmTest/kotlin/entity/channel/NewsChannelTest.kt +++ b/core/src/jvmTest/kotlin/entity/channel/NewsChannelTest.kt @@ -3,11 +3,11 @@ package dev.kord.core.entity.channel import dev.kord.common.entity.ChannelType import dev.kord.common.entity.optional.optionalSnowflake import dev.kord.core.cache.data.ChannelData -import equality.GuildChannelEqualityTest -import mockKord +import dev.kord.core.equality.GuildChannelEqualityTest +import dev.kord.core.mockKord @Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") internal class NewsChannelTest : GuildChannelEqualityTest by GuildChannelEqualityTest({ id, guildId -> val kord = mockKord() NewsChannel(ChannelData(id, guildId = guildId.optionalSnowflake(), type = ChannelType.GuildNews), kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/entity/channel/TextChannelTest.kt b/core/src/jvmTest/kotlin/entity/channel/TextChannelTest.kt index 3edf1c227a87..0ec14972d899 100644 --- a/core/src/jvmTest/kotlin/entity/channel/TextChannelTest.kt +++ b/core/src/jvmTest/kotlin/entity/channel/TextChannelTest.kt @@ -3,11 +3,11 @@ package dev.kord.core.entity.channel import dev.kord.common.entity.ChannelType import dev.kord.common.entity.optional.optionalSnowflake import dev.kord.core.cache.data.ChannelData -import equality.GuildChannelEqualityTest -import mockKord +import dev.kord.core.equality.GuildChannelEqualityTest +import dev.kord.core.mockKord @Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") internal class TextChannelTest : GuildChannelEqualityTest by GuildChannelEqualityTest({ id, guildId -> val kord = mockKord() TextChannel(ChannelData(id, guildId = guildId.optionalSnowflake(), type = ChannelType.GuildNews), kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/entity/channel/VoiceChannelTest.kt b/core/src/jvmTest/kotlin/entity/channel/VoiceChannelTest.kt index a6101b31c449..c2788de85d6a 100644 --- a/core/src/jvmTest/kotlin/entity/channel/VoiceChannelTest.kt +++ b/core/src/jvmTest/kotlin/entity/channel/VoiceChannelTest.kt @@ -3,11 +3,11 @@ package dev.kord.core.entity.channel import dev.kord.common.entity.ChannelType import dev.kord.common.entity.optional.optionalSnowflake import dev.kord.core.cache.data.ChannelData -import equality.GuildChannelEqualityTest -import mockKord +import dev.kord.core.equality.GuildChannelEqualityTest +import dev.kord.core.mockKord @Suppress("DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") internal class VoiceChannelTest : GuildChannelEqualityTest by GuildChannelEqualityTest({ id, guildId -> val kord = mockKord() VoiceChannel(ChannelData(id, guildId = guildId.optionalSnowflake(), type = ChannelType.GuildNews), kord) -}) \ No newline at end of file +}) diff --git a/core/src/jvmTest/kotlin/equality/BehaviorEqualityTest.kt b/core/src/jvmTest/kotlin/equality/BehaviorEqualityTest.kt index d0f1ffbd964e..0c9fdd641491 100644 --- a/core/src/jvmTest/kotlin/equality/BehaviorEqualityTest.kt +++ b/core/src/jvmTest/kotlin/equality/BehaviorEqualityTest.kt @@ -1,7 +1,7 @@ -package equality +package dev.kord.core.equality import dev.kord.core.entity.KordEntity -import randomId +import dev.kord.core.randomId import kotlin.test.Test import kotlin.test.assertEquals diff --git a/core/src/jvmTest/kotlin/equality/ChannelEqualityTest.kt b/core/src/jvmTest/kotlin/equality/ChannelEqualityTest.kt index d6b85a04a3dc..f3c4e7138777 100644 --- a/core/src/jvmTest/kotlin/equality/ChannelEqualityTest.kt +++ b/core/src/jvmTest/kotlin/equality/ChannelEqualityTest.kt @@ -1,10 +1,10 @@ -package equality +package dev.kord.core.equality import dev.kord.common.entity.Snowflake import dev.kord.core.behavior.channel.ChannelBehavior import dev.kord.core.entity.KordEntity -import mockKord -import randomId +import dev.kord.core.mockKord +import dev.kord.core.randomId import kotlin.test.Test import kotlin.test.assertEquals diff --git a/core/src/jvmTest/kotlin/equality/EntityEqualityTest.kt b/core/src/jvmTest/kotlin/equality/EntityEqualityTest.kt index 956c3197b100..40d752b55fc8 100644 --- a/core/src/jvmTest/kotlin/equality/EntityEqualityTest.kt +++ b/core/src/jvmTest/kotlin/equality/EntityEqualityTest.kt @@ -1,8 +1,8 @@ -package equality +package dev.kord.core.equality import dev.kord.common.entity.Snowflake import dev.kord.core.entity.KordEntity -import randomId +import dev.kord.core.randomId import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotEquals diff --git a/core/src/jvmTest/kotlin/equality/GuildChannelEqualityTest.kt b/core/src/jvmTest/kotlin/equality/GuildChannelEqualityTest.kt index 39951040f031..ede33df820cf 100644 --- a/core/src/jvmTest/kotlin/equality/GuildChannelEqualityTest.kt +++ b/core/src/jvmTest/kotlin/equality/GuildChannelEqualityTest.kt @@ -1,4 +1,4 @@ -package equality +package dev.kord.core.equality import dev.kord.common.entity.Snowflake import dev.kord.core.entity.KordEntity @@ -13,4 +13,4 @@ interface GuildChannelEqualityTest : } } -} \ No newline at end of file +} diff --git a/core/src/jvmTest/kotlin/equality/GuildEntityEqualityTest.kt b/core/src/jvmTest/kotlin/equality/GuildEntityEqualityTest.kt index 0f4e950ab4db..4a8dd284c7be 100644 --- a/core/src/jvmTest/kotlin/equality/GuildEntityEqualityTest.kt +++ b/core/src/jvmTest/kotlin/equality/GuildEntityEqualityTest.kt @@ -1,8 +1,8 @@ -package equality +package dev.kord.core.equality import dev.kord.common.entity.Snowflake import dev.kord.core.entity.KordEntity -import randomId +import dev.kord.core.randomId import kotlin.test.Test import kotlin.test.assertNotEquals diff --git a/core/src/jvmTest/kotlin/interaction/CommandTypesTest.kt b/core/src/jvmTest/kotlin/interaction/CommandTypesTest.kt index e69dd9af391f..094229ba15c4 100644 --- a/core/src/jvmTest/kotlin/interaction/CommandTypesTest.kt +++ b/core/src/jvmTest/kotlin/interaction/CommandTypesTest.kt @@ -1,12 +1,14 @@ -package interaction +package dev.kord.core.interaction -import dev.kord.common.annotation.KordPreview import dev.kord.common.entity.ApplicationCommandOptionType import dev.kord.common.entity.InteractionCallbackData import dev.kord.core.cache.data.ApplicationInteractionData -import dev.kord.core.entity.interaction.* +import dev.kord.core.entity.interaction.GroupCommand +import dev.kord.core.entity.interaction.InteractionCommand +import dev.kord.core.entity.interaction.RootCommand +import dev.kord.core.entity.interaction.SubCommand +import dev.kord.core.mockKord import kotlinx.serialization.json.* -import mockKord import org.junit.jupiter.api.Test import kotlin.test.assertEquals @@ -84,4 +86,4 @@ class CommandsTypeTests { assertEquals("group", command.groupName) assertEquals("subCommand", command.name) } -} \ No newline at end of file +} diff --git a/core/src/jvmTest/kotlin/rest/RestTest.kt b/core/src/jvmTest/kotlin/rest/RestTest.kt index 17de2bbd1dd7..6ccaf030d54e 100644 --- a/core/src/jvmTest/kotlin/rest/RestTest.kt +++ b/core/src/jvmTest/kotlin/rest/RestTest.kt @@ -1,4 +1,4 @@ -package rest +package dev.kord.core.rest import dev.kord.common.Color import dev.kord.common.entity.* diff --git a/gateway/src/commonTest/kotlin/gateway/DefaultGatewayTest.kt b/gateway/src/commonTest/kotlin/DefaultGatewayTest.kt similarity index 100% rename from gateway/src/commonTest/kotlin/gateway/DefaultGatewayTest.kt rename to gateway/src/commonTest/kotlin/DefaultGatewayTest.kt diff --git a/gateway/src/commonTest/kotlin/json/CommandTest.kt b/gateway/src/commonTest/kotlin/json/CommandTest.kt index ded8edbead94..5e7420f4c1db 100644 --- a/gateway/src/commonTest/kotlin/json/CommandTest.kt +++ b/gateway/src/commonTest/kotlin/json/CommandTest.kt @@ -1,4 +1,4 @@ -package json +package dev.kord.gateway.json import dev.kord.common.entity.DiscordBotActivity import dev.kord.common.entity.DiscordShard @@ -12,8 +12,8 @@ import dev.kord.gateway.* import kotlinx.datetime.Instant import kotlinx.serialization.json.* import kotlin.js.JsName -import kotlin.test.assertEquals import kotlin.test.Test +import kotlin.test.assertEquals private val json = Json { encodeDefaults = false } diff --git a/gateway/src/commonTest/kotlin/json/RegressionTests.kt b/gateway/src/commonTest/kotlin/json/RegressionTests.kt index 48a41704d203..24fc3e5239f3 100644 --- a/gateway/src/commonTest/kotlin/json/RegressionTests.kt +++ b/gateway/src/commonTest/kotlin/json/RegressionTests.kt @@ -1,4 +1,4 @@ -package json +package dev.kord.gateway.json import dev.kord.gateway.Event import dev.kord.gateway.Reconnect diff --git a/gateway/src/commonTest/kotlin/json/SerializationTest.kt b/gateway/src/commonTest/kotlin/json/SerializationTest.kt index cf257e819fb3..8bdad14c8d2e 100644 --- a/gateway/src/commonTest/kotlin/json/SerializationTest.kt +++ b/gateway/src/commonTest/kotlin/json/SerializationTest.kt @@ -1,4 +1,4 @@ -package json +package dev.kord.gateway.json import dev.kord.common.entity.UserFlags import dev.kord.common.entity.UserPremium diff --git a/gateway/src/commonTest/kotlin/json/SnowflakeTest.kt b/gateway/src/commonTest/kotlin/json/SnowflakeTest.kt index f7d1baaf8bd7..b760627953ce 100644 --- a/gateway/src/commonTest/kotlin/json/SnowflakeTest.kt +++ b/gateway/src/commonTest/kotlin/json/SnowflakeTest.kt @@ -1,4 +1,4 @@ -package json +package dev.kord.gateway.json import dev.kord.common.entity.Snowflake import kotlinx.serialization.Serializable diff --git a/gateway/src/commonTest/kotlin/json/Util.kt b/gateway/src/commonTest/kotlin/json/Util.kt index 525affb86125..0d653a4a4917 100644 --- a/gateway/src/commonTest/kotlin/json/Util.kt +++ b/gateway/src/commonTest/kotlin/json/Util.kt @@ -1,4 +1,4 @@ -package json +package dev.kord.gateway.json import dev.kord.test.file import kotlin.test.assertEquals diff --git a/gateway/src/commonTest/kotlin/ratelimit/IdentifyRateLimiterTest.kt b/gateway/src/commonTest/kotlin/ratelimit/IdentifyRateLimiterTest.kt index 4a2995b1de4e..81d51da4ae0a 100644 --- a/gateway/src/commonTest/kotlin/ratelimit/IdentifyRateLimiterTest.kt +++ b/gateway/src/commonTest/kotlin/ratelimit/IdentifyRateLimiterTest.kt @@ -1,4 +1,4 @@ -package ratelimit +package dev.kord.gateway.ratelimit import dev.kord.common.KordConfiguration import dev.kord.common.entity.DiscordUser @@ -8,7 +8,6 @@ import dev.kord.gateway.GatewayCloseCode.Unknown import dev.kord.gateway.InvalidSession import dev.kord.gateway.Ready import dev.kord.gateway.ReadyData -import dev.kord.gateway.ratelimit.IdentifyRateLimiter import kotlinx.coroutines.* import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.* diff --git a/gateway/src/commonTest/kotlin/helper/LinearRetryTest.kt b/gateway/src/commonTest/kotlin/retry/LinearRetryTest.kt similarity index 95% rename from gateway/src/commonTest/kotlin/helper/LinearRetryTest.kt rename to gateway/src/commonTest/kotlin/retry/LinearRetryTest.kt index 7f2ebfe37924..a11a53d9f8b4 100644 --- a/gateway/src/commonTest/kotlin/helper/LinearRetryTest.kt +++ b/gateway/src/commonTest/kotlin/retry/LinearRetryTest.kt @@ -1,6 +1,5 @@ -package helper +package dev.kord.gateway.retry -import dev.kord.gateway.retry.LinearRetry import kotlinx.coroutines.test.currentTime import kotlinx.coroutines.test.runTest import kotlin.test.Test diff --git a/gateway/src/jsMain/kotlin/dev/kord/gateway/DefaultGateway.kt b/gateway/src/jsMain/kotlin/DefaultGateway.kt similarity index 100% rename from gateway/src/jsMain/kotlin/dev/kord/gateway/DefaultGateway.kt rename to gateway/src/jsMain/kotlin/DefaultGateway.kt diff --git a/gateway/src/jsMain/kotlin/dev/kord/gateway/Inflater.kt b/gateway/src/jsMain/kotlin/Inflater.kt similarity index 100% rename from gateway/src/jsMain/kotlin/dev/kord/gateway/Inflater.kt rename to gateway/src/jsMain/kotlin/Inflater.kt diff --git a/gateway/src/jsMain/kotlin/dev/kord/gateway/internal/JsInflater.kt b/gateway/src/jsMain/kotlin/internal/JsInflater.kt similarity index 100% rename from gateway/src/jsMain/kotlin/dev/kord/gateway/internal/JsInflater.kt rename to gateway/src/jsMain/kotlin/internal/JsInflater.kt diff --git a/gateway/src/jvmMain/kotlin/dev/kord/gateway/DefaultGatewayJvm.kt b/gateway/src/jvmMain/kotlin/DefaultGatewayJvm.kt similarity index 100% rename from gateway/src/jvmMain/kotlin/dev/kord/gateway/DefaultGatewayJvm.kt rename to gateway/src/jvmMain/kotlin/DefaultGatewayJvm.kt diff --git a/gateway/src/jvmMain/kotlin/dev/kord/gateway/Inflater.kt b/gateway/src/jvmMain/kotlin/Inflater.kt similarity index 100% rename from gateway/src/jvmMain/kotlin/dev/kord/gateway/Inflater.kt rename to gateway/src/jvmMain/kotlin/Inflater.kt diff --git a/rest/src/commonTest/kotlin/builder/EmojiModifyBuilderTest.kt b/rest/src/commonTest/kotlin/builder/EmojiModifyBuilderTest.kt index c497dd6a93a3..e413f431e044 100644 --- a/rest/src/commonTest/kotlin/builder/EmojiModifyBuilderTest.kt +++ b/rest/src/commonTest/kotlin/builder/EmojiModifyBuilderTest.kt @@ -1,3 +1,5 @@ +package dev.kord.rest.builder + import dev.kord.common.entity.optional.Optional import dev.kord.rest.builder.guild.EmojiModifyBuilder import kotlin.js.JsName diff --git a/rest/src/jsMain/kotlin/dev/kord/rest/request/RecoveredStackTrace.kt b/rest/src/jsMain/kotlin/RecoveredStackTrace.kt similarity index 100% rename from rest/src/jsMain/kotlin/dev/kord/rest/request/RecoveredStackTrace.kt rename to rest/src/jsMain/kotlin/RecoveredStackTrace.kt diff --git a/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/MessageCreateBuilderJvm.kt b/rest/src/jvmMain/kotlin/builder/message/create/MessageCreateBuilderJvm.kt similarity index 100% rename from rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/create/MessageCreateBuilderJvm.kt rename to rest/src/jvmMain/kotlin/builder/message/create/MessageCreateBuilderJvm.kt diff --git a/rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/MessageModifyBuilderJvm.kt b/rest/src/jvmMain/kotlin/builder/message/modify/MessageModifyBuilderJvm.kt similarity index 100% rename from rest/src/jvmMain/kotlin/dev/kord/rest/builder/message/modify/MessageModifyBuilderJvm.kt rename to rest/src/jvmMain/kotlin/builder/message/modify/MessageModifyBuilderJvm.kt diff --git a/rest/src/jvmMain/kotlin/dev/kord/rest/request/RecoveredStackTrace.kt b/rest/src/jvmMain/kotlin/request/RecoveredStackTrace.kt similarity index 100% rename from rest/src/jvmMain/kotlin/dev/kord/rest/request/RecoveredStackTrace.kt rename to rest/src/jvmMain/kotlin/request/RecoveredStackTrace.kt diff --git a/rest/src/jvmMain/kotlin/dev/kord/rest/request/RequestBuilder.kt b/rest/src/jvmMain/kotlin/request/RequestBuilder.kt similarity index 100% rename from rest/src/jvmMain/kotlin/dev/kord/rest/request/RequestBuilder.kt rename to rest/src/jvmMain/kotlin/request/RequestBuilder.kt diff --git a/samples/src/commonMain/kotlin/dev/kord/core/PingBot.kt b/samples/src/commonMain/kotlin/core/PingBot.kt similarity index 100% rename from samples/src/commonMain/kotlin/dev/kord/core/PingBot.kt rename to samples/src/commonMain/kotlin/core/PingBot.kt diff --git a/samples/src/commonMain/kotlin/dev/kord/gateway/GatewayExample.kt b/samples/src/commonMain/kotlin/gateway/GatewayExample.kt similarity index 100% rename from samples/src/commonMain/kotlin/dev/kord/gateway/GatewayExample.kt rename to samples/src/commonMain/kotlin/gateway/GatewayExample.kt diff --git a/samples/src/commonMain/kotlin/dev/kord/rest/RestExample.kt b/samples/src/commonMain/kotlin/rest/RestExample.kt similarity index 100% rename from samples/src/commonMain/kotlin/dev/kord/rest/RestExample.kt rename to samples/src/commonMain/kotlin/rest/RestExample.kt diff --git a/test-kit/src/commonMain/kotlin/dev/kord/test/Annotations.kt b/test-kit/src/commonMain/kotlin/Annotations.kt similarity index 100% rename from test-kit/src/commonMain/kotlin/dev/kord/test/Annotations.kt rename to test-kit/src/commonMain/kotlin/Annotations.kt diff --git a/test-kit/src/commonMain/kotlin/dev/kord/test/Platfrom.kt b/test-kit/src/commonMain/kotlin/Platfrom.kt similarity index 100% rename from test-kit/src/commonMain/kotlin/dev/kord/test/Platfrom.kt rename to test-kit/src/commonMain/kotlin/Platfrom.kt diff --git a/test-kit/src/jsMain/kotlin/dev/kord/test/IgnoreOnJs.kt b/test-kit/src/jsMain/kotlin/IgnoreOnJs.kt similarity index 100% rename from test-kit/src/jsMain/kotlin/dev/kord/test/IgnoreOnJs.kt rename to test-kit/src/jsMain/kotlin/IgnoreOnJs.kt diff --git a/test-kit/src/jsMain/kotlin/dev/kord/test/Platform.kt b/test-kit/src/jsMain/kotlin/Platform.kt similarity index 100% rename from test-kit/src/jsMain/kotlin/dev/kord/test/Platform.kt rename to test-kit/src/jsMain/kotlin/Platform.kt diff --git a/test-kit/src/jsMain/kotlin/dev/kord/test/Platform.node.kt b/test-kit/src/jsMain/kotlin/Platform.node.kt similarity index 100% rename from test-kit/src/jsMain/kotlin/dev/kord/test/Platform.node.kt rename to test-kit/src/jsMain/kotlin/Platform.node.kt diff --git a/test-kit/src/jvmMain/kotlin/dev/kord/test/IgnoreOnJvm.kt b/test-kit/src/jvmMain/kotlin/IgnoreOnJvm.kt similarity index 100% rename from test-kit/src/jvmMain/kotlin/dev/kord/test/IgnoreOnJvm.kt rename to test-kit/src/jvmMain/kotlin/IgnoreOnJvm.kt diff --git a/test-kit/src/jvmMain/kotlin/dev/kord/test/Platform.kt b/test-kit/src/jvmMain/kotlin/Platform.kt similarity index 100% rename from test-kit/src/jvmMain/kotlin/dev/kord/test/Platform.kt rename to test-kit/src/jvmMain/kotlin/Platform.kt From 01509cf64a5cd921eeb71f6dea7635faa4e555c2 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Thu, 30 Mar 2023 21:23:53 +0200 Subject: [PATCH 066/136] BaseKordBuilder instead of KordBuilderBase --- core/api/core.api | 16 ++++++++-------- .../kotlin/builder/kord/KordBuilder.kt | 5 ++--- core/src/jsMain/kotlin/KordBuilder.kt | 2 +- .../jvmMain/kotlin/builder/kord/KordBuilder.kt | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/core/api/core.api b/core/api/core.api index a6e2ab46197c..e22bb8ad054a 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -2081,14 +2081,7 @@ public final class dev/kord/core/builder/components/ButtonBuilderExtensionsKt { public static final fun emoji (Ldev/kord/rest/builder/component/ButtonBuilder;Ldev/kord/core/entity/ReactionEmoji$Unicode;)V } -public final class dev/kord/core/builder/kord/KordBuilder : dev/kord/core/builder/kord/KordBuilderBase { - public fun (Ljava/lang/String;)V - public fun build (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public final fun getEnableShutdownHook ()Z - public final fun setEnableShutdownHook (Z)V -} - -public abstract class dev/kord/core/builder/kord/KordBuilderBase { +public abstract class dev/kord/core/builder/kord/BaseKordBuilder { public fun build (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; protected final fun buildBase (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public final fun cache (Lkotlin/jvm/functions/Function2;)V @@ -2112,6 +2105,13 @@ public abstract class dev/kord/core/builder/kord/KordBuilderBase { public final fun sharding (Lkotlin/jvm/functions/Function1;)V } +public final class dev/kord/core/builder/kord/KordBuilder : dev/kord/core/builder/kord/BaseKordBuilder { + public fun (Ljava/lang/String;)V + public fun build (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public final fun getEnableShutdownHook ()Z + public final fun setEnableShutdownHook (Z)V +} + public final class dev/kord/core/builder/kord/KordBuilderKt { public static final synthetic fun invoke (Ldev/kord/gateway/DefaultGateway$Companion;Ldev/kord/core/ClientResources;Ldev/kord/gateway/retry/Retry;)Ldev/kord/gateway/DefaultGateway; public static synthetic fun invoke$default (Ldev/kord/gateway/DefaultGateway$Companion;Ldev/kord/core/ClientResources;Ldev/kord/gateway/retry/Retry;ILjava/lang/Object;)Ldev/kord/gateway/DefaultGateway; diff --git a/core/src/commonMain/kotlin/builder/kord/KordBuilder.kt b/core/src/commonMain/kotlin/builder/kord/KordBuilder.kt index 93abacf1b3b3..a30efa507e99 100644 --- a/core/src/commonMain/kotlin/builder/kord/KordBuilder.kt +++ b/core/src/commonMain/kotlin/builder/kord/KordBuilder.kt @@ -38,7 +38,6 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.serialization.json.Json import mu.KotlinLogging -import kotlin.DeprecationLevel.ERROR import kotlin.DeprecationLevel.HIDDEN import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -63,9 +62,9 @@ public operator fun DefaultGateway.Companion.invoke( private val logger = KotlinLogging.logger { } private val gatewayInfoJson = Json { ignoreUnknownKeys = true } -public expect class KordBuilder(token: String) : KordBuilderBase +public expect class KordBuilder(token: String) : BaseKordBuilder -public abstract class KordBuilderBase internal constructor(public val token: String) { +public abstract class BaseKordBuilder internal constructor(public val token: String) { private var shardsBuilder: (recommended: Int) -> Shards = { Shards(it) } private var gatewayBuilder: (resources: ClientResources, shards: List) -> List = { resources, shards -> diff --git a/core/src/jsMain/kotlin/KordBuilder.kt b/core/src/jsMain/kotlin/KordBuilder.kt index bf295b40f3a6..a3d196befb43 100644 --- a/core/src/jsMain/kotlin/KordBuilder.kt +++ b/core/src/jsMain/kotlin/KordBuilder.kt @@ -1,3 +1,3 @@ package dev.kord.core.builder.kord -public actual class KordBuilder actual constructor(token: String) : KordBuilderBase(token) +public actual class KordBuilder actual constructor(token: String) : BaseKordBuilder(token) diff --git a/core/src/jvmMain/kotlin/builder/kord/KordBuilder.kt b/core/src/jvmMain/kotlin/builder/kord/KordBuilder.kt index c9a74b5c91b8..949249cfb12f 100644 --- a/core/src/jvmMain/kotlin/builder/kord/KordBuilder.kt +++ b/core/src/jvmMain/kotlin/builder/kord/KordBuilder.kt @@ -5,7 +5,7 @@ import dev.kord.gateway.Gateway import kotlinx.coroutines.runBlocking import kotlin.concurrent.thread -public actual class KordBuilder actual constructor(token: String) : KordBuilderBase(token) { +public actual class KordBuilder actual constructor(token: String) : BaseKordBuilder(token) { /** * Enable adding a [Runtime.addShutdownHook] to log out of the [Gateway] when the process is killed. */ From 2fbfb9fcc3b8921b7926e91260d951d324989713 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Thu, 30 Mar 2023 21:59:19 +0200 Subject: [PATCH 067/136] Don't depend on ksp-annotations in core:live-tests --- core/live-tests/build.gradle.kts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core/live-tests/build.gradle.kts b/core/live-tests/build.gradle.kts index cd731baa2b82..730e7277baa7 100644 --- a/core/live-tests/build.gradle.kts +++ b/core/live-tests/build.gradle.kts @@ -4,16 +4,13 @@ plugins { kotlin { sourceSets { - commonMain { + applyKordOptIns() + addTestKit(targets) + commonTest { dependencies { implementation(projects.core) - implementation(projects.kspAnnotations) } } - addTestKit(targets) - } - sourceSets { - applyKordOptIns() } } From 71d9c378745cf15cba04851b21d38541da93aff5 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Thu, 30 Mar 2023 22:21:58 +0200 Subject: [PATCH 068/136] Make Inflate class no longer open --- gateway/src/jsMain/kotlin/internal/JsInflater.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/src/jsMain/kotlin/internal/JsInflater.kt b/gateway/src/jsMain/kotlin/internal/JsInflater.kt index 04f8913d17a3..7a0b752ddb28 100644 --- a/gateway/src/jsMain/kotlin/internal/JsInflater.kt +++ b/gateway/src/jsMain/kotlin/internal/JsInflater.kt @@ -6,6 +6,6 @@ package dev.kord.gateway.internal import js.typedarrays.Uint8Array import node.buffer.Buffer -internal open external class Inflate { - open fun process(data: Uint8Array): Buffer +internal external class Inflate { + fun process(data: Uint8Array): Buffer } From f70993686863b9bb36b5713df495a9e5f7122a78 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Thu, 30 Mar 2023 22:35:02 +0200 Subject: [PATCH 069/136] Cleanup Inflater code --- gateway/src/jvmMain/kotlin/Inflater.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gateway/src/jvmMain/kotlin/Inflater.kt b/gateway/src/jvmMain/kotlin/Inflater.kt index 19a20d07dd70..9d9940d162d2 100644 --- a/gateway/src/jvmMain/kotlin/Inflater.kt +++ b/gateway/src/jvmMain/kotlin/Inflater.kt @@ -13,8 +13,6 @@ internal actual class Inflater { it.write(data) } - return outputStream.use { - String(outputStream.toByteArray(), 0, outputStream.size(), Charsets.UTF_8) - } + return outputStream.use { it.toByteArray().decodeToString() } } } From 1af826192f0a291a535121d6004212835c652312 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Thu, 30 Mar 2023 22:49:19 +0200 Subject: [PATCH 070/136] Specify platform type explicitly --- test-kit/src/jvmMain/kotlin/Platform.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-kit/src/jvmMain/kotlin/Platform.kt b/test-kit/src/jvmMain/kotlin/Platform.kt index 5345e9ddc97e..e890a2778cac 100644 --- a/test-kit/src/jvmMain/kotlin/Platform.kt +++ b/test-kit/src/jvmMain/kotlin/Platform.kt @@ -3,7 +3,7 @@ package dev.kord.test import io.ktor.utils.io.* import io.ktor.utils.io.jvm.javaio.* -actual fun getEnv(name: String) = System.getenv(name) +actual fun getEnv(name: String): String? = System.getenv(name) actual suspend fun file(project: String, path: String): String = ClassLoader.getSystemResource(path).readText() actual suspend fun readFile(project: String, path: String): ByteReadChannel = ClassLoader.getSystemResourceAsStream(path)!!.toByteReadChannel() From a18ed6cfc6ab0fdc3b8c0d8f5107531a4bc05851 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Thu, 30 Mar 2023 23:13:38 +0200 Subject: [PATCH 071/136] Remove unnecessary runTest --- .../src/commonTest/kotlin/regression/CacheMissRegression.kt | 6 +----- .../application/ApplicationGuildCommandPermissions.kt | 2 -- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/core/live-tests/src/commonTest/kotlin/regression/CacheMissRegression.kt b/core/live-tests/src/commonTest/kotlin/regression/CacheMissRegression.kt index 50bb6822f7a2..e547779900c6 100644 --- a/core/live-tests/src/commonTest/kotlin/regression/CacheMissRegression.kt +++ b/core/live-tests/src/commonTest/kotlin/regression/CacheMissRegression.kt @@ -110,11 +110,7 @@ class CacheMissingRegressions { fun `if data not in cache explode`() = runTest { withKord { kord -> val id = 5uL - assertFailsWith { - runTest { - kord.getChannel(Snowflake(id)) - } - } + assertFailsWith { kord.getChannel(Snowflake(id)) } } } diff --git a/core/src/commonMain/kotlin/entity/application/ApplicationGuildCommandPermissions.kt b/core/src/commonMain/kotlin/entity/application/ApplicationGuildCommandPermissions.kt index 72f070ea7ab8..a7580794ffe9 100644 --- a/core/src/commonMain/kotlin/entity/application/ApplicationGuildCommandPermissions.kt +++ b/core/src/commonMain/kotlin/entity/application/ApplicationGuildCommandPermissions.kt @@ -6,8 +6,6 @@ import dev.kord.core.cache.data.GuildApplicationCommandPermissionData import dev.kord.core.cache.data.GuildApplicationCommandPermissionsData import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow -import kotlin.DeprecationLevel.HIDDEN -import kotlin.jvm.JvmName public class GuildApplicationCommandPermission(public val data: GuildApplicationCommandPermissionData) { From 80656c031e455be882c95c4a57fd35372043529e Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Thu, 30 Mar 2023 23:21:13 +0200 Subject: [PATCH 072/136] Restore suspend function --- core/api/core.api | 1 + core/src/commonMain/kotlin/cache/DataCacheExtensions.kt | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/core/api/core.api b/core/api/core.api index 24cd4463bc15..535f1901c837 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -2170,6 +2170,7 @@ public final class dev/kord/core/cache/CachingGateway : dev/kord/cache/api/DataC public final class dev/kord/core/cache/DataCacheExtensionsKt { public static final fun createView (Ldev/kord/cache/api/DataCache;)Ldev/kord/core/cache/DataCacheView; + public static final synthetic fun createView (Ldev/kord/cache/api/DataCache;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun registerKordData (Ldev/kord/cache/api/DataCache;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } diff --git a/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt b/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt index dc14b3812b64..c28238bd1854 100644 --- a/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt +++ b/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt @@ -4,6 +4,8 @@ import dev.kord.cache.api.DataCache import dev.kord.cache.api.query import dev.kord.common.annotation.KordInternal import dev.kord.core.cache.data.* +import kotlin.DeprecationLevel.HIDDEN +import kotlin.jvm.JvmName /** * Registers all Kord data classes for this cache @@ -55,3 +57,8 @@ internal suspend fun DataCache.removeKordData() { * directly to this instance. */ public fun DataCache.createView(): DataCacheView = DataCacheView(this) + +@Suppress("RedundantSuspendModifier") +@Deprecated("Binary compatibility, keep for some releases.", level = HIDDEN) +@JvmName("createView") +public suspend fun DataCache.createView0(): DataCacheView = createView() From d010227212f24d6c9f6dff664dca7e5d960d40a4 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Thu, 30 Mar 2023 23:22:58 +0200 Subject: [PATCH 073/136] [ci skip] Update readme files to reflect MPP --- README.md | 148 ++++++++----------------------------------- core-voice/README.md | 4 ++ core/README.md | 2 +- gateway/README.md | 2 +- rest/README.md | 2 +- voice/README.md | 2 +- 6 files changed, 35 insertions(+), 125 deletions(-) create mode 100644 core-voice/README.md diff --git a/README.md b/README.md index 56aeed272700..647c3b6b2c45 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ you to try out our library, we don't recommend you use this in production just y If you have any feedback, we'd love to hear it, hit us up on discord or write up an issue if you have any suggestions! -## What is Kord +## What is Kord? Kord is a [coroutine-based](https://kotlinlang.org/docs/reference/coroutines-overview.html), modularized implementation of the Discord API, written 100% in [Kotlin](https://kotlinlang.org/). @@ -26,28 +26,41 @@ unconventional things, and we want to allow you to do those in a safe and suppor ## Status of Kord -* [X] [Discord Gateway](https://github.com/kordlib/kord/tree/master/gateway) -* [x] [Discord Rest API](https://github.com/kordlib/kord/tree/master/rest) -* [X] [High level abstraction + caching](https://github.com/kordlib/kord/tree/master/core) -* [X] [Discord Voice](https://github.com/kordlib/kord/tree/master/voice) +* [X] [Discord Gateway](https://github.com/kordlib/kord/tree/0.9.x/gateway) +* [x] [Discord Rest API](https://github.com/kordlib/kord/tree/0.9.x/rest) +* [X] [High level abstraction + caching](https://github.com/kordlib/kord/tree/0.9.x/core) +* [X] [Discord Voice](https://github.com/kordlib/kord/tree/0.9.x/voice) * [ ] Support for multiple processes [#7](https://github.com/kordlib/kord/issues/7) -Right now Kord *should* provide a full mapping of the non-voice API. We're currently working on a testing library for -easy bot testing against a semi mocked client as well as our own command system to facilitate more complex bot -development. +Right now, Kord *should* provide a full mapping of the non-voice API on Kotlin/JVM and Kotlin/JS and an experimental +mapping of the Voice API on Kotlin/JVM ## Documentation * [Dokka docs](https://kordlib.github.io/kord/) * [Wiki](https://github.com/kordlib/kord/wiki) +## Modules + +| Module | Docs | Artifact¹ | JVM | JS | Native² | +|--------------------------|---------------------------------------------------------|-------------------|-----|----|---------| +| [rest](rest) | [rest](https://kordlib.github.io/kord/rest) | `kord-rest` | ✅ | ✅ | ❌ | +| [gateway](gateway) | [gateway](https://kordlib.github.io/kord/gateway) | `kord-gateway` | ✅ | ✅ | ❌ | +| [core](core) | [core](https://kordlib.github.io/kord/core) | `kord-core` | ✅ | ✅ | ❌ | +| [voice](voice) | [voice](https://kordlib.github.io/kord/voice) | `kord-voice` | ✅ | ❌³ | ❌ | +| [core-voice](core-voice) | [core-voice](https://kordlib.github.io/kord/core-voice) | `kord-core-voice` | ✅ | ❌ | ❌ | + +¹ These artifacts only supports Gradle Version 5.3 or higher, for older Gradle versions and Maven please append `-jvm` +² For Native Support please see #69 +³ For Voice JS please see #69 + ## Installation Replace `{version}` with the latest version number on maven central. -For Snapshots replace `{version}` with `{branch}-SNAPSHOT` +For Snapshots replace `{version}` with `{branch}-SNAPSHOT` -e.g: `0.7.x-SNAPSHOT` +e.g: `0.7.x-SNAPSHOT` or `feature-mpp-SNAPSHOT` for the branch `feature/mpp` [![Download](https://img.shields.io/maven-central/v/dev.kord/kord-core.svg?label=Maven%20Central&style=for-the-badge)](https://search.maven.org/search?q=g:%22dev.kord%22%20AND%20a:%22kord-core%22) @@ -111,125 +124,18 @@ dependencies { dev.kord - kord-core + kord-core-jvm {version} ``` -## Modules - -### Core - -A higher level API, combining `rest` and `gateway`, with additional (optional) caching. Unless you're writing your own -abstractions, we'd recommend using this. - -```kotlin -suspend fun main() { - val kord = Kord("your bot token") - val pingPong = ReactionEmoji.Unicode("\uD83C\uDFD3") - - kord.on { - if (message.content != "!ping") return@on - - val response = message.channel.createMessage("Pong!") - response.addReaction(pingPong) - - delay(5000) - message.delete() - response.delete() - } - - kord.login { - @OptIn(PrivilegedIntent::class) - intents += Intent.MessageContent - } -} -``` - -### Rest - -A low level mapping of Discord's REST API. Requests follow -Discord's [rate limits](https://discord.com/developers/docs/topics/rate-limits). - -```kotlin -suspend fun main() { - val rest = RestClient("your bot token") - val channelId = Snowflake(605212557522763787) - - rest.channel.createMessage(channelId) { - content = "Hello Kord!" - - embed { - color = Color(red = 0, green = 0, blue = 255) - description = "Hello embed!" - } - } -} -``` - -### Gateway - -A low level mapping of [Discord's Gateway](https://discord.com/developers/docs/topics/gateway), which maintains the -connection and rate limits commands. - -```kotlin -suspend fun main() { - val gateway = DefaultGateway() - - gateway.on { - println("${message.author.username}: ${message.content}") - val words = message.content.split(' ') - when (words.firstOrNull()) { - "!close" -> gateway.stop() - "!detach" -> gateway.detach() - } - } - - gateway.start("your bot token") { - @OptIn(PrivilegedIntent::class) - intents += Intent.MessageContent - } -} -``` - - -### Voice - -A mapping of [Discord's Voice Connection](https://discord.com/developers/docs/topics/voice-connections), which maintains the connection and handles audio transmission. - -If you want to use voice, you need to enable the voice capability, -which is only available for Gradle - -```kotlin -dependencies { - implementation("dev.kord", "core", "") { - capabilities { - requireCapability("dev.kord:core-voice:") - } - } -} -``` - -```kotlin -suspend fun main() { - val kord = Kord("your token") - val voiceChannel = kord.getChannelOf(id = Snowflake(1))!! - - voiceChannel.connect { - audioProvider { AudioFrame.fromData(/* your opus encoded audio */) } - } - - kord.login() -} -``` - ## FAQ ## Will you support kotlin multi-platform -We will, there's an [issue](https://github.com/kordlib/kord/issues/69) open to track the features we want/need to make a -transition to MPP smooth. +Currently we're supporting both Kotlin/JVM and Kotlin/JS for the majority of our API, for more information check +[Modules](#modules) and #69 -## When will you document your code +## When will you document your code? Yes. diff --git a/core-voice/README.md b/core-voice/README.md new file mode 100644 index 000000000000..cd46520ce733 --- /dev/null +++ b/core-voice/README.md @@ -0,0 +1,4 @@ +# core-voice + +This Module adds extensions to [core](../core) for [kord-voice](../voice). Please read the [voice](../voice) +documentation for more information diff --git a/core/README.md b/core/README.md index 38e5988f516b..01d53ad43a6d 100644 --- a/core/README.md +++ b/core/README.md @@ -99,7 +99,7 @@ dependencies { dev.kord - kord-core + kord-core-jvm {version} ``` diff --git a/gateway/README.md b/gateway/README.md index cc713636fcc3..19ca819f8ea8 100644 --- a/gateway/README.md +++ b/gateway/README.md @@ -108,7 +108,7 @@ dependencies { dev.kord - kord-gateway + kord-gateway-jvm {version} ``` diff --git a/rest/README.md b/rest/README.md index 59fe8aac2e52..3cef5021b66b 100644 --- a/rest/README.md +++ b/rest/README.md @@ -84,7 +84,7 @@ dependencies { dev.kord - kord-rest + kord-rest-jvm {version} ``` diff --git a/voice/README.md b/voice/README.md index e3daf9504b7b..891e54ee3f4a 100644 --- a/voice/README.md +++ b/voice/README.md @@ -148,7 +148,7 @@ dependencies { ```xml dev.kord - kord-voice + kord-voice-jvm {version} ``` From 4726b8ffdb905f74368018f2252994d57e4eb40d Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Thu, 30 Mar 2023 23:43:31 +0200 Subject: [PATCH 074/136] Use assertFalse --- core/live-tests/src/commonTest/kotlin/KordTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/live-tests/src/commonTest/kotlin/KordTest.kt b/core/live-tests/src/commonTest/kotlin/KordTest.kt index c23f1e25ddca..c91db63b330a 100644 --- a/core/live-tests/src/commonTest/kotlin/KordTest.kt +++ b/core/live-tests/src/commonTest/kotlin/KordTest.kt @@ -4,7 +4,7 @@ import dev.kord.core.event.gateway.ReadyEvent import kotlinx.coroutines.test.runTest import kotlin.js.JsName import kotlin.test.Test -import kotlin.test.assertEquals +import kotlin.test.assertFalse internal class KordTest { @Test @@ -13,6 +13,6 @@ internal class KordTest { val kord = Kord.restOnly(testToken) val job = kord.on {} kord.shutdown() - assertEquals(false, job.isActive) + assertFalse(job.isActive) } } From d7b05c75b912cfa4022ab64c3540b79a78c9aee6 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Thu, 30 Mar 2023 23:47:14 +0200 Subject: [PATCH 075/136] Remove unused imports --- .../kotlin/cache/data/GuildApplicationCommandPermissionData.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/src/commonMain/kotlin/cache/data/GuildApplicationCommandPermissionData.kt b/core/src/commonMain/kotlin/cache/data/GuildApplicationCommandPermissionData.kt index f0b66404ebf2..7da1ef525417 100644 --- a/core/src/commonMain/kotlin/cache/data/GuildApplicationCommandPermissionData.kt +++ b/core/src/commonMain/kotlin/cache/data/GuildApplicationCommandPermissionData.kt @@ -3,9 +3,6 @@ package dev.kord.core.cache.data import dev.kord.common.entity.ApplicationCommandPermissionType import dev.kord.common.entity.DiscordGuildApplicationCommandPermission import dev.kord.common.entity.Snowflake -import kotlin.DeprecationLevel.HIDDEN -import kotlin.jvm.JvmName - public data class GuildApplicationCommandPermissionData( val id: Snowflake, From a2c802910177775d2f4d7eb6819652c4664bb1c2 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 00:00:34 +0200 Subject: [PATCH 076/136] Remove unused import --- core/src/commonMain/kotlin/entity/Guild.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/commonMain/kotlin/entity/Guild.kt b/core/src/commonMain/kotlin/entity/Guild.kt index 6d465c5b2282..2992b7ac3e5b 100644 --- a/core/src/commonMain/kotlin/entity/Guild.kt +++ b/core/src/commonMain/kotlin/entity/Guild.kt @@ -25,7 +25,6 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlinx.datetime.Instant import dev.kord.core.hash -import kotlin.DeprecationLevel.HIDDEN import kotlin.time.Duration /** From dbb880a5172be675b1f1fbd6ba69eaea1514e219 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 00:03:40 +0200 Subject: [PATCH 077/136] Remove unused var --- core/live-tests/src/commonTest/kotlin/StrategyTest.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/live-tests/src/commonTest/kotlin/StrategyTest.kt b/core/live-tests/src/commonTest/kotlin/StrategyTest.kt index 33dd1a28e9b2..d7c0a9837ff7 100644 --- a/core/live-tests/src/commonTest/kotlin/StrategyTest.kt +++ b/core/live-tests/src/commonTest/kotlin/StrategyTest.kt @@ -11,8 +11,6 @@ import kotlin.test.assertNull class StrategyTest { - lateinit var kord: Kord - @Test @JsName("test1") fun `rest only`() = runTest { From cbba0b1e73d430c0c90d1ab44fafd24da925e36d Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 00:25:21 +0200 Subject: [PATCH 078/136] Remove suspend from Inflater --- gateway/src/commonMain/kotlin/DefaultGatewayBuilder.kt | 2 -- gateway/src/commonMain/kotlin/Inflater.kt | 2 +- gateway/src/jsMain/kotlin/Inflater.kt | 2 +- gateway/src/jvmMain/kotlin/Inflater.kt | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/gateway/src/commonMain/kotlin/DefaultGatewayBuilder.kt b/gateway/src/commonMain/kotlin/DefaultGatewayBuilder.kt index bc3d45fa351d..080e2000761c 100644 --- a/gateway/src/commonMain/kotlin/DefaultGatewayBuilder.kt +++ b/gateway/src/commonMain/kotlin/DefaultGatewayBuilder.kt @@ -16,8 +16,6 @@ import io.ktor.serialization.kotlinx.json.* import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableSharedFlow -import kotlin.DeprecationLevel.HIDDEN -import kotlin.jvm.JvmName import kotlin.time.Duration.Companion.seconds public class DefaultGatewayBuilder { diff --git a/gateway/src/commonMain/kotlin/Inflater.kt b/gateway/src/commonMain/kotlin/Inflater.kt index 3fcdaa2b136d..30781d20a1fa 100644 --- a/gateway/src/commonMain/kotlin/Inflater.kt +++ b/gateway/src/commonMain/kotlin/Inflater.kt @@ -3,5 +3,5 @@ package dev.kord.gateway import io.ktor.websocket.* internal expect class Inflater() { - suspend fun Frame.inflateData(): String + fun Frame.inflateData(): String } diff --git a/gateway/src/jsMain/kotlin/Inflater.kt b/gateway/src/jsMain/kotlin/Inflater.kt index 9ad8c6a3e13b..4d23682f8da2 100644 --- a/gateway/src/jsMain/kotlin/Inflater.kt +++ b/gateway/src/jsMain/kotlin/Inflater.kt @@ -8,7 +8,7 @@ import node.buffer.BufferEncoding internal actual class Inflater { private val inflate = Inflate() - actual suspend fun Frame.inflateData(): String { + actual fun Frame.inflateData(): String { val buffer = Buffer.from(data) return inflate.process(buffer).toString(BufferEncoding.utf8) diff --git a/gateway/src/jvmMain/kotlin/Inflater.kt b/gateway/src/jvmMain/kotlin/Inflater.kt index 9d9940d162d2..1884a03ccbfe 100644 --- a/gateway/src/jvmMain/kotlin/Inflater.kt +++ b/gateway/src/jvmMain/kotlin/Inflater.kt @@ -7,7 +7,7 @@ import java.util.zip.InflaterOutputStream internal actual class Inflater { private val delegate = java.util.zip.Inflater() - actual suspend fun Frame.inflateData(): String { + actual fun Frame.inflateData(): String { val outputStream = ByteArrayOutputStream() InflaterOutputStream(outputStream, delegate).use { it.write(data) From 193e1347851c469ee440df5e5e75a4dccafd4f50 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 00:34:37 +0200 Subject: [PATCH 079/136] Initial delay --- gateway/src/commonMain/kotlin/Ticker.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/src/commonMain/kotlin/Ticker.kt b/gateway/src/commonMain/kotlin/Ticker.kt index 608118ccf2b3..1be7d39101cb 100644 --- a/gateway/src/commonMain/kotlin/Ticker.kt +++ b/gateway/src/commonMain/kotlin/Ticker.kt @@ -52,7 +52,7 @@ public class Ticker(private val dispatcher: CoroutineDispatcher = Dispatchers.De private fun tickingFlow(period: Long): Flow = flow { while (true) { - emit(Unit) delay(period) + emit(Unit) } } From 81e4a5b9bd5b5b079a56876865a6212f93f79443 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 00:36:52 +0200 Subject: [PATCH 080/136] Unused import --- gateway/src/commonMain/kotlin/ratelimit/IdentifyRateLimiter.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/gateway/src/commonMain/kotlin/ratelimit/IdentifyRateLimiter.kt b/gateway/src/commonMain/kotlin/ratelimit/IdentifyRateLimiter.kt index abd2deba636b..17e2662f4325 100644 --- a/gateway/src/commonMain/kotlin/ratelimit/IdentifyRateLimiter.kt +++ b/gateway/src/commonMain/kotlin/ratelimit/IdentifyRateLimiter.kt @@ -11,7 +11,6 @@ import kotlinx.coroutines.channels.onSuccess import kotlinx.coroutines.flow.* import kotlinx.coroutines.selects.select import mu.KotlinLogging -import kotlin.DeprecationLevel.ERROR import kotlin.jvm.JvmField import kotlin.time.Duration.Companion.seconds import kotlin.time.times From 11b75e2f3e418114b68d223335f3f778e3c84db5 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 00:48:41 +0200 Subject: [PATCH 081/136] Remove duplicate sample --- gateway/src/samples/kotlin/EventListener.kt | 46 --------------------- 1 file changed, 46 deletions(-) delete mode 100644 gateway/src/samples/kotlin/EventListener.kt diff --git a/gateway/src/samples/kotlin/EventListener.kt b/gateway/src/samples/kotlin/EventListener.kt deleted file mode 100644 index 762bc041915d..000000000000 --- a/gateway/src/samples/kotlin/EventListener.kt +++ /dev/null @@ -1,46 +0,0 @@ -import dev.kord.common.entity.PresenceStatus -import dev.kord.common.ratelimit.IntervalRateLimiter -import dev.kord.gateway.* -import dev.kord.gateway.retry.LinearRetry -import io.ktor.client.* -import io.ktor.client.plugins.contentnegotiation.* -import io.ktor.client.plugins.websocket.* -import io.ktor.serialization.kotlinx.json.* -import kotlinx.coroutines.flow.filterIsInstance -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach -import kotlin.time.Duration.Companion.seconds - -suspend fun main(args: Array) { - val token = args.firstOrNull() ?: error("expected a token") - - val gateway = DefaultGateway { - reconnectRetry = LinearRetry(2.seconds, 20.seconds, 10) - sendRateLimiter = IntervalRateLimiter(limit = 120, interval = 60.seconds) - } - - gateway.events.filterIsInstance().onEach { - val words = it.message.content.split(' ') - when (words.firstOrNull()) { - "!close" -> gateway.stop() - "!detach" -> gateway.detach() - "!status" -> when (words.getOrNull(1)) { - "playing" -> gateway.editPresence { - status = PresenceStatus.Online - afk = false - playing("Kord") - } - } - "!ping" -> gateway.editPresence { - status = PresenceStatus.Online - afk = false - listening("a ${gateway.ping.value?.inWholeMilliseconds} ms ping") - } - } - }.launchIn(gateway) - - gateway.start(token) { - @OptIn(PrivilegedIntent::class) - intents = Intents.all - } -} From 9674e3485547f2e225913655b09480ea5b8250c3 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 00:55:14 +0200 Subject: [PATCH 082/136] No buildconfig in rest --- rest/build.gradle.kts | 2 -- 1 file changed, 2 deletions(-) diff --git a/rest/build.gradle.kts b/rest/build.gradle.kts index 574f2f9838f2..38614071f42a 100644 --- a/rest/build.gradle.kts +++ b/rest/build.gradle.kts @@ -1,8 +1,6 @@ -@Suppress("DSL_SCOPE_VIOLATION") // false positive for `libs` in IntelliJ plugins { `kord-multiplatform-module` `kord-publishing` - alias(libs.plugins.buildconfig) } kotlin { From 7a09dbc62b5906a2efecde0d4fa0d78bcfa5cf08 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 00:57:28 +0200 Subject: [PATCH 083/136] Remove unused imports --- .../kotlin/builder/message/create/MessageCreateBuilder.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt b/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt index 529268f595e0..d7b28c95dab6 100644 --- a/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/message/create/MessageCreateBuilder.kt @@ -10,8 +10,6 @@ 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 io.ktor.util.cio.* -import kotlin.DeprecationLevel.ERROR import kotlin.contracts.InvocationKind import kotlin.contracts.contract From 74cc849ecb03590a311c1f26aff9d89881830997 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 01:03:02 +0200 Subject: [PATCH 084/136] Restore assertions --- rest/src/commonTest/kotlin/request/MessageRequests.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rest/src/commonTest/kotlin/request/MessageRequests.kt b/rest/src/commonTest/kotlin/request/MessageRequests.kt index 3a8e2b92672a..1b5ac39a4df8 100644 --- a/rest/src/commonTest/kotlin/request/MessageRequests.kt +++ b/rest/src/commonTest/kotlin/request/MessageRequests.kt @@ -10,7 +10,6 @@ import dev.kord.rest.service.ChannelService import io.ktor.client.* import io.ktor.client.engine.mock.* import io.ktor.client.request.forms.* -import io.ktor.util.cio.* import kotlinx.coroutines.test.runTest import kotlinx.datetime.Clock import kotlinx.serialization.encodeToString @@ -64,13 +63,14 @@ class MessageRequests { val fileChannel = readFile("images/kord.png") with(fileChannel) { + assertFalse(isClosedForWrite) assertFalse(isClosedForRead) - assertTrue(totalBytesRead == 0L) + assertEquals(0L, totalBytesRead) val createdMessage = channelService.createMessage(mockId) { addFile(fileName, ChannelProvider { fileChannel }) } - assertEquals(createdMessage, mockMessage) + assertEquals(mockMessage, createdMessage) assertTrue(isClosedForWrite) assertTrue(isClosedForRead) From d0f0dd68a4ad30c2ccfecf08cd31f057bd8d3154 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 01:11:47 +0200 Subject: [PATCH 085/136] order like in ide --- settings.gradle.kts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index c93362a4d1aa..a355a4dd5486 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,15 +8,15 @@ include( "bom", "common", "core", + "core:live-tests", + "core-voice", "gateway", "ksp-annotations", "ksp-processors", "rest", - "voice", - "core-voice", - "test-kit", "samples", - "core:live-tests" + "test-kit", + "voice", ) enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") From 83e40ded949f935694cd0569e71ed5e315549a9a Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 14:57:03 +0200 Subject: [PATCH 086/136] Fix test --- rest/src/commonTest/kotlin/request/MessageRequests.kt | 3 ++- test-kit/src/commonMain/kotlin/{Platfrom.kt => Platform.kt} | 0 2 files changed, 2 insertions(+), 1 deletion(-) rename test-kit/src/commonMain/kotlin/{Platfrom.kt => Platform.kt} (100%) diff --git a/rest/src/commonTest/kotlin/request/MessageRequests.kt b/rest/src/commonTest/kotlin/request/MessageRequests.kt index 1b5ac39a4df8..b6ce4d879bac 100644 --- a/rest/src/commonTest/kotlin/request/MessageRequests.kt +++ b/rest/src/commonTest/kotlin/request/MessageRequests.kt @@ -1,5 +1,6 @@ package dev.kord.rest.request +import dev.kord.common.Platform import dev.kord.common.entity.DiscordAttachment import dev.kord.common.entity.DiscordMessage import dev.kord.common.entity.DiscordUser @@ -63,7 +64,7 @@ class MessageRequests { val fileChannel = readFile("images/kord.png") with(fileChannel) { - assertFalse(isClosedForWrite) + if (Platform.IS_JVM) assertFalse(isClosedForWrite) // only read lazily on jvm assertFalse(isClosedForRead) assertEquals(0L, totalBytesRead) diff --git a/test-kit/src/commonMain/kotlin/Platfrom.kt b/test-kit/src/commonMain/kotlin/Platform.kt similarity index 100% rename from test-kit/src/commonMain/kotlin/Platfrom.kt rename to test-kit/src/commonMain/kotlin/Platform.kt From 5e6f6a0c4475cc280fac1d4b917ae8832829fcfd Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 15:23:55 +0200 Subject: [PATCH 087/136] Adjust Gradle config --- buildSrc/src/main/kotlin/Compiler.kt | 11 ++-- buildSrc/src/main/kotlin/Documentation.kt | 51 ++++++++----------- buildSrc/src/main/kotlin/KspUtils.kt | 7 --- buildSrc/src/main/kotlin/TestKit.kt | 9 ++-- .../src/main/kotlin/kord-module.gradle.kts | 7 ++- .../kord-multiplatform-module.gradle.kts | 24 +++++---- core-voice/build.gradle.kts | 2 + core/live-tests/build.gradle.kts | 10 ++-- 8 files changed, 59 insertions(+), 62 deletions(-) delete mode 100644 buildSrc/src/main/kotlin/KspUtils.kt diff --git a/buildSrc/src/main/kotlin/Compiler.kt b/buildSrc/src/main/kotlin/Compiler.kt index fefa694e20c7..4162905f7363 100644 --- a/buildSrc/src/main/kotlin/Compiler.kt +++ b/buildSrc/src/main/kotlin/Compiler.kt @@ -1,5 +1,4 @@ import kotlinx.atomicfu.plugin.gradle.AtomicFUPluginExtension -import org.gradle.api.NamedDomainObjectContainer import org.gradle.api.Project import org.gradle.api.artifacts.VersionCatalogsExtension import org.gradle.kotlin.dsl.configure @@ -31,12 +30,10 @@ fun KotlinCommonCompilerOptions.applyKordCompilerOptions() { freeCompilerArgs.add("-progressive") } -fun NamedDomainObjectContainer.applyKordOptIns() { - all { - languageSettings { - if ("Test" in name) optIn(OptIns.coroutines) - kordOptIns.forEach(::optIn) - } +fun KotlinSourceSet.applyKordOptIns() { + languageSettings { + if ("Test" in name) optIn(OptIns.coroutines) + kordOptIns.forEach(::optIn) } } diff --git a/buildSrc/src/main/kotlin/Documentation.kt b/buildSrc/src/main/kotlin/Documentation.kt index e275d00b54c1..db5da77659e5 100644 --- a/buildSrc/src/main/kotlin/Documentation.kt +++ b/buildSrc/src/main/kotlin/Documentation.kt @@ -1,40 +1,33 @@ -import org.gradle.api.tasks.TaskContainer -import org.gradle.kotlin.dsl.withType import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask import java.net.URL -fun TaskContainer.configureDokka(additionalConfiguration: AbstractDokkaLeafTask.() -> Unit = {}) { - withType().configureEach { +fun AbstractDokkaLeafTask.applyKordDokkaOptions() { + failOnWarning.set(true) - failOnWarning.set(true) + dokkaSourceSets.configureEach { - dokkaSourceSets.configureEach { + jdkVersion.set(Jvm.target) - jdkVersion.set(Jvm.target) + suppressGeneratedFiles.set(false) - suppressGeneratedFiles.set(false) - - sourceLink { - localDirectory.set(project.projectDir) - remoteUrl.set(URL("https://github.com/kordlib/kord/blob/${Library.commitHashOrDefault("0.9.x")}/${project.name}")) - remoteLineSuffix.set("#L") - } - - externalDocumentationLink("https://kotlinlang.org/api/kotlinx.coroutines/") - externalDocumentationLink("https://kotlinlang.org/api/kotlinx.serialization/") - externalDocumentationLink( - url = "https://kotlinlang.org/api/kotlinx-datetime/", - packageListUrl = "https://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/package-list", - ) - externalDocumentationLink("https://api.ktor.io/") - - // don't list `TweetNaclFast` in docs - perPackageOption { - matchingRegex.set("""com\.iwebpp\.crypto""") - suppress.set(true) - } + sourceLink { + localDirectory.set(project.projectDir) + remoteUrl.set(URL("https://github.com/kordlib/kord/blob/${Library.commitHashOrDefault("0.9.x")}/${project.name}")) + remoteLineSuffix.set("#L") } - additionalConfiguration() + externalDocumentationLink("https://kotlinlang.org/api/kotlinx.coroutines/") + externalDocumentationLink("https://kotlinlang.org/api/kotlinx.serialization/") + externalDocumentationLink( + url = "https://kotlinlang.org/api/kotlinx-datetime/", + packageListUrl = "https://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/package-list", + ) + externalDocumentationLink("https://api.ktor.io/") + + // don't list `TweetNaclFast` in docs + perPackageOption { + matchingRegex.set("""com\.iwebpp\.crypto""") + suppress.set(true) + } } } diff --git a/buildSrc/src/main/kotlin/KspUtils.kt b/buildSrc/src/main/kotlin/KspUtils.kt deleted file mode 100644 index 71e20bafd576..000000000000 --- a/buildSrc/src/main/kotlin/KspUtils.kt +++ /dev/null @@ -1,7 +0,0 @@ -import org.gradle.api.Task -import org.gradle.api.tasks.TaskContainer - -fun Task.dependsOnKspKotlin(name: String = "kspKotlin") { - val kspKotlin = project.tasks.findByName(name) - if (kspKotlin != null) dependsOn(kspKotlin) -} diff --git a/buildSrc/src/main/kotlin/TestKit.kt b/buildSrc/src/main/kotlin/TestKit.kt index 1098b84cbee5..0d4b24dfe8f8 100644 --- a/buildSrc/src/main/kotlin/TestKit.kt +++ b/buildSrc/src/main/kotlin/TestKit.kt @@ -1,12 +1,11 @@ -import org.gradle.api.NamedDomainObjectContainer -import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.KotlinTarget val KotlinTarget.safeName: String get() = if (name == "metadata") "common" else name -fun NamedDomainObjectContainer.addTestKit(targets: Iterable) { - targets.forEach { - findByName("${it.safeName}Test")?.apply { +fun KotlinMultiplatformExtension.addTestKit() { + targets.forEach { target -> + sourceSets.findByName("${target.safeName}Test")?.apply { dependencies { implementation(project(":test-kit")) } diff --git a/buildSrc/src/main/kotlin/kord-module.gradle.kts b/buildSrc/src/main/kotlin/kord-module.gradle.kts index 6224eae5dbbd..de04aacacaff 100644 --- a/buildSrc/src/main/kotlin/kord-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-module.gradle.kts @@ -1,3 +1,4 @@ +import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -42,7 +43,9 @@ tasks { useJUnitPlatform() } - configureDokka() + withType().configureEach { + applyKordDokkaOptions() + } withType().configureEach { doFirst { require(!Library.isUndefined) { "No release/snapshot version found." } } @@ -50,7 +53,7 @@ tasks { kotlinSourcesJar { // include sources generated by ksp - dependsOnKspKotlin() + dependsOn("kspKotlin") } } diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index 50305406db1a..c06742e8a645 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -1,3 +1,4 @@ +import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest @@ -31,8 +32,13 @@ kotlin { } } + addTestKit() + sourceSets { - applyKordOptIns() + all { + applyKordOptIns() + } + commonMain { // mark ksp src dir kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") @@ -42,7 +48,6 @@ kotlin { dependsOn(commonMain.get()) } - addTestKit(targets) targets.forEach { if (it.safeName != "jvm" && it.safeName != "common") { findByName("${it.safeName}Main")?.apply { @@ -56,25 +61,26 @@ kotlin { configureAtomicFU() tasks { - getByName("jvmTest") { + named("jvmTest") { useJUnitPlatform() } - withType() { + withType().configureEach { environment("PROJECT_ROOT", rootProject.projectDir.absolutePath) } afterEvaluate { - listOf("compileKotlinJvm", "compileKotlinJs", "jvmSourcesJar", "jsSourcesJar", "sourcesJar").forEach { - getByName(it) { - dependsOnKspKotlin("kspCommonMainKotlinMetadata") + listOf("compileKotlinJvm", "compileKotlinJs", "jvmSourcesJar", "jsSourcesJar", "sourcesJar").forEach { task -> + named(task) { + dependsOn("kspCommonMainKotlinMetadata") } } } afterEvaluate { - configureDokka { - dependsOnKspKotlin("kspCommonMainKotlinMetadata") + withType().configureEach { + applyKordDokkaOptions() + dependsOn("kspCommonMainKotlinMetadata") } } } diff --git a/core-voice/build.gradle.kts b/core-voice/build.gradle.kts index 356fca4c82b8..3b9f804a3869 100644 --- a/core-voice/build.gradle.kts +++ b/core-voice/build.gradle.kts @@ -6,4 +6,6 @@ plugins { dependencies { api(projects.core) api(projects.voice) + + ksp(projects.kspProcessors) } diff --git a/core/live-tests/build.gradle.kts b/core/live-tests/build.gradle.kts index 730e7277baa7..b2984e4bc639 100644 --- a/core/live-tests/build.gradle.kts +++ b/core/live-tests/build.gradle.kts @@ -3,9 +3,13 @@ plugins { } kotlin { + addTestKit() + sourceSets { - applyKordOptIns() - addTestKit(targets) + all { + applyKordOptIns() + } + commonTest { dependencies { implementation(projects.core) @@ -15,7 +19,7 @@ kotlin { } tasks { - withType { + withType().configureEach { enabled = !System.getenv("KORD_TEST_TOKEN").isNullOrBlank() } } From fc1c475ca0fcaa3072f166e02328d0a2da2f33d4 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 20:28:24 +0200 Subject: [PATCH 088/136] Remove unnecessary task dependency --- buildSrc/src/main/kotlin/kord-module.gradle.kts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/buildSrc/src/main/kotlin/kord-module.gradle.kts b/buildSrc/src/main/kotlin/kord-module.gradle.kts index de04aacacaff..52bef7a880ee 100644 --- a/buildSrc/src/main/kotlin/kord-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-module.gradle.kts @@ -50,11 +50,6 @@ tasks { withType().configureEach { doFirst { require(!Library.isUndefined) { "No release/snapshot version found." } } } - - kotlinSourcesJar { - // include sources generated by ksp - dependsOn("kspKotlin") - } } publishing { From 0cf77310944623756e96bff2b6518b65b0b4ae30 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 20:28:24 +0200 Subject: [PATCH 089/136] More tweaks to build logic --- .../src/main/kotlin/kord-module.gradle.kts | 11 +++++----- .../kord-multiplatform-module.gradle.kts | 22 +++++++++---------- .../main/kotlin/kord-publishing.gradle.kts | 8 +++---- common/build.gradle.kts | 4 ---- core-voice/build.gradle.kts | 2 -- core/build.gradle.kts | 4 ---- gateway/build.gradle.kts | 4 ---- rest/build.gradle.kts | 4 ---- voice/build.gradle.kts | 1 - 9 files changed, 21 insertions(+), 39 deletions(-) diff --git a/buildSrc/src/main/kotlin/kord-module.gradle.kts b/buildSrc/src/main/kotlin/kord-module.gradle.kts index 52bef7a880ee..11d9b23b13e4 100644 --- a/buildSrc/src/main/kotlin/kord-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-module.gradle.kts @@ -15,24 +15,25 @@ repositories { mavenCentral() } +dependencies { + ksp(project(":ksp-processors")) +} + kotlin { explicitApi() jvmToolchain(Jvm.target) sourceSets { - // mark ksp src dir - main { kotlin.srcDir("build/generated/ksp/main/kotlin") } - // allow `ExperimentalCoroutinesApi` for `runTest {}` - test { languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") } + test { languageSettings.optIn(OptIns.coroutines) } } } configureAtomicFU() tasks { - withType { + withType().configureEach { compilerOptions { applyKordCompilerOptions() freeCompilerArgs.addAll(kordOptIns.map { "-opt-in=$it" }) diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index c06742e8a645..847d3fce3c45 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -15,6 +15,10 @@ repositories { mavenCentral() } +dependencies { + kspCommonMainMetadata(project(":ksp-processors")) +} + kotlin { explicitApi() @@ -61,7 +65,7 @@ kotlin { configureAtomicFU() tasks { - named("jvmTest") { + withType().configureEach { useJUnitPlatform() } @@ -69,18 +73,14 @@ tasks { environment("PROJECT_ROOT", rootProject.projectDir.absolutePath) } - afterEvaluate { - listOf("compileKotlinJvm", "compileKotlinJs", "jvmSourcesJar", "jsSourcesJar", "sourcesJar").forEach { task -> - named(task) { - dependsOn("kspCommonMainKotlinMetadata") - } + for (task in listOf("compileKotlinJvm", "compileKotlinJs", "jvmSourcesJar", "jsSourcesJar")) { + named(task) { + dependsOn("kspCommonMainKotlinMetadata") } } - afterEvaluate { - withType().configureEach { - applyKordDokkaOptions() - dependsOn("kspCommonMainKotlinMetadata") - } + withType().configureEach { + applyKordDokkaOptions() + dependsOn("kspCommonMainKotlinMetadata") } } diff --git a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts index 964fad0190e7..83eb5dafc01a 100644 --- a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts @@ -7,16 +7,16 @@ plugins { publishing { publications { - withType { + withType().configureEach { val platform = name.substringAfterLast('-') - val dokkaJar = tasks.register("${platform}DokkaJar", Jar::class) { + val dokkaJar = tasks.register("${platform}DokkaJar") { archiveClassifier.set("javadoc") destinationDirectory.set(buildDir.resolve(platform)) - from(tasks.getByName("dokkaHtml")) + from(tasks.named("dokkaHtml")) } artifact(dokkaJar) groupId = Library.group - artifactId = "kord-${artifactId}" + artifactId = "kord-$artifactId" version = Library.version pom { diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 8dbdee8f8759..00f98e5a9b96 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -41,10 +41,6 @@ kotlin { } } -dependencies { - kspCommonMainMetadata(projects.kspProcessors) -} - /* This will generate a file named "BuildConfigGenerated.kt" that looks like: diff --git a/core-voice/build.gradle.kts b/core-voice/build.gradle.kts index 3b9f804a3869..356fca4c82b8 100644 --- a/core-voice/build.gradle.kts +++ b/core-voice/build.gradle.kts @@ -6,6 +6,4 @@ plugins { dependencies { api(projects.core) api(projects.voice) - - ksp(projects.kspProcessors) } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 0e93a3e205d0..9714d8d8f5a9 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -24,10 +24,6 @@ kotlin { } } -dependencies { - kspCommonMainMetadata(projects.kspProcessors) -} - tasks { dokkaHtmlMultiModule { enabled = false diff --git a/gateway/build.gradle.kts b/gateway/build.gradle.kts index f86b6cd6fe83..484f8efa43e6 100644 --- a/gateway/build.gradle.kts +++ b/gateway/build.gradle.kts @@ -51,7 +51,3 @@ kotlin { } } } - -dependencies { - kspCommonMainMetadata(projects.kspProcessors) -} diff --git a/rest/build.gradle.kts b/rest/build.gradle.kts index 38614071f42a..a3663a547641 100644 --- a/rest/build.gradle.kts +++ b/rest/build.gradle.kts @@ -34,7 +34,3 @@ kotlin { } } } - -dependencies { - kspCommonMainMetadata(projects.kspProcessors) -} diff --git a/voice/build.gradle.kts b/voice/build.gradle.kts index e43848547967..da6b41f43831 100644 --- a/voice/build.gradle.kts +++ b/voice/build.gradle.kts @@ -10,7 +10,6 @@ dependencies { api(projects.gateway) compileOnly(projects.kspAnnotations) - ksp(projects.kspProcessors) api(libs.ktor.network) } From cdeca21d8f81b427c67fafc7723085d260d029c0 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 23:04:27 +0200 Subject: [PATCH 090/136] Restore formatting for RegressionTests --- gateway/src/commonTest/kotlin/json/RegressionTests.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gateway/src/commonTest/kotlin/json/RegressionTests.kt b/gateway/src/commonTest/kotlin/json/RegressionTests.kt index 24fc3e5239f3..831aade5e824 100644 --- a/gateway/src/commonTest/kotlin/json/RegressionTests.kt +++ b/gateway/src/commonTest/kotlin/json/RegressionTests.kt @@ -32,10 +32,7 @@ class RegressionTests { @Test @JsName("test4") fun `Unknown event with successfully parses`() = runTest { - Json.decodeFromString( - Event.DeserializationStrategy, - file("eventWithUnknownData") - ) //dispatch event with non-existent type + Json.decodeFromString(Event.DeserializationStrategy, file("eventWithUnknownData")) //dispatch event with non-existent type } } From 62b0cd89709b719d2202a1ccbad8cf81ac32f38b Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 23:29:29 +0200 Subject: [PATCH 091/136] Remove explicit coroutines dependency in gateway --- gateway/build.gradle.kts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gateway/build.gradle.kts b/gateway/build.gradle.kts index 484f8efa43e6..8c51b5aa45c3 100644 --- a/gateway/build.gradle.kts +++ b/gateway/build.gradle.kts @@ -10,9 +10,8 @@ kotlin { api(projects.common) api(libs.bundles.ktor.client.serialization) - api(libs.ktor.client.core) - api(libs.kotlinx.coroutines.core) api(libs.ktor.client.websockets) + api(libs.ktor.client.core) } } From 1e6d9793bec4f1dd3cd7da027fd62f9376cfbbd8 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Fri, 31 Mar 2023 23:47:36 +0200 Subject: [PATCH 092/136] Empty error message instead of kotlin.Unit --- .../kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt | 3 +-- gateway/src/commonMain/kotlin/Utils.kt | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/core/src/commonMain/kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt b/core/src/commonMain/kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt index 3b000435df80..8725cfa03012 100644 --- a/core/src/commonMain/kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt +++ b/core/src/commonMain/kotlin/gateway/handler/DefaultGatewayEventInterceptor.kt @@ -3,7 +3,6 @@ package dev.kord.core.gateway.handler import dev.kord.common.annotation.KordPreview import dev.kord.core.Kord import dev.kord.core.gateway.ShardEvent -import io.ktor.util.logging.* import mu.KotlinLogging import dev.kord.core.event.Event as CoreEvent @@ -60,7 +59,7 @@ public class DefaultGatewayEventInterceptor @KordPreview public constructor( } return null }.onFailure { - logger.error(it) {} + logger.error(it) { "" } }.getOrNull() } } diff --git a/gateway/src/commonMain/kotlin/Utils.kt b/gateway/src/commonMain/kotlin/Utils.kt index a60a6b1a3963..fd897c41b80c 100644 --- a/gateway/src/commonMain/kotlin/Utils.kt +++ b/gateway/src/commonMain/kotlin/Utils.kt @@ -3,4 +3,4 @@ package dev.kord.gateway import mu.KLogger @PublishedApi -internal fun KLogger.error(throwable: Throwable): Unit = error(throwable) {} +internal fun KLogger.error(throwable: Throwable): Unit = error(throwable) { "" } From de614b2ac5650248813e009ad85b14800bc46811 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Sat, 1 Apr 2023 00:16:57 +0200 Subject: [PATCH 093/136] Clean dependencies in build scripts --- .../kord-multiplatform-module.gradle.kts | 2 -- core/build.gradle.kts | 1 - gateway/build.gradle.kts | 29 ------------------- rest/build.gradle.kts | 15 ---------- samples/build.gradle.kts | 1 - test-kit/build.gradle.kts | 2 -- 6 files changed, 50 deletions(-) diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index 847d3fce3c45..73c16ce3c4a8 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -42,12 +42,10 @@ kotlin { all { applyKordOptIns() } - commonMain { // mark ksp src dir kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") } - val nonJvm by creating { dependsOn(commonMain.get()) } diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 9714d8d8f5a9..e3748e5d6f2c 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -15,7 +15,6 @@ kotlin { api(libs.kord.cache.map) } } - jvmTest { dependencies { implementation(libs.mockk) diff --git a/gateway/build.gradle.kts b/gateway/build.gradle.kts index 8c51b5aa45c3..ec7df6731ffd 100644 --- a/gateway/build.gradle.kts +++ b/gateway/build.gradle.kts @@ -11,42 +11,13 @@ kotlin { api(libs.bundles.ktor.client.serialization) api(libs.ktor.client.websockets) - api(libs.ktor.client.core) } } - - jvmMain { - dependencies { - api(libs.ktor.client.cio) - } - } - jsMain { dependencies { - api(libs.ktor.client.js) api(libs.kotlinx.nodejs) api(npm("fast-zlib", "2.0.1")) } } - - commonTest { - dependencies { - implementation(libs.bundles.test.common) - implementation(libs.ktor.client.mock) - } - } - - jsTest { - dependencies { - implementation(libs.bundles.test.js) - } - } - - jvmTest { - dependencies { - runtimeOnly(libs.bundles.test.runtime) - implementation(libs.kotlin.test.junit5) - } - } } } diff --git a/rest/build.gradle.kts b/rest/build.gradle.kts index a3663a547641..21202494c784 100644 --- a/rest/build.gradle.kts +++ b/rest/build.gradle.kts @@ -10,27 +10,12 @@ kotlin { api(projects.common) api(libs.bundles.ktor.client.serialization) - api(libs.ktor.client.core) } } - commonTest { dependencies { - implementation(projects.testKit) implementation(libs.ktor.client.mock) } } - - jsMain { - dependencies { - api(libs.ktor.client.js) - } - } - - jvmMain { - dependencies { - api(libs.ktor.client.cio) - } - } } } diff --git a/samples/build.gradle.kts b/samples/build.gradle.kts index 42ffcec709b4..2e16a83d74de 100644 --- a/samples/build.gradle.kts +++ b/samples/build.gradle.kts @@ -13,7 +13,6 @@ kotlin { implementation(projects.core) } } - jvmMain { dependencies { runtimeOnly(libs.slf4j.simple) diff --git a/test-kit/build.gradle.kts b/test-kit/build.gradle.kts index 7cfcc632d6fc..8a07c0c329f2 100644 --- a/test-kit/build.gradle.kts +++ b/test-kit/build.gradle.kts @@ -11,13 +11,11 @@ kotlin { api(projects.common) } } - jsMain { dependencies { api(libs.bundles.test.js) } } - jvmMain { dependencies { api(libs.bundles.test.runtime) From 005ca20959a0cd835ab0170714c52a0d400945db Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Sat, 1 Apr 2023 00:43:34 +0200 Subject: [PATCH 094/136] Remove unused bundle --- gradle/libs.versions.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 630f71f61e7c..97190acbc55a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -88,7 +88,6 @@ ksp-plugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin ktor-client-serialization = ["ktor-client-content-negotiation", "ktor-serialization-kotlinx-json"] -test-implementation = ["kotlinx-coroutines-test", "kotlin-test-junit5", "junit-jupiter-api", "mockk"] test-common = ["kotlinx-coroutines-test", "kotlin-test", "kotlin-test-annotations-common"] test-runtime = ["kotlin-test-junit5", "junit-jupiter-engine", "slf4j-simple"] test-js = ["kotlin-test-js", "kotlinx-nodejs"] From ec332d21da946b0f9491eb9848c44079ac338fd9 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Sun, 2 Apr 2023 16:00:39 +0200 Subject: [PATCH 095/136] Remove @KordInternal from public API --- buildSrc/src/main/kotlin/BinaryCompatibility.kt | 6 ++++++ buildSrc/src/main/kotlin/kord-module.gradle.kts | 4 ++++ .../main/kotlin/kord-multiplatform-module.gradle.kts | 6 ++++++ common/api/common.api | 12 ------------ core/api/core.api | 3 --- 5 files changed, 16 insertions(+), 15 deletions(-) create mode 100644 buildSrc/src/main/kotlin/BinaryCompatibility.kt diff --git a/buildSrc/src/main/kotlin/BinaryCompatibility.kt b/buildSrc/src/main/kotlin/BinaryCompatibility.kt new file mode 100644 index 000000000000..02a3708d10a9 --- /dev/null +++ b/buildSrc/src/main/kotlin/BinaryCompatibility.kt @@ -0,0 +1,6 @@ +import kotlinx.validation.ApiValidationExtension + +fun ApiValidationExtension.applyKordOptions() { + val annotations = listOf("KordInternal") + nonPublicMarkers.addAll(annotations.map { "dev.kord.common.annotation.$it" }) +} diff --git a/buildSrc/src/main/kotlin/kord-module.gradle.kts b/buildSrc/src/main/kotlin/kord-module.gradle.kts index 11d9b23b13e4..33d453dde8b7 100644 --- a/buildSrc/src/main/kotlin/kord-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-module.gradle.kts @@ -15,6 +15,10 @@ repositories { mavenCentral() } +apiValidation { + applyKordOptions() +} + dependencies { ksp(project(":ksp-processors")) } diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index 73c16ce3c4a8..7370dbb19e80 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -1,3 +1,4 @@ +import gradle.kotlin.dsl.accessors._e5121a5856746b077c6819bbe5a86a2f.apiValidation import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest @@ -19,6 +20,11 @@ dependencies { kspCommonMainMetadata(project(":ksp-processors")) } +apiValidation { + applyKordOptions() +} + + kotlin { explicitApi() diff --git a/common/api/common.api b/common/api/common.api index b0423525d437..b30f4d202d9d 100644 --- a/common/api/common.api +++ b/common/api/common.api @@ -164,13 +164,6 @@ public final class dev/kord/common/LocaleKt { public static final fun getKLocale (Ljava/util/Locale;)Ldev/kord/common/Locale; } -public final class dev/kord/common/Platform { - public static final field INSTANCE Ldev/kord/common/Platform; - public static final field IS_BROWSER Z - public static final field IS_JVM Z - public static final field IS_NODE Z -} - public abstract interface annotation class dev/kord/common/annotation/DeprecatedSinceKord : java/lang/annotation/Annotation { public abstract fun version ()Ljava/lang/String; } @@ -8514,11 +8507,6 @@ public abstract class dev/kord/common/exception/RequestException : java/lang/Exc public fun (Ljava/lang/Throwable;)V } -public final class dev/kord/common/http/HttpEngine : io/ktor/client/engine/HttpClientEngineFactory { - public static final field INSTANCE Ldev/kord/common/http/HttpEngine; - public fun create (Lkotlin/jvm/functions/Function1;)Lio/ktor/client/engine/HttpClientEngine; -} - public abstract class dev/kord/common/ratelimit/AbstractIntervalRateLimiter : dev/kord/common/ratelimit/IntervalRateLimiter { public synthetic fun (IJLkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun consume (Lkotlin/coroutines/Continuation;)Ljava/lang/Object; diff --git a/core/api/core.api b/core/api/core.api index 535f1901c837..c458e79802d9 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -2118,8 +2118,6 @@ public final class dev/kord/core/builder/kord/KordBuilderKt { } public final class dev/kord/core/builder/kord/KordBuilderUtilKt { - public static final fun configure (Lio/ktor/client/HttpClient;)Lio/ktor/client/HttpClient; - public static final fun getBotIdFromToken (Ljava/lang/String;)Ldev/kord/common/entity/Snowflake; } public final class dev/kord/core/builder/kord/KordProxyBuilder : dev/kord/core/builder/kord/RestOnlyBuilder { @@ -2171,7 +2169,6 @@ public final class dev/kord/core/cache/CachingGateway : dev/kord/cache/api/DataC public final class dev/kord/core/cache/DataCacheExtensionsKt { public static final fun createView (Ldev/kord/cache/api/DataCache;)Ldev/kord/core/cache/DataCacheView; public static final synthetic fun createView (Ldev/kord/cache/api/DataCache;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static final fun registerKordData (Ldev/kord/cache/api/DataCache;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } public final class dev/kord/core/cache/DataCacheView : dev/kord/cache/api/DataCache { From cec147cc5f0feb12e5280a30a32781c1cf384ae0 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Sun, 2 Apr 2023 16:20:03 +0200 Subject: [PATCH 096/136] Add comments for ksp-annotations publishing --- common/build.gradle.kts | 6 ++++-- ksp-annotations/build.gradle.kts | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 00f98e5a9b96..bfd4f569bb15 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -34,8 +34,10 @@ kotlin { jsMain { dependencies { api(libs.ktor.client.js) - // When targeting K/JS needs to be present at compile time for users - api(projects.kspAnnotations) + + // workaround for https://youtrack.jetbrains.com/issue/KT-43500 + // (intended to be compileOnly in commonMain only) + implementation(projects.kspAnnotations) } } } diff --git a/ksp-annotations/build.gradle.kts b/ksp-annotations/build.gradle.kts index bdc0f024093d..6f5e04a93812 100644 --- a/ksp-annotations/build.gradle.kts +++ b/ksp-annotations/build.gradle.kts @@ -1,5 +1,7 @@ plugins { `kord-internal-multiplatform-module` + + // workaround for https://youtrack.jetbrains.com/issue/KT-43500 (intended to be unpublished) org.jetbrains.dokka `kord-publishing` } From 8da2c57915ba684c5eb429ad2ca3207731cde86b Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Sun, 2 Apr 2023 20:24:08 +0200 Subject: [PATCH 097/136] Clean BCV config --- buildSrc/src/main/kotlin/BinaryCompatibility.kt | 5 ++--- buildSrc/src/main/kotlin/kord-module.gradle.kts | 8 ++++---- .../src/main/kotlin/kord-multiplatform-module.gradle.kts | 5 +---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/buildSrc/src/main/kotlin/BinaryCompatibility.kt b/buildSrc/src/main/kotlin/BinaryCompatibility.kt index 02a3708d10a9..c457cea65e45 100644 --- a/buildSrc/src/main/kotlin/BinaryCompatibility.kt +++ b/buildSrc/src/main/kotlin/BinaryCompatibility.kt @@ -1,6 +1,5 @@ import kotlinx.validation.ApiValidationExtension -fun ApiValidationExtension.applyKordOptions() { - val annotations = listOf("KordInternal") - nonPublicMarkers.addAll(annotations.map { "dev.kord.common.annotation.$it" }) +fun ApiValidationExtension.applyKordBCVOptions() { + nonPublicMarkers += "dev.kord.common.annotation.KordInternal" } diff --git a/buildSrc/src/main/kotlin/kord-module.gradle.kts b/buildSrc/src/main/kotlin/kord-module.gradle.kts index 33d453dde8b7..1c7608680a4b 100644 --- a/buildSrc/src/main/kotlin/kord-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-module.gradle.kts @@ -15,14 +15,14 @@ repositories { mavenCentral() } -apiValidation { - applyKordOptions() -} - dependencies { ksp(project(":ksp-processors")) } +apiValidation { + applyKordBCVOptions() +} + kotlin { explicitApi() diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index 7370dbb19e80..473bc1fe17ee 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -1,7 +1,5 @@ -import gradle.kotlin.dsl.accessors._e5121a5856746b077c6819bbe5a86a2f.apiValidation import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest -import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest plugins { org.jetbrains.kotlin.multiplatform @@ -21,10 +19,9 @@ dependencies { } apiValidation { - applyKordOptions() + applyKordBCVOptions() } - kotlin { explicitApi() From 761366e280f5094b21c6643afda219db3ccde524 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Sun, 2 Apr 2023 21:57:10 +0200 Subject: [PATCH 098/136] A single dokkaJar task is enough --- .../main/kotlin/kord-publishing.gradle.kts | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts index 83eb5dafc01a..593dd1348b86 100644 --- a/buildSrc/src/main/kotlin/kord-publishing.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-publishing.gradle.kts @@ -5,15 +5,14 @@ plugins { signing } +val dokkaJar by tasks.registering(Jar::class) { + archiveClassifier.set("javadoc") + from(tasks.named("dokkaHtml")) +} + publishing { publications { withType().configureEach { - val platform = name.substringAfterLast('-') - val dokkaJar = tasks.register("${platform}DokkaJar") { - archiveClassifier.set("javadoc") - destinationDirectory.set(buildDir.resolve(platform)) - from(tasks.named("dokkaHtml")) - } artifact(dokkaJar) groupId = Library.group artifactId = "kord-$artifactId" @@ -54,16 +53,16 @@ publishing { } } } + } - if (!isJitPack) { - repositories { - maven { - url = uri(if (Library.isSnapshot) Repo.snapshotsUrl else Repo.releasesUrl) + if (!isJitPack) { + repositories { + maven { + url = uri(if (Library.isSnapshot) Repo.snapshotsUrl else Repo.releasesUrl) - credentials { - username = System.getenv("NEXUS_USER") - password = System.getenv("NEXUS_PASSWORD") - } + credentials { + username = System.getenv("NEXUS_USER") + password = System.getenv("NEXUS_PASSWORD") } } } From f4bacfa2e42054deb92b43cbdf01da375e1a19e8 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Sun, 2 Apr 2023 22:46:57 +0200 Subject: [PATCH 099/136] Use previous logic to format DiscordBitSet on JVM --- common/build.gradle.kts | 4 ++-- common/src/commonMain/kotlin/DiscordBitSet.kt | 12 ++---------- common/src/jvmMain/kotlin/DiscordBitSetJvm.kt | 9 ++++++++- common/src/nonJvm/kotlin/DiscordBitSet.kt | 9 +++++++-- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index bfd4f569bb15..cc3ce336be74 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -13,8 +13,7 @@ kotlin { api(libs.kotlinx.serialization.json) api(libs.kotlinx.datetime) api(libs.kotlin.logging) - // Replacement for java.io - api(libs.ktor.utils) + api(libs.ktor.client.core) compileOnly(projects.kspAnnotations) @@ -27,6 +26,7 @@ kotlin { } nonJvm { dependencies { + api(libs.ktor.utils) implementation(libs.bignum) implementation(libs.bundles.stately) } diff --git a/common/src/commonMain/kotlin/DiscordBitSet.kt b/common/src/commonMain/kotlin/DiscordBitSet.kt index 8c604548db55..8098026c4701 100644 --- a/common/src/commonMain/kotlin/DiscordBitSet.kt +++ b/common/src/commonMain/kotlin/DiscordBitSet.kt @@ -1,6 +1,5 @@ package dev.kord.common -import io.ktor.utils.io.core.* import kotlinx.serialization.KSerializer import kotlinx.serialization.Serializable import kotlinx.serialization.descriptors.PrimitiveKind @@ -17,7 +16,7 @@ private const val WIDTH = Long.SIZE_BITS @Suppress("FunctionName") public fun EmptyBitSet(): DiscordBitSet = DiscordBitSet() -internal expect fun formatIntegerFromBigEndianByteArray(data: ByteArray): String +internal expect fun formatIntegerFromLittleEndianLongArray(data: LongArray): String internal expect fun parseIntegerToBigEndianByteArray(value: String): ByteArray @Serializable(with = DiscordBitSetSerializer::class) @@ -26,14 +25,7 @@ public class DiscordBitSet(internal var data: LongArray) { // data is in little- public val isEmpty: Boolean get() = data.all { it == 0L } - public val value: String - get() { - // need to convert from little-endian data to big-endian expected by BigInteger - return withBuffer(data.size * Long.SIZE_BYTES) { - writeFully(data.reversedArray()) - formatIntegerFromBigEndianByteArray(readBytes()) - } - } + public val value: String get() = formatIntegerFromLittleEndianLongArray(data) public val size: Int get() = data.size * WIDTH diff --git a/common/src/jvmMain/kotlin/DiscordBitSetJvm.kt b/common/src/jvmMain/kotlin/DiscordBitSetJvm.kt index 002c7491b1aa..591cae341588 100644 --- a/common/src/jvmMain/kotlin/DiscordBitSetJvm.kt +++ b/common/src/jvmMain/kotlin/DiscordBitSetJvm.kt @@ -1,6 +1,13 @@ package dev.kord.common import java.math.BigInteger +import java.nio.ByteBuffer + +internal actual fun formatIntegerFromLittleEndianLongArray(data: LongArray): String { + // need to convert from little-endian data to big-endian expected by BigInteger + val buffer = ByteBuffer.allocate(data.size * Long.SIZE_BYTES) + buffer.asLongBuffer().put(data.reversedArray()) + return BigInteger(buffer.array()).toString() +} -internal actual fun formatIntegerFromBigEndianByteArray(data: ByteArray): String = BigInteger(data).toString() internal actual fun parseIntegerToBigEndianByteArray(value: String): ByteArray = BigInteger(value).toByteArray() diff --git a/common/src/nonJvm/kotlin/DiscordBitSet.kt b/common/src/nonJvm/kotlin/DiscordBitSet.kt index 1eaae15bfe71..3c0e5f121a3e 100644 --- a/common/src/nonJvm/kotlin/DiscordBitSet.kt +++ b/common/src/nonJvm/kotlin/DiscordBitSet.kt @@ -2,9 +2,14 @@ package dev.kord.common import com.ionspin.kotlin.bignum.integer.BigInteger import com.ionspin.kotlin.bignum.integer.Sign +import io.ktor.utils.io.core.* -internal actual fun formatIntegerFromBigEndianByteArray(data: ByteArray): String = - BigInteger.fromByteArray(data, Sign.POSITIVE).toString() +internal actual fun formatIntegerFromLittleEndianLongArray(data: LongArray) = + withBuffer(data.size * Long.SIZE_BYTES) { + // need to convert from little-endian data to big-endian expected by BigInteger + writeFully(data.reversedArray()) + BigInteger.fromByteArray(readBytes(), Sign.POSITIVE).toString() + } internal actual fun parseIntegerToBigEndianByteArray(value: String): ByteArray = BigInteger.parseString(value).toByteArray() From f37e698c23820ccb1a8c4c521dde9cf7dcb57f53 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Sun, 2 Apr 2023 22:49:56 +0200 Subject: [PATCH 100/136] That's an implementation dependency --- common/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index cc3ce336be74..dd46ee93c085 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -26,7 +26,7 @@ kotlin { } nonJvm { dependencies { - api(libs.ktor.utils) + implementation(libs.ktor.utils) implementation(libs.bignum) implementation(libs.bundles.stately) } From b0bb52f8f7b99097dae043cb705d56ab720e3034 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Sun, 2 Apr 2023 23:00:44 +0200 Subject: [PATCH 101/136] Restore redundant suspend modifier It's out of scope for this PR. --- core/api/core.api | 3 +-- core/src/commonMain/kotlin/cache/DataCacheExtensions.kt | 9 +-------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/core/api/core.api b/core/api/core.api index 3406138558e7..2c8e92140e59 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -2167,8 +2167,7 @@ public final class dev/kord/core/cache/CachingGateway : dev/kord/cache/api/DataC } public final class dev/kord/core/cache/DataCacheExtensionsKt { - public static final fun createView (Ldev/kord/cache/api/DataCache;)Ldev/kord/core/cache/DataCacheView; - public static final synthetic fun createView (Ldev/kord/cache/api/DataCache;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun createView (Ldev/kord/cache/api/DataCache;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } public final class dev/kord/core/cache/DataCacheView : dev/kord/cache/api/DataCache { diff --git a/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt b/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt index c28238bd1854..94fb21ef3876 100644 --- a/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt +++ b/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt @@ -4,8 +4,6 @@ import dev.kord.cache.api.DataCache import dev.kord.cache.api.query import dev.kord.common.annotation.KordInternal import dev.kord.core.cache.data.* -import kotlin.DeprecationLevel.HIDDEN -import kotlin.jvm.JvmName /** * Registers all Kord data classes for this cache @@ -56,9 +54,4 @@ internal suspend fun DataCache.removeKordData() { * Creates a [DataCacheView] for this view, only removing elements that were added * directly to this instance. */ -public fun DataCache.createView(): DataCacheView = DataCacheView(this) - -@Suppress("RedundantSuspendModifier") -@Deprecated("Binary compatibility, keep for some releases.", level = HIDDEN) -@JvmName("createView") -public suspend fun DataCache.createView0(): DataCacheView = createView() +public suspend fun DataCache.createView(): DataCacheView = DataCacheView(this) From 5a8fbf18cb3fa0575c173635151314d1166cf1d3 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Sun, 2 Apr 2023 23:21:00 +0200 Subject: [PATCH 102/136] const val for Platform.IS_JVM on JS --- common/src/jsMain/kotlin/Platform.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/jsMain/kotlin/Platform.kt b/common/src/jsMain/kotlin/Platform.kt index 8285c9e52b32..f9c76458c131 100644 --- a/common/src/jsMain/kotlin/Platform.kt +++ b/common/src/jsMain/kotlin/Platform.kt @@ -4,7 +4,7 @@ import dev.kord.common.annotation.KordInternal @KordInternal public actual object Platform { - public actual val IS_JVM: Boolean = false + public actual const val IS_JVM: Boolean = false public actual val IS_NODE: Boolean get() = js( "typeof process !== 'undefined' && process.versions != null && process.versions.node != null" From 5fbbfe6e935385cbf6128f8e724eb0a6427204f4 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Sun, 2 Apr 2023 23:37:51 +0200 Subject: [PATCH 103/136] Move version of fast-zlib to libs.versions.toml Also make it an implementation dependency. --- gateway/build.gradle.kts | 4 ++-- gradle/libs.versions.toml | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gateway/build.gradle.kts b/gateway/build.gradle.kts index ec7df6731ffd..17f13890306b 100644 --- a/gateway/build.gradle.kts +++ b/gateway/build.gradle.kts @@ -15,8 +15,8 @@ kotlin { } jsMain { dependencies { - api(libs.kotlinx.nodejs) - api(npm("fast-zlib", "2.0.1")) + implementation(libs.kotlinx.nodejs) + implementation(npm("fast-zlib", libs.versions.fastZlib.get())) } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 97190acbc55a..c22f12fbf52e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,8 +7,11 @@ kotlinx-coroutines = "1.6.4" # https://github.com/Kotlin/kotlinx.coroutines kotlinx-serialization = "1.5.0" # https://github.com/Kotlin/kotlinx.serialization kotlinx-datetime = "0.4.0" # https://github.com/Kotlin/kotlinx-datetime kotlin-logging = "3.0.5" # https://github.com/oshai/kotlin-logging -kord-cache = "0.4.0" -stately = "2.0.0-rc1" +kord-cache = "0.4.0" # https://github.com/kordlib/cache + +# implementation dependencies +stately = "2.0.0-rc1" # https://github.com/touchlab/Stately +fastZlib = "2.0.1" # https://github.com/timotejroiko/fast-zlib # code generation ksp = "1.8.10-1.0.9" # https://github.com/google/ksp From 46c53d14cf5a9595c38ce7fdb11ad0f7a0d65d7d Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Sun, 2 Apr 2023 23:42:40 +0200 Subject: [PATCH 104/136] Remove unused imports --- gateway/src/commonMain/kotlin/DefaultGateway.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/gateway/src/commonMain/kotlin/DefaultGateway.kt b/gateway/src/commonMain/kotlin/DefaultGateway.kt index d820f4e2fb42..9460da5e64d5 100644 --- a/gateway/src/commonMain/kotlin/DefaultGateway.kt +++ b/gateway/src/commonMain/kotlin/DefaultGateway.kt @@ -11,8 +11,6 @@ import io.ktor.client.* import io.ktor.client.plugins.websocket.* import io.ktor.client.request.* import io.ktor.http.* -import io.ktor.util.logging.* -import io.ktor.utils.io.charsets.* import io.ktor.websocket.* import kotlinx.atomicfu.AtomicRef import kotlinx.atomicfu.atomic From e4fc17af1673e556c1f62ca385f7d6ab3641ae0d Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Sun, 2 Apr 2023 23:45:45 +0200 Subject: [PATCH 105/136] Restore formatting --- gateway/src/commonMain/kotlin/DefaultGateway.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/gateway/src/commonMain/kotlin/DefaultGateway.kt b/gateway/src/commonMain/kotlin/DefaultGateway.kt index 9460da5e64d5..42ad204cfb38 100644 --- a/gateway/src/commonMain/kotlin/DefaultGateway.kt +++ b/gateway/src/commonMain/kotlin/DefaultGateway.kt @@ -209,7 +209,6 @@ public class DefaultGateway(private val data: DefaultGatewayData) : Gateway { state.update { State.Stopped } throw IllegalStateException("Gateway closed: ${reason.code} ${reason.message}") } - discordReason.resetSession -> { setStopped() } From a67d587db71202b9565ba2d010aad90687261135 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 3 Apr 2023 01:06:36 +0200 Subject: [PATCH 106/136] Clean libs.versions.toml --- common/build.gradle.kts | 2 +- gradle/libs.versions.toml | 22 ++++++++++------------ test-kit/build.gradle.kts | 3 +-- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index dd46ee93c085..055544ab147e 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -28,7 +28,7 @@ kotlin { dependencies { implementation(libs.ktor.utils) implementation(libs.bignum) - implementation(libs.bundles.stately) + implementation(libs.stately.collections) } } jsMain { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c22f12fbf52e..9da88264431e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,6 +10,8 @@ kotlin-logging = "3.0.5" # https://github.com/oshai/kotlin-logging kord-cache = "0.4.0" # https://github.com/kordlib/cache # implementation dependencies +kotlinx-nodejs = "18.14.0-pre.502" # https://github.com/JetBrains/kotlin-wrappers +bignum = "0.3.8" # https://github.com/ionspin/kotlin-multiplatform-bignum stately = "2.0.0-rc1" # https://github.com/touchlab/Stately fastZlib = "2.0.1" # https://github.com/timotejroiko/fast-zlib @@ -51,28 +53,25 @@ kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-c kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" } kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" } kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" } -kotlinx-atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version.ref = "kotlinx-atomicfu" } -kotlinx-nodejs = { module = "org.jetbrains.kotlin-wrappers:kotlin-node", version = "18.14.0-pre.502" } +kotlinx-nodejs = { module = "org.jetbrains.kotlin-wrappers:kotlin-node", version.ref = "kotlinx-nodejs" } # other kotlin-logging = { module = "io.github.microutils:kotlin-logging", version.ref = "kotlin-logging" } +# JDK replacements +bignum = { module = "com.ionspin.kotlin:bignum", version.ref = "bignum" } +stately-collections = { module = "co.touchlab:stately-concurrent-collections", version.ref = "stately" } + # code generation ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" } kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoet" } kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlinpoet" } -# JDK Replacements -bignum = { module = "com.ionspin.kotlin:bignum", version = "0.3.8" } -stately-collections = { module = "co.touchlab:stately-concurrent-collections", version.ref = "stately" } -stately-concurrency = { module = "co.touchlab:stately-concurrency", version.ref = "stately" } - # tests +kotlin-test-annotations-common = { module = "org.jetbrains.kotlin:kotlin-test-annotations-common", version.ref = "kotlin" } kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test-common", version.ref = "kotlin" } kotlin-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref = "kotlin" } -kotlin-test-annotations-common = { module = "org.jetbrains.kotlin:kotlin-test-annotations-common", version.ref = "kotlin" } kotlin-test-junit5 = { module = "org.jetbrains.kotlin:kotlin-test-junit5", version.ref = "kotlin" } -junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit5" } junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit5" } mockk = { module = "io.mockk:mockk", version.ref = "mockk" } slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" } @@ -91,10 +90,9 @@ ksp-plugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin ktor-client-serialization = ["ktor-client-content-negotiation", "ktor-serialization-kotlinx-json"] -test-common = ["kotlinx-coroutines-test", "kotlin-test", "kotlin-test-annotations-common"] -test-runtime = ["kotlin-test-junit5", "junit-jupiter-engine", "slf4j-simple"] +test-common = ["kotlin-test-annotations-common", "kotlin-test", "kotlinx-coroutines-test"] test-js = ["kotlin-test-js", "kotlinx-nodejs"] -stately = ["stately-collections", "stately-concurrency"] +test-jvm = ["kotlin-test-junit5", "junit-jupiter-engine", "slf4j-simple"] pluginsForBuildSrc = [ "kotlin-jvm-plugin", diff --git a/test-kit/build.gradle.kts b/test-kit/build.gradle.kts index 8a07c0c329f2..9903037cff90 100644 --- a/test-kit/build.gradle.kts +++ b/test-kit/build.gradle.kts @@ -18,8 +18,7 @@ kotlin { } jvmMain { dependencies { - api(libs.bundles.test.runtime) - api(libs.kotlin.test.junit5) + api(libs.bundles.test.jvm) } } } From 066757688f114f77ec885c40e3dc4e6972acd078 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 3 Apr 2023 01:48:49 +0200 Subject: [PATCH 107/136] Clean test-kit annotations --- test-kit/src/commonMain/kotlin/Annotations.kt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/test-kit/src/commonMain/kotlin/Annotations.kt b/test-kit/src/commonMain/kotlin/Annotations.kt index d7c5d089758f..bcc93e2653d5 100644 --- a/test-kit/src/commonMain/kotlin/Annotations.kt +++ b/test-kit/src/commonMain/kotlin/Annotations.kt @@ -3,17 +3,14 @@ package dev.kord.test import kotlin.annotation.AnnotationTarget.CLASS +import kotlin.annotation.AnnotationTarget.FUNCTION -/** - * Ignores this Test on JS platforms. - */ -@Target(AnnotationTarget.FUNCTION, CLASS) +/** Ignores this test on JS platforms. */ +@Target(CLASS, FUNCTION) @OptionalExpectation expect annotation class IgnoreOnJs() -/** - * Ignores this test on JVM. - */ -@Target(AnnotationTarget.FUNCTION, CLASS) +/** Ignores this test on the JVM. */ +@Target(CLASS, FUNCTION) @OptionalExpectation expect annotation class IgnoreOnJvm() From 8e12712706bfdba9b9cefc9e6f18a7cc1aa38fba Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 3 Apr 2023 01:56:41 +0200 Subject: [PATCH 108/136] Don't keep reference to ticker Flow --- gateway/src/commonMain/kotlin/Ticker.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/gateway/src/commonMain/kotlin/Ticker.kt b/gateway/src/commonMain/kotlin/Ticker.kt index 1be7d39101cb..99c35b6a3a07 100644 --- a/gateway/src/commonMain/kotlin/Ticker.kt +++ b/gateway/src/commonMain/kotlin/Ticker.kt @@ -24,21 +24,18 @@ public class Ticker(private val dispatcher: CoroutineDispatcher = Dispatchers.De private val mutex = Mutex() - private var ticker: Flow? = null private var listener: Job? = null public suspend fun tickAt(intervalMillis: Long, block: suspend () -> Unit) { - stop() mutex.withLock { - ticker = tickingFlow(intervalMillis) - - listener = ticker?.onEach { + listener?.cancel() + listener = tickingFlow(intervalMillis).onEach { try { block() } catch (exception: Exception) { logger.error(exception) } - }?.launchIn(this) + }.launchIn(this) } } From 7eb4a645503a49cdd2cdead337d02889147d2238 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 3 Apr 2023 02:45:27 +0200 Subject: [PATCH 109/136] Fix KordEventDropTest on JS --- core/build.gradle.kts | 10 +++++ .../kotlin/performance/KordEventDropTest.kt | 42 ++++++++++--------- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index e3748e5d6f2c..58bca499628c 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -4,6 +4,16 @@ plugins { } kotlin { + js { + nodejs { + testTask { + useMocha { + timeout = "10000" // KordEventDropTest is too slow for default 2 seconds timeout + } + } + } + } + sourceSets { commonMain { dependencies { diff --git a/core/src/commonTest/kotlin/performance/KordEventDropTest.kt b/core/src/commonTest/kotlin/performance/KordEventDropTest.kt index 76a8ab111454..e5e0763883df 100644 --- a/core/src/commonTest/kotlin/performance/KordEventDropTest.kt +++ b/core/src/commonTest/kotlin/performance/KordEventDropTest.kt @@ -12,13 +12,16 @@ import dev.kord.gateway.* import dev.kord.gateway.builder.Shards import dev.kord.rest.request.KtorRequestHandler import dev.kord.rest.service.RestClient -import dev.kord.test.IgnoreOnJs import io.ktor.client.* -import kotlinx.coroutines.* -import kotlinx.coroutines.channels.Channel +import kotlinx.atomicfu.atomic +import kotlinx.coroutines.CompletableDeferred +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.launch import kotlinx.coroutines.test.runTest import kotlinx.datetime.Clock import kotlin.coroutines.CoroutineContext @@ -27,7 +30,6 @@ import kotlin.js.JsName import kotlin.test.Test import kotlin.test.assertEquals import kotlin.time.Duration -import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds class KordEventDropTest { @@ -56,7 +58,7 @@ class KordEventDropTest { Shards(1), maxConcurrency = 1, HttpClient(), - EntitySupplyStrategy.cache + EntitySupplyStrategy.cache, ), cache = DataCache.none(), DefaultMasterGateway(mapOf(0 to SpammyGateway)), @@ -69,7 +71,6 @@ class KordEventDropTest { @Test @JsName("test1") - @IgnoreOnJs // currently this doesn't work on JS for some reason fun `hammering the gateway does not drop core events`() = runTest { val amount = 1_000 @@ -104,24 +105,27 @@ class KordEventDropTest { ), 0 ) - val channel = Channel() + val counter = object { + private val counter = atomic(0) + fun incrementAndGet() = counter.incrementAndGet() + val value by counter + } + val completion = CompletableDeferred() + kord.on { - channel.send(Unit) + if (counter.incrementAndGet() == amount) completion.complete(Unit) } launch { - repeat(amount) { SpammyGateway.events.emit(event) } - } - var received = 0 - withContext(Dispatchers.Default) { - withTimeout(1.minutes) { - for (unit in channel) { - if (++received == amount) { - channel.close() - } - } + // wait until we are actually listening + SpammyGateway.events.subscriptionCount.first { it == 1 } + + repeat(amount) { + SpammyGateway.events.emit(event) } } - assertEquals(amount, received) + + completion.await() + assertEquals(amount, counter.value) } } From f430b47e3298ac6cb5ff18567eb29ad6a6239970 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 3 Apr 2023 02:49:59 +0200 Subject: [PATCH 110/136] Restore formatting --- .../commonTest/kotlin/performance/KordEventDropTest.kt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/core/src/commonTest/kotlin/performance/KordEventDropTest.kt b/core/src/commonTest/kotlin/performance/KordEventDropTest.kt index e5e0763883df..7f6aeb98e49c 100644 --- a/core/src/commonTest/kotlin/performance/KordEventDropTest.kt +++ b/core/src/commonTest/kotlin/performance/KordEventDropTest.kt @@ -52,14 +52,7 @@ class KordEventDropTest { } val kord = Kord( - resources = ClientResources( - "token", - Snowflake(0u), - Shards(1), - maxConcurrency = 1, - HttpClient(), - EntitySupplyStrategy.cache, - ), + resources = ClientResources("token", Snowflake(0u), Shards(1), maxConcurrency = 1, HttpClient(), EntitySupplyStrategy.cache), cache = DataCache.none(), DefaultMasterGateway(mapOf(0 to SpammyGateway)), RestClient(KtorRequestHandler("token", clock = Clock.System)), From b2a8692c512be5357854d1c99d160e3a5d508163 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 3 Apr 2023 03:03:55 +0200 Subject: [PATCH 111/136] Restore formatting --- common/src/commonTest/kotlin/json/Util.kt | 48 +++++++++++++++-------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/common/src/commonTest/kotlin/json/Util.kt b/common/src/commonTest/kotlin/json/Util.kt index a44194e5f60d..00d62b3c2aa8 100644 --- a/common/src/commonTest/kotlin/json/Util.kt +++ b/common/src/commonTest/kotlin/json/Util.kt @@ -4,50 +4,66 @@ import dev.kord.common.entity.* import dev.kord.common.entity.optional.* import kotlin.test.assertEquals -infix fun String?.shouldBe(value: String?) = +infix fun String?.shouldBe(value: String?){ assertEquals(value, this) +} -infix fun Optional.shouldBe(value: String?) = +infix fun Optional.shouldBe(value: String?){ assertEquals(value, this.value) +} -infix fun OptionalBoolean.shouldBe(value: Boolean) = +infix fun OptionalBoolean.shouldBe(value: Boolean){ assertEquals(value, this.value) +} -infix fun Snowflake?.shouldBe(value: String?) = +infix fun Snowflake?.shouldBe(value: String?){ assertEquals(value, this?.toString()) +} -infix fun OptionalSnowflake?.shouldBe(value: String?) = +infix fun OptionalSnowflake?.shouldBe(value: String?){ assertEquals(value, this?.value?.toString()) +} -infix fun VerificationLevel?.shouldBe(value: VerificationLevel?) = +infix fun VerificationLevel?.shouldBe(value: VerificationLevel?){ assertEquals(value, this) +} -infix fun DefaultMessageNotificationLevel?.shouldBe(value: DefaultMessageNotificationLevel?) = +infix fun DefaultMessageNotificationLevel?.shouldBe(value: DefaultMessageNotificationLevel?){ assertEquals(value, this) +} -infix fun MFALevel?.shouldBe(value: MFALevel?) = +infix fun MFALevel?.shouldBe(value: MFALevel?){ assertEquals(value, this) +} -infix fun ExplicitContentFilter?.shouldBe(value: ExplicitContentFilter?) = +infix fun ExplicitContentFilter?.shouldBe(value: ExplicitContentFilter?){ assertEquals(value, this) +} -infix fun PremiumTier?.shouldBe(value: PremiumTier?) = +infix fun PremiumTier?.shouldBe(value: PremiumTier?){ assertEquals(value, this) +} -infix fun SystemChannelFlags?.shouldBe(value: SystemChannelFlags?) = +infix fun SystemChannelFlags?.shouldBe(value: SystemChannelFlags?){ assertEquals(value, this) +} -infix fun List?.shouldBe(value: List?) = +infix fun List?.shouldBe(value: List?){ assertEquals(value, this) +} -infix fun Int?.shouldBe(value: Int?) = +infix fun Int?.shouldBe(value: Int?){ assertEquals(value, this) +} -infix fun OptionalInt?.shouldBe(value: Int?) = +infix fun OptionalInt?.shouldBe(value: Int?){ assertEquals(value, this.value) +} -infix fun Optional.shouldBe(that: T?) = +infix fun Optional.shouldBe(that: T?) { assertEquals(that, this.value) +} -infix fun T.shouldBe(that: T) = +infix fun T.shouldBe(that: T) { assertEquals(that, this) +} From d52928654b7252df51fdae0e9bbc33deba3a93b3 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 3 Apr 2023 03:07:07 +0200 Subject: [PATCH 112/136] Remove comment that wasn't there before --- .../src/main/kotlin/BaseVoiceChannelBehaviorExtensions.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-voice/src/main/kotlin/BaseVoiceChannelBehaviorExtensions.kt b/core-voice/src/main/kotlin/BaseVoiceChannelBehaviorExtensions.kt index 1d576ef984e0..c6da181516d1 100644 --- a/core-voice/src/main/kotlin/BaseVoiceChannelBehaviorExtensions.kt +++ b/core-voice/src/main/kotlin/BaseVoiceChannelBehaviorExtensions.kt @@ -1,4 +1,4 @@ -@file:JvmName("VoiceBaseVoiceChannelBehavior") // preserve old name for binary compatibility +@file:JvmName("VoiceBaseVoiceChannelBehavior") package dev.kord.core.behavior.channel From 262fef1bc0f6f26f945a90c1bfc471d08e4ab8a5 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 3 Apr 2023 03:11:15 +0200 Subject: [PATCH 113/136] Remove unused imports --- .../kotlin/behavior/channel/MessageChannelBehavior.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/src/commonMain/kotlin/behavior/channel/MessageChannelBehavior.kt b/core/src/commonMain/kotlin/behavior/channel/MessageChannelBehavior.kt index 5d25b19a2c75..76702092614b 100644 --- a/core/src/commonMain/kotlin/behavior/channel/MessageChannelBehavior.kt +++ b/core/src/commonMain/kotlin/behavior/channel/MessageChannelBehavior.kt @@ -8,6 +8,7 @@ import dev.kord.core.entity.Message import dev.kord.core.entity.Strategizable import dev.kord.core.entity.channel.MessageChannel import dev.kord.core.exception.EntityNotFoundException +import dev.kord.core.hash import dev.kord.core.supplier.EntitySupplier import dev.kord.core.supplier.EntitySupplyStrategy import dev.kord.rest.builder.message.EmbedBuilder @@ -25,11 +26,8 @@ import kotlinx.coroutines.flow.takeWhile import kotlinx.coroutines.launch import kotlinx.datetime.Clock import kotlinx.datetime.Instant -import dev.kord.core.hash -import kotlin.DeprecationLevel.HIDDEN import kotlin.contracts.InvocationKind import kotlin.contracts.contract -import kotlin.coroutines.coroutineContext import kotlin.js.JsName import kotlin.time.Duration.Companion.seconds import kotlin.time.TimeMark @@ -215,7 +213,7 @@ public interface MessageChannelBehavior : ChannelBehavior, Strategizable { * * @throws [RestRequestException] if something went wrong during the request. */ - @JsName("sendTyping") // otherwise clashes with channel typefield + @JsName("sendTyping") // otherwise clashes with Channel.type property public suspend fun type() { kord.rest.channel.triggerTypingIndicator(id) } From 5c28674de37138829b31dface682fd14a36a5c98 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 3 Apr 2023 03:15:07 +0200 Subject: [PATCH 114/136] Remove unused imports --- core/src/commonMain/kotlin/entity/channel/DmChannel.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/commonMain/kotlin/entity/channel/DmChannel.kt b/core/src/commonMain/kotlin/entity/channel/DmChannel.kt index af5540e6eca4..e03ac7476e38 100644 --- a/core/src/commonMain/kotlin/entity/channel/DmChannel.kt +++ b/core/src/commonMain/kotlin/entity/channel/DmChannel.kt @@ -15,7 +15,6 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.map -import kotlin.js.JsName /** * An instance of a Discord DM channel. From ada7e92e84600eae84cb34f46240f480b95aff01 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 3 Apr 2023 03:30:08 +0200 Subject: [PATCH 115/136] Remove last plain assert() calls --- .../src/jvmTest/kotlin/interaction/CommandTypesTest.kt | 10 ++++------ core/src/jvmTest/kotlin/rest/RestTest.kt | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/core/src/jvmTest/kotlin/interaction/CommandTypesTest.kt b/core/src/jvmTest/kotlin/interaction/CommandTypesTest.kt index 094229ba15c4..aa97c32046ed 100644 --- a/core/src/jvmTest/kotlin/interaction/CommandTypesTest.kt +++ b/core/src/jvmTest/kotlin/interaction/CommandTypesTest.kt @@ -11,6 +11,7 @@ import dev.kord.core.mockKord import kotlinx.serialization.json.* import org.junit.jupiter.api.Test import kotlin.test.assertEquals +import kotlin.test.assertIs class CommandsTypeTests { @@ -54,8 +55,7 @@ class CommandsTypeTests { val serializedRoot = Json.decodeFromJsonElement(InteractionCallbackData.serializer(), root) val data = ApplicationInteractionData.from(serializedRoot, null) val command = InteractionCommand(data, mockKord()) - assert(command is RootCommand) - command as RootCommand + assertIs(command) assertEquals(1L, command.integers["argument"]) assertEquals("root", command.rootName) @@ -66,8 +66,7 @@ class CommandsTypeTests { val sub = Json.decodeFromJsonElement(InteractionCallbackData.serializer(), subCommand) val data = ApplicationInteractionData.from(sub, null) val command = InteractionCommand(data, mockKord()) - assert(command is SubCommand) - command as SubCommand + assertIs(command) assertEquals(1L, command.integers["argument"]) assertEquals("root", command.rootName) assertEquals("subCommand", command.name) @@ -79,8 +78,7 @@ class CommandsTypeTests { val grouping = Json.decodeFromJsonElement(InteractionCallbackData.serializer(), group) val data = ApplicationInteractionData.from(grouping, null) val command = InteractionCommand(data, mockKord()) - assert(command is GroupCommand) - command as GroupCommand + assertIs(command) assertEquals(1L, command.integers["argument"]) assertEquals("root", command.rootName) assertEquals("group", command.groupName) diff --git a/core/src/jvmTest/kotlin/rest/RestTest.kt b/core/src/jvmTest/kotlin/rest/RestTest.kt index 6ccaf030d54e..a4b3c8a61403 100644 --- a/core/src/jvmTest/kotlin/rest/RestTest.kt +++ b/core/src/jvmTest/kotlin/rest/RestTest.kt @@ -172,7 +172,7 @@ class RestServiceTest { content = "TEST REPLY" } - assert(reply.referencedMessage?.id == referenceMessage.id) + assertEquals(referenceMessage.id, reply.referencedMessage?.id) } val messages = channel.messages.toList() @@ -371,10 +371,10 @@ class RestServiceTest { val category = guild.createCategory("my category") val textChannel = category.createTextChannel("test child text channel") - assert(textChannel.category == category) + assertEquals(category, textChannel.category) val voiceChannel = category.createVoiceChannel("test child voice channel") - assert(voiceChannel.category == category) + assertEquals(category, voiceChannel.category) } @Test From b573d62093bec9e8c356ed4dee12e07ada2b509b Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 3 Apr 2023 03:34:36 +0200 Subject: [PATCH 116/136] Clean KSPUtils --- ksp-processors/src/main/kotlin/KSPUtils.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ksp-processors/src/main/kotlin/KSPUtils.kt b/ksp-processors/src/main/kotlin/KSPUtils.kt index f9b3f0173a93..56be262c64ca 100644 --- a/ksp-processors/src/main/kotlin/KSPUtils.kt +++ b/ksp-processors/src/main/kotlin/KSPUtils.kt @@ -16,20 +16,20 @@ internal fun KSAnnotation.isOfType(qualifiedName: String) = && annotationType.resolve().declaration.qualifiedName?.asString() == qualifiedName internal class AnnotationArguments private constructor(private val map: Map) { - private inline fun get(parameter: KProperty1) = map[parameter.name] as V? + private inline fun get(parameter: KProperty1) = map[parameter.name] as V? + + internal inline fun getSafe(parameter: KProperty1) = + get(parameter) ?: error("Missing required parameter: $parameter") - internal inline fun getSafe(parameter: KProperty1) = get(parameter) ?: error("Missing required parameter: $parameter") // https://github.com/google/ksp/issues/885 - internal inline fun getOrDefault(parameter: KProperty1, defaultValue: V) = get(parameter) ?: defaultValue + internal inline fun getOrDefault(parameter: KProperty1, defaultValue: V) = + get(parameter) ?: defaultValue internal fun getRaw(parameter: KProperty1) = map[parameter.name] internal companion object { internal val KSAnnotation.annotationArguments: AnnotationArguments - get() { - return AnnotationArguments(arguments - .associate { it.name!!.getShortName() to it.value }) - } + get() = AnnotationArguments(arguments.associate { it.name!!.getShortName() to it.value }) } } From e15c5dac7813b09340cf3abbd57ac86d38c17a91 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 3 Apr 2023 03:35:06 +0200 Subject: [PATCH 117/136] Clean KSPUtils --- ksp-processors/src/main/kotlin/KSPUtils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ksp-processors/src/main/kotlin/KSPUtils.kt b/ksp-processors/src/main/kotlin/KSPUtils.kt index 56be262c64ca..9764229055cd 100644 --- a/ksp-processors/src/main/kotlin/KSPUtils.kt +++ b/ksp-processors/src/main/kotlin/KSPUtils.kt @@ -28,7 +28,7 @@ internal class AnnotationArguments private constructor(private val map: Map) = map[parameter.name] internal companion object { - internal val KSAnnotation.annotationArguments: AnnotationArguments + internal val KSAnnotation.annotationArguments get() = AnnotationArguments(arguments.associate { it.name!!.getShortName() to it.value }) } } From 413e55a61a7322072e6707715fa6495ae7a24d48 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Mon, 3 Apr 2023 03:42:01 +0200 Subject: [PATCH 118/136] Clean KordEnum.kt --- ksp-processors/src/main/kotlin/kordenum/KordEnum.kt | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/ksp-processors/src/main/kotlin/kordenum/KordEnum.kt b/ksp-processors/src/main/kotlin/kordenum/KordEnum.kt index fe913ca9a851..e0c90a6cdf62 100644 --- a/ksp-processors/src/main/kotlin/kordenum/KordEnum.kt +++ b/ksp-processors/src/main/kotlin/kordenum/KordEnum.kt @@ -61,10 +61,8 @@ internal fun KSAnnotation.toKordEnumOrNull(logger: KSPLogger): KordEnum? { val valueName = args.getOrDefault(GenerateKordEnum::valueName, "value") val deprecatedEntries = args.getRaw(GenerateKordEnum::deprecatedEntries) as List<*>? ?: emptyList() - val valuesPropertyName = args.getOrDefault(GenerateKordEnum::valuesPropertyName, "") - .ifEmpty { null } - val valuesPropertyType = args.getRaw(GenerateKordEnum::valuesPropertyType)?.toValuesPropertyType() - ?: NONE + val valuesPropertyName = args.getOrDefault(GenerateKordEnum::valuesPropertyName, "").ifEmpty { null } + val valuesPropertyType = args.getRaw(GenerateKordEnum::valuesPropertyType)?.toValuesPropertyType() ?: NONE if (valuesPropertyName != null) { if (valuesPropertyType == NONE) { logger.error("Didn't specify valuesPropertyType", symbol = this) @@ -117,10 +115,8 @@ private fun Any?.toEntryOrNull(valueType: ValueType, isDeprecated: Boolean, logg val kDoc = args.getOrDefault(GenerateKordEnum.Entry::kDoc, "").toKDoc() val isKordExperimental = args.getOrDefault(GenerateKordEnum.Entry::isKordExperimental, false) val deprecationMessage = args.getOrDefault(GenerateKordEnum.Entry::deprecationMessage, "") - @Suppress("RemoveRedundantSpreadOperator") // Removing the emptyArray() will cause a compiler error - val replaceWith = args.getRaw(GenerateKordEnum.Entry::replaceWith)?.toReplaceWith() ?: ReplaceWith("", *emptyArray()) - val deprecationLevel = args.getRaw(GenerateKordEnum.Entry::deprecationLevel)?.toDeprecationLevel() - ?: WARNING + val replaceWith = args.getRaw(GenerateKordEnum.Entry::replaceWith)?.toReplaceWith() ?: ReplaceWith("", imports = emptyArray()) + val deprecationLevel = args.getRaw(GenerateKordEnum.Entry::deprecationLevel)?.toDeprecationLevel() ?: WARNING val value = when (valueType) { INT -> { @@ -135,7 +131,6 @@ private fun Any?.toEntryOrNull(valueType: ValueType, isDeprecated: Boolean, logg intValue } - STRING -> { if (intValue != GenerateKordEnum.Entry.DEFAULT_INT_VALUE) { logger.error("Specified intValue for valueType $valueType", symbol = this) From b17faebc6f5b7508c1325f79c3aee707b1ac20a8 Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Tue, 4 Apr 2023 11:42:33 +0200 Subject: [PATCH 119/136] Apply requested changes - Move Platform to test-kit - Restore stack trace recovery tests --- common/src/commonMain/kotlin/Platform.kt | 10 ---- common/src/jsMain/kotlin/Platform.kt | 16 ------ common/src/jvmMain/kotlin/Platform.kt | 10 ---- .../kotlin/request/StackTraceRecoveryTest.kt | 53 +++++++++++++++++++ rest/src/jsMain/kotlin/RecoveredStackTrace.kt | 1 - .../dev/kord/rest/request/StackTrace.kt | 17 ++++++ .../dev/kord/rest/request/StackTrace.kt | 18 +++++++ test-kit/src/commonMain/kotlin/Platform.kt | 6 +++ test-kit/src/jsMain/kotlin/Platform.kt | 13 ++++- test-kit/src/jvmMain/kotlin/Platform.kt | 5 ++ 10 files changed, 111 insertions(+), 38 deletions(-) delete mode 100644 common/src/commonMain/kotlin/Platform.kt delete mode 100644 common/src/jsMain/kotlin/Platform.kt delete mode 100644 common/src/jvmMain/kotlin/Platform.kt create mode 100644 rest/src/commonTest/kotlin/request/StackTraceRecoveryTest.kt create mode 100644 rest/src/jsTest/kotlin/dev/kord/rest/request/StackTrace.kt create mode 100644 rest/src/jvmTest/kotlin/dev/kord/rest/request/StackTrace.kt diff --git a/common/src/commonMain/kotlin/Platform.kt b/common/src/commonMain/kotlin/Platform.kt deleted file mode 100644 index e69599df10c9..000000000000 --- a/common/src/commonMain/kotlin/Platform.kt +++ /dev/null @@ -1,10 +0,0 @@ -package dev.kord.common - -import dev.kord.common.annotation.KordInternal - -@KordInternal -public expect object Platform { - public val IS_JVM: Boolean - public val IS_NODE: Boolean - public val IS_BROWSER: Boolean -} diff --git a/common/src/jsMain/kotlin/Platform.kt b/common/src/jsMain/kotlin/Platform.kt deleted file mode 100644 index f9c76458c131..000000000000 --- a/common/src/jsMain/kotlin/Platform.kt +++ /dev/null @@ -1,16 +0,0 @@ -package dev.kord.common - -import dev.kord.common.annotation.KordInternal - -@KordInternal -public actual object Platform { - public actual const val IS_JVM: Boolean = false - public actual val IS_NODE: Boolean - get() = js( - "typeof process !== 'undefined' && process.versions != null && process.versions.node != null" - ) as Boolean - public actual val IS_BROWSER: Boolean - get() = js( - "typeof window !== 'undefined' && typeof window.document !== 'undefined' || typeof self !== 'undefined' && typeof self.location !== 'undefined'" - ) as Boolean -} diff --git a/common/src/jvmMain/kotlin/Platform.kt b/common/src/jvmMain/kotlin/Platform.kt deleted file mode 100644 index 8fe26557559d..000000000000 --- a/common/src/jvmMain/kotlin/Platform.kt +++ /dev/null @@ -1,10 +0,0 @@ -package dev.kord.common - -import dev.kord.common.annotation.KordInternal - -@KordInternal -public actual object Platform { - public actual const val IS_JVM: Boolean = true - public actual const val IS_NODE: Boolean = false - public actual const val IS_BROWSER: Boolean = false -} diff --git a/rest/src/commonTest/kotlin/request/StackTraceRecoveryTest.kt b/rest/src/commonTest/kotlin/request/StackTraceRecoveryTest.kt new file mode 100644 index 000000000000..69aa3eadcd2b --- /dev/null +++ b/rest/src/commonTest/kotlin/request/StackTraceRecoveryTest.kt @@ -0,0 +1,53 @@ +package dev.kord.rest.request + +import dev.kord.rest.json.response.GatewayResponse +import dev.kord.rest.route.Route +import io.ktor.client.* +import io.ktor.client.engine.mock.* +import io.ktor.http.* +import io.ktor.util.* +import io.ktor.utils.io.* +import kotlinx.coroutines.test.runTest +import kotlin.js.JsName +import kotlin.test.Test + +expect class StackTraceElement +expect fun currentThreadStackTrace(): StackTraceElement +internal expect fun RecoveredStackTrace.validate(expected: StackTraceElement) + +class StackTraceRecoveryTest { + + @Test + @JsName("test1") + fun `test stack trace recovery`() = runTest { + val mockEngine = MockEngine { + respond( + content = ByteReadChannel.Empty, + status = HttpStatusCode.NotFound + ) + } + + val client = HttpClient(mockEngine) + val handler = KtorRequestHandler(client = client, token = "") + .withStackTraceRecovery() + + val request = JsonRequest( + Route.GatewayGet, // The mock engine will 404 for any request, so we just use an endpoint without params + emptyMap(), + StringValues.Empty, + StringValues.Empty, + null + ) + + val stackTrace = currentThreadStackTrace() + try { + handler.handle(request) + } catch (e: Throwable) { + e.printStackTrace() + + val recovered = e.suppressedExceptions.first { it is RecoveredStackTrace } as RecoveredStackTrace + recovered.printStackTrace() + recovered.validate(stackTrace) + } + } +} diff --git a/rest/src/jsMain/kotlin/RecoveredStackTrace.kt b/rest/src/jsMain/kotlin/RecoveredStackTrace.kt index fbd70f036f3d..0eb06fa964bc 100644 --- a/rest/src/jsMain/kotlin/RecoveredStackTrace.kt +++ b/rest/src/jsMain/kotlin/RecoveredStackTrace.kt @@ -9,7 +9,6 @@ internal actual fun RecoveredStackTrace.sanitizeStackTrace() { // at _no_name_provided__304.invoke_29q9u6(/home/mik/IdeaProjects/ktor-suspend-function-gun-tests/src/commonTest/kotlin/Test.kt:9) val dynamic = asDynamic() val stack = dynamic.stack as String? ?: "" - stackTraceToString() dynamic.stack = stack.lines().toMutableList().apply { repeat(2) { removeAt(1) diff --git a/rest/src/jsTest/kotlin/dev/kord/rest/request/StackTrace.kt b/rest/src/jsTest/kotlin/dev/kord/rest/request/StackTrace.kt new file mode 100644 index 000000000000..6f23c0ec465e --- /dev/null +++ b/rest/src/jsTest/kotlin/dev/kord/rest/request/StackTrace.kt @@ -0,0 +1,17 @@ +package dev.kord.rest.request + +import kotlin.test.assertEquals + +actual typealias StackTraceElement = String + +//[0]: at $handleCOROUTINE$6.doResume_5yljmg_k$ (C:\Users\micha\IdeaProjects\kord\rest\src\commonMain\kotlin\request\KtorRequestHandler.kt:64:28) +//[1]: at currentThreadStackTrace (C:\Users\micha\IdeaProjects\kord\rest\src\jsTest\kotlin\dev\kord\rest\request\StackTrace.kt:5:59) +//[2]: at $executeCOROUTINE$0.CoroutineImpl.resumeWith_7onugl_k$ (C:\Users\micha\IdeaProjects\kord\rest\build\compileSync\js\test\testDevelopmentExecutable\kotlin\commonMainSources\libraries\stdlib\src\kotlin\util\Standard.kt:55:40) +actual fun currentThreadStackTrace(): StackTraceElement = + Exception().stackTraceToString().lineSequence().drop(3).first().trim() + +internal actual fun RecoveredStackTrace.validate(expected: StackTraceElement) { + // The first two lines are artifacts from coroutines which are not present in expected + val actual = stackTraceToString().lineSequence().drop(2).first().trim() + assertEquals(expected, actual) +} diff --git a/rest/src/jvmTest/kotlin/dev/kord/rest/request/StackTrace.kt b/rest/src/jvmTest/kotlin/dev/kord/rest/request/StackTrace.kt new file mode 100644 index 000000000000..d05eb1c9fe77 --- /dev/null +++ b/rest/src/jvmTest/kotlin/dev/kord/rest/request/StackTrace.kt @@ -0,0 +1,18 @@ +package dev.kord.rest.request + +import kotlin.test.assertEquals + +actual typealias StackTraceElement = java.lang.StackTraceElement + +// [0]: java.lang.Thread.getStackTrace(Thread.java) +actual fun currentThreadStackTrace(): StackTraceElement = Thread.currentThread().stackTrace[1] + +internal actual fun RecoveredStackTrace.validate(expected: StackTraceElement) { + // at dev.kord.rest.request.StackTraceRecoveryTest$test stack trace recovery$1.invokeSuspend(StackTraceRecoveryTest.kt:39) + with(stackTrace.first()) { + assertEquals(expected.className, className) + assertEquals(expected.fileName, fileName) + assertEquals(expected.lineNumber + 2, lineNumber) // +2 because capture is two lines deeper + assertEquals(expected.methodName, methodName) + } +} diff --git a/test-kit/src/commonMain/kotlin/Platform.kt b/test-kit/src/commonMain/kotlin/Platform.kt index 00f7f92ee664..587c0f0a3413 100644 --- a/test-kit/src/commonMain/kotlin/Platform.kt +++ b/test-kit/src/commonMain/kotlin/Platform.kt @@ -2,6 +2,12 @@ package dev.kord.test import io.ktor.utils.io.* +expect object Platform { + val IS_JVM: Boolean + val IS_NODE: Boolean + val IS_BROWSER: Boolean +} + expect fun getEnv(name: String): String? expect suspend fun file(project: String, path: String): String expect suspend fun readFile(project: String, path: String): ByteReadChannel diff --git a/test-kit/src/jsMain/kotlin/Platform.kt b/test-kit/src/jsMain/kotlin/Platform.kt index 758fdcd58b4b..d590c5aed1c7 100644 --- a/test-kit/src/jsMain/kotlin/Platform.kt +++ b/test-kit/src/jsMain/kotlin/Platform.kt @@ -2,12 +2,23 @@ package dev.kord.test -import dev.kord.common.Platform import dev.kord.common.annotation.KordInternal import io.ktor.utils.io.* import js.core.get import node.process.process +actual object Platform { + actual val IS_JVM: Boolean = false + actual val IS_NODE: Boolean + get() = js( + "typeof process !== 'undefined' && process.versions != null && process.versions.node != null" + ) as Boolean + actual val IS_BROWSER: Boolean + get() = js( + "typeof window !== 'undefined' && typeof window.document !== 'undefined' || typeof self !== 'undefined' && typeof self.location !== 'undefined'" + ) as Boolean +} + actual fun getEnv(name: String) = process.env[name] actual suspend fun file(project: String, path: String): String = diff --git a/test-kit/src/jvmMain/kotlin/Platform.kt b/test-kit/src/jvmMain/kotlin/Platform.kt index e890a2778cac..a6f0b71f2705 100644 --- a/test-kit/src/jvmMain/kotlin/Platform.kt +++ b/test-kit/src/jvmMain/kotlin/Platform.kt @@ -2,6 +2,11 @@ package dev.kord.test import io.ktor.utils.io.* import io.ktor.utils.io.jvm.javaio.* +actual object Platform { + actual const val IS_JVM: Boolean = true + actual const val IS_NODE: Boolean = false + actual const val IS_BROWSER: Boolean = false +} actual fun getEnv(name: String): String? = System.getenv(name) actual suspend fun file(project: String, path: String): String = ClassLoader.getSystemResource(path).readText() From 85b4f4e08cd4259c4a47711290d5fd2fd828dc6b Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Tue, 4 Apr 2023 11:43:51 +0200 Subject: [PATCH 120/136] Make IS_JVM const --- test-kit/src/jsMain/kotlin/Platform.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-kit/src/jsMain/kotlin/Platform.kt b/test-kit/src/jsMain/kotlin/Platform.kt index d590c5aed1c7..7533117ed358 100644 --- a/test-kit/src/jsMain/kotlin/Platform.kt +++ b/test-kit/src/jsMain/kotlin/Platform.kt @@ -8,7 +8,7 @@ import js.core.get import node.process.process actual object Platform { - actual val IS_JVM: Boolean = false + actual const val IS_JVM: Boolean = false actual val IS_NODE: Boolean get() = js( "typeof process !== 'undefined' && process.versions != null && process.versions.node != null" From d2859d21c049e41268968a7556a5ed032b30a0ba Mon Sep 17 00:00:00 2001 From: Michael Rittmeister Date: Tue, 4 Apr 2023 12:00:31 +0200 Subject: [PATCH 121/136] Fix test on JVM --- rest/src/commonTest/kotlin/request/MessageRequests.kt | 2 +- rest/src/jvmTest/kotlin/dev/kord/rest/request/StackTrace.kt | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rest/src/commonTest/kotlin/request/MessageRequests.kt b/rest/src/commonTest/kotlin/request/MessageRequests.kt index b6ce4d879bac..e19821c23541 100644 --- a/rest/src/commonTest/kotlin/request/MessageRequests.kt +++ b/rest/src/commonTest/kotlin/request/MessageRequests.kt @@ -1,6 +1,5 @@ package dev.kord.rest.request -import dev.kord.common.Platform import dev.kord.common.entity.DiscordAttachment import dev.kord.common.entity.DiscordMessage import dev.kord.common.entity.DiscordUser @@ -8,6 +7,7 @@ import dev.kord.common.entity.MessageType.Default import dev.kord.common.entity.Snowflake import dev.kord.rest.json.readFile import dev.kord.rest.service.ChannelService +import dev.kord.test.Platform import io.ktor.client.* import io.ktor.client.engine.mock.* import io.ktor.client.request.forms.* diff --git a/rest/src/jvmTest/kotlin/dev/kord/rest/request/StackTrace.kt b/rest/src/jvmTest/kotlin/dev/kord/rest/request/StackTrace.kt index d05eb1c9fe77..a8e643b80082 100644 --- a/rest/src/jvmTest/kotlin/dev/kord/rest/request/StackTrace.kt +++ b/rest/src/jvmTest/kotlin/dev/kord/rest/request/StackTrace.kt @@ -5,14 +5,16 @@ import kotlin.test.assertEquals actual typealias StackTraceElement = java.lang.StackTraceElement // [0]: java.lang.Thread.getStackTrace(Thread.java) -actual fun currentThreadStackTrace(): StackTraceElement = Thread.currentThread().stackTrace[1] +@Suppress("NOTHING_TO_INLINE") // inlining produces the actual stacktrace +actual inline fun currentThreadStackTrace(): StackTraceElement = Thread.currentThread().stackTrace[1] internal actual fun RecoveredStackTrace.validate(expected: StackTraceElement) { // at dev.kord.rest.request.StackTraceRecoveryTest$test stack trace recovery$1.invokeSuspend(StackTraceRecoveryTest.kt:39) with(stackTrace.first()) { assertEquals(expected.className, className) assertEquals(expected.fileName, fileName) - assertEquals(expected.lineNumber + 2, lineNumber) // +2 because capture is two lines deeper + // -11 because there is a discrepancy due to coroutines + assertEquals(expected.lineNumber - 11, lineNumber) assertEquals(expected.methodName, methodName) } } From 7ff0b16aa5ad9f5cf11d231aaf453774c147f80d Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Tue, 4 Apr 2023 22:39:06 +0200 Subject: [PATCH 122/136] Remove useless OptIn --- test-kit/src/jsMain/kotlin/Platform.kt | 3 --- test-kit/src/jvmMain/kotlin/Platform.kt | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/test-kit/src/jsMain/kotlin/Platform.kt b/test-kit/src/jsMain/kotlin/Platform.kt index 7533117ed358..70be0397537c 100644 --- a/test-kit/src/jsMain/kotlin/Platform.kt +++ b/test-kit/src/jsMain/kotlin/Platform.kt @@ -1,8 +1,5 @@ -@file:OptIn(KordInternal::class) - package dev.kord.test -import dev.kord.common.annotation.KordInternal import io.ktor.utils.io.* import js.core.get import node.process.process diff --git a/test-kit/src/jvmMain/kotlin/Platform.kt b/test-kit/src/jvmMain/kotlin/Platform.kt index a6f0b71f2705..363270db8d56 100644 --- a/test-kit/src/jvmMain/kotlin/Platform.kt +++ b/test-kit/src/jvmMain/kotlin/Platform.kt @@ -2,6 +2,7 @@ package dev.kord.test import io.ktor.utils.io.* import io.ktor.utils.io.jvm.javaio.* + actual object Platform { actual const val IS_JVM: Boolean = true actual const val IS_NODE: Boolean = false From 44d118b8f108eb3de761ac2a9ff22656a475319a Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Tue, 4 Apr 2023 22:55:30 +0200 Subject: [PATCH 123/136] Remove dependency on common in test-kit --- test-kit/build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/test-kit/build.gradle.kts b/test-kit/build.gradle.kts index 9903037cff90..93ad034df435 100644 --- a/test-kit/build.gradle.kts +++ b/test-kit/build.gradle.kts @@ -8,7 +8,6 @@ kotlin { dependencies { api(libs.bundles.test.common) api(libs.ktor.utils) - api(projects.common) } } jsMain { From 8da5428d0e7dd9c68e185da226ed95ab29a87811 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Tue, 4 Apr 2023 23:24:33 +0200 Subject: [PATCH 124/136] Rename nonJvm source set to nonJvmMain --- buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts | 4 ++-- common/build.gradle.kts | 2 +- common/src/{nonJvm => nonJvmMain}/kotlin/ConcurrentHashMap.kt | 0 common/src/{nonJvm => nonJvmMain}/kotlin/DiscordBitSet.kt | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename common/src/{nonJvm => nonJvmMain}/kotlin/ConcurrentHashMap.kt (100%) rename common/src/{nonJvm => nonJvmMain}/kotlin/DiscordBitSet.kt (100%) diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index 473bc1fe17ee..0fc6e1ccc412 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -49,14 +49,14 @@ kotlin { // mark ksp src dir kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") } - val nonJvm by creating { + val nonJvmMain by creating { dependsOn(commonMain.get()) } targets.forEach { if (it.safeName != "jvm" && it.safeName != "common") { findByName("${it.safeName}Main")?.apply { - dependsOn(nonJvm) + dependsOn(nonJvmMain) } } } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 055544ab147e..3975a46823f0 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -24,7 +24,7 @@ kotlin { api(libs.ktor.client.cio) } } - nonJvm { + nonJvmMain { dependencies { implementation(libs.ktor.utils) implementation(libs.bignum) diff --git a/common/src/nonJvm/kotlin/ConcurrentHashMap.kt b/common/src/nonJvmMain/kotlin/ConcurrentHashMap.kt similarity index 100% rename from common/src/nonJvm/kotlin/ConcurrentHashMap.kt rename to common/src/nonJvmMain/kotlin/ConcurrentHashMap.kt diff --git a/common/src/nonJvm/kotlin/DiscordBitSet.kt b/common/src/nonJvmMain/kotlin/DiscordBitSet.kt similarity index 100% rename from common/src/nonJvm/kotlin/DiscordBitSet.kt rename to common/src/nonJvmMain/kotlin/DiscordBitSet.kt From cbe5e46dd99bc7d48423406729ab81ec37f98097 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Tue, 4 Apr 2023 23:37:47 +0200 Subject: [PATCH 125/136] Remove addTestKit() --- buildSrc/src/main/kotlin/TestKit.kt | 14 -------------- .../kotlin/kord-multiplatform-module.gradle.kts | 17 ++++++++++------- core/live-tests/build.gradle.kts | 4 +--- 3 files changed, 11 insertions(+), 24 deletions(-) delete mode 100644 buildSrc/src/main/kotlin/TestKit.kt diff --git a/buildSrc/src/main/kotlin/TestKit.kt b/buildSrc/src/main/kotlin/TestKit.kt deleted file mode 100644 index 0d4b24dfe8f8..000000000000 --- a/buildSrc/src/main/kotlin/TestKit.kt +++ /dev/null @@ -1,14 +0,0 @@ -import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension -import org.jetbrains.kotlin.gradle.plugin.KotlinTarget - -val KotlinTarget.safeName: String get() = if (name == "metadata") "common" else name - -fun KotlinMultiplatformExtension.addTestKit() { - targets.forEach { target -> - sourceSets.findByName("${target.safeName}Test")?.apply { - dependencies { - implementation(project(":test-kit")) - } - } - } -} diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index 0fc6e1ccc412..8339f1ba5037 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -39,8 +39,6 @@ kotlin { } } - addTestKit() - sourceSets { all { applyKordOptIns() @@ -49,17 +47,22 @@ kotlin { // mark ksp src dir kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") } + commonTest { + dependencies { + implementation(project(":test-kit")) + } + } val nonJvmMain by creating { dependsOn(commonMain.get()) } - - targets.forEach { - if (it.safeName != "jvm" && it.safeName != "common") { - findByName("${it.safeName}Main")?.apply { + targets + .map { it.name } + .filter { it != "jvm" && it != "metadata" } + .forEach { target -> + sourceSets.getByName("${target}Main") { dependsOn(nonJvmMain) } } - } } } diff --git a/core/live-tests/build.gradle.kts b/core/live-tests/build.gradle.kts index b2984e4bc639..86fe49a30fc1 100644 --- a/core/live-tests/build.gradle.kts +++ b/core/live-tests/build.gradle.kts @@ -3,16 +3,14 @@ plugins { } kotlin { - addTestKit() - sourceSets { all { applyKordOptIns() } - commonTest { dependencies { implementation(projects.core) + implementation(projects.testKit) } } } From 202da8a4e4545a1b3e0a66f03827951faabdfc09 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Wed, 5 Apr 2023 14:05:50 +0200 Subject: [PATCH 126/136] Fix locale formatting in GuildModifyBuilder --- rest/src/commonMain/kotlin/builder/guild/GuildModifyBuilder.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest/src/commonMain/kotlin/builder/guild/GuildModifyBuilder.kt b/rest/src/commonMain/kotlin/builder/guild/GuildModifyBuilder.kt index 185ebb5c2952..d03ea1c812e2 100644 --- a/rest/src/commonMain/kotlin/builder/guild/GuildModifyBuilder.kt +++ b/rest/src/commonMain/kotlin/builder/guild/GuildModifyBuilder.kt @@ -94,7 +94,7 @@ public class GuildModifyBuilder : AuditRequestBuilder { _systemChannelId, _rulesChannelId, _publicUpdatesChannelId, - _preferredLocale.map { "${it.language}-${it.country}" }, + _preferredLocale.map { locale -> "${locale.language}${locale.country?.let { "-$it" } ?: ""}" }, features = _features, ) } From 80c1b43f11f98986db5ab6a5eda1b3db5dbc4c7d Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Wed, 5 Apr 2023 14:21:42 +0200 Subject: [PATCH 127/136] voice is not yet mpp --- voice/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/voice/README.md b/voice/README.md index 891e54ee3f4a..e3daf9504b7b 100644 --- a/voice/README.md +++ b/voice/README.md @@ -148,7 +148,7 @@ dependencies { ```xml dev.kord - kord-voice-jvm + kord-voice {version} ``` From e2d6ea056bd1e477eae9854c525ab8e072d4064a Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Wed, 5 Apr 2023 14:25:06 +0200 Subject: [PATCH 128/136] Fix whitespace --- core-voice/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-voice/README.md b/core-voice/README.md index cd46520ce733..199acba8f34a 100644 --- a/core-voice/README.md +++ b/core-voice/README.md @@ -1,4 +1,4 @@ # core-voice -This Module adds extensions to [core](../core) for [kord-voice](../voice). Please read the [voice](../voice) +This Module adds extensions to [core](../core) for [kord-voice](../voice). Please read the [voice](../voice) documentation for more information From e9b07c36ea694f53893b94dd1968db8f967c1fbf Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Wed, 5 Apr 2023 14:29:03 +0200 Subject: [PATCH 129/136] Simpler links to subprojects --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 92b5109ff2d8..84901b588527 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ unconventional things, and we want to allow you to do those in a safe and suppor ## Status of Kord -* [X] [Discord Gateway](https://github.com/kordlib/kord/tree/0.9.x/gateway) -* [x] [Discord Rest API](https://github.com/kordlib/kord/tree/0.9.x/rest) -* [X] [High level abstraction + caching](https://github.com/kordlib/kord/tree/0.9.x/core) -* [X] [Discord Voice](https://github.com/kordlib/kord/tree/0.9.x/voice) +* [X] [Discord Gateway](/gateway) +* [x] [Discord Rest API](/rest) +* [X] [High level abstraction + caching](/core) +* [X] [Discord Voice](/voice) * [ ] Support for multiple processes [#7](https://github.com/kordlib/kord/issues/7) Right now, Kord *should* provide a full mapping of the non-voice API on Kotlin/JVM and Kotlin/JS and an experimental @@ -142,4 +142,4 @@ Yes. # This project is supported by JetBrains -[![JetBrains Logo (Main) logo](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://jb.gg/OpenSourceSupport) \ No newline at end of file +[![JetBrains Logo (Main) logo](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://jb.gg/OpenSourceSupport) From 759c592ba11911e06a7f7f0d0012823ef8ea9890 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Wed, 5 Apr 2023 14:39:50 +0200 Subject: [PATCH 130/136] Up-to-date snapshot example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 84901b588527..87717a6d3299 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Replace `{version}` with the latest version number on maven central. For Snapshots replace `{version}` with `{branch}-SNAPSHOT` -e.g: `0.7.x-SNAPSHOT` or `feature-mpp-SNAPSHOT` for the branch `feature/mpp` +e.g: `0.9.x-SNAPSHOT` for the branch `0.9.x` or `feature-mpp-SNAPSHOT` for the branch `feature/mpp` [![Download](https://img.shields.io/maven-central/v/dev.kord/kord-core.svg?label=Maven%20Central&style=for-the-badge)](https://search.maven.org/search?q=g:%22dev.kord%22%20AND%20a:%22kord-core%22) From b4d8a1c848bdc78e5a5c31c13317218df8eebe53 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Wed, 5 Apr 2023 14:48:04 +0200 Subject: [PATCH 131/136] Add common to modules table --- README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 87717a6d3299..26e6f3bf4b16 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ unconventional things, and we want to allow you to do those in a safe and suppor ## Status of Kord -* [X] [Discord Gateway](/gateway) -* [x] [Discord Rest API](/rest) -* [X] [High level abstraction + caching](/core) -* [X] [Discord Voice](/voice) +* [X] [Discord Gateway](gateway) +* [x] [Discord Rest API](rest) +* [X] [High level abstraction + caching](core) +* [X] [Discord Voice](voice) * [ ] Support for multiple processes [#7](https://github.com/kordlib/kord/issues/7) Right now, Kord *should* provide a full mapping of the non-voice API on Kotlin/JVM and Kotlin/JS and an experimental @@ -42,17 +42,18 @@ mapping of the Voice API on Kotlin/JVM ## Modules -| Module | Docs | Artifact¹ | JVM | JS | Native² | +| Module | Docs | Artifact | JVM | JS | Native² | |--------------------------|---------------------------------------------------------|-------------------|-----|----|---------| -| [rest](rest) | [rest](https://kordlib.github.io/kord/rest) | `kord-rest` | ✅ | ✅ | ❌ | -| [gateway](gateway) | [gateway](https://kordlib.github.io/kord/gateway) | `kord-gateway` | ✅ | ✅ | ❌ | -| [core](core) | [core](https://kordlib.github.io/kord/core) | `kord-core` | ✅ | ✅ | ❌ | +| [common](common) | [common](https://kordlib.github.io/kord/common) | `kord-common`¹ | ✅ | ✅ | ❌ | +| [rest](rest) | [rest](https://kordlib.github.io/kord/rest) | `kord-rest`¹ | ✅ | ✅ | ❌ | +| [gateway](gateway) | [gateway](https://kordlib.github.io/kord/gateway) | `kord-gateway`¹ | ✅ | ✅ | ❌ | +| [core](core) | [core](https://kordlib.github.io/kord/core) | `kord-core`¹ | ✅ | ✅ | ❌ | | [voice](voice) | [voice](https://kordlib.github.io/kord/voice) | `kord-voice` | ✅ | ❌³ | ❌ | | [core-voice](core-voice) | [core-voice](https://kordlib.github.io/kord/core-voice) | `kord-core-voice` | ✅ | ❌ | ❌ | ¹ These artifacts only supports Gradle Version 5.3 or higher, for older Gradle versions and Maven please append `-jvm` ² For Native Support please see #69 -³ For Voice JS please see #69 +³ For Voice JS please see #69 ## Installation From f72b493ab4170d7caeb03a88aa24a2fabde7d2f2 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Wed, 5 Apr 2023 15:02:00 +0200 Subject: [PATCH 132/136] Add @suppress to internal API --- common/src/commonMain/kotlin/ConcurrentHashMap.kt | 4 +++- common/src/commonMain/kotlin/http/HttpEngine.kt | 1 + common/src/jsMain/kotlin/http/HttpEngine.kt | 1 + common/src/jvmMain/kotlin/ConcurrentHashMap.kt | 1 + common/src/jvmMain/kotlin/http/HttpEngine.kt | 1 + common/src/nonJvmMain/kotlin/ConcurrentHashMap.kt | 1 + core/src/commonMain/kotlin/builder/kord/KordBuilderUtil.kt | 2 ++ core/src/commonMain/kotlin/cache/DataCacheExtensions.kt | 2 ++ 8 files changed, 12 insertions(+), 1 deletion(-) diff --git a/common/src/commonMain/kotlin/ConcurrentHashMap.kt b/common/src/commonMain/kotlin/ConcurrentHashMap.kt index 773e8d2981c6..6e0ea0791fb5 100644 --- a/common/src/commonMain/kotlin/ConcurrentHashMap.kt +++ b/common/src/commonMain/kotlin/ConcurrentHashMap.kt @@ -3,7 +3,9 @@ package dev.kord.common import dev.kord.common.annotation.KordInternal /** - * Platform agnostic implementation of ConcurrentHashMap. + * Platform-agnostic implementation of ConcurrentHashMap. + * + * @suppress */ @KordInternal public expect class ConcurrentHashMap() : MutableMap diff --git a/common/src/commonMain/kotlin/http/HttpEngine.kt b/common/src/commonMain/kotlin/http/HttpEngine.kt index b723790693fe..feabfdbdebd6 100644 --- a/common/src/commonMain/kotlin/http/HttpEngine.kt +++ b/common/src/commonMain/kotlin/http/HttpEngine.kt @@ -3,5 +3,6 @@ package dev.kord.common.http import dev.kord.common.annotation.KordInternal import io.ktor.client.engine.* +/** @suppress */ @KordInternal public expect object HttpEngine : HttpClientEngineFactory diff --git a/common/src/jsMain/kotlin/http/HttpEngine.kt b/common/src/jsMain/kotlin/http/HttpEngine.kt index 67f7ed245579..b3d5dcea53f4 100644 --- a/common/src/jsMain/kotlin/http/HttpEngine.kt +++ b/common/src/jsMain/kotlin/http/HttpEngine.kt @@ -3,5 +3,6 @@ package dev.kord.common.http import dev.kord.common.annotation.KordInternal import io.ktor.client.engine.js.* +/** @suppress */ @KordInternal public actual typealias HttpEngine = Js diff --git a/common/src/jvmMain/kotlin/ConcurrentHashMap.kt b/common/src/jvmMain/kotlin/ConcurrentHashMap.kt index 33efe6d2faed..4fb4ddeb7366 100644 --- a/common/src/jvmMain/kotlin/ConcurrentHashMap.kt +++ b/common/src/jvmMain/kotlin/ConcurrentHashMap.kt @@ -2,5 +2,6 @@ package dev.kord.common import dev.kord.common.annotation.KordInternal +/** @suppress */ @KordInternal public actual typealias ConcurrentHashMap = java.util.concurrent.ConcurrentHashMap diff --git a/common/src/jvmMain/kotlin/http/HttpEngine.kt b/common/src/jvmMain/kotlin/http/HttpEngine.kt index bc68406ee48c..a201c8d46c79 100644 --- a/common/src/jvmMain/kotlin/http/HttpEngine.kt +++ b/common/src/jvmMain/kotlin/http/HttpEngine.kt @@ -4,5 +4,6 @@ import dev.kord.common.annotation.KordInternal import io.ktor.client.engine.* import io.ktor.client.engine.cio.* +/** @suppress */ @KordInternal public actual object HttpEngine : HttpClientEngineFactory by CIO diff --git a/common/src/nonJvmMain/kotlin/ConcurrentHashMap.kt b/common/src/nonJvmMain/kotlin/ConcurrentHashMap.kt index 5791f8f91ecc..be329858c821 100644 --- a/common/src/nonJvmMain/kotlin/ConcurrentHashMap.kt +++ b/common/src/nonJvmMain/kotlin/ConcurrentHashMap.kt @@ -3,5 +3,6 @@ package dev.kord.common import co.touchlab.stately.collections.ConcurrentMutableMap import dev.kord.common.annotation.KordInternal +/** @suppress */ @KordInternal public actual typealias ConcurrentHashMap = ConcurrentMutableMap diff --git a/core/src/commonMain/kotlin/builder/kord/KordBuilderUtil.kt b/core/src/commonMain/kotlin/builder/kord/KordBuilderUtil.kt index a6cf63e2b7dd..0f0d9e0dd757 100644 --- a/core/src/commonMain/kotlin/builder/kord/KordBuilderUtil.kt +++ b/core/src/commonMain/kotlin/builder/kord/KordBuilderUtil.kt @@ -19,6 +19,7 @@ internal fun HttpClientConfig<*>.defaultConfig() { install(WebSockets) } +/** @suppress */ @KordInternal public fun HttpClient?.configure(): HttpClient { if (this != null) return this.config { @@ -40,6 +41,7 @@ public fun HttpClient?.configure(): HttpClient { } } +/** @suppress */ @KordInternal public fun getBotIdFromToken(token: String): Snowflake = try { Snowflake(token.substringBefore('.').decodeBase64String()) diff --git a/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt b/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt index 94fb21ef3876..ec322be7f50d 100644 --- a/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt +++ b/core/src/commonMain/kotlin/cache/DataCacheExtensions.kt @@ -7,6 +7,8 @@ import dev.kord.core.cache.data.* /** * Registers all Kord data classes for this cache + * + * @suppress */ @KordInternal public suspend fun DataCache.registerKordData(): Unit = register( From 7f0455e7d8acbdaa207881184b753d71c5b92ccd Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Wed, 5 Apr 2023 15:27:44 +0200 Subject: [PATCH 133/136] Actual issue for duplicate library warning --- buildSrc/src/main/kotlin/Compiler.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/Compiler.kt b/buildSrc/src/main/kotlin/Compiler.kt index 4162905f7363..3d4cc2614d16 100644 --- a/buildSrc/src/main/kotlin/Compiler.kt +++ b/buildSrc/src/main/kotlin/Compiler.kt @@ -25,7 +25,7 @@ object Jvm { } fun KotlinCommonCompilerOptions.applyKordCompilerOptions() { - // TODO: Enable again once https://youtrack.jetbrains.com/issue/KT-51110 is fixed + // TODO: set to true again once https://github.com/Kotlin/kotlinx-atomicfu/issues/289 is fixed allWarningsAsErrors.set(false) freeCompilerArgs.add("-progressive") } From eb685d1248a2785be1041773176c97f0daa58b6d Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Wed, 5 Apr 2023 15:50:49 +0200 Subject: [PATCH 134/136] . --- common/src/commonMain/kotlin/annotation/Annotations.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/commonMain/kotlin/annotation/Annotations.kt b/common/src/commonMain/kotlin/annotation/Annotations.kt index 3e9fc57065ce..c3355c01d84c 100644 --- a/common/src/commonMain/kotlin/annotation/Annotations.kt +++ b/common/src/commonMain/kotlin/annotation/Annotations.kt @@ -85,7 +85,7 @@ public annotation class DeprecatedSinceKord(val version: String) * Marks an API for internal use only. */ @MustBeDocumented -@RequiresOptIn("This API is intended for internal use only", level = ERROR) +@RequiresOptIn("This API is intended for internal use only.", level = ERROR) @Retention(BINARY) @Target(CLASS, PROPERTY, FUNCTION, TYPEALIAS) public annotation class KordInternal From a9d12d2aaff173b7829c00a4d5923d0a973c7d2d Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Wed, 5 Apr 2023 16:33:04 +0200 Subject: [PATCH 135/136] Less indentation --- .../src/main/kotlin/kord-multiplatform-module.gradle.kts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts index 8339f1ba5037..b33a4e65cfc6 100644 --- a/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts +++ b/buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts @@ -31,11 +31,9 @@ kotlin { } jvmToolchain(Jvm.target) - targets { - all { - compilations.all { - compilerOptions.options.applyKordCompilerOptions() - } + targets.all { + compilations.all { + compilerOptions.options.applyKordCompilerOptions() } } From ab19ddea8931bf1f11476790ace4e1267c8e9e31 Mon Sep 17 00:00:00 2001 From: Lukellmann Date: Wed, 5 Apr 2023 17:09:32 +0200 Subject: [PATCH 136/136] No documentation for ksp-annotations --- ksp-annotations/build.gradle.kts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ksp-annotations/build.gradle.kts b/ksp-annotations/build.gradle.kts index 6f5e04a93812..f4f0c10edf1c 100644 --- a/ksp-annotations/build.gradle.kts +++ b/ksp-annotations/build.gradle.kts @@ -1,7 +1,13 @@ +import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask + plugins { `kord-internal-multiplatform-module` - // workaround for https://youtrack.jetbrains.com/issue/KT-43500 (intended to be unpublished) + // workaround for https://youtrack.jetbrains.com/issue/KT-43500 (not intended to be published) org.jetbrains.dokka `kord-publishing` } + +tasks.withType().configureEach { + enabled = false +}