1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-09-20 14:01:55 +00:00
musix-oss/struct/funcs/urlMatch.js

16 lines
773 B
JavaScript
Raw Normal View History

2020-02-05 20:02:53 +00:00
module.exports = async function (client, msg, youtube, voiceChannel, url) {
if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
2020-03-12 11:56:31 +00:00
const lmsg = await msg.channel.send(client.messages.loadingSongs);
2020-02-05 20:02:53 +00:00
const playlist = await youtube.getPlaylist(url);
const videos = await playlist.getVideos();
for (const video of Object.values(videos)) {
const video2 = await youtube.getVideoByID(video.id);
await client.funcs.handleVideo(video2, msg, voiceChannel, client, true);
}
2020-03-12 11:56:31 +00:00
client.messages.playlistAdded = client.messages.playlistAdded.replace("%TITLE%", playlist.title);
lmsg.edit(client.messages.playlistAdded);
2020-02-05 20:02:53 +00:00
return true;
} else {
return false;
}
};