Skip to content

Commit

Permalink
[Fix] Create the queue only if the song was found
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Sep 30, 2021
1 parent 36a9130 commit 2a96eab
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions commands/music/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ module.exports = {
],
});

const songString = interaction.options.getString("song");
const searchSong = await client.player.search(songString, {
requestedBy: interaction.user,
});

if (!searchSong.tracks.length || !searchSong)
return interaction.followUp({
embeds: [embedMessage("#9dcc37", `❌ | Song not found`)],
});

const queue = client.player.createQueue(interaction.guildId, {
metadata: interaction,
leaveOnEnd: false,
Expand All @@ -48,16 +58,6 @@ module.exports = {
},
});

const songString = interaction.options.getString("song");
const searchSong = await client.player.search(songString, {
requestedBy: interaction.user,
});

if (!searchSong.tracks.length || !searchSong)
return interaction.followUp({
embeds: [embedMessage("#9dcc37", `❌ | Song not found`)],
});

try {
if (!queue.connection)
await queue.connect(interaction.member.voice.channel);
Expand Down

0 comments on commit 2a96eab

Please sign in to comment.