diff options
author | mat <github@matdoes.dev> | 2021-12-30 16:18:57 -0600 |
---|---|---|
committer | mat <github@matdoes.dev> | 2021-12-30 16:18:57 -0600 |
commit | 342d31e99d1fbd7bcc941e34bb2a175382f3e26e (patch) | |
tree | c735fa67652d49386d3b55b42567ea3ebd57c5c4 /build/discord.js | |
parent | f7d1263ea669968a4b69d80cede9b77f240de4b6 (diff) | |
download | skyblock-api-342d31e99d1fbd7bcc941e34bb2a175382f3e26e.tar.gz skyblock-api-342d31e99d1fbd7bcc941e34bb2a175382f3e26e.tar.bz2 skyblock-api-342d31e99d1fbd7bcc941e34bb2a175382f3e26e.zip |
remove build folder
Diffstat (limited to 'build/discord.js')
-rw-r--r-- | build/discord.js | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/build/discord.js b/build/discord.js deleted file mode 100644 index bf906a9..0000000 --- a/build/discord.js +++ /dev/null @@ -1,37 +0,0 @@ -import fetch from 'node-fetch'; -import { Agent } from 'https'; -const DISCORD_CLIENT_ID = '885347559382605916'; -const httpsAgent = new Agent({ - keepAlive: true -}); -export async function exchangeCode(redirectUri, code) { - const API_ENDPOINT = 'https://discord.com/api/v6'; - const CLIENT_SECRET = process.env.discord_client_secret; - if (!CLIENT_SECRET) { - console.error('discord_client_secret isn\'t in env, couldn\'t login with discord'); - return null; - } - const data = { - 'client_id': DISCORD_CLIENT_ID, - 'client_secret': CLIENT_SECRET, - 'grant_type': 'authorization_code', - 'code': code, - 'redirect_uri': redirectUri, - 'scope': 'identify' - }; - const fetchResponse = await fetch(API_ENDPOINT + '/oauth2/token', { - method: 'POST', - agent: () => httpsAgent, - headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, - body: new URLSearchParams(data).toString() - }); - return await fetchResponse.json(); -} -export async function getUser(accessToken) { - const API_ENDPOINT = 'https://discord.com/api/v6'; - const response = await fetch(API_ENDPOINT + '/users/@me', { - headers: { 'Authorization': 'Bearer ' + accessToken }, - agent: () => httpsAgent, - }); - return await response.json(); -} |