Reputation: 27
var rbx = require('roblox-js');
rbx.login('INF_BOT', '$$$')
.then(function (info) {
console.log('Logged in with ID ' + info.userId);
rbx.getPlayers(539310, 1)
.then(function (players) {
for( var Plr in players) {
console.log(Plr)
}
})
.catch(function (err){
console.error(err.stack);
})
})
.catch(function (err) {
console.error(err.stack);
});
I keep getting the output: http://prntscr.com/e0upfl
Here is the getPlayers.js: http://pastebin.com/wD6bjStc
I have no clue why .then is throwing the error, basically the getPlayers returns and object, within that object there is a promise and status, within the promis there is an object... Atleast that is what the API is showing me.
Basically I am running a function called getPlayers() but it returns an object, and in that object is a Promise, and a function. I need to get the Promise and .then it...
Upvotes: 0
Views: 1526
Reputation: 59213
I'm bored so I decided to help you out and navigate the roblox-js lib for you.
The code here is what is returned from the getPlayers
function. Looks like you need to look for getPlayers().promise.then
rather than just getPlayers().then
as the function doesn't return just the promise. It returns an object with a property called promise
(what you're looking for I presume) and a getStatus
function.
var rbx = require('roblox-js');
rbx.login('INF_BOT', '$$$')
.then(function (info) {
console.log('Logged in with ID ' + info.userId);
rbx.getPlayers(539310, 1).promise // <-------------------------------
.then(function (players) {
for (var Plr in players) {
console.log(Plr);
}
})
.catch(function (err) {
console.error(err.stack);
})
})
.catch(function (err) {
console.error(err.stack);
});
Upvotes: 2