diff --git a/.gitignore b/.gitignore index 92d5b0b5..2743837c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ .env -serviceAccount.json -package.json package-lock.json .vscode/ node_modules/ +serviceAccount.json +package.json \ No newline at end of file diff --git a/commands/play.js b/commands/play.js index d18c3b0a..99b8e7a2 100644 --- a/commands/play.js +++ b/commands/play.js @@ -36,7 +36,7 @@ module.exports = { await client.funcs.handleVideo(video2, message, voiceChannel, client, true); } return message.channel.send(`:white_check_mark: Playlist: **${playlist.title}** has been added to the queue!`); - } else { + } else if (client.global.db.guilds[message.guild.id].songSelection) { try { var video = await youtube.getVideo(url); } catch (error) { @@ -67,6 +67,19 @@ module.exports = { } } return client.funcs.handleVideo(video, message, voiceChannel, client, false); + } else { + try { + var video = await youtube.getVideo(url); + } catch (error) { + try { + var videos = await youtube.searchVideos(searchString, 1); + var video = await youtube.getVideoByID(videos[0].id); + } catch (err) { + console.error(err); + return message.channel.send(':x: I could not obtain any search results!'); + } + } + return client.funcs.handleVideo(video, message, voiceChannel, client, false); } } };