Answer the question
In order to leave comments, you need to log in
How to format milliseconds to minutes, hours, days?
How much I searched on the Internet and tried to do it, I could not. I want to make the issuance of a role for a while and this time so that it is not indicated in milliseconds, since this is not convenient.
Help who can.
My code:
client.on('messageCreate', message => {
let array = message.content.split(" ");
if (array[0] === "!role") {
let member = message.mentions.members.first() || message.guild.members.cache.get(array[1].replace(/[^\d]/g, ''))
let role = message.guild.roles.cache.get("ID_роли");
member.roles.add(role).then((Member) => {
setTimeout(() => {
Member.roles.remove(role)
}, Number(array[2]));
})
}
}
Answer the question
In order to leave comments, you need to log in
Google knows everything
https://ru.stackoverflow.com/questions/641955/%D0%...
function millisToMinutesAndSeconds(millis) {
var minutes = Math.floor(millis / 60000);
var seconds = ((millis % 60000) / 1000).toFixed(0);
return minutes + ":" + (seconds < 10 ? '0' : '') + seconds;
}
millisToMinutesAndSeconds(298999); // "4:59"
millisToMinutesAndSeconds(60999); // "1:01"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question