From b5f7c700503129d9b8340da91e976c9815322ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hor=C3=A1=C4=8Dek?= Date: Sat, 11 Apr 2020 16:09:48 +0200 Subject: [PATCH] muuusiccc --- commands/play.js | 2 +- helpers/music.js | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/commands/play.js b/commands/play.js index a091860..1d58b03 100644 --- a/commands/play.js +++ b/commands/play.js @@ -17,4 +17,4 @@ exports.help = { exports.run = async (client, message, args, level, data) => { client.music.play(message, args[0]); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/helpers/music.js b/helpers/music.js index 510e0be..c457f53 100644 --- a/helpers/music.js +++ b/helpers/music.js @@ -54,7 +54,7 @@ module.exports = client => { }; client.music.isYouTubeLink = function(query) { - return query.startsWith('https://youtube.com/') || query.startsWith('http://youtube.com/') || query.startsWith('https://youtu.be/') || query.startswith('http://youtu.be/') || query.startsWith('https://m.youtube.com/') || query.startsWith('http://m.youtube.com/') || query.startsWith('https://www.youtube.com/') || query.startsWith('http://www.youtube.com/'); + return query.startsWith('https://youtube.com/') || query.startsWith('http://youtube.com/') || query.startsWith('https://youtu.be/') || query.startsWith('http://youtu.be/') || query.startsWith('https://m.youtube.com/') || query.startsWith('http://m.youtube.com/') || query.startsWith('https://www.youtube.com/') || query.startsWith('http://www.youtube.com/'); }; client.music.getLinkFromID = function(id) { @@ -72,9 +72,7 @@ module.exports = client => { response = await fetch('https://www.googleapis.com/youtube/v3/search?key=' + client.config.keys.yt + '&part=id,snippet&maxResults=1&q=' + encodeURIComponent(query)); }; - let json = await response.json(); - - let parsed = JSON.parse(json); + let parsed = await response.json(); if(parsed.items) { let video = parsed.items[0]; @@ -98,7 +96,7 @@ module.exports = client => { let vc = message.member.voice.channel; - let video = client.music.getVideoByQuery(query); + let video = await client.music.getVideoByQuery(query); if(video) { // Fix the bot if somehow broken @@ -121,7 +119,8 @@ module.exports = client => { guild.playing = true; let connection = await vc.join(); - guild.dispatcher = connection.play(await ytdl(client.music.getLinkFromID(guild.queue[0].id.videoId)), {type: 'opus'}); + + guild.dispatcher = connection.play(await ytdl(client.music.getLinkFromID(guild.queue[0].video.id.videoId)), {type: 'opus'}); guild.dispatcher.setVolume(0.5); }; } else {