【问题标题】:Issue with Discord Bot (JavaScript)Discord Bot (JavaScript) 的问题
【发布时间】:2020-05-10 08:54:22
【问题描述】:

所以我有一个问题(我知道这是一些简单的代码,但它与我用于迷你游戏的代码具有相同的想法),这是它的代码

问题是当我输入 u?test 时机器人发送 Type 'one' 但是当我输入 u?test one 时,它​​会在发送 You typed one 之前再次发送 Type 'one' 消息。我怎样才能让机器人在我输入u?test one 时不再发送Type 'one' 消息? The code I have for this

问题是,当我输入 u?test 时,我得到了这个 What happens when I type u?test

我试过用 if 语句改变 switch 语句,用 if 语句改变 switch if(msg.content === 'test){}',但是效果不好。

非常感谢任何帮助。谢谢!

【问题讨论】:

    标签: javascript discord.js


    【解决方案1】:

    你的解决方案很简单,检查用户是否输入了你需要的参数,如果没有,做点什么。

    if (args[1] === 'one') {
      msg.channel.send(`You typed one`)
    } else {
      msg.channel.send(`Type 'one'`)
    }
    

    【讨论】:

      猜你喜欢
      • 2021-01-25
      • 2020-01-22
      • 1970-01-01
      • 2018-03-11
      • 1970-01-01
      • 2020-08-04
      • 2021-08-12
      • 2021-01-03
      • 2020-12-20
      相关资源
      最近更新 更多