diff --git a/lib/economy/getGroupPayoutEligibility.js b/lib/economy/getGroupPayoutEligibility.js new file mode 100644 index 000000000..2f5488d85 --- /dev/null +++ b/lib/economy/getGroupPayoutEligibility.js @@ -0,0 +1,48 @@ +// Includes +const http = require('../util/http.js').func + +// Args +exports.required = ['group', 'member'] +exports.optional = ['jar'] + +// Docs +/** + * 🔓 Get if a user can be paid from group funds. + * @category Group + * @alias getGroupPayoutEligibility + * @param {number} group - The id of the group. + * @param {number} member - The member to check payout status for. + * @returns {Promise} + * @example const noblox = require("noblox.js") + * // Log in with cookie + * const payoutStatus = await noblox.getGroupPayoutEligibility(1, 2) + **/ + +// Define +function getGroupPayoutEligibility (group, member, jar) { + return new Promise((resolve, reject) => { + const httpOpt = { + url: `https://economy.roblox.com/v1/groups/${group}/users-payout-eligibility?userIds=${member}`, + options: { + method: 'GET', + resolveWithFullResponse: true, + jar + } + } + + return http(httpOpt) + .then(function (res) { + const responseData = JSON.parse(res.body) + if (res.statusCode !== 200) { + reject(new Error(responseData.errors[0].message)) + } else { + resolve(responseData) + } + }) + .catch(error => reject(error)) + }) +} + +exports.func = function (args) { + return getGroupPayoutEligibility(args.group, args.member, args.jar) +} diff --git a/lib/index.js b/lib/index.js index bd6063b3a..97cea96b4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -103,6 +103,7 @@ noblox.demote = require('./groups/demote.js') noblox.exile = require('./groups/exile.js') noblox.getAuditLog = require('./groups/getAuditLog.js') noblox.getGroup = require('./groups/getGroup.js') +noblox.getGroupPayoutEligibility = require('./economy/getGroupPayoutEligibility.js') noblox.getGroupSocialLinks = require('./groups/getGroupSocialLinks.js') noblox.getGroups = require('./groups/getGroups.js') noblox.getJoinRequest = require('./groups/getJoinRequest.js') diff --git a/typings/index.d.ts b/typings/index.d.ts index 5f12970f8..7eba768f4 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -866,6 +866,12 @@ declare module "noblox.js" { updated: Date; } + interface PayoutAllowedList { + usersGroupPayoutEligibility: { + [K: string]: string; + } + } + interface GroupDescriptionResult { newDescription: string } @@ -1746,6 +1752,11 @@ declare module "noblox.js" { * 🔓 Gets the amount of Robux in a group. */ function getGroupFunds(group: number): Promise; + + /** + * 🔐 Gets the payout eligibility status of a group member. + */ + function getGroupPayoutEligibility(groupId: number, userId: number, jar?: CookieJar): Promise; /** * 🔐 Gets recent Robux revenue summary for a group; shows pending Robux. | Requires "Spend group funds" permissions. diff --git a/typings/jsDocs.ts b/typings/jsDocs.ts index 6a85a8a3a..0abbc1f4c 100644 --- a/typings/jsDocs.ts +++ b/typings/jsDocs.ts @@ -1201,6 +1201,15 @@ type GroupShout = { updated: Date; } +/** + * @typedef +*/ +type PayoutAllowedList = { + usersGroupPayoutEligibility: { + [k: string]: string; + } +} + /** * @typedef */