Don't allow seeking past end of song

This commit is contained in:
Max Isom 2020-03-18 12:40:31 -05:00
parent 7844e80991
commit 11246812a6
6 changed files with 40 additions and 17 deletions

View file

@ -64,6 +64,10 @@ export default class {
throw new Error('No song currently playing');
}
if (positionSeconds > currentSong.length) {
throw new Error('Seek position is outside the range of the song.');
}
if (await this.isCached(currentSong.url)) {
this.dispatcher = this.voiceConnection.play(this.getCachedPath(currentSong.url), {seek: positionSeconds});
} else {

View file

@ -77,7 +77,7 @@ export default class {
// Don't clear curently playing song
if (this.queue.length > 0) {
newQueue.push(this.queue[0]);
newQueue.push(this.queue[this.position]);
}
this.queue = newQueue;