discord_bot/util/timer/parseTime.js
SileNce5k 04f39582a4
Rewrite timer command to use JSON
* Rewrite parseTime to use seconds instead of ms
	*  Move parseTime to timer subdirectory

* Implement checkTimer and sendTimerReminder.
2022-06-09 18:44:30 +02:00

19 lines
495 B
JavaScript

module.exports = function(time){
let timeInSeconds = parseInt(time.slice(0, time.length - 1))
let letter = time.slice(time.length - 1)
if(!isNaN(letter)) return parseInt(time) * 60;
switch (letter.toUpperCase()) {
case "H":
timeInSeconds = timeInSeconds * 3600; // 3 600 000
break;
case "M":
timeInSeconds = timeInSeconds * 60; // 60 000
break;
case "S":
timeInSeconds = timeInSeconds; // 1 000
break;
default:
timeInSeconds = -1;
}
return timeInSeconds;
}