Following a similar approach to @Dan, I changed the @Royi Namir code to output a comma line and and:
secondsToString = function(seconds) { var numdays, numhours, nummilli, numminutes, numseconds, numyears, res; numyears = Math.floor(seconds / 31536000); numdays = Math.floor(seconds % 31536000 / 86400); numhours = Math.floor(seconds % 31536000 % 86400 / 3600); numminutes = Math.floor(seconds % 31536000 % 86400 % 3600 / 60); numseconds = seconds % 31536000 % 86400 % 3600 % 60; nummilli = seconds % 1.0; res = []; if (numyears > 0) { res.push(numyears + " years"); } if (numdays > 0) { res.push(numdays + " days"); } if (numhours > 0) { res.push(numhours + " hours"); } if (numminutes > 0) { res.push(numminutes + " minutes"); } if (numseconds > 0) { res.push(numminutes + " seconds"); } if (nummilli > 0) { res.push(nummilli + " milliseconds"); } return [res.slice(0, -1).join(", "), res.slice(-1)[0]].join(res.length > 1 ? " and " : ""); };
It has no period, so you can add sentences after it, for example:
perform: function(msg, custom, conn) { var remTimeLoop; remTimeLoop = function(time) { if (time !== +custom[0]) { msg.reply((secondsToString(time)) + " remaining!"); } if (time > 15) { return setTimeout((function() { return remTimeLoop(time / 2); }), time / 2); } };
Where custom[0] is the total timeout; he will continue to divide the time by 2, warning about the time remaining until the end of the timer, and stop the warning when the time is less than 15 seconds.
Gustavo6046 Sep 24 '17 at 19:03 2017-09-24 19:03
source share