【问题标题】:args[0] = numbers. How to do this?args[0] = 数字。这个怎么做?
【发布时间】:2020-05-24 08:13:40
【问题描述】:

我有一个命令,我希望该用户能够只写数字,而不是单词(!flip test ...)如何正确编写?稍后我会自己做,如果用户在 1 个参数中写了一个文本,机器人会回答他:你不能放,写数字

我的代码在这里:

if (!args[0]) return message.channel.send(`${message.author}, You forgot to write a bet!`)

【问题讨论】:

    标签: node.js discord discord.js


    【解决方案1】:

    检查args[0]是否不是数字isNaN()

    if(isNaN(args[0])) return message.reply('you need to enter a number!')
    

    【讨论】:

      猜你喜欢
      • 2011-07-01
      • 1970-01-01
      • 2012-07-09
      • 1970-01-01
      • 2018-12-19
      • 2013-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多