diff options
Diffstat (limited to 'AudioBackend.js')
| -rw-r--r-- | AudioBackend.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/AudioBackend.js b/AudioBackend.js index 354f26d..7d24b1c 100644 --- a/AudioBackend.js +++ b/AudioBackend.js @@ -39,6 +39,7 @@ export let currentTrack; export let playerState; export let isAudioStatePaused; +let totalTrack = files.length; export async function voiceInit(bot) { bot.channels.fetch(voiceChannel).then(async channel => { @@ -97,7 +98,6 @@ export async function shufflePlaylist(bot) { } export async function nextAudio(bot) { - let totalTrack = files.length; totalTrack--; if (currentTrack >= totalTrack) { console.log('All beats in the playlist has finished, repeating beats...'); @@ -109,6 +109,18 @@ export async function nextAudio(bot) { } } +export async function previousAudio(bot, interaction) { + if (currentTrack <= 0) { + return await interaction.reply({ content: 'You are at the beginning of the playlist, cannot go further than this', ephemeral: true }); + } else { + await interaction.reply({ content: 'Playing previous music', ephemeral: true }); + player.stop(); + currentTrack--; + audio = files[currentTrack]; + return await playAudio(bot); + } +} + export async function inputAudio(bot, integer) { const inputFiles = readdirSync('music'); audio = inputFiles[integer]; |
