From 9cf18c626dead2f222f22ce1f9028cf744a9b0d0 Mon Sep 17 00:00:00 2001 From: Ammar249-SDG Date: Mon, 25 May 2026 11:27:49 +0200 Subject: [PATCH] Add PDF download command with error handling --- commands/Pdf.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 commands/Pdf.js diff --git a/commands/Pdf.js b/commands/Pdf.js new file mode 100644 index 00000000..e0e19d59 --- /dev/null +++ b/commands/Pdf.js @@ -0,0 +1,33 @@ +module.exports = { + pattern: "pdf", + desc: "تنزيل ملف PDF من رابط مباشر", + category: "downloader", + + async execute(sock, msg, args, { from, reply }) { + try { + let url = args[0]; + + if (!url) { + return reply("❌ أرسل رابط PDF مباشر بعد الأمر\nمثال:.pdf https://site.com/file.pdf"); + } + + if (!url.includes(".pdf")) { + return reply("❌ الرابط لازم ينتهي بـ.pdf"); + } + + await reply("⏳ جاري تحميل الملف..."); + + await sock.sendMessage(from, { + document: { url: url }, + mimetype: "application/pdf", + fileName: "document.pdf" + }, { quoted: msg }); + + await reply("✅ تم إرسال الملف"); + + } catch (e) { + console.log(e); + reply("❌ فشل التحميل. تأكد إن الرابط مباشر وشغال"); + } + } + }