From b6ee119e3d30a4ea664fe79f36a00c09199a53fb Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Mon, 25 Sep 2023 22:32:36 +0500 Subject: [PATCH] seek to given time in the link --- commands/Music/play.js | 27 ++++++++++++++++++++------- dashboard/docs/updates.md | 1 + 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/commands/Music/play.js b/commands/Music/play.js index c1934816..66e1b899 100644 --- a/commands/Music/play.js +++ b/commands/Music/play.js @@ -61,7 +61,7 @@ class Play extends BaseCommand { if (!searchResult.hasTracks()) return interaction.error("music/play:NO_RESULT", { query }, { edit: true }); else { - client.player.play(interaction.member.voice.channel, searchResult, { + const { queue } = await client.player.play(interaction.member.voice.channel, searchResult, { nodeOptions: { metadata: { client, @@ -76,13 +76,20 @@ class Play extends BaseCommand { maxSize: 200, maxHistorySize: 50, }); + + interaction.editReply({ + content: interaction.translate("music/play:ADDED_QUEUE", { + songName: searchResult.hasPlaylist() ? searchResult.playlist.title : searchResult.tracks[0].title, + }), + }); + + if (query.match(/&t=[[0-9]+/g) != null) { + const time = query.match(/&t=[[0-9]+/g)[0].split("=")[1]; + + queue.node.seek(time * 1000); + } } - interaction.editReply({ - content: interaction.translate("music/play:ADDED_QUEUE", { - songName: searchResult.hasPlaylist() ? searchResult.playlist.title : searchResult.tracks[0].title, - }), - }); } /** @@ -93,7 +100,13 @@ class Play extends BaseCommand { */ async autocompleteRun(client, interaction) { const query = interaction.options.getString("query"); - if (query.includes("http") || query === "") return; + if (query === "") return; + if (query.includes("http")) return interaction.respond([ + { + name: "Current link", + value: query, + }, + ]); const results = await client.player.search(query); diff --git a/dashboard/docs/updates.md b/dashboard/docs/updates.md index ba58d04d..20eba5cf 100644 --- a/dashboard/docs/updates.md +++ b/dashboard/docs/updates.md @@ -2,6 +2,7 @@ * Добавлено * Логи удаления сообщений!\ Настройку можно найти в *config set* и в панели управления. + * Начало проигрывания видео с указанного в ссылке времени. ### JaBa v4.3.3 * Добавлено