mirror of
https://github.com/JonnyBro/JaBa.git
synced 2025-04-03 17:37:38 +05:00
Merge branch 'main' into dev
This commit is contained in:
commit
4a24ff6389
1 changed files with 27 additions and 6 deletions
|
@ -44,13 +44,34 @@ 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") });
|
if (!perms.has(PermissionsBitField.Flags.Connect) || !perms.has(PermissionsBitField.Flags.Speak)) return interaction.editReply({ content: interaction.translate("music/play:VOICE_CHANNEL_CONNECT") });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var searchResult = await client.player.search(query, {
|
var searchResult;
|
||||||
requestedBy: interaction.user,
|
if (!query.includes("http")) {
|
||||||
searchEngine: QueryType.AUTO
|
const search = await playdl.search(query, { limit: 10 });
|
||||||
});
|
|
||||||
|
|
||||||
if (!searchResult.tracks[0] || !searchResult)
|
if (search) {
|
||||||
return interaction.editReply({ content: interaction.translate("music/play:NO_RESULT", { query, error: "Ничего не найдено" }) });
|
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" }) });
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
return interaction.editReply({
|
return interaction.editReply({
|
||||||
|
|
Loading…
Add table
Reference in a new issue