-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Make ID -> Id more consistent across the project - Rename method files to not include s at the end - Add BotMethods.getApplicationInfo - bump deps - Add a tokenless file for getting an oauth2 token. More to come soon - HTTP delete is not allowed to have a body - remove explicit dep on undici - min version of node is v16.15.0 for fetch
- Loading branch information
1 parent
a2ed29a
commit 3bdbce9
Showing
16 changed files
with
180 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
{ | ||
"name": "snowtransfer", | ||
"version": "0.10.9", | ||
"version": "0.11.0", | ||
"description": "Minimalistic Rest client for the Discord Api", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"engines": { | ||
"node": ">=14.18.0" | ||
"node": ">=16.15.0" | ||
}, | ||
"keywords": [ | ||
"discord", | ||
|
@@ -18,7 +18,7 @@ | |
"microservice bot" | ||
], | ||
"scripts": { | ||
"build:src": "tsup src/index.ts --clean --dts --sourcemap --format cjs --target node14 --minify-whitespace --minify-syntax --treeshake && node ./sourceMapPostProcess.js", | ||
"build:src": "tsup src/index.ts --clean --dts --sourcemap --format cjs --target node16 --minify-whitespace --minify-syntax --treeshake && node ./sourceMapPostProcess.js", | ||
"build:docs": "typedoc --name SnowTransfer --excludeExternals --sort static-first --sort alphabetical" | ||
}, | ||
"repository": { | ||
|
@@ -29,18 +29,17 @@ | |
"author": "wolke <[email protected]>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"discord-api-types": "^0.37.114", | ||
"undici": "^7.2.0" | ||
"discord-api-types": "^0.37.119" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^22.10.2", | ||
"@typescript-eslint/eslint-plugin": "^8.18.2", | ||
"@typescript-eslint/parser": "^8.18.2", | ||
"eslint": "^9.17.0", | ||
"tsup": "^8.3.5", | ||
"typedoc": "^0.27.6", | ||
"typedoc-plugin-mdn-links": "^4.0.6", | ||
"typescript": "^5.7.2" | ||
"@types/node": "^22.13.1", | ||
"@typescript-eslint/eslint-plugin": "^8.23.0", | ||
"@typescript-eslint/parser": "^8.23.0", | ||
"eslint": "^9.20.0", | ||
"tsup": "^8.3.6", | ||
"typedoc": "^0.27.7", | ||
"typedoc-plugin-mdn-links": "^4.0.12", | ||
"typescript": "^5.7.3" | ||
}, | ||
"files": [ | ||
"dist", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { RESTPostOAuth2AccessTokenResult } from "discord-api-types/v10"; | ||
|
||
import Endpoints = require("./Endpoints"); | ||
|
||
/** | ||
* Get an oauth token after being authorized | ||
* @since 0.11.0 | ||
* @param clientId The ID of your application. For older bots, this is different from your bot's user ID | ||
* @param redirectURI The URI Discord will redirect the user to after they authorize | ||
* @param clientSecret The secret of your client you can obtain from the Application page | ||
* @param code The code returned from Discord from the oauth authorize flow | ||
* @returns The authorization | ||
* | ||
* @example | ||
* const { tokenless } = require("snowtransfer") | ||
* const result = await tokenless.getOauth2Token(id, redirectURI, secret, code) | ||
*/ | ||
async function getOauth2Token(clientId: string, redirectURI: string, clientSecret: string, code: string): Promise<RESTPostOAuth2AccessTokenResult> { | ||
const response = await fetch(`${Endpoints.BASE_HOST}${Endpoints.OAUTH2_TOKEN}`, { | ||
method: "POST", | ||
body: new URLSearchParams({ | ||
grant_type: "authorization_code", | ||
code, | ||
client_id: clientId, | ||
client_secret: clientSecret, | ||
redirect_uri: redirectURI | ||
}) | ||
}); | ||
return response.json() as Promise<RESTPostOAuth2AccessTokenResult>; | ||
} | ||
|
||
export = { | ||
getOauth2Token | ||
} |