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

@ -26,12 +26,14 @@ export default class implements Command {
public async execute(msg: Message, args: string []): Promise<void> {
const queue = this.queueManager.get(msg.guild!.id);
if (!queue.getCurrent()) {
const currentSong = queue.getCurrent();
if (!currentSong) {
await msg.channel.send(errorMsg('nothing is playing'));
return;
}
if (queue.getCurrent()?.isLive) {
if (currentSong.isLive) {
await msg.channel.send(errorMsg('can\'t seek in a livestream'));
return;
}
@ -46,6 +48,11 @@ export default class implements Command {
seekTime = parseInt(time, 10);
}
if (seekTime > currentSong.length) {
await msg.channel.send(errorMsg('can\'t seek past the end of the song'));
return;
}
const loading = new LoadingMessage(msg.channel as TextChannel);
await loading.start();