diff --git a/plugins/yt.js b/plugins/yt.js index 0502b3b..4735fa4 100644 --- a/plugins/yt.js +++ b/plugins/yt.js @@ -154,3 +154,64 @@ izumi( ); } ); +izumi({ + pattern: "play ?(.*)", + fromMe: true, + desc: "Play YouTube video or audio", + type: "user", +}, async (message, match) => { + match = match || message.reply_message.text; + if (!match) { + await message.reply("🎵 *Give me a query to search* 🎵"); + return; + } + + try { + let { dlink, title, vid } = await ytsdl(match); + let buff = await getBuffer(dlink); + + let data = { + jid: message.jid, + button: [ + { + type: "reply", + params: { + display_text: "📹 VIDEO", + id: `${PREFIX}video${match}`, + }, + }, + { + type: "reply", + params: { + display_text: "🎵 AUDIO", + id: `${PREFIX}song${match}`, + }, + }, + { + type: "url", + params: { + display_text: "🔗 YouTube", + url: `https://youtu.be/${vid}`, + merchant_url: `https://youtu.be/${vid}`, + }, + }, + ], + header: { + title: `${config.BOT_NAME}`, + subtitle: "Enjoy your media", + hasMediaAttachment: false, + }, + footer: { + text: `Powered by ${config.OWNER_NAME}`, + }, + body: { + text: `*${title}*\nChoose an option below to proceed:`, + }, + }; + + await message.sendMessage(message.jid, data, {}, "interactive"); + } catch (error) { + console.error("Error handling:", error); + await message.reply(" _Error processing your request. Please try again later._ "); + } +});