Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into feature/native
Browse files Browse the repository at this point in the history
# Conflicts:
#	buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts
#	gradle/libs.versions.toml
#	voice/src/commonMain/kotlin/gateway/DefaultVoiceGatewayBuilder.kt
  • Loading branch information
lukellmann committed Apr 4, 2024
2 parents 3944b8d + 7350a21 commit 89cf26e
Show file tree
Hide file tree
Showing 21 changed files with 1,445 additions and 551 deletions.
10 changes: 9 additions & 1 deletion buildSrc/src/main/kotlin/Targets.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ fun KotlinMultiplatformExtension.targets() {
if (project.name != "voice" && project.name != "core-voice") {
mingwX64()
js {
nodejs()
nodejs {
testTask {
useMocha {
// disable timeouts, some tests are too slow for default 2-second timeout:
// https://mochajs.org/#-timeout-ms-t-ms
timeout = "0"
}
}
}
useCommonJs()
}
}
Expand Down
3 changes: 1 addition & 2 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ plugins {
}

kotlin {
targets()
sourceSets {
commonMain {
dependencies {
Expand All @@ -22,7 +21,7 @@ kotlin {
}
jvmMain {
dependencies {
api(libs.ktor.client.cio)
api(libs.ktor.client.okhttp)
}
}
nonJvmMain {
Expand Down
4 changes: 2 additions & 2 deletions common/src/jvmMain/kotlin/http/HttpEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package dev.kord.common.http

import dev.kord.common.annotation.KordInternal
import io.ktor.client.engine.*
import io.ktor.client.engine.cio.*
import io.ktor.client.engine.okhttp.OkHttp

/** @suppress */
@KordInternal
public actual fun httpEngine(): HttpClientEngineFactory<HttpClientEngineConfig> = CIO
public actual fun httpEngine(): HttpClientEngineFactory<HttpClientEngineConfig> = OkHttp
10 changes: 0 additions & 10 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ plugins {
}

kotlin {
js {
nodejs {
testTask {
useMocha {
timeout = "10000" // KordEventDropTest is too slow for default 2 seconds timeout
}
}
}
}

sourceSets {
commonMain {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@ import dev.kord.core.entity.application.*
import dev.kord.core.event.Event


@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
level = DeprecationLevel.WARNING,
)
public sealed interface ApplicationCommandCreateEvent : Event {
public val command: GuildApplicationCommand
}

@Suppress("DEPRECATION")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
level = DeprecationLevel.WARNING,
)
public class ChatInputCommandCreateEvent(
override val command: GuildChatInputCommand,
override val kord: Kord,
Expand All @@ -17,6 +28,12 @@ public class ChatInputCommandCreateEvent(
) : ApplicationCommandCreateEvent


@Suppress("DEPRECATION")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
level = DeprecationLevel.WARNING,
)
public class UserCommandCreateEvent(
override val command: GuildUserCommand,
override val kord: Kord,
Expand All @@ -25,6 +42,12 @@ public class UserCommandCreateEvent(
) : ApplicationCommandCreateEvent


@Suppress("DEPRECATION")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
level = DeprecationLevel.WARNING,
)
public class MessageCommandCreateEvent(
override val command: GuildMessageCommand,
override val kord: Kord,
Expand All @@ -33,6 +56,12 @@ public class MessageCommandCreateEvent(
) : ApplicationCommandCreateEvent


@Suppress("DEPRECATION")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
level = DeprecationLevel.WARNING,
)
public class UnknownApplicationCommandCreateEvent(
override val command: UnknownGuildApplicationCommand,
override val kord: Kord,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@ import dev.kord.core.entity.application.*
import dev.kord.core.event.Event


@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
level = DeprecationLevel.WARNING,
)
public sealed interface ApplicationCommandDeleteEvent : Event {
public val command: GuildApplicationCommand
}

@Suppress("DEPRECATION")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
level = DeprecationLevel.WARNING,
)
public class ChatInputCommandDeleteEvent(
override val command: GuildChatInputCommand,
override val kord: Kord,
Expand All @@ -17,6 +28,12 @@ public class ChatInputCommandDeleteEvent(
) : ApplicationCommandDeleteEvent


@Suppress("DEPRECATION")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
level = DeprecationLevel.WARNING,
)
public class UserCommandDeleteEvent(
override val command: GuildUserCommand,
override val kord: Kord,
Expand All @@ -25,6 +42,12 @@ public class UserCommandDeleteEvent(
) : ApplicationCommandDeleteEvent


@Suppress("DEPRECATION")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
level = DeprecationLevel.WARNING,
)
public class MessageCommandDeleteEvent(
override val command: GuildMessageCommand,
override val kord: Kord,
Expand All @@ -33,6 +56,12 @@ public class MessageCommandDeleteEvent(
) : ApplicationCommandDeleteEvent


@Suppress("DEPRECATION")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
level = DeprecationLevel.WARNING,
)
public class UnknownApplicationCommandDeleteEvent(
override val command: UnknownGuildApplicationCommand,
override val kord: Kord,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@ import dev.kord.core.entity.application.*
import dev.kord.core.event.Event


@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
level = DeprecationLevel.WARNING,
)
public sealed interface ApplicationCommandUpdateEvent : Event {
public val command: GuildApplicationCommand
}

@Suppress("DEPRECATION")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
level = DeprecationLevel.WARNING,
)
public class ChatInputCommandUpdateEvent(
override val command: GuildChatInputCommand,
override val kord: Kord,
Expand All @@ -17,6 +28,12 @@ public class ChatInputCommandUpdateEvent(
) : ApplicationCommandUpdateEvent


@Suppress("DEPRECATION")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
level = DeprecationLevel.WARNING,
)
public class UserCommandUpdateEvent(
override val command: GuildUserCommand,
override val kord: Kord,
Expand All @@ -25,13 +42,25 @@ public class UserCommandUpdateEvent(
) : ApplicationCommandUpdateEvent


@Suppress("DEPRECATION")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
level = DeprecationLevel.WARNING,
)
public class MessageCommandUpdateEvent(
override val command: GuildMessageCommand,
override val kord: Kord,
override val shard: Int,
override val customContext: Any?,
) : ApplicationCommandUpdateEvent

@Suppress("DEPRECATION")
@Deprecated(
"This event is not supposed to be sent to bots. See https://github.com/discord/discord-api-docs/issues/3690 for " +
"details.",
level = DeprecationLevel.WARNING,
)
public class UnknownApplicationCommandUpdateEvent(
override val command: UnknownGuildApplicationCommand,
override val kord: Kord,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import dev.kord.core.event.Event as CoreEvent

internal class InteractionEventHandler : BaseGatewayEventHandler() {

@Suppress("DEPRECATION")
override suspend fun handle(event: Event, shard: Int, kord: Kord, context: LazyContext?): CoreEvent? =
when (event) {
is InteractionCreate -> handle(event, shard, kord, context)
Expand Down Expand Up @@ -53,6 +54,7 @@ internal class InteractionEventHandler : BaseGatewayEventHandler() {
return coreEvent
}

@Suppress("DEPRECATION")
private suspend fun handle(
event: ApplicationCommandCreate,
shard: Int,
Expand All @@ -71,6 +73,7 @@ internal class InteractionEventHandler : BaseGatewayEventHandler() {
}


@Suppress("DEPRECATION")
private suspend fun handle(
event: ApplicationCommandUpdate,
shard: Int,
Expand All @@ -89,6 +92,7 @@ internal class InteractionEventHandler : BaseGatewayEventHandler() {
return coreEvent
}

@Suppress("DEPRECATION")
private suspend fun handle(
event: ApplicationCommandDelete,
shard: Int,
Expand Down
2 changes: 1 addition & 1 deletion gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ suspend fun main(args: Array<String>) {
val token = args.firstOrNull() ?: error("token required")

val gateway = DefaultGateway { // optional builder for custom configuration
client = HttpClient(CIO) {
client = HttpClient {
install(WebSockets)
install(JsonFeature)
}
Expand Down
2 changes: 1 addition & 1 deletion gateway/src/commonMain/kotlin/DefaultGateway.kt
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public class DefaultGateway(private val data: DefaultGatewayData) : Gateway {

try {
defaultGatewayLogger.trace { "Gateway <<< $json" }
val event = jsonParser.decodeFromString(Event.DeserializationStrategy, json) ?: return
val event = jsonParser.decodeFromString(Event.DeserializationStrategy, json)
data.eventFlow.emit(event)
} catch (exception: Exception) {
defaultGatewayLogger.error(exception) { "" }
Expand Down
Loading

0 comments on commit 89cf26e

Please sign in to comment.