diff --git a/rest/api/rest.api b/rest/api/rest.api index f0b237763c2..541efb4ea8f 100644 --- a/rest/api/rest.api +++ b/rest/api/rest.api @@ -6492,10 +6492,11 @@ public abstract interface class dev/kord/rest/route/ResponseMapper { public abstract class dev/kord/rest/route/Route { public static final field Companion Ldev/kord/rest/route/Route$Companion; - public synthetic fun (Lio/ktor/http/HttpMethod;Ljava/lang/String;Ldev/kord/rest/route/ResponseMapper;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (Lio/ktor/http/HttpMethod;Ljava/lang/String;Ldev/kord/rest/route/ResponseMapper;ZLkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (Lio/ktor/http/HttpMethod;Ljava/lang/String;Lkotlinx/serialization/DeserializationStrategy;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (Lio/ktor/http/HttpMethod;Ljava/lang/String;Lkotlinx/serialization/DeserializationStrategy;ZLkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Lio/ktor/http/HttpMethod;Ljava/lang/String;Ldev/kord/rest/route/ResponseMapper;ZZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Lio/ktor/http/HttpMethod;Ljava/lang/String;Ldev/kord/rest/route/ResponseMapper;ZZLkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Lio/ktor/http/HttpMethod;Ljava/lang/String;Lkotlinx/serialization/DeserializationStrategy;ZZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Lio/ktor/http/HttpMethod;Ljava/lang/String;Lkotlinx/serialization/DeserializationStrategy;ZZLkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun getAffectedByGlobalRateLimit ()Z public final fun getMapper ()Ldev/kord/rest/route/ResponseMapper; public final fun getMethod ()Lio/ktor/http/HttpMethod; public final fun getPath ()Ljava/lang/String; diff --git a/rest/api/rest.klib.api b/rest/api/rest.klib.api index 09199d14d8e..1af2cb5b897 100644 --- a/rest/api/rest.klib.api +++ b/rest/api/rest.klib.api @@ -7211,6 +7211,8 @@ sealed class <#A: kotlin/Any?, #B: dev.kord.common.entity/Choice> dev.kord.rest. } sealed class <#A: kotlin/Any?> dev.kord.rest.route/Route { // dev.kord.rest.route/Route|null[0] + final val affectedByGlobalRateLimit // dev.kord.rest.route/Route.affectedByGlobalRateLimit|{}affectedByGlobalRateLimit[0] + final fun (): kotlin/Boolean // dev.kord.rest.route/Route.affectedByGlobalRateLimit.|(){}[0] final val mapper // dev.kord.rest.route/Route.mapper|{}mapper[0] final fun (): dev.kord.rest.route/ResponseMapper<#A> // dev.kord.rest.route/Route.mapper.|(){}[0] final val method // dev.kord.rest.route/Route.method|{}method[0] diff --git a/rest/src/commonMain/kotlin/ratelimit/AbstractRateLimiter.kt b/rest/src/commonMain/kotlin/ratelimit/AbstractRateLimiter.kt index 0fb31876233..f7ca7067f4c 100644 --- a/rest/src/commonMain/kotlin/ratelimit/AbstractRateLimiter.kt +++ b/rest/src/commonMain/kotlin/ratelimit/AbstractRateLimiter.kt @@ -33,7 +33,9 @@ public abstract class AbstractRateLimiter internal constructor(public val clock: } override suspend fun await(request: Request<*, *>): RequestToken { - globalSuspensionPoint.value.await() + if (request.route.affectedByGlobalRateLimit) { + globalSuspensionPoint.value.await() + } val buckets = request.buckets buckets.forEach { it.awaitAndLock() } diff --git a/rest/src/commonMain/kotlin/route/Route.kt b/rest/src/commonMain/kotlin/route/Route.kt index 7476d62e5ef..d36346b19bd 100644 --- a/rest/src/commonMain/kotlin/route/Route.kt +++ b/rest/src/commonMain/kotlin/route/Route.kt @@ -50,6 +50,7 @@ public sealed class Route( public val path: String, public val mapper: ResponseMapper, public val requiresAuthorizationHeader: Boolean = true, + public val affectedByGlobalRateLimit: Boolean = true ) { public companion object { @@ -91,7 +92,8 @@ public sealed class Route( path: String, strategy: DeserializationStrategy, requiresAuthorizationHeader: Boolean = true, - ) : this(method, path, ValueJsonMapper(strategy), requiresAuthorizationHeader) + affectedByGlobalRateLimit: Boolean = true + ) : this(method, path, ValueJsonMapper(strategy), requiresAuthorizationHeader, affectedByGlobalRateLimit) override fun toString(): String = "Route(method:${method.value},path:$path,mapper:$mapper)" @@ -990,6 +992,7 @@ public sealed class Route( "/interactions/$InteractionId/$InteractionToken/callback", NoStrategy, requiresAuthorizationHeader = false, + affectedByGlobalRateLimit = false ) public object OriginalInteractionResponseGet : @@ -998,6 +1001,7 @@ public sealed class Route( "/webhooks/$ApplicationId/$InteractionToken/messages/@original", DiscordMessage.serializer(), requiresAuthorizationHeader = false, + affectedByGlobalRateLimit = false ) public object OriginalInteractionResponseModify : @@ -1006,6 +1010,7 @@ public sealed class Route( "/webhooks/$ApplicationId/$InteractionToken/messages/@original", DiscordMessage.serializer(), requiresAuthorizationHeader = false, + affectedByGlobalRateLimit = false ) public object OriginalInteractionResponseDelete : @@ -1014,6 +1019,7 @@ public sealed class Route( "/webhooks/$ApplicationId/$InteractionToken/messages/@original", NoStrategy, requiresAuthorizationHeader = false, + affectedByGlobalRateLimit = false ) public object FollowupMessageCreate : @@ -1022,6 +1028,7 @@ public sealed class Route( "/webhooks/$ApplicationId/$InteractionToken", DiscordMessage.serializer(), requiresAuthorizationHeader = false, + affectedByGlobalRateLimit = false ) public object FollowupMessageGet : @@ -1030,6 +1037,7 @@ public sealed class Route( "/webhooks/$ApplicationId/$InteractionToken/messages/$MessageId", DiscordMessage.serializer(), requiresAuthorizationHeader = false, + affectedByGlobalRateLimit = false ) public object FollowupMessageModify : @@ -1038,6 +1046,7 @@ public sealed class Route( "/webhooks/$ApplicationId/$InteractionToken/messages/$MessageId", DiscordMessage.serializer(), requiresAuthorizationHeader = false, + affectedByGlobalRateLimit = false ) public object FollowupMessageDelete : @@ -1046,6 +1055,7 @@ public sealed class Route( "/webhooks/$ApplicationId/$InteractionToken/messages/$MessageId", NoStrategy, requiresAuthorizationHeader = false, + affectedByGlobalRateLimit = false )