yoosiks
yoosiks
DIAdiscord.js - Imagine an app
Created by yoosiks on 6/3/2024 in #djs-questions
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?
3 replies