-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolved merge conflicts with upstream/master
- Loading branch information
Showing
31 changed files
with
3,749 additions
and
734 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Run tests | ||
|
||
on: | ||
workflow_dispatch | ||
|
||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install yarn | ||
run: npm install -g yarn | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Lint lib/ | ||
run: yarn lint | ||
- name: Run tests | ||
env: | ||
COOKIE: ${{ secrets.COOKIE }} | ||
COOKIE_2: ${{ secrets.COOKIE_2 }} | ||
run: yarn test | ||
|
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import jest from "eslint-plugin-jest"; | ||
import globals from "globals"; | ||
import path from "node:path"; | ||
import { fileURLToPath } from "node:url"; | ||
import js from "@eslint/js"; | ||
import { FlatCompat } from "@eslint/eslintrc"; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
const compat = new FlatCompat({ | ||
baseDirectory: __dirname, | ||
recommendedConfig: js.configs.recommended, | ||
allConfig: js.configs.all | ||
}); | ||
|
||
export default [...compat.extends("standard", "plugin:jest/recommended"), { | ||
plugins: { | ||
jest, | ||
}, | ||
|
||
languageOptions: { | ||
globals: { | ||
...globals.commonjs, | ||
...globals.node, | ||
Atomics: "readonly", | ||
SharedArrayBuffer: "readonly", | ||
}, | ||
|
||
ecmaVersion: 2018, | ||
sourceType: "commonjs", | ||
}, | ||
|
||
rules: {}, | ||
}]; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Includes | ||
const http = require('../util/http.js').func | ||
|
||
// Args | ||
exports.required = ['userId'] | ||
exports.optional = ['jar'] | ||
|
||
// Docs | ||
/** | ||
* 🔓 Gets the amount of robux for the authenticated user. | ||
* @category User | ||
* @param {number} userId - Must match the userId of the authenticated user | ||
* @alias getUserFunds | ||
* @returns {Promise<number>} | ||
* @example const noblox = require("noblox.js") | ||
* // Login using your cookie | ||
* const currentUser = await noblox.setCookie(process.env.ROBLOXCOOKIE) | ||
* const robux = await noblox.getUserFunds(currentUser.id) | ||
*/ | ||
|
||
// Define | ||
function getUserFunds (userId, jar) { | ||
return http({ | ||
url: `//economy.roblox.com/v1/users/${userId}/currency`, | ||
options: { | ||
jar, | ||
resolveWithFullResponse: true | ||
} | ||
}) | ||
.then(({ statusCode, body }) => { | ||
const { robux, errors } = JSON.parse(body) | ||
if (statusCode === 200) { | ||
return robux | ||
} else if (statusCode === 400 || statusCode === 403) { | ||
throw new Error(`${errors[0].message} | userId: ${userId}`) | ||
} else { | ||
throw new Error(`An unknown error occurred with getUserFunds() | [${statusCode}] userId: ${userId}`) | ||
} | ||
}) | ||
} | ||
|
||
exports.func = function ({ userId, jar }) { | ||
return getUserFunds(userId, jar) | ||
} |
Oops, something went wrong.