aboutsummaryrefslogtreecommitdiff
path: root/build/discord.js
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2021-09-06 21:06:22 +0000
committerGitHub <noreply@github.com>2021-09-06 21:06:22 +0000
commit487f208565894f332ca58c13e1b208c3beb9c8c6 (patch)
treeb3209e94cc63658b5430bc1949b80140cc27efe4 /build/discord.js
parent4f03cb71b30978b277ff292dbddeba182117a7cb (diff)
downloadskyblock-api-487f208565894f332ca58c13e1b208c3beb9c8c6.tar.gz
skyblock-api-487f208565894f332ca58c13e1b208c3beb9c8c6.tar.bz2
skyblock-api-487f208565894f332ca58c13e1b208c3beb9c8c6.zip
Bump node-fetch from 2.6.1 to 3.0.0 (#116)
* Bump node-fetch from 2.6.1 to 3.0.0 Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 3.0.0. - [Release notes](https://github.com/node-fetch/node-fetch/releases) - [Changelog](https://github.com/node-fetch/node-fetch/blob/main/docs/CHANGELOG.md) - [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.1...v3.0.0) --- updated-dependencies: - dependency-name: node-fetch dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * fix issues with node fetch 3.0 * change module to esnext instead of commonjs * fix imports and tests * fix package-lock.json Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mat <github@matdoes.dev> Co-authored-by: mat <27899617+mat-1@users.noreply.github.com>
Diffstat (limited to 'build/discord.js')
-rw-r--r--build/discord.js24
1 files changed, 8 insertions, 16 deletions
diff --git a/build/discord.js b/build/discord.js
index ba9f3eb..ca910b2 100644
--- a/build/discord.js
+++ b/build/discord.js
@@ -1,16 +1,10 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.getUser = exports.exchangeCode = void 0;
-const node_fetch_1 = __importDefault(require("node-fetch"));
-const https_1 = require("https");
+import fetch from 'node-fetch';
+import { Agent } from 'https';
const DISCORD_CLIENT_ID = '656634948148527107';
-const httpsAgent = new https_1.Agent({
+const httpsAgent = new Agent({
keepAlive: true
});
-async function exchangeCode(redirectUri, code) {
+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) {
@@ -25,7 +19,7 @@ async function exchangeCode(redirectUri, code) {
'redirect_uri': redirectUri,
'scope': 'identify'
};
- const fetchResponse = await node_fetch_1.default(API_ENDPOINT + '/oauth2/token', {
+ const fetchResponse = await fetch(API_ENDPOINT + '/oauth2/token', {
method: 'POST',
agent: () => httpsAgent,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
@@ -33,13 +27,11 @@ async function exchangeCode(redirectUri, code) {
});
return await fetchResponse.json();
}
-exports.exchangeCode = exchangeCode;
-async function getUser(accessToken) {
+export async function getUser(accessToken) {
const API_ENDPOINT = 'https://discord.com/api/v6';
- const response = await node_fetch_1.default(API_ENDPOINT + '/users/@me', {
+ const response = await fetch(API_ENDPOINT + '/users/@me', {
headers: { 'Authorization': 'Bearer ' + accessToken },
agent: () => httpsAgent,
});
- return response.json();
+ return await response.json();
}
-exports.getUser = getUser;