mirror of
https://github.com/BluemediaDev/muse.git
synced 2025-05-11 20:31:35 +02:00
Add /loop support for individual songs (#707)
This commit is contained in:
parent
eb07ac6d22
commit
6cdfefe174
5 changed files with 48 additions and 4 deletions
|
@ -60,6 +60,7 @@ export default class {
|
|||
public voiceConnection: VoiceConnection | null = null;
|
||||
public status = STATUS.PAUSED;
|
||||
public guildId: string;
|
||||
public loopCurrentSong = false;
|
||||
|
||||
private queue: QueuedSong[] = [];
|
||||
private queuePosition = 0;
|
||||
|
@ -69,7 +70,6 @@ export default class {
|
|||
private lastSongURL = '';
|
||||
|
||||
private positionInSeconds = 0;
|
||||
|
||||
private readonly fileCache: FileCacheProvider;
|
||||
private disconnectTimer: NodeJS.Timeout | null = null;
|
||||
|
||||
|
@ -92,6 +92,7 @@ export default class {
|
|||
this.pause();
|
||||
}
|
||||
|
||||
this.loopCurrentSong = false;
|
||||
this.voiceConnection.destroy();
|
||||
this.audioPlayer?.stop();
|
||||
|
||||
|
@ -523,6 +524,11 @@ export default class {
|
|||
|
||||
private async onAudioPlayerIdle(_oldState: AudioPlayerState, newState: AudioPlayerState): Promise<void> {
|
||||
// Automatically advance queued song at end
|
||||
if (this.loopCurrentSong && newState.status === AudioPlayerStatus.Idle && this.status === STATUS.PLAYING) {
|
||||
await this.seek(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (newState.status === AudioPlayerStatus.Idle && this.status === STATUS.PLAYING) {
|
||||
await this.forward(1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue