Spaces:
Paused
Paused
File size: 2,255 Bytes
8d8d92b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
/*╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺
⭐PROJECT NAME:
SUBZERO WHATSAPP MD BOT
⭐DEVELOPER
MR FRANK
⭐ MY TEAM
XERO CODERS
⭐ OUR WEBSITE
https://github.com/ZwSyntax/SUBZERO-MD
© TRY DECRYPTING IF YOU CAN⚠
╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺*/
const config = require('../config');
const { cmd, commands } = require('../command');
const fs = require('fs');
const path = require('path');
cmd({
pattern: "save",
react: "📁",
alias: ["store"],
desc: "Save and send back a media file (image, video, or audio).",
category: "media",
use: ".save <caption>",
filename: __filename,
},
async (conn, mek, m, { quoted, q, reply }) => {
try {
if (!quoted) {
return reply("❌ Reply to a media message (video, image, or audio) with the `.save` command.");
}
const messageType = quoted.mtype;
let mediaType;
// Determine the type of media
if (/video/.test(messageType)) {
mediaType = "video";
} else if (/image/.test(messageType)) {
mediaType = "image";
} else if (/audio/.test(messageType)) {
mediaType = "audio";
} else {
return reply("❌ Only video, image, or audio messages are supported.");
}
// Download and save the media file
const mediaPath = await conn.downloadAndSaveMediaMessage(quoted);
const filePath = path.resolve(mediaPath);
// Send the saved media back
const mediaMessage = {
caption: q || '',
}
mediaMessage[mediaType] = { url: `file://${filePath}` }
await conn.sendMessage(m.sender, mediaMessage, { quoted: mek })
await reply("✅ Successfully saved and sent the media file.")
} catch (error) {
console.error(error);
reply("❌ Failed to save and send the media. Please try again.")
}
});
|