bbb / bot /command /download /facebook.js
Nexchan's picture
Add application file
0ee7b04
import axios from "axios";
async function delay(ms) {
return new Promise((r) => setTimeout(r, ms));
}
export default {
command: ["facebook", "fb", "fbdl"],
description: "Download Facebook video/reel",
example: "%p%cmd <url>",
name: "facebook",
tags: "download",
run: async (m, { conn }) => {
try {
const url = m.args[0];
if (!/https?:\/\/(fb\.watch|(www\.|web\.|m\.)?facebook\.com)/i.test(url)) {
return m.reply(`Example: ${m.prefix + m.command} https://www.facebook.com/...`);
}
m.reply("⏳ Sedang memproses...");
const res = await axios.get("https://api.nyxs.pw/dl/fb?url=" + url);
const result = res.data?.result?.hd;
if (!result) return m.reply("Gagal mengambil video 😔");
const video = await axios.get(result, { responseType: "arraybuffer" });
await conn.sendMessage(m.from, { video: Buffer.from(video.data) }, { quoted: m });
} catch (e) {
console.error(e);
await m.reply("Terjadi kesalahan: " + e.message);
}
},
};