Closed BottyRBLX closed 7 years ago
You are using promises incorrectly. Remember that you have to put all following commands in a .then function.
rbx.login('username', 'password'); // Put this at the top of the script for running during initialization, since it only needs to be done once. You don't have to use a .then here because we can assume that by the time someone sends a command the login has already completed.
rbx.getIdFromUsername(args[0])
.then(function (user) {
var options = {
group: 3030452,
target: user,
name: '[8] Headmaster'
}
rbx.setRank(options)
.then(function (newRole) {
message.channel.send('The new role is: ' + JSON.stringify(newRole));
});
});
Hi, I followed your advice it worked for the most part but then this happened.
It returns undefined.
@sentanos
You are running getShout before the login has time to complete. Something like this would ensure that you are executing the next step once the previous one has completed:
rbx.login('username', 'password')
.then(function () {
rbx.getShout(3030452).then(console.log);
});
I got this error:
When running this: