Skip to content

Commit

Permalink
added play
Browse files Browse the repository at this point in the history
  • Loading branch information
sataniceypz authored Jul 9, 2024
1 parent d2869e6 commit 02706a7
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions plugins/yt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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._ ");
}
});

0 comments on commit 02706a7

Please sign in to comment.