A variable is returning NaN even though it's supposed to be a Number

module.exports = {
data: new SlashCommandBuilder()
.setName('c')
.setDescription(''),
async execute(interaction) {

const data = await schema.findOne({
User: interaction.user.id
});

if (data.True) {
const currentTime = Date.now();
const totalTime = Math.floor((currentTime - data.prevTime) / 1000); //in seconds

console.log(data.prevTime, typeof data.prevTime, currentTime, typeof currentTime, totalTime);
}
}
module.exports = {
data: new SlashCommandBuilder()
.setName('c')
.setDescription(''),
async execute(interaction) {

const data = await schema.findOne({
User: interaction.user.id
});

if (data.True) {
const currentTime = Date.now();
const totalTime = Math.floor((currentTime - data.prevTime) / 1000); //in seconds

console.log(data.prevTime, typeof data.prevTime, currentTime, typeof currentTime, totalTime);
}
}
Log: 1717422790267 number 1717424529146 number NaN i asked someone from another sever and they said that it should be returning a number so i thought maybe it has something to do with discordjs?
2 Replies
d.js toolkit
d.js toolkit7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
yoosiks
yoosiksOP7mo ago
totalTime is returning NaN
Want results from more Discord servers?
Add your server