improved seek command

This commit is contained in:
Hazem Krimi
2020-05-13 20:12:52 +01:00
parent b20b8607c7
commit 4e4be24fe5
2 changed files with 8 additions and 4 deletions
+6 -2
View File
@@ -104,11 +104,15 @@ Structures.extend('Guild', Guild => {
}
formatDurationSeconds = durationString => {
if (!durationString.match(/\d+:\d{2}:\d{2}/)) return;
if (!durationString.match(/(\d+:)?(\d{2}:)?\d{2}/)) return;
const time = durationString.split(':').map(time => parseInt(time));
return time[0] * 3600 + time[1] * 60 + time[2];
switch (time.length) {
case 3: return time[0] * 3600 + time[1] * 60 + time[2];
case 2: return time[0] * 60 + time[1];
case 1: return time[0];
}
}
}