sentanos / roblox-js

!!!THIS PROJECT IS NO LONGER MAINTAINED!!! Execute ROBLOX website actions in node.js
MIT License
45 stars 45 forks source link

Help #32

Closed BottyRBLX closed 7 years ago

BottyRBLX commented 7 years ago

I got this error: image

When running this: image

sentanos commented 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));
  });
});
BottyRBLX commented 7 years ago

Hi, I followed your advice it worked for the most part but then this happened.

image

BottyRBLX commented 7 years ago

It returns undefined.

BottyRBLX commented 7 years ago

@sentanos

sentanos commented 7 years ago

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);
});