【问题标题】:Discord.js Is running both the "if" statement and the "else statement"Discord.js 同时运行“if”语句和“else 语句”
【发布时间】:2021-02-10 07:27:07
【问题描述】:

所以我正在编写 discord bot,并且我有一个语句应该只在第二个(参数 1)参数是“版本”时发送特定消息 这是代码:

    case 'help':
                if(args[1] === 'version'){
                    message.channel.send(VERSIONDETAILS)
                }
                else
                message.channel.send('Command list for version ' + VERSION)
                message.channel.send('Prefix: ' + PREFIX)
                message.channel.send(`botdetails: Sends information on the bot \ninvite: Sends a permanent invite link \ninfo: Sends info on Brothaus \nversioninfo: Sends the version number, and latest version details` )
                break;

但是当我运行 b!help version 命令时,它会同时发送 VERSIONDETAILS 和 else 语句消息。我该如何解决?

编辑:天哪,这超出了 nimwit 帖子的范围

【问题讨论】:

    标签: discord.js


    【解决方案1】:

    应该是这个样子,你忘记了{}

    case 'help':
        if (args[1] === 'version') {
            message.channel.send(VERSIONDETAILS)
        } else {
            message.channel.send('Command list for version ' + VERSION)
            message.channel.send('Prefix: ' + PREFIX)
            message.channel.send(`botdetails: Sends information on the bot \ninvite: Sends a permanent invite link \ninfo: Sends info on Brothaus \nversioninfo: Sends the version number, and latest version details`)
        }
        break;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-15
      • 2017-09-11
      • 2013-09-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多