1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-06-16 18:56:00 +00:00

updated video search

This commit is contained in:
MatteZ02
2020-03-23 09:59:09 +02:00
parent 7e20f54362
commit 11cea679d1
4 changed files with 479 additions and 14 deletions

View File

@ -1,4 +1,5 @@
const YouTube = require("simple-youtube-api");
const search = require('yt-search');
module.exports = {
name: 'play',
@ -37,16 +38,15 @@ module.exports = {
try {
var video = await youtube.getVideo(url);
} catch (error) {
try {
const videos = await youtube.searchVideos(searchString, 1);
var video = await youtube.getVideoByID(videos[0].id);
} catch (err) {
console.error(err);
if (err.code === 403) {
return msg.channel.send(client.messages.quotaReached);
search(searchString, function (err, res) {
if (err) return console.log(err);
if (res.videos.length === 0) {
msg.channel.send(client.messages.noResults);
} else {
client.funcs.handleVideo(res.videos[0], msg, voiceChannel, client, false);
}
return msg.channel.send(client.messages.noResults);
}
})
return;
}
return client.funcs.handleVideo(video, msg, voiceChannel, client, false);
}

View File

@ -1,9 +1,8 @@
module.exports = async function (video, msg, voiceChannel, client, playlist = false) {
const Discord = require('discord.js');
const song = {
id: video.id,
title: Discord.Util.escapeMarkdown(video.title),
url: `https://www.youtube.com/watch?v=${video.id}`,
url: video.url,
author: msg.author
}