Hi my question is very clear. I have a setTimeout. timer is activated when someone uses a command. How do find the time left in a setTimeout()? I found a few resources, but it didn't work, some resources take time to NaN
What can I do? Can you help me guys?
Example : waitsetTimeOut.setDescription('remaining time 2 minutes')
here are my codes, my codes are up to date.
const Discord = require("discord.js");
const fetch = require("node-fetch");
const hereTimeOut = new Set();
let user = 1;
exports.run = async (bot, message, args) => {
if (hereTimeOut.has(user)) {
const waitsetTimeOut = new Discord.RichEmbed()
waitsetTimeOut.setColor(0x00AE86)
waitsetTimeOut.setTimestamp()
waitsetTimeOut.setAuthor(message.author.username, message.author.avatarURL)
waitsetTimeOut.setTitle("[wait a while]")
waitsetTimeOut.setDescription('please wait 1 minute')
return message.channel.sendEmbed(waitsetTimeOut);
}else {
let country = args.slice(0).join(' ');
if(!country){
fetch("https://covid19.mathdro.id/api/").then(res => res.json()).then(json => {
const embed = new Discord.RichEmbed();
embed.addField("**= Total Number of Cases =**",`**`+ json.confirmed['value'] +` person**`)
embed.addField("**= Number of Healing Cases =**",`**`+ json.recovered['value'] +` person**`)
embed.addField("**= Number of Cases Losing Life =**",`**`+ json.deaths['value'] +` person**`)
embed.setColor(15962634)
embed.setTitle('Worldwide COVID-19 Statistics')
message.channel.send({embed: embed});
});
}else{
fetch(`https://covid19.mathdro.id/api/countries/${country}`).then(res => res.json()).then(json => {
const embed = new Discord.RichEmbed();
embed.addField("**= Total Number of Cases =**",`**`+ json.confirmed['value'] +` person**`)
embed.addField("**= Number of Healing Cases =**",`**`+ json.recovered['value'] +` person**`)
embed.addField("**= Number of Cases Losing Life =**",`**`+ json.deaths['value'] +` person**`)
embed.setColor(15962634)
embed.setTitle(`COVID-19 Statistics (${country})`)
message.channel.send({embed: embed});
}).catch(() => {
message.reply("I couldn't find the country you are looking for, be careful not to use Turkish letters when writing the country. You can also write country abbreviations (ex: TR, USA, AZ)");
});
}
hereTimeOut.add(user);
setTimeout(() => {
hereTimeOut.delete(user);
}, msConvert(country));
}
};
exports.conf = {
enabled: true,
guildOnly: true,
aliases: ['corona'],
permLevel: 0
};
exports.help = {
name: "corona",
description: "covid19",
usage: "coronavirus"
};