File size: 2,069 Bytes
2821330 | 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 | const axios = require('axios');
module.exports.config = {
name: "gdrive",
version: "1.0.1",
hasPermssion: 0,
credits: "Jonell Magallanes",
description: "Get the URL Download from Video, Audio is sent from the group and Get Google Drive Link No Expired Link",
usePrefix: false,
commandCategory: "Tool",
usages: "getLink",
cooldowns: 5,
};
module.exports.languages = {
"vi": {
"invalidFormat": "❌ Tin nhắn bạn phản hồi phải là một audio, video, ảnh nào đó"
},
"en": {
"invalidFormat": "❌ Your need reply a message have contain an audio, video or picture"
}
}
module.exports.run = async ({ api, event, getText }) => {
if (event.type !== "message_reply") return api.sendMessage(getText("invalidFormat"), event.threadID, event.messageID);
if (!event.messageReply.attachments || event.messageReply.attachments.length === 0) return api.sendMessage(getText("invalidFormat"), event.threadID, event.messageID);
if (event.messageReply.attachments.length > 1) return api.sendMessage(getText("invalidFormat"), event.threadID, event.messageID);
const pro = await api.sendMessage("Uploading Attachment Url.....", event.threadID, event.messageID);
const attachmentUrl = event.messageReply.attachments[0].url;
try {
const apiUrl = `https://ccprojectapis.ddns.net/api/gdrive?url=${attachmentUrl}`;
api.editMessage("Uploading Google Drive......", pro.messageID, event.threadID, event.messageID);
const response = await axios.get(apiUrl);
const responseData = response.data;
api.editMessage("Completed.", pro.messageID, event.threadID, event.messageID);
return api.editMessage(`☁️ 𝗚𝗼𝗼𝗴𝗹𝗲 𝗗𝗿𝗶𝘃𝗲 𝗨𝗽𝗹𝗼𝗮𝗱 𝗙𝗶𝗹𝗲 \n━━━━━━━━━━━━━━━━━━\n${responseData}`, pro.messageID, event.threadID, event.messageID);
} catch (error) {
console.error('Error sending request to external API:', error);
return api.sendMessage(error.message, event.threadID, event.messageID);
}
} |