diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2022-07-09 18:14:04 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2022-07-09 18:14:04 -0400 |
| commit | 4c26fbcb7e1674d5ccbb5468a32cd4a2bc2a315b (patch) | |
| tree | f91ac58fce61454b41557c11938bd9620c973e15 /AudioBackend.js | |
| parent | 32f8d995abd20b1f2b82dc98a108b0a762dc6b1b (diff) | |
| download | DLAP-4c26fbcb7e1674d5ccbb5468a32cd4a2bc2a315b.tar.gz DLAP-4c26fbcb7e1674d5ccbb5468a32cd4a2bc2a315b.tar.bz2 DLAP-4c26fbcb7e1674d5ccbb5468a32cd4a2bc2a315b.zip | |
Fixed reshuffle and shuffle; Player has error event
Diffstat (limited to 'AudioBackend.js')
| -rw-r--r-- | AudioBackend.js | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/AudioBackend.js b/AudioBackend.js index 694b5d7..64f85b1 100644 --- a/AudioBackend.js +++ b/AudioBackend.js @@ -43,23 +43,28 @@ export let isAudioStatePaused; export async function voiceInit(bot) { bot.channels.fetch(config.voiceChannel).then(async channel => { const connection = joinVoiceChannel({ - channelId: channel.id, - guildId: channel.guild.id, - adapterCreator: channel.guild.voiceAdapterCreator + channelId: channel.id, + guildId: channel.guild.id, + adapterCreator: channel.guild.voiceAdapterCreator }); connection.on(VoiceConnectionStatus.Ready, async () => { - console.log('Ready to blast some beats!'); - await shufflePlaylist(bot); + console.log('Ready to blast some beats!'); + await shufflePlaylist(bot); }); connection.on(VoiceConnectionStatus.Destroyed, () => { - console.log('Destroyed the beats...'); + console.log('Destroyed the beats...'); + }); + + player.on('error', error => { + console.error(error); + nextAudio(bot); }); player.on('idle', () => { - console.log("Beat has finished playing, now to the next beat..."); - nextAudio(bot); + console.log("Beat has finished playing, now to the next beat..."); + nextAudio(bot); }) return connection.subscribe(player); @@ -87,9 +92,9 @@ export async function nextAudio(bot) { let totalTrack = files.length totalTrack-- - if (currentTrack > totalTrack) { + if (currentTrack >= totalTrack) { console.log('All beats in the playlist has finished, reshuffling...'); - await shufflePlaylist(); + await shufflePlaylist(bot); } else { currentTrack++ audio = audioArray[currentTrack]; |
