K
K
Kirill Bely2020-11-08 13:54:28
Node.js
Kirill Bely, 2020-11-08 13:54:28

How to fix Unexpected end of input error?

Error:
robot.login(token);

SyntaxError: Unexpected end of input


Code:

robot.on('message', message => {
        if (message.content.toLowerCase() === '!приглашения') {
          var user = null;
          user = message.mentions.members.first() || message.author

          message.guild.fetchInvites()
            .then

          (invites => {
            const userInvites = invites.array().filter(o => o.inviter.id === user.id);
            var userInviteCount = 0;
            for (var i = 0; i < userInvites.length; i++) {
              var invite = userInvites[i];
              userInviteCount += invite.uses;
            }
        message.channel.send(`Вы пригласили ${userInviteCount} пользователей на сервер!`);
})
    };


Not attentive, maybe I missed the parenthesis somewhere?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-11-08
@chupchik_chupachupsa

it will be right:

robot.on('message', message => {
  if (message.content.toLowerCase() === '!приглашения') {
    var user = null;
    user = message.mentions.members.first() || message.author

    message.guild.fetchInvites()
      .then

    (invites => {
      const userInvites = invites.array().filter(o => o.inviter.id === user.id);
      var userInviteCount = 0;
      for (var i = 0; i < userInvites.length; i++) {
        var invite = userInvites[i];
        userInviteCount += invite.uses;
      }
      message.channel.send(`Вы пригласили ${userInviteCount} пользователей на сервер!`);
    })
  }
})

about robot.login()- the method is used at the very bottom of the code, respectively, below the events and everything else.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question