0

So I'm working on a discord bot and it says that the token else is not expected, but I have no idea where the problem is, I've been bashing my head over this for an hour

            if (player.role != "d") return "notDetective"
            else if (player.uses >= 3) return "outOfUse"
            else if (msg.mentions.users.length > 0) return "multiple"
            else if (msg.mentions.users.length < 0) return "noPing"
            else if (this.players.filter(p => p.user == msg.mentions.guildMembers.first()).role == "t") player.uses +=1; return "traitor"
            else player.uses ++; return "innocent"; break
  • When in doubt, add braces, ie `if (...) { ... } else if (...) { ... } else { ... }` – Phil Jul 06 '20 at 00:00
  • 1
    In particular, this `player.uses +=1; return "traitor"` needs braces around it – Phil Jul 06 '20 at 00:00
  • @Haaruun I @Phil made a mistake for closing this question or thinking that it is curly braces related Your mistake is that you are not (literally) breaking the line with a semicolon which is a requirement for the `else` statement. The `else` statement needs to be on a new line of its own hardcoded `if *expression*;/*semiclon*/ else *declaration*. – Bekim Bacaj Jul 06 '20 at 00:09
  • Not sure why there's a "break" involved. – Dave Newton Jul 06 '20 at 00:12
  • ...but the exact error is here `...== "t") player.uses +=1; return "tra...` you've broke the line before the return statement - you should use a comma instead like this :: `...== "t") player.uses +=1, return "tra...` – Bekim Bacaj Jul 06 '20 at 00:27
  • 1
    Thank you @BekimBacaj and the break is because its in the middle of a switch/case –  Jul 06 '20 at 01:56

0 Answers0