aboutsummaryrefslogtreecommitdiff
path: root/AudioBackend.js
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2022-07-13 21:58:34 -0400
committerAndrew Lee <alee14498@protonmail.com>2022-07-13 21:58:34 -0400
commitd5ca0d40e77462cc7ad9e0d26d3430da21874d4f (patch)
treed264fac27982604bd7a17b5cf43f112dbe8cc83b /AudioBackend.js
parent0937181902a0e79d6bdf72295be259a41794f855 (diff)
downloadDLAP-d5ca0d40e77462cc7ad9e0d26d3430da21874d4f.tar.gz
DLAP-d5ca0d40e77462cc7ad9e0d26d3430da21874d4f.tar.bz2
DLAP-d5ca0d40e77462cc7ad9e0d26d3430da21874d4f.zip
Renamed skip to next, added previous command
Diffstat (limited to 'AudioBackend.js')
-rw-r--r--AudioBackend.js14
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];