From d5ca0d40e77462cc7ad9e0d26d3430da21874d4f Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Wed, 13 Jul 2022 21:58:34 -0400 Subject: Renamed skip to next, added previous command --- AudioBackend.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'AudioBackend.js') 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]; -- cgit v1.2.3