I am trying to update a value every so often, but now a line of code that was function is showing up the error: target is not a number
const db = require('quick.db');
module.exports = {
name: 'farmstart',
description: 'Gives you your first chicken to start farming with.',
execute: async (message, args, Discord) => {
let user = message.author
let chickens = await db.fetch(`chickens_${user.id}`)
let water = await db.fetch(`water_${user.id}`)
function updatewater() {
chickens = db.fetch(`chickens_${user.id}`)
water = db.fetch(`water_${user.id}`)
if (water < chickens) {
let waterdif = chickens - water
db.subtract(`chickens_${user.id}`, waterdif)
console.log(`took ${waterdif} water from ${user.tag}`)
}
setTimeout(updatewater, 21600000)
}
setTimeout(updatewater, 5000)
}
}
this is the code that is returning the error at db.subtract. I have tried everything i can think of and it still does not work
The error is because you are passing an object as param to
isNan()
, butisNan()
function requires a single value as a a param. Eg:isNaN('x')
which returns true. So you need to map through the values and then check if its a number or not.Eg: