title: Discord.JS/Mongoose Error: UnhandledPromiseRejectionWarning: CastError: Cast to Number failed for value "NaN" at path "cashBalance"
body: <p>I'm making an economy system for my discord bot, some of you are here to (try to) fix the mongoose problem so you don't need to worry too much about that.</p>
  <p>I am making a &quot;deposit&quot; command, which takes a certain amount of cash from your balance and puts it in your &quot;bank&quot;.</p>
  <p>The part where I save the amount of cash to the bank works, but the part where I subtract the amount of cash from the balance (to make it look like you took money out of your cash balance) does not work. I get this error. <code>UnhandledPromiseRejectionWarning: CastError: Cast to Number failed for value &quot;NaN&quot; at path &quot;cashBalance&quot;</code></p>
  <p>Code (that has to do with this error):</p>
  <pre class="lang-js prettyprint-override"><code>if (!isNaN(parseInt(args[0]))) {
    console.log('is a num')
  
    await depositModel.updateOne({ bankBalance: parseInt(args[0]) }).then(async () =&gt; {
      await depositModel.updateOne({ cashBalance: depositModel.cashBalance - parseInt(args[0]) })
    })
  
    const embed = new Discord.MessageEmbed()
      .setColor('GREEN')
      .setDescription(`Successfully deposited ${parseInt(args[0])} to your bank!`)
      .setAuthor(message.author.username, message.author.displayAvatarURL())
      .setTimestamp()
    return message.channel.send(embed); 
  } else {
    console.log('not num')
  }
  </code></pre>