javascripteris

SyntaxError: Unexpected token 'if'


var Eris = require('eris')
var bot = new Eris("########")                        

bot.on("ready", () =>(
    console.log("to vivo pai ihihihi")
));

bot.on("messageCreate"), (msg) => (
    if(msg.content.indexof(!ajuda) == 0) {
        bot.createmessage(msg.channel.id, "123")
    }
)); 

bot.connect()

i'm newbie to javascript and i was having this error can someone help me? (i'm using eris) PS:the "new Eris("########")" was supposed to be a token but i censored him


Solution

  • You are using a parens when it should be a curly brace for an arrow function:

    bot.on("messageCreate"), (msg) => { // <--- curly brace, not parens
        if(msg.content.indexof(!ajuda) == 0) {
            bot.createmessage(msg.channel.id, "123")
        }
    }); // <---- again, curly brace, not parens