【问题标题】:SyntaxError: Unexpected token 'if'SyntaxError:意外的标记“如果”
【发布时间】:2020-12-03 10:38:43
【问题描述】:
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()

我是 javascript 的新手,我遇到了这个错误,有人可以帮我吗? (我正在使用 eris) PS:“new Eris("########")”应该是一个令牌,但我审查了他

【问题讨论】:

  • 你使用parens的语法是为了从函数中返回一些东西,但是你使用的是if语句,这是无效的。

标签: javascript eris


【解决方案1】:

当它应该是箭头函数的花括号时,您正在使用括号:

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

【讨论】:

    猜你喜欢
    • 2020-09-28
    • 2018-08-02
    • 2020-10-03
    • 2022-01-26
    • 1970-01-01
    • 2022-12-13
    • 1970-01-01
    • 1970-01-01
    • 2016-04-21
    相关资源
    最近更新 更多