JDA-Applications / JDA-Utilities

A series of tools and utilities for JDA to assist in bot creation
Apache License 2.0
218 stars 111 forks source link

Replace discordapp.com with discord.com #107

Closed duncte123 closed 4 years ago

duncte123 commented 4 years ago

Pull Request

Pull Request Checklist

Please follow the following steps before opening this PR.
PRs that do not complete the checklist will be subject to denial for missing information.

Pull Request Information

Check and fill in the blanks for all that apply:

Description

Discord recently changed their domain from discordapp.com to discord.com (the cdn is still on discordapp.com) meaning that the domains used need to be updated

duncte123 commented 4 years ago

Can someone review this asap? It has all sorts of weird behavior because it gets redirected to discord.com

Temp fix is to add an interceptor for now

private val oAuth2Client = OAuth2Client.Builder()
.setClientId(config.discord.oauth.clientId)
.setClientSecret(config.discord.oauth.clientSecret)
.setOkHttpClient(
    OkHttpClient.Builder()
        .addInterceptor {
            var request = it.request()
            val httpUrl = request.url()

            if (httpUrl.host().contains("discordapp")){
                val newHttpUrl = httpUrl.newBuilder()
                    .host("discord.com")
                    .build()

                request = request.newBuilder()
                    .url(newHttpUrl)
                    .build()
            }

            it.proceed(request)
        }
        .build()
)
.build()