I’m using node.js to make a discord bot for my game studio’s server, however for one of the bot commands (changerank), the bot must be Authenticated to a Roblox Account.
I tried doing the following:
(index.js)
client.on('ready', async () => { // when the discord bot is ready
console.log('The client is ready!')
axios.post(`https://auth.roblox.com/v1/login`, {
"ctype": config.robloxToken,
"password": "*******", // hidden
})
oh and for any reason you need the changerank command that actually uses the account its this
long
const discord = require("discord.js")
const axios = require("axios")
//
module.exports = {
commands: ['editrank'],
expectedArgs: '<@DiscordMention>',
minArgs: 2,
maxArgs: 2,
callback: async (message, args, text) => {
let u = message.mentions.users.first() || args[0]
try {
if (isNaN(u.id || u)) {
message.channel.send(`You didnt supply a valid user to rank, please mention a user or give me their **Discord UID**.`)
} else {
message.channel.send(`Ranking..`).then((m1) => {
console.log('past load')
axios.get(`https://api.blox.link/v1/user/${u.id || u}`).then((res) => {
console.log('got axios')
console.log(res)
if (res.data.status === "error") {
m1.edit(`${u} isn't linked to bloxlink, please get them to verify in <#862059534000586763>. | **REMEMBER**: I need either their @ or their __Discord UID__`)
return
} else if (res.data.status === "ok") {
m1.edit(`Checking specified arguments`)
if (!args[1]) {
m1.edit(`There was no rank ID specified.`)
return
} else if (args[1]) {
if (isNaN(args[1])) {
m1.edit(`You specified an invalid rank ID.`)
return
} else if (!isNaN(args[1])) {
// User ID Found & rank id found
m1.edit(`User ID and Rank ID Found (${res.data.primaryAccount}), attempting to rank.`)
let uid = res.data.primaryAccount
// https://groups.roblox.com/v1/groups/groupId/users/userId
axios.patch(`https://groups.roblox.com/v1/groups/${10863499}/users/${uid}`, {
roleId: args[1]
}).then(()=>{
m1.delete()
const embed = new discord.MessageEmbed()
.setTitle('Ranked!')
.setDescription('Ranked user!')
})
}
}
}
})
})
}
} catch (error) {
message.channel.send('Unknown Error: Try checking if the user is valid')
}
},
permissions: 'ADMINISTRATOR',
}
As @Xacima said in order to login you need a valid cookie. Because when you logout the cookie is being changed you can do the following: Open a private window in your browser, login in the account you want to use for your ranking services, copy the cookie and then press delete. When the Roblox security value is deleted, reload the page and it you should be loged out! Note: Your cookie will be working for some days, but after a period of time you will need to redo this process. Oh and by the way, sorry for responding late.