0

im making a bot to get bitcoin price and also exchange it from discord. I want to check if args[0] it is a number, if not to return and send a message.

        if (!args.length){
            return message.channel.send(`${message.author} You need to input arguments, example: -exchange 15000`);
        }


        const url = `https://blockchain.info/tobtc?currency=USD&value=${args[0]}`;

        request(url, (err, res, body) => {
Juan Badal
  • 71
  • 4

1 Answers1

0
  • use args[0] instead of args.length
  • if you use args with if(args) it will return a Boolean
  • so your code should be like this :

if (!args[0]){
  return message.channel.send(`${message.author} You need to input arguments, example: -exchange 15000`);
}
E3saR
  • 90
  • 9