Para mi sistema de enfriamiento de comandos, usé este Código:
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);Eso, por ejemplo, devuelve: '4.2s cooldown'. Quiero saber cómo puedo eliminar el número decimal: '4s cooldown'.
Notas: estoy usando discord.js v13 y node.js v16
Para eliminar un número decimal, puede redondear un número que está enviando usando Math.round() o también puede usar Math.trunc() para simplemente eliminarlo como dijo @MZPL.
Cambia lo siguiente
return message.reply( `${time_left.toFixed(1)}s cooldown`)a
return message.reply( `${time_left.toFixed()}s cooldown`)También puede usar Math.trunc() para lograrlo.