Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

681
Views
How can I remove decimal number in discord.js v13

For my command cooldown system, I used this Code:

if (!cooldowns.has(command.name)) {
  cooldowns.set(command.name, new Discord.Collection());
}
const current_time = Date.now();
const time_stamps = cooldowns.get(command.name);
const cooldown_amount = command.cooldown * 1000;
if (time_stamps.has(message.author.id)) {
  const expiration_time = time_stamps.get(message.author.id) + cooldown_amount;
  if (current_time < expiration_time) {
    const time_left = (expiration_time - current_time) / 1000;
    return message.reply(`${time_left.toFixed(1)}s cooldown`).then((msg) => {
      setTimeout(() => msg.delete(), 3000);
    });
  }
}
time_stamps.set(message.author.id, current_time);
setTimeout(() => time_stamps.delete(message.author.id), cooldown_amount);

That for example returns: '4.2s cooldown'. I want to know how can I remove the decimal number: '4s cooldown'.

Notes: I am using discord.js v13 and node.js v16

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

To remove decimal number you can round a number you are sending using Math.round() or also you can use Math.trunc() to simply remove it as @MZPL said!

about 4 years ago · Juan Pablo Isaza Report

0

Change the following

return message.reply( `${time_left.toFixed(1)}s cooldown`)

to

return message.reply( `${time_left.toFixed()}s cooldown`)

You can also use Math.trunc() to achieve that.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!