funblox
Version:
This package made by fedee#9606 this a roblox API you may use it for your verification or something if you use our package give us credit <3.
2 lines • 11.4 kB
JavaScript
var ae=Object.defineProperty;var me=(r,e)=>{for(var o in e)ae(r,o,{get:e[o],enumerable:!0})};var L={};me(L,{api:()=>J,auth:()=>v,catalog:()=>b,economy:()=>pe,friends:()=>h,games:()=>x,groups:()=>u,mobileAPI:()=>fe,thumbnails:()=>y,users:()=>I});import f from"got-cjs";import ue from"tough-cookie";import{FileCookieStore as ce}from"tough-cookie-file-store";var le=new ue.CookieJar(new ce("./.cookies")),m=le;var p=new Map,k=new Map;var J=f.extend({prefixUrl:"https://api.roblox.com/",responseType:"json",cookieJar:m,cache:p}),pe=f.extend({prefixUrl:"https://economy.roblox.com/",responseType:"json",cookieJar:m,cache:p}),v=f.extend({prefixUrl:"https://auth.roblox.com/",responseType:"json",cookieJar:m,cache:p}),u=f.extend({prefixUrl:"https://groups.roblox.com/",responseType:"json",cookieJar:m,cache:p}),x=f.extend({prefixUrl:"https://games.roblox.com/",responseType:"json",cookieJar:m,cache:p}),b=f.extend({prefixUrl:"https://catalog.roblox.com/",responseType:"json",cookieJar:m,cache:p}),h=f.extend({prefixUrl:"https://friends.roblox.com/",responseType:"json",cookieJar:m,cache:p}),y=f.extend({prefixUrl:"https://thumbnails.roblox.com/",responseType:"json",cookieJar:m,cache:p}),I=f.extend({prefixUrl:"https://users.roblox.com/",responseType:"json",cookieJar:m,cache:p}),fe=f.extend({prefixUrl:"https://www.roblox.com/mobileapi/",responseType:"json",cookieJar:m,cache:p});function w(r){return new Promise(async(e,o)=>{let t=await J.get(`users/get-by-username?username=${r}`),n=JSON.parse(JSON.stringify(t.body));if(t.statusCode!==200)return o(new Error("Not found. - getUser.js"));e(n.Id)})}async function P(r){return new Promise(async(e,o)=>{if(typeof r=="number"){let t=Number(r),n=await I(`v1/users/${t}/`),s=await h(`v1/users/${t}/followers`),i=await h(`v1/users/${t}/friends`),a=await h(`v1/users/${t}/followings`),c=await y(`v1/users/avatar?userIds=${t}&size=720x720&format=Png&isCircular=false`),g=await h(`v1/users/${t}/followings/count`),d=await h(`v1/users/${t}/friends/count`),O=await h(`v1/users/${t}/followers/count`),l=JSON.parse(JSON.stringify(n.body)),C=JSON.parse(JSON.stringify(s.body)),$=JSON.parse(JSON.stringify(i.body)),E=JSON.parse(JSON.stringify(a.body)),ee=JSON.parse(JSON.stringify(c.body)),re=JSON.parse(JSON.stringify(g.body)),te=JSON.parse(JSON.stringify(d.body)),oe=JSON.parse(JSON.stringify(O.body)),ne=re.count,se=te.count,ie=oe.count,V=[];C.data.forEach(S=>{V.push(S.id)});let B=[];$.data.forEach(S=>{B.push(S.id)});let z=[];E.data.forEach(S=>{z.push(S.id)}),e({id:l.id,username:l.name,description:l.description,created:l.created,avatar_url:ee.data[0].imageUrl,friends:{count:se,ids:B},followers:{count:ie,ids:V},following:{count:ne,ids:z}})}else if(typeof r=="string"){let t=await w(r),n=await P(t);e(n)}else o(new TypeError("Identifier must be a number or a string"))})}function G(r){return new Promise(async(e,o)=>{if(typeof r=="number"){let t=await u.get(`v1/groups/${r}/roles`),n=await y.get(`v1/groups/icons?format=Png&groupIds=${r}&isCircular=false&size=420x420`),s=await u.get(`v1/groups/${r}`),i=JSON.parse(JSON.stringify(t.body)),a=JSON.parse(JSON.stringify(s.body)),c=JSON.parse(JSON.stringify(n.body)),g={id:a.id||null,name:a.name||null,description:a.description||null,owner:a.owner||null,membercount:a.memberCount||null,thumbnail:c.data[0].imageUrl||null,shout:null,roles:[]};a.shout&&(g.shout={content:a.shout.body,created:a.shout.created,author:{id:a.shout.poster.userId,username:a.shout.poster.username,displayName:a.shout.poster.displayName}});for(let d of i.roles){let O=i.roles.indexOf(d);if(g.roles.push({id:d.id,name:d.name,membercount:d.memberCount}),O+1==i.roles.length)return e(g)}return e(g)}else{let t=await u.get(`v1/groups/search/lookup?groupName=${r}`),n=JSON.parse(JSON.stringify(t.body));if(!n.data.length)throw new Error("Group not found");let s=await G(n.data[0].id);if(s)return e(s);o(new Error("Group not found"))}})}function R(r,e){return new Promise(async(o,t)=>{if(Number(e)){let n=await u.get(`v2/users/${Number(e)}/groups/roles?groupid=${Number(r)}`),s=JSON.parse(JSON.stringify(n.body));if(s.errors&&s.errors[0].code==1)return t(new Error("Not found. - getUserRank.js"));let i=s.data.find(a=>r===a.group.id);if(!i)return t(new Error("Not found. - getUserRank.js"));o(i.role)}else if(typeof e=="string"){let n=await w(e);if(!n)return t(new TypeError("User was not found."));let s=await R(r,n);o(s)}})}function X(r,e){return new Promise(async(o,t)=>{if(Number(r))try{let n=await x.get(`v2/users/${r}/favorite/games?accessFilter=All&limit=${e}&sortOrder=Asc`),s=JSON.parse(JSON.stringify(n.body));o(s.data)}catch(n){t(n)}else t(new Error("userId must be a number"))})}function M(){return new Promise(async(r,e)=>{try{let o=b.get("v1/categories");r(o.json())}catch(o){e(o)}})}function Y(r){return new Promise(async(e,o)=>{if(Number(r))try{let t=await b.get(`v1/favorites/bundles/${r}/count`);e(JSON.parse(JSON.stringify(t.body)))}catch(t){o(t)}else o(new Error("Item ID must be a number"))})}function _(r){return new Promise(async(e,o)=>{if(Number(r))try{let t=await b.get(`v1/favorites/assets/${Number(r)}/count`);e(JSON.parse(JSON.stringify(t.body)))}catch(t){o(t)}else o(new Error("Item ID must be a number"))})}var T={body:{sizes:["30x30","48x48","60x60","75x75","100x100","110x110","140x140","150x150","150x200","180x180","250x250","352x352","420x420","720x720"],endpoint:"avatar"},bust:{sizes:["48x48","50x50","60x60","75x75","100x100","150x150","180x180","352x352","420x420"],endpoint:"avatar-bust"},headshot:{sizes:["48x48","50x50","60x60","75x75","100x100","110x110","150x150","180x180","352x352","420x420","720x720"],endpoint:"avatar-headshot"}};async function D(r,e,o,t,n="body"){return new Promise(async(s,i)=>{if(Number(r)){n=n.toLowerCase(),Object.keys(T).includes(n)||i(new TypeError(`Invalid cropping type provided: ${n} | Use: ${Object.keys(T).join(", ")}`));let{sizes:a,endpoint:c}=T[n];e=e||a[a.length-1],typeof e=="number"&&(e=`${e}x${e}`),a.includes(e)||i(new TypeError(`Invalid size parameter provided: ${e} | [${n.toUpperCase()}] Use: ${a.join(", ")}`)),o.toLowerCase()!=="png"&&o.toLowerCase()!=="jpeg"&&i(new TypeError(`Invalid image type provided: ${o} | Use: png, jpeg`));let g=await y.get(`v1/users/${c}?userIds=${r}&size=${e}&format=${o}&isCircular=${t}`),d=JSON.parse(JSON.stringify(g.body));return s({Thumbnail:d.data[0].imageUrl})}else{let a=await P(r);if(a.id){let c=await D(a.id,e,o,t,n);return s(c)}else i(new Error("User not found"))}})}function W(r){return new Promise(async(e,o)=>{try{let t=await b.get(`v1/users/${Number(r)}/bundles`),n=JSON.parse(JSON.stringify(t.body));e(n.data)}catch(t){o(t)}})}function ge(r){return new Promise(async(e,o)=>{if(Number(r)){let t=await x.get(`v1/games?universeIds=${r}`),n=await y.get(`v1/places/gameicons?placeIds=${r}&size=128x128&format=Jpeg&isCircular=true`),s=JSON.parse(JSON.stringify(t.body)),i=JSON.parse(JSON.stringify(n.body));e({id:s.id||null,name:s.name||null,description:s.description||null,creator:s.creator||null,thumbnails:i.imageUrl||null,price:s.price||null,allowedGearGenres:s.allowedGearGenres||null,allowedGearCategories:s.allowedGearCategories||null,playing:s.playing||null,visits:s.visits||null,maxPlayers:s.maxPlayers||null,created:s.created||null,updated:s.updated||null,genres:s.genres||null,favoritedCount:s.favoritedCount||null})}else return o(new Error("Invalid identifier, it should be a number not a string."))})}var de="Number is not a universe id, use getUniverseId() to get the universe id.";function q(r){function e(o){return o==500,!0}return new Promise(async function(o,t){if(Number(r)){let n=await x.get(`v1/games/votes?universeIds=${r}`),s=JSON.parse(JSON.stringify(n.body));return e(n.statusCode)&&t(new Error(`${n.statusCode}: ${n.statusMessage}`)),s[0]||t(new TypeError(de)),o({upVotes:s.data[0].upVotes,downVotes:s.data[0].downVotes})}})}function H(r){return new Promise(async(e,o)=>{let t=await J.get(`universes/get-universe-containing-place?placeid=${r}`),n=JSON.parse(JSON.stringify(t.body));n.body.success?e(n.data.universeId):o(new Error(n.data.errors[0].message))})}function j(){return new Promise(async(r,e)=>{if(k.has("XCSRF"))return r(k.get("XCSRF"));let o=await v.post("/v2/logout",{cookieJar:m});if(o.statusCode!==200)return e(new Error("Authentication API returned an error: "+o.statusCode));let t=o.headers["x-csrf-token"];return t?(k.set("XCSRF",t),r(t)):e(new Error("Could not get XCSRF token!"))})}function F(r){return new Promise(async(e,o)=>{if(typeof r=="number"){let t=await u.get(`v1/groups/${r}/roles`),n=JSON.parse(JSON.stringify(t.body)),s={roles:[]};for(let i of n.roles){let a=n.roles.indexOf(i);if(s[0].roles.push({id:i.id,name:i.name,membercount:i.memberCount}),a+1==n.roles.length)return e(s)}return e(s)}else o(new TypeError("Group param must be a number"))})}function A(r,e){return new Promise(async(o,t)=>{let n=await F(r);if(typeof e=="number"||typeof e=="string"&&typeof r=="number"){if(typeof e=="string"){let s=n.roles.find(({name:i})=>i===e);return o({id:s.id,name:s.name,membercount:s.membercount})}else if(typeof e=="number"){let s=n.roles.find(({id:i})=>i===e);return o({id:s.id,name:s.name,membercount:s.membercount})}}else t(new TypeError("The rank must be a number/string and the groupID must be a number."))})}function U(r,e,o){return new Promise(async(t,n)=>{if(typeof r=="number"&&typeof e=="number"&&typeof o=="number"){let s=await R(r,e),i={roleId:o};await u.patch(`v1/groups/${r}/users/${e}`,{cookieJar:m,json:i,headers:{"Content-Type":"application/json","X-CSRF-Token":await j()}}).then(function(){let a=A(r,o);t({oldRank:s,newRank:a})}).catch(function(a){n(a)})}else n(new TypeError("All the parameters in this function should be numeric, please check your parameters"))})}function N(r,e,o){return new Promise(async(t,n)=>{let s=await u.get(`v1/groups/${r}/roles`),i=JSON.parse(JSON.stringify(s.body)),a=await R(r,e);for(let c=0;c<i.roles.length;c++)if(i.roles[c].id===a.id){let O=c+o,l=i.roles[O],C=i.roles.indexOf(l),$=i.roles[C];l===0?n(new TypeError("Can't demote someone to rank 0 (GUEST) unless I exile them...")):l?l>0&&l&&l<255&&await U(r,e,C.rolese).then(async function(){return t({newRank:$,oldRank:a})}).catch(function(E){n(new TypeError(E))}):n(new TypeError("Can't find this user next rank..."))}})}async function K(r,e){return new Promise(async(o,t)=>{if(!isNaN(r))if(typeof e=="number"){let n=await N(r,e,1);o(n)}else if(typeof e=="string"){let n=await w(e),s=await N(r,n,1);o(s)}else t(new TypeError("User must be a number or a string"))})}function Q(r,e){return new Promise(async(o,t)=>{if(!isNaN(r))if(typeof e=="number"){let n=await N(r,e,Number(-1));o(n)}else if(typeof e=="string"){let n=await w(e),s=await N(r,n,Number(-1));o(s)}else t(new TypeError("User must be a number or a string"))})}function Z(r){return new Promise(async(e,o)=>{let t=await v.post("v1/session");if(!r.toLowerCase().includes("warning:-"))return o(new TypeError("You didn't include the Roblox Warning. Please include the entire .ROBLOSECURITY cookie."));if(t.statusCode!==200)return o(new Error("Not found. - getUser.js"));e()})}export{L as api,Q as demote,M as getCategories,Y as getFavoritesOfBundle,_ as getFavoritesOfItem,q as getGameVotes,G as getGroup,ge as getPlaceInfo,D as getPlayerThumbnail,H as getUniverseId,P as getUser,W as getUserBundles,X as getUserFavoriteGames,R as getUserRank,K as promote,Z as setCookie,U as setRank};
//# sourceMappingURL=index.mjs.map