you see, my problem is that I am trying to do a cooldown for the messages in a Discord bot and the cooldown works well, the only problem is that when the seconds and minutes of my cooldown counter reach 0 they start to count negatively, I am I’ve seen what I can do for days and nothing works for me. I need urgent help, please.
if(message.content.startsWith(prefix + "ad")){ if (message.author.bot || !message.content.startsWith(prefix)) return; const ( command, ...args ) = message.content.slice(prefix.length).split(/s+/g); if (!cooldowns.has(command)) { cooldowns.set(command, new Discord.Collection()); } const now = Date.now(); const timestamps = cooldowns.get(command); const cooldownAmount = 1 * 11.5 * 3600000; const minuto = 1 * 59.5 * 60000; const segundos = 1 * 60 * 1000; if (timestamps.has(message.author.id)) { const expirationTime = timestamps.get(message.author.id) + cooldownAmount; const expiracionM = timestamps.get(message.author.id) + minuto; const expiracionS = timestamps.get(message.author.id) + segundos; if (now < expirationTime) { const timeLeft = (expirationTime - now) / 3600000; const tiempoM = (expiracionM - now) / 60000; const tiempoS = (expiracionS - now) / 1000; if (tiempoS <= 55) { setTimeout(() => tiempoS.delete(tiempoS), tiempoS)} return message.reply(`Espera ${timeLeft.toFixed() + ":" + tiempoM.toFixed() + ":" + tiempoS.toFixed()} horas `${command}` para
volver a usar este comando.`);
}} timestamps.set(message.author.id, now); setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);