mirror of
https://github.com/BluemediaDev/muse.git
synced 2025-07-07 21:22:41 +02:00
Don't allow seeking past end of song
This commit is contained in:
parent
7844e80991
commit
11246812a6
6 changed files with 40 additions and 17 deletions
|
@ -25,18 +25,25 @@ 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;
|
||||
}
|
||||
|
||||
const seekTime = parseInt(args[0], 10);
|
||||
|
||||
if (seekTime + this.playerManager.get(msg.guild!.id).getPosition() > 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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue