Transitioned all Misc, audio, Selmer Specific, admin, anime/manga, and inventory commands to Slash Command format. The RSS and reactionrole commands are still broken and all game commands are still in message format due to compications

This commit is contained in:
ION606
2022-09-27 16:45:50 -04:00
parent a190a250a6
commit e1002d748d
45 changed files with 1951 additions and 1058 deletions
+43
View File
@@ -0,0 +1,43 @@
const axios = require('axios');
/**
* @param {String} purl
* @returns {Promise<Array<String>>}
*
* @example
* const purls = getPlaylistUrls(url);
* purls.then((urls) => { console.log(urls); });
*/
async function getPlaylistUrls(bot, purl, isPremium) {
const gApiKey = bot.youtubeAPIKey;
const numSongs = (isPremium) ? 20 : 10;
return new Promise(async (resolve, reject) => {
try {
const pid = (purl.split("list=")[1]).replace("&feature=share", "");
await axios.get(`https://www.googleapis.com/youtube/v3/playlistItems`, {
params: {
part: 'id,snippet',
maxResults: numSongs,
playlistId: pid,
key: gApiKey
}
})
.then((result) => {
const l = [];
result.data.items.forEach((vid, ind) => {
const vurl = `https://www.youtube.com/watch?v=${vid.snippet.resourceId.videoId}`
const pvurl = `https://www.youtube.com/watch?v=${vid.snippet.resourceId.videoId}&list=${pid}&index=${ind+1}`
l.push({video_url: vurl, in_playlist_url: pvurl});
});
resolve(l);
}).catch((err) => { reject(err.message); });
} catch (err) {
reject(err.message);
}
});
}
module.exports = { getPlaylistUrls }