Created
July 27, 2020 21:37
-
-
Save Neztore/b0c6a689e06d9aa3e85ce7ecf211d73e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Includes | |
| var http = require('../util/http.js').func | |
| var getGeneralToken = require('../util/getGeneralToken.js').func | |
| // Args | |
| exports.required = ['group'] | |
| exports.optional = ['sortOrder', 'limit', 'cursor', 'jar'] | |
| // Define | |
| function getJoinRequests (jar, group, sortOrder, limit, cursor) { | |
| return new Promise((resolve, reject) => { | |
| var httpOpt = { | |
| url: `//groups.roblox.com/v1/groups/${group}/join-requests?limit=${limit}&sortOrder=${sortOrder}&cursor=${cursor}`, | |
| options: { | |
| method: 'GET', | |
| jar: jar, | |
| resolveWithFullResponse: true | |
| } | |
| } | |
| return http(httpOpt) | |
| .then(function (res) { | |
| if (res.statusCode === 200) { | |
| resolve(JSON.parse(res.body)) | |
| } else { | |
| const body = JSON.parse(res.body) || {} | |
| if (body.errors && body.errors.length > 0) { | |
| var errors = body.errors.map((e) => { | |
| return e.message | |
| }) | |
| reject(new Error(`${res.statusCode} ${errors.join(', ')}`)) | |
| } | |
| } | |
| }) | |
| }) | |
| } | |
| exports.func = function (args) { | |
| console.log(args.jar); | |
| const jar = args.jar | |
| const sortOrder = args.sortOrder || 'Asc' | |
| const limit = args.limit || (10).toString() | |
| const cursor = args.cursor || '' | |
| return getJoinRequests(jar, args.group, sortOrder, limit, cursor) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment