From b3993b80264fea71d65be1a774ce1736f387249d Mon Sep 17 00:00:00 2001 From: naseif Date: Fri, 1 Oct 2021 08:00:13 +0000 Subject: [PATCH] [Fix] Fixed a bug with the lyrics command where the bot would crash if there are no songs playing while searching --- commands/music/lyrics.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/commands/music/lyrics.js b/commands/music/lyrics.js index 5e8f7a1..fbf45dd 100644 --- a/commands/music/lyrics.js +++ b/commands/music/lyrics.js @@ -15,18 +15,28 @@ module.exports = { const songString = interaction.options.getString("song"); const lyricsClient = Lyrics.init(); const queue = client.player.getQueue(interaction.guild); - let songTitle; if (songString) { songTitle = songString; } else { - songTitle = queue.current.title; + if (!queue) + return await interaction.followUp({ + embeds: [ + embedMessage( + "#9dcc37", + "❌ There is no music playing to search for lyrics!" + ), + ], + }); + if (queue.current.title) { + songTitle = queue.current.title; - const filterName = queue.current.title.indexOf("("); + const filterName = queue.current.title.indexOf("("); - if (filterName !== -1) { - songTitle = songTitle.slice(0, filterName); + if (filterName !== -1) { + songTitle = songTitle.slice(0, filterName); + } } }