mirror of
https://github.com/musix-org/musix-oss
synced 2024-12-22 21:13:18 +00:00
Update playlist.js
This commit is contained in:
parent
1917fe7784
commit
72e600454f
@ -70,51 +70,53 @@ module.exports = {
|
|||||||
};
|
};
|
||||||
message.channel.send(":white_check_mark: Queue saved!");
|
message.channel.send(":white_check_mark: Queue saved!");
|
||||||
} else if (args[1] === 'add') {
|
} else if (args[1] === 'add') {
|
||||||
const youtube = new YouTube(client.config.apikey);
|
if (client.global.db.playlists[args[2]].saved) {
|
||||||
const searchString = args.slice(2).join(" ");
|
const youtube = new YouTube(client.config.apikey);
|
||||||
const url = args[2] ? args[2].replace(/<(.+)>/g, "$1") : "";
|
const searchString = args.slice(2).join(" ");
|
||||||
if (!args[2]) return message.channel.send(':x: You need to use a link or search for a song!');
|
const url = args[2] ? args[2].replace(/<(.+)>/g, "$1") : "";
|
||||||
try {
|
if (!args[2]) return message.channel.send(':x: You need to use a link or search for a song!');
|
||||||
var video = await youtube.getVideo(url);
|
|
||||||
} catch (error) {
|
|
||||||
try {
|
try {
|
||||||
var videos = await youtube.searchVideos(searchString, 10);
|
var video = await youtube.getVideo(url);
|
||||||
let index = 0;
|
} catch (error) {
|
||||||
const embed = new Discord.RichEmbed()
|
|
||||||
.setTitle("__Song Selection__")
|
|
||||||
.setDescription(`${videos.map(video2 => `**${++index}** ${he.decode(video2.title)} `).join('\n')}`)
|
|
||||||
.setFooter("Please provide a number ranging from 1-10 to select one of the search results.")
|
|
||||||
.setColor("#b50002")
|
|
||||||
message.channel.send(embed);
|
|
||||||
try {
|
try {
|
||||||
var response = await message.channel.awaitMessages(message2 => message2.content > 0 && message2.content < 11, {
|
var videos = await youtube.searchVideos(searchString, 10);
|
||||||
maxMatches: 1,
|
let index = 0;
|
||||||
time: 10000,
|
const embed = new Discord.RichEmbed()
|
||||||
errors: ['time']
|
.setTitle("__Song Selection__")
|
||||||
});
|
.setDescription(`${videos.map(video2 => `**${++index}** ${he.decode(video2.title)} `).join('\n')}`)
|
||||||
|
.setFooter("Please provide a number ranging from 1-10 to select one of the search results.")
|
||||||
|
.setColor("#b50002")
|
||||||
|
message.channel.send(embed);
|
||||||
|
try {
|
||||||
|
var response = await message.channel.awaitMessages(message2 => message2.content > 0 && message2.content < 11, {
|
||||||
|
maxMatches: 1,
|
||||||
|
time: 10000,
|
||||||
|
errors: ['time']
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
return message.channel.send(':x: Cancelling video selection');
|
||||||
|
}
|
||||||
|
const videoIndex = parseInt(response.first().content);
|
||||||
|
var video = await youtube.getVideoByID(videos[videoIndex - 1].id);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return message.channel.send(':x: Cancelling video selection');
|
return message.channel.send(':x: I could not obtain any search results!');
|
||||||
}
|
}
|
||||||
const videoIndex = parseInt(response.first().content);
|
|
||||||
var video = await youtube.getVideoByID(videos[videoIndex - 1].id);
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
return message.channel.send(':x: I could not obtain any search results!');
|
|
||||||
}
|
}
|
||||||
}
|
let song = {
|
||||||
let song = {
|
id: video.id,
|
||||||
id: video.id,
|
title: Discord.Util.escapeMarkdown(video.title),
|
||||||
title: Discord.Util.escapeMarkdown(video.title),
|
url: `https://www.youtube.com/watch?v=${video.id}`
|
||||||
url: `https://www.youtube.com/watch?v=${video.id}`
|
}
|
||||||
}
|
client.global.db.playlists[message.guild.id].songs.push(song);
|
||||||
client.global.db.playlists[message.guild.id].songs.push(song);
|
message.channel.send(`:white_check_mark: ${song.title} added to the playlist!`);
|
||||||
message.channel.send(`:white_check_mark: ${song.title} added to the playlist!`);
|
} else return message.channel.send(':x: There is no playlist saved! Start by using the save option!')
|
||||||
} else {
|
} else {
|
||||||
const embed = new Discord.RichEmbed()
|
const embed = new Discord.RichEmbed()
|
||||||
.setTitle('Options for playlist!')
|
.setTitle('Options for playlist!')
|
||||||
.addField('play', 'Play the guild specific queue.', true)
|
.addField('play', 'Play the guild specific queue.', true)
|
||||||
.addField('save', 'Save the currently playing queue.', true)
|
.addField('save', 'Save the currently playing queue. Note that this will overwrite the currently saved queue!', true)
|
||||||
.addField('add', 'Add songs to the playlist. Like song selection', true)
|
.addField('add', 'Add songs to the playlist. Like song selection', true)
|
||||||
.setFooter(`how to use: ${prefix}playlist <Option> <Optional option>`)
|
.setFooter(`how to use: ${prefix}playlist <Option> <Optional option>`)
|
||||||
.setAuthor(client.user.username, client.user.displayAvatarURL)
|
.setAuthor(client.user.username, client.user.displayAvatarURL)
|
||||||
|
Loading…
Reference in New Issue
Block a user