diff --git a/core/README.md b/core/README.md index 01d53ad43a6..591693de64d 100644 --- a/core/README.md +++ b/core/README.md @@ -1,8 +1,8 @@ # Kord Core -Kord `core` is an implementation of the discord api build on top of the [gateway](https://gitlab.com/kordlib/kord/tree/master/gateway), -[rest](https://gitlab.com/kordlib/kord/tree/master/rest) and [cache](https://gitlab.com/kordlib/cache) modules. It features a high level representation of Discord's entities and their behaviour -in a non-blocking, coroutine focused, event-driven design. +Kord `core` is an implementation of the discord api build on top of the [gateway](../gateway), [rest](../rest) and +[cache](https://github.com/kordlib/cache) modules. It features a high level representation of Discord's entities and +their behavior in a non-blocking, coroutine focused, event-driven design. ## Example usage @@ -31,45 +31,22 @@ suspend fun main() { } } ``` -## Installation - -Replace `{version}` with the latest version number on maven central. - -For Snapshots replace `{version}` with `{branch}-SNAPSHOT` -e.g: `0.7.x-SNAPSHOT` +## Installation -[![Download](https://img.shields.io/nexus/r/dev.kord/kord-core?color=fb5502&label=Kord&logoColor=05c1fd&server=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2F&style=for-the-badge) ](https://search.maven.org/search?q=g:dev.kord) -[![Snapshot](https://img.shields.io/nexus/s/dev.kord/kord-core?label=SNAPSHOT&server=https%3A%2F%2Foss.sonatype.org%2F&style=for-the-badge)](https://oss.sonatype.org/#nexus-search;quick~dev.kord) -### Gradle (groovy) +See the root [README](../README.md#installation) for more information. -```groovy -repositories { - mavenCentral() - // Kord Snapshots Repository (Optional): - maven("https://oss.sonatype.org/content/repositories/snapshots") -} -``` +### Gradle (Kotlin) -```groovy +```kotlin dependencies { implementation("dev.kord:kord-core:{version}") } ``` -### Gradle (kotlin) +### Gradle (Groovy) -```kotlin -repositories { - mavenCentral() - // Kord Snapshots Repository (Optional): - maven("https://oss.sonatype.org/content/repositories/snapshots") -} -``` - ---- - -```kotlin +```groovy dependencies { implementation("dev.kord:kord-core:{version}") } @@ -77,26 +54,7 @@ dependencies { ### Maven -##### Kord Snapshots Repository (Optional): - ```xml - - - snapshots-repo - https://oss.sonatype.org/content/repositories/snapshots - - false - - - true - - -``` - ---- - -```xml - dev.kord kord-core-jvm diff --git a/core/src/commonMain/kotlin/supplier/StoreEntitySupplier.kt b/core/src/commonMain/kotlin/supplier/StoreEntitySupplier.kt index 0c53ee6adad..3404a634c86 100644 --- a/core/src/commonMain/kotlin/supplier/StoreEntitySupplier.kt +++ b/core/src/commonMain/kotlin/supplier/StoreEntitySupplier.kt @@ -60,9 +60,11 @@ public class StoreEntitySupplier( } - override suspend fun getMemberOrNull(guildId: Snowflake, userId: Snowflake): Member? { - return storeAndReturn(supplier.getMemberOrNull(guildId, userId)) { it.data } - } + override suspend fun getMemberOrNull(guildId: Snowflake, userId: Snowflake): Member? = + supplier.getMemberOrNull(guildId, userId)?.also { member -> + cache.put(member.data) + cache.put(member.memberData) + } override suspend fun getMessageOrNull(channelId: Snowflake, messageId: Snowflake): Message? { return storeAndReturn(supplier.getMessageOrNull(channelId, messageId)) { it.data } @@ -104,9 +106,11 @@ public class StoreEntitySupplier( return storeOnEach(supplier.getGuildBans(guildId, limit)) { it.data } } - override fun getGuildMembers(guildId: Snowflake, limit: Int?): Flow { - return storeOnEach(supplier.getGuildMembers(guildId, limit)) { it.data } - } + override fun getGuildMembers(guildId: Snowflake, limit: Int?): Flow = + supplier.getGuildMembers(guildId, limit).onEach { member -> + cache.put(member.data) + cache.put(member.memberData) + } override fun getGuildVoiceRegions(guildId: Snowflake): Flow { return storeOnEach(supplier.getGuildVoiceRegions(guildId)) { it.data } diff --git a/gateway/README.md b/gateway/README.md index af7c3cee1de..4a2fe908717 100644 --- a/gateway/README.md +++ b/gateway/README.md @@ -1,6 +1,6 @@ # Kord gateway -A low-level implementation of discord's [gateway](https://discordapp.com/developers/docs/topics/gateway). +A low-level implementation of discord's [gateway](https://discord.com/developers/docs/topics/gateway). ## Example usage @@ -11,7 +11,6 @@ suspend fun main(args: Array) { val gateway = DefaultGateway { // optional builder for custom configuration client = HttpClient { install(WebSockets) - install(JsonFeature) } reconnectRetry = LinearRetry(2.seconds, 20.seconds, 10) sendRateLimiter = IntervalRateLimiter(120, 60.seconds) @@ -39,46 +38,22 @@ suspend fun main(args: Array) { } } ``` -## Installation - -Replace `{version}` with the latest version number on maven central. - -For Snapshots replace `{version}` with `{branch}-SNAPSHOT` -e.g: `0.7.x-SNAPSHOT` - -[![Download](https://img.shields.io/nexus/r/dev.kord/kord-gateway?color=fb5502&label=Kord&logoColor=05c1fd&server=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2F&style=for-the-badge) ](https://search.maven.org/search?q=g:dev.kord) -[![Snapshot](https://img.shields.io/nexus/s/dev.kord/kord-gateway?label=SNAPSHOT&server=https%3A%2F%2Foss.sonatype.org%2F&style=for-the-badge)](https://oss.sonatype.org/#nexus-search;quick~dev.kord) +## Installation -### Gradle (groovy) +See the root [README](../README.md#installation) for more information. -```groovy -repositories { - mavenCentral() - // Kord Snapshots Repository (Optional): - maven("https://oss.sonatype.org/content/repositories/snapshots") -} -``` +### Gradle (Kotlin) -```groovy +```kotlin dependencies { implementation("dev.kord:kord-gateway:{version}") } ``` -### Gradle (kotlin) - -```kotlin -repositories { - mavenCentral() - // Kord Snapshots Repository (Optional): - maven("https://oss.sonatype.org/content/repositories/snapshots") -} -``` - ---- +### Gradle (Groovy) -```kotlin +```groovy dependencies { implementation("dev.kord:kord-gateway:{version}") } @@ -86,26 +61,7 @@ dependencies { ### Maven -##### Kord Snapshots Repository (Optional): - ```xml - - - snapshots-repo - https://oss.sonatype.org/content/repositories/snapshots - - false - - - true - - -``` - ---- - -```xml - dev.kord kord-gateway-jvm diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3151f51326f..077d5a39b9e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -18,7 +18,7 @@ stately = "2.0.7" # https://github.com/touchlab/Stately fastZlib = "2.0.1" # https://github.com/timotejroiko/fast-zlib # code generation -ksp = "2.0.20-RC-1.0.24" # https://github.com/google/ksp +ksp = "2.0.20-RC2-1.0.24" # https://github.com/google/ksp kotlinpoet = "1.18.1" # https://github.com/square/kotlinpoet # tests @@ -79,7 +79,7 @@ kotlin-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref = 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 = "junit-jupiter" } junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit-jupiter" } -junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version = "junit-platform" } +junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junit-platform" } mockk = { module = "io.mockk:mockk", version.ref = "mockk" } slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" } kbson = { module = "org.mongodb.kbson:kbson", version.ref = "kbson" } diff --git a/rest/README.md b/rest/README.md index 3cef5021b66..829d54c6aae 100644 --- a/rest/README.md +++ b/rest/README.md @@ -13,48 +13,23 @@ suspend fun main(args: Array) { val username = rest.user.getCurrentUser().username println("using $username's token") } -``` -## Installation - -Replace `{version}` with the latest version number on maven central. - -For Snapshots replace `{version}` with `{branch}-SNAPSHOT` - -e.g: `0.7.x-SNAPSHOT` +``` -[![Download](https://img.shields.io/nexus/r/dev.kord/kord-rest?color=fb5502&label=Kord&logoColor=05c1fd&server=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2F&style=for-the-badge) ](https://search.maven.org/search?q=g:dev.kord) -[![Snapshot](https://img.shields.io/nexus/s/dev.kord/kord-rest?label=SNAPSHOT&server=https%3A%2F%2Foss.sonatype.org%2F&style=for-the-badge)](https://oss.sonatype.org/#nexus-search;quick~dev.kord) +## Installation +See the root [README](../README.md#installation) for more information. -### Gradle (groovy) +### Gradle (Kotlin) -```groovy -repositories { - mavenCentral() - // Kord Snapshots Repository (Optional): - maven("https://oss.sonatype.org/content/repositories/snapshots") -} -``` - -```groovy +```kotlin dependencies { implementation("dev.kord:kord-rest:{version}") } ``` -### Gradle (kotlin) - -```kotlin -repositories { - mavenCentral() - // Kord Snapshots Repository (Optional): - maven("https://oss.sonatype.org/content/repositories/snapshots") -} -``` - ---- +### Gradle (Groovy) -```kotlin +```groovy dependencies { implementation("dev.kord:kord-rest:{version}") } @@ -62,26 +37,7 @@ dependencies { ### Maven -##### Kord Snapshots Repository (Optional): - ```xml - - - snapshots-repo - https://oss.sonatype.org/content/repositories/snapshots - - false - - - true - - -``` - ---- - -```xml - dev.kord kord-rest-jvm diff --git a/voice/README.md b/voice/README.md index e3daf9504b7..b46ce67bd2e 100644 --- a/voice/README.md +++ b/voice/README.md @@ -124,19 +124,19 @@ processIncomingAudio(connection.streams.incomingAudioFrames) ## Installation -Replace `{version}` with the latest version number on maven central. +See the root [README](../README.md#installation) for more information. -[![Download](https://img.shields.io/maven-central/v/dev.kord/kord-voice.svg?color=fb5502&label=Kord&logoColor=05c1fd&style=for-the-badge)](https://search.maven.org/search?q=g:%22dev.kord%22%20AND%20a:%22kord-voice%22) +### Gradle (Kotlin) -### Gradle (groovy) -```groovy +```kotlin dependencies { implementation("dev.kord:kord-voice:{version}") } ``` -### Gradle (kotlin) -```kotlin +### Gradle (Groovy) + +```groovy dependencies { implementation("dev.kord:kord-voice:{version}") } @@ -144,7 +144,6 @@ dependencies { ### Maven -##### Kord Snapshots Repository (Optional): ```xml dev.kord