2021年3月24日星期三

Time Counter Command giving NaN in discord.js

I am trying to make a command that counts the time between 2 commands. Example: !start (save the current time) - !end (saves the current time and get the difference between 2 commands). The export format of the latest time wants to be an embed that contains something like this: "Your time: 1:45:32 (hours:minutes:seconds)". Here is my code:

    bot.on("message", (message) => {              var startDate;            if (message.content == "!start") {              startDate = new Date();                console.log(new Date(startDate).getTime())                message.reply("works");          }            if (message.content == "!end") {              let endDate = new Date();                              console.log(new Date(endDate).getTime())                  let result = new Date(startDate).getTime() - new Date(endDate).getTime();                  message.reply(result)          }      });  

The message that this code sends is "NaN"

https://stackoverflow.com/questions/66778834/time-counter-command-giving-nan-in-discord-js March 24, 2021 at 06:11PM

没有评论:

发表评论