I want my Discord bot to retrieve few YouTube videos from a specific channel. Until there, that works fine, but I want it to retrieve from the recent one to the old one.
Here is my code:
if(command === "meps") {
var opts = {
maxResults: 5,
key: 'API KEY',
channelId: 'UCcgvwZgeQIRQ-g9WDqgwXFw',
type: 'video'
};
const lawMeps = new Discord.RichEmbed()
.setAuthor("lawAMV", "https://yt3.ggpht.com/-464n3t5gsuw/AAAAAAAAAAI/AAAAAAAAAAA/csBjGhz51gY/s176-c-k-no-mo-rj-c0xffffff/photo.jpg")
.setDescription("Recent MEPs")
.setThumbnail("https://yt3.ggpht.com/-464n3t5gsuw/AAAAAAAAAAI/AAAAAAAAAAA/csBjGhz51gY/s176-c-k-no-mo-rj-c0xffffff/photo.jpg")
.setColor("#553B82");
search('lawAMVs mep', opts, function (err, results) {
if (err) return console.log(err);
for (var resultCount = 0; resultCount < opts.maxResults; resultCount++) {
var publishedAt = new Date(results[resultCount].publishedAt);
if (results[resultCount].title.startsWith("MEP"))
{
lawMeps.addField(results[resultCount].title, results[resultCount].link + "\nPublished at: " + publishedAt, true);
}
}
message.channel.send(lawMeps);
});
}
答案 0 :(得分:0)
这是固定的家伙。
我刚刚在order: 'date',
和关键行之间添加了maxResults: 5,
。
由于某些原因它以前没有用过,但现在进展顺利! :d