From 3f81f1086f46b8e1882ed0827483a22929330be3 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Wed, 30 Mar 2022 16:34:24 -0400 Subject: Renamed project; Auto creates music folder when not detected; Removed audio limitation --- AudioBackend.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'AudioBackend.js') diff --git a/AudioBackend.js b/AudioBackend.js index 5960f3e..d7b6852 100644 --- a/AudioBackend.js +++ b/AudioBackend.js @@ -1,6 +1,6 @@ /************************************************************************** * - * DLMP3 Bot: A Discord bot that plays local MP3 audio tracks. + * DLAP Bot: A Discord bot that plays local audio tracks. * (C) Copyright 2022 * Programmed by Andrew Lee * @@ -64,20 +64,12 @@ export async function voiceInit(bot) { export async function searchAudio(bot){ //TODO: Eventually this system will need a rework so it won't repeat the same files. - while (true) { - audio = files[Math.floor(Math.random() * files.length)]; - console.log('Searching .mp3 file...'); - if (audio.endsWith('.mp3')) { - break; - } - } - + audio = files[Math.floor(Math.random() * files.length)]; return await playAudio(bot); } export async function inputAudio(bot, integer) { - audio = files[integer] - + audio = files[integer]; return await playAudio(bot); } @@ -86,6 +78,7 @@ export async function playAudio(bot) { await player.play(resource); + audio = audio.split('.').slice(0, -1).join('.'); console.log('Now playing: ' + audio); if (config.txtFile === true) { @@ -107,7 +100,6 @@ export async function playAudio(bot) { } export function destroyAudio(interaction) { - if (config.txtFile === true) { fileData = "Now Playing: Nothing"; fs.writeFile("now-playing.txt", fileData, (err) => { -- cgit v1.2.3