Skip to content

Commit

Permalink
USER_AGENT (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukellmann authored Mar 11, 2022
1 parent d97f473 commit 3575921
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion common/src/main/kotlin/KordConstants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package dev.kord.common
public object KordConstants {

/** Kord's value for the [User Agent header](https://discord.com/developers/docs/reference#user-agent). */
public const val UserAgent: String = "DiscordBot (https://github.com/kordlib/kord, 0.8.0-M12)"
public const val USER_AGENT: String = "DiscordBot (https://github.com/kordlib/kord, 0.8.0-M12)"
}
2 changes: 1 addition & 1 deletion core/src/main/kotlin/builder/kord/KordBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public class KordBuilder(public val token: String) {
*/
private suspend fun HttpClient.getGatewayInfo(): BotGatewayResponse {
val response = get<HttpResponse>("${Route.baseUrl}${Route.GatewayBotGet.path}") {
header(UserAgent, KordConstants.UserAgent)
header(UserAgent, KordConstants.USER_AGENT)
header(Authorization, "Bot $token")
}
val responseBody = response.readText()
Expand Down
2 changes: 1 addition & 1 deletion rest/src/main/kotlin/service/RestService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public abstract class RestService(@PublishedApi internal val requestHandler: Req
val request = RequestBuilder(route)
.apply(builder)
.apply {
unencodedHeader(UserAgent, KordConstants.UserAgent)
unencodedHeader(UserAgent, KordConstants.USER_AGENT)
if (route.requiresAuthorizationHeader) {
unencodedHeader(Authorization, "Bot ${requestHandler.token}")
}
Expand Down

0 comments on commit 3575921

Please sign in to comment.