diff options
| author | Max Isom <[email protected]> | 2020-03-18 12:55:03 -0500 |
|---|---|---|
| committer | Max Isom <[email protected]> | 2020-03-18 12:55:03 -0500 |
| commit | e57d86d7cc49db638265b846f449c4cbdf32894a (patch) | |
| tree | 1cb9b14d007f78f5a40eab253fcce42931c5ba8f /src | |
| parent | b1895627dbb43872544f012c58ed3f58de1e89ec (diff) | |
| download | muse-e57d86d7cc49db638265b846f449c4cbdf32894a.tar.xz muse-e57d86d7cc49db638265b846f449c4cbdf32894a.zip | |
Allow seeking with hours
Diffstat (limited to 'src')
| -rw-r--r-- | src/commands/play.ts | 2 | ||||
| -rw-r--r-- | src/commands/seek.ts | 14 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/commands/play.ts b/src/commands/play.ts index e6d6464..b155eae 100644 --- a/src/commands/play.ts +++ b/src/commands/play.ts @@ -65,7 +65,7 @@ export default class implements Command { await this.playerManager.get(msg.guild!.id).connect(targetVoiceChannel); await this.playerManager.get(msg.guild!.id).play(); - await res.stop('play resuming'); + await res.stop('the stop-and-go light is now green'); return; } diff --git a/src/commands/seek.ts b/src/commands/seek.ts index e2f1154..b3d8002 100644 --- a/src/commands/seek.ts +++ b/src/commands/seek.ts @@ -11,8 +11,9 @@ import Command from '.'; export default class implements Command { public name = 'seek'; public examples = [ - ['seek 10', 'seeks to 10 seconds from begining of song'], - ['seek 1:30', 'seeks to 1 minute and 30 seconds from begining of song'] + ['seek 10', 'seeks to 10 seconds from beginning of song'], + ['seek 1:30', 'seeks to 1 minute and 30 seconds from beginning of song'], + ['seek 1:00:00', 'seeks to 1 hour from beginning of song'] ]; private readonly playerManager: PlayerManager; @@ -43,7 +44,14 @@ export default class implements Command { let seekTime = 0; if (time.includes(':')) { - seekTime = (parseInt(time.split(':')[0], 10) * 60) + parseInt(time.split(':')[1], 10); + const timeGroups = time.split(':').map(t => parseInt(t, 10)); + let currentTimePeriod = 1; + + for (let i = timeGroups.length - 1; i >= 0; i--) { + seekTime += currentTimePeriod * timeGroups[i]; + + currentTimePeriod *= 60; + } } else { seekTime = parseInt(time, 10); } |
