UNPKG

noblox-bonk

Version:
60 lines (55 loc) 1.35 kB
// Includes const http = require('../util/http.js').func const getGeneralToken = require('../util/getGeneralToken.js').func // Args exports.required = ['userId'] exports.optional = ['jar'] // Docs /** * 🔐 Block a user. * @category User * @alias block * @param {number} userId - The id of the user that is being blocked. * @returns {Promise<void>} * @example const noblox = require("noblox.js") * // Login using your cookie * noblox.block(123456) **/ // Define function block (jar, token, userId) { return new Promise((resolve, reject) => { const httpOpt = { url: '//www.roblox.com/userblock/blockuser', options: { method: 'POST', jar: jar, headers: { 'X-CSRF-TOKEN': token }, json: { blockeeId: userId }, resolveWithFullResponse: true } } return http(httpOpt) .then(function (res) { if (res.statusCode === 200) { const body = res.body if (!body.success) { reject(new Error(body.message)) } resolve() } else { reject(new Error('Block failed')) } }) }) } exports.func = function (args) { const jar = args.jar return getGeneralToken({ jar: jar }) .then(function (xcsrf) { return block(jar, xcsrf, args.userId) }) }