From 0641ccfb0d3f8163be3fdc21bba3ce01687c09cb Mon Sep 17 00:00:00 2001 From: Wizzard Date: Sat, 17 Aug 2024 18:36:59 -0400 Subject: [PATCH] Update play.js --- commands/play.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/commands/play.js b/commands/play.js index aa44cc8..640e95a 100644 --- a/commands/play.js +++ b/commands/play.js @@ -116,14 +116,10 @@ module.exports = { playNextInQueue(message.guild.id); return; } else { - loadingMessage = await message.channel.send(`**Loading**...`); - - tempFilePath = path.join(__dirname, '../utils/tmp', `${uuidv4()}.mp3`); - console.log(`YouTube link received: ${searchQuery}`); videoUrl = searchQuery; - exec(`yt-dlp --cookies ${path.join(__dirname, '../cookies.txt')} --print title ${searchQuery}`, (error, stdout, stderr) => { + exec(`yt-dlp --cookies ${path.join(__dirname, '../cookies.txt')} --print title ${searchQuery}`, async (error, stdout, stderr) => { if (error) { console.error(`Error getting title: ${error}`); message.reply('Failed to retrieve video title.'); @@ -133,6 +129,10 @@ module.exports = { title = stdout.trim() || "Unknown Title"; console.log(`Retrieved title: ${title}`); + loadingMessage = await message.channel.send(`**Loading**... ${title}`); + + tempFilePath = path.join(__dirname, '../utils/tmp', `${uuidv4()}.mp3`); + exec(`yt-dlp --cookies ${path.join(__dirname, '../cookies.txt')} --format bestaudio --output "${tempFilePath}" ${searchQuery}`, async (error, stdout, stderr) => { if (error) { console.error(`Error downloading file: ${error}`); @@ -223,4 +223,4 @@ function isValidURL(string) { } catch (_) { return false; } -} \ No newline at end of file +}