aboutsummaryrefslogtreecommitdiff
path: root/src/discord.ts
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-30 12:48:48 -0500
committermat <github@matdoes.dev>2022-05-30 12:48:48 -0500
commitf8b1876203c6d0449e597bf9d9de4bdabf55b242 (patch)
tree72c2dd7679de28c3b50d19601135d1f215f52a2e /src/discord.ts
parent5777b24bbf1ccad2b4c897d8c3960b892405b7c0 (diff)
downloadskyblock-api-f8b1876203c6d0449e597bf9d9de4bdabf55b242.tar.gz
skyblock-api-f8b1876203c6d0449e597bf9d9de4bdabf55b242.tar.bz2
skyblock-api-f8b1876203c6d0449e597bf9d9de4bdabf55b242.zip
Replace node-fetch with undici and bump deps
Diffstat (limited to 'src/discord.ts')
-rw-r--r--src/discord.ts10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/discord.ts b/src/discord.ts
index 7871fa3..e6ca743 100644
--- a/src/discord.ts
+++ b/src/discord.ts
@@ -1,11 +1,7 @@
-import fetch from 'node-fetch'
-import { Agent } from 'https'
+import { fetch } from 'undici'
const DISCORD_CLIENT_ID = '885347559382605916'
-const httpsAgent = new Agent({
- keepAlive: true
-})
export interface TokenResponse {
access_token: string
@@ -49,7 +45,6 @@ export async function exchangeCode(redirectUri: string, code: string): Promise<T
API_ENDPOINT + '/oauth2/token',
{
method: 'POST',
- agent: () => httpsAgent,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams(data).toString()
}
@@ -63,8 +58,7 @@ export async function getUser(accessToken: string): Promise<DiscordUser> {
const response = await fetch(
API_ENDPOINT + '/users/@me',
{
- headers: {'Authorization': 'Bearer ' + accessToken},
- agent: () => httpsAgent,
+ headers: { 'Authorization': 'Bearer ' + accessToken },
}
)
return await response.json() as DiscordUser