From b248684fc3f83ce005c3e24e33b4dd5097f68916 Mon Sep 17 00:00:00 2001 From: JonnyBro Date: Sat, 10 Sep 2022 23:53:40 +0500 Subject: [PATCH] =?UTF-8?q?=D0=AF=20=D0=BD=D0=B5=20=D1=83=D0=BC=D0=B5?= =?UTF-8?q?=D1=8E=20=D0=B3=D0=B8=D1=82=D1=85=D0=B0=D0=B1=D0=BE=D0=BC=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D1=8C?= =?UTF-8?q?=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/Music/play.js | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/commands/Music/play.js b/commands/Music/play.js index 761be1b7..46a699b2 100644 --- a/commands/Music/play.js +++ b/commands/Music/play.js @@ -44,34 +44,13 @@ class Play extends BaseCommand { if (!perms.has(PermissionsBitField.Flags.Connect) || !perms.has(PermissionsBitField.Flags.Speak)) return interaction.editReply({ content: interaction.translate("music/play:VOICE_CHANNEL_CONNECT") }); try { - var searchResult; - if (!query.includes("http")) { - const search = await playdl.search(query, { limit: 10 }); + var searchResult = await client.player.search(query, { + requestedBy: interaction.user, + searchEngine: QueryType.AUTO + }); - if (search) { - const found = search.map(track => new Track(client.player, { - title: track.title, - duration: Util.buildTimeCode(Util.parseMS(track.durationInSec * 1000)), - thumbnail: track.thumbnails[0].url || "https://cdn.discordapp.com/attachments/708642702602010684/1012418217660121089/noimage.png", - views: track.views, - author: track.channel.name, - description: "search", - url: track.url, - requestedBy: interaction.user, - playlist: null, - source: "youtube" - })); - - searchResult = { playlist: null, tracks: found, searched: true }; - } - } else { - searchResult = await client.player.search(query, { - requestedBy: interaction.user - }); - - if (!searchResult.tracks[0] || !searchResult) - return interaction.editReply({ content: interaction.translate("music/play:NO_RESULT", { query, error: "Unknown Error" }) }); - } + if (!searchResult.tracks[0] || !searchResult) + return interaction.editReply({ content: interaction.translate("music/play:NO_RESULT", { query, error: "Unknown Error" }) }); } catch (error) { console.log(error); return interaction.editReply({ @@ -87,7 +66,7 @@ class Play extends BaseCommand { autoSelfDeaf: true, leaveOnEnd: true, leaveOnStop: true, - bufferingTimeout: 1000, + bufferingTimeout: 1000 }); if (searchResult.searched) {