sentanos / roblox-js

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

Verification issue... #48

Closed nishi7409 closed 7 years ago

nishi7409 commented 7 years ago

Code - https://hastebin.com/pofaderila.js Error - http://prntscr.com/gbgb9n

tl;dr - I don't understand what I'm doing wrong, I've spent the last few days trying to fix this issue, but I'm truly lost.

sentanos commented 7 years ago

What is so hard to understand? You have these two lines which are testing for both a username and an ID:

var nicknames = await rbx.getUsernameFromId(args[1]);
var usernamenotid = rbx.getIdFromUsername(args[1])

Obviously it cannot be both, so one of them is always going to error even if you have a valid user.

sentanos commented 7 years ago

I think you may be misunderstanding rbx.getUsernameFromId. It accepts the user's user ID and returns the user's username. That's it. If args[1] is the user ID it will work, otherwise it will error. If it doesn't error then rbx.getIdFromUsername will because it needs a username and not a user ID.

nishi7409 commented 7 years ago

  if (message.content.startsWith(prefix + "verify")) {
    var args = message.content.split(/[ ]+/)
    console.log(args[1])
    if (message.member.roles.exists('name', 'VERIFIED')) {
      return  message.author.send("You've already been verified!")
    }
    const token1 = code[Math.floor(Math.random() * code.length)];
    const location = await message.channel.send(message.author + `\nPlease input the following code into your account's description then run the command, \`!done\` back here.\n\n**${token1}**\n\n***For this verification process to work, the code must be the only text with the account's description (feel free to change it after the verification process).***`).then(message => message.channel);
    const asdkasdlkasdj = { max: 1, time: 40000, errors: ['time'] };
    const collected = await location.awaitMessages(response => response.content === '!done', asdkasdlkasdj).catch(() => null);
    console.log(1)
    if (!collected) {
      return message.author.send("Please try the verification process again...");
    }
    // var nicknames = await rbx.getUsernameFromId(args[1]);
    // var usernamenotid = rbx.getIdFromUsername(args[1])
    console.log(2)
    await rbx.login(options);
    const blurb = rbx.getIdFromUsername(args[1]).then(rbx.getBlurb);
    message.member.setNickname("asdkzxkk123123")
    console.log(3)
    if (blurb === token1) {
      await message.member.addRole(message.guild.roles.find('name', 'VERIFIED')).catch(console.error);
      message.member.setNickname("laksjdlkjasdklj");
      return message.author.send("You've officially linked your ROBLOX account with your Discord account.");
    }
    else {
      return message.author.send("Sorry, but I couldn't find the code on your account's description.\nIf the code was hashed out, please send a message to a user with the role of `admin2`! ")
    }
  }```

Alright, I'm getting somewhere.

Problem is that the user account can not verify the blurb of said username (in short, it always returns the message of, "Sorry, but I couldn't find the code on your account's description.\nIf the code was hashed out, please send a message to a user with the role of `admin2`!".
sentanos commented 7 years ago

You are not awaiting the blurb promise.

const blurb = await rbx.getIdFromUsername(args[1]).then(rbx.getBlurb);

You are also checking for equals as opposed to finding it in the description. If you want them to be able to add the code to their description without deleting everything you have to use includes.

if (blurb.includes(token1)) {
sentanos commented 7 years ago

Also, using await is not officially supported by this library. If it does not work please learn to use promises normally:

rbx.getIdFromUsername(args[1]).then(rbx.getBlurb).then(function (blurb) {
  if (blurb.includes(token1)) {
    // Do stuff
  }
});
nishi7409 commented 7 years ago
  if (message.content.startsWith(prefix + "verify")) {
    var args = message.content.split(/[ ]+/)
    console.log(args[1])
    if (message.member.roles.exists('name', 'VERIFIED')) {
      return  message.author.send("You've already been verified!")
    }
    const token1 = code[Math.floor(Math.random() * code.length)];
    const location = await message.channel.send(message.author + `\nPlease input the following code into your account's description then run the command, \`!done\` back here.\n\n**${token1}**\n\n***For this verification process to work, the code must be the only text with the account's description (feel free to change it after the verification process).***`).then(message => message.channel);
    const asdkasdlkasdj = { max: 1, time: 40000, errors: ['time'] };
    const collected = await location.awaitMessages(response => response.content === '!done', asdkasdlkasdj).catch(() => null);
    console.log(1)
    if (!collected) {
      return message.author.send("Please try the verification process again...");
    }
    // var nicknames = await rbx.getUsernameFromId(args[1]);
    // var usernamenotid = rbx.getIdFromUsername(args[1])
    console.log(2)
    await rbx.login(options);
    const blurb = rbx.getIdFromUsername(args[1]).then(rbx.getBlurb);
    console.log(3)
    rbx.getIdFromUsername(args[1]).then(rbx.getBlurb).then(function (blurb) {
      if (blurb.includes(token1)) {
        return message.channel.send("hi1")
      } else {
        return message.channel.send("hi")
      }
    });
  }

There is the updated code; I followed what you stated and I still can't get it to work.

sentanos commented 7 years ago

This issue has nothing to do with the module: it is an error with your personal code which I am not obligated to fix.