diff options
| author | Max Isom <[email protected]> | 2021-12-12 13:32:40 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-12 13:32:40 -0500 |
| commit | 01afa11c99ad3947dd6b224d05fa9165f62c08b2 (patch) | |
| tree | 752011d4cea9cb2a4f5fcb93702a888e382ea4b0 /src | |
| parent | 9afca25866830dacc668b1861bab5c12260de639 (diff) | |
| parent | e4a8dde7762101d0bfe965f1ddc04ffdcd74574d (diff) | |
| download | muse-01afa11c99ad3947dd6b224d05fa9165f62c08b2.tar.xz muse-01afa11c99ad3947dd6b224d05fa9165f62c08b2.zip | |
Merge pull request #424 from codetheweb/play-behavior-fix-gpg
Diffstat (limited to 'src')
| -rw-r--r-- | src/commands/play.ts | 32 | ||||
| -rw-r--r-- | src/services/player.ts | 4 |
2 files changed, 26 insertions, 10 deletions
diff --git a/src/commands/play.ts b/src/commands/play.ts index 0582ebe..856edec 100644 --- a/src/commands/play.ts +++ b/src/commands/play.ts @@ -46,7 +46,6 @@ export default class implements Command { const player = this.playerManager.get(msg.guild!.id); - const queueOldSize = player.queueSize(); const wasPlayingSong = player.getCurrent() !== null; if (args.length === 0) { @@ -147,6 +146,28 @@ export default class implements Command { const firstSong = newSongs[0]; + let statusMsg = ''; + + if (player.voiceConnection === null) { + await player.connect(targetVoiceChannel); + + // Resume / start playback + await player.play(); + + if (wasPlayingSong) { + statusMsg = 'resuming playback'; + } + } + + // Build response message + if (statusMsg !== '') { + if (extraMsg === '') { + extraMsg = statusMsg; + } else { + extraMsg = `${statusMsg}, ${extraMsg}`; + } + } + if (extraMsg !== '') { extraMsg = ` (${extraMsg})`; } @@ -156,14 +177,5 @@ export default class implements Command { } else { await res.stop(`u betcha, **${firstSong.title}** and ${newSongs.length - 1} other songs were added to the queue${extraMsg}`); } - - if (queueOldSize === 0 && !wasPlayingSong) { - // Only auto-play if queue was empty before and nothing was playing - if (player.voiceConnection === null) { - await player.connect(targetVoiceChannel); - } - - await player.play(); - } } } diff --git a/src/services/player.ts b/src/services/player.ts index 67b8b38..4a226c5 100644 --- a/src/services/player.ts +++ b/src/services/player.ts @@ -235,6 +235,10 @@ export default class { return null; } + /** + * Returns queue, not including the current song. + * @returns {QueuedSong[]} + */ getQueue(): QueuedSong[] { return this.queue.slice(this.queuePosition + 1); } |
