diff options
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/AudioControl.js | 19 | ||||
| -rw-r--r-- | backend/PlayAudio.js | 2 | ||||
| -rw-r--r-- | backend/VoiceInitialization.js | 2 |
3 files changed, 17 insertions, 6 deletions
diff --git a/backend/AudioControl.js b/backend/AudioControl.js index 71952c1..2b314d2 100644 --- a/backend/AudioControl.js +++ b/backend/AudioControl.js @@ -22,20 +22,31 @@ import { readdirSync, readFileSync } from 'node:fs'; import { shufflePlaylist, orderPlaylist } from './QueueSystem.js'; import { playAudio, currentTrack, updatePlaylist } from './PlayAudio.js'; import { player } from './VoiceInitialization.js'; +import { destroyAudio } from './Shutdown.js'; -const { shuffle } = JSON.parse(readFileSync('./config.json', 'utf-8')); +const { shuffle, repeat } = JSON.parse(readFileSync('./config.json', 'utf-8')); export const files = readdirSync('music'); export let playerState; export let isAudioStatePaused; let totalTrack = files.length; +async function repeatCheck(bot) { + if (repeat) { + console.log('All beats in the playlist has finished, repeating beats...'); + totalTrack = files.length; + return (shuffle) ? await shufflePlaylist(bot) : await orderPlaylist(bot); + } else { + console.log('All beats in the playlist has finished.'); + updatePlaylist('stop'); + audioState(2); + } +} + export async function nextAudio(bot) { totalTrack--; if (currentTrack >= totalTrack) { - console.log('All beats in the playlist has finished, repeating beats...'); - totalTrack = files.length; - return (shuffle === true) ? await shufflePlaylist(bot) : await orderPlaylist(bot); + await repeatCheck(bot); } else { updatePlaylist('next'); return await playAudio(bot); diff --git a/backend/PlayAudio.js b/backend/PlayAudio.js index 3ae2b91..d698798 100644 --- a/backend/PlayAudio.js +++ b/backend/PlayAudio.js @@ -77,7 +77,7 @@ export async function playAudio(bot) { } const statusEmbed = new EmbedBuilder(); - if (metadataEmpty === true) { + if (metadataEmpty) { statusEmbed.setTitle('Now Playing'); statusEmbed.addFields( { name: 'Title', value: audio }, diff --git a/backend/VoiceInitialization.js b/backend/VoiceInitialization.js index d95bfa6..a9e1149 100644 --- a/backend/VoiceInitialization.js +++ b/backend/VoiceInitialization.js @@ -39,7 +39,7 @@ export async function voiceInit(bot) { connection.on(VoiceConnectionStatus.Ready, async() => { console.log('Ready to blast some beats!'); - return (shuffle === true) ? await shufflePlaylist(bot) : await orderPlaylist(bot); + return (shuffle) ? await shufflePlaylist(bot) : await orderPlaylist(bot); }); connection.on(VoiceConnectionStatus.Destroyed, () => { |
