Search code examples
javascriptnode.jsroblox

Unable to de-rank people with Roblox groups api, node.js


Due to issues, we need to mass de-rank a lot of people, but when attempting to make a request through Roblox's group api, it returns 401 (unauthorized request)

I'm pretty sure the token is valid, and the bot does have permission to derank them. The code is below.

const token = "TOKEN WOULD GO HERE BUT NOT SHOWN"
const axios = require('axios')
const noblox = require('noblox.js')
const rolesetID = 36926359
const groupId = 5598688
const url = `https://groups.roblox.com/v1/groups/5598688/roles/${rolesetID}/users?limit=100`
let userCount = 0

for (let i = 0; i < 1000; i++) {
    axios.get(`${url}`)
    .then(async function (response) {
        response.data.data.forEach(async data => {
          if(data.username == 'lickty123') {
          } else {
            let url = `https://groups.roblox.com/v1/groups/5598688/users/${data.userId}`
            await axios.patch(url, { body: { roleId: 36926437,Cookie: ".ROBLOSECURITY=" + token} })
            .then(async (res) => {
                console.log(`${data.userID} has been demoted!`)
            })
            .catch(error => {
              console.log(error)
            })
        }
      });
      // userCount = userCount + 100
     // console.log(`${userCount} people have been demoted`)
    })
    wait(1)
}

Any help is appreciated.


Solution

  • you have to put the Cookie field in headers, not body
    you also have to include your x-csrf-token in headers, which can be achieved with noblox via noblox.getGeneralToken()