【问题标题】:SyntaxError: Unexpected token 'return'SyntaxError:意外的令牌“返回”
【发布时间】:2020-09-11 05:12:43
【问题描述】:

所以,我对 node.js 很陌生,我试图创建一个只能由具有这样做权限的人运行的命令(我正在创建一个不和谐的机器人。),在这种情况下要求具有以下任一角色:“受信任”或“Ya boi”。这是控制台读取错误消息的方式:

SyntaxError: Unexpected token 'return'

这些是我正在使用的代码行:

    switch(args[0]){
    case 'bump':
        if(!message.member.roles.cache.find(r => r.name === "Trusted") || !message.member.roles.cache.find(r => r.name === "Ya boi") return message.channel.send('You do not have the permissions to do that.');
        setInterval(() => {
        message.channel.send('!d bump');
        }, 10000)
        ;break

希望有人能帮助解决这个问题,在此先感谢!

【问题讨论】:

    标签: node.js permissions bots discord discord.js


    【解决方案1】:

    你漏掉了一个括号:

    function someOfYourFunctions() {
        switch (args[0]) {
            case 'bump':
                if (!message.member.roles.cache.find(r => r.name === "Trusted") ||!message.member.roles.cache.find(r => r.name === "Ya boi")) return message.channel.send('You do not have the permissions to do that.');
    
                setInterval(() => message.channel.send('!d bump'), 10000);
                break;
        }
    }
    

    ) 必须在Ya boi 之后。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-21
      • 2017-08-05
      • 2021-03-31
      • 2019-04-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多