← back to browse
goat command

drive

Upload video or media to Google Drive and return shareable URL.

0
views
0
likes
0
installs
raw source
const axios = require('axios');

module.exports.config = {
 name: "drive",
 version: "0.0.1",
 role: 2,
 author: "π“†©π‘…π‘œπ’·π’Ύπ“ƒπ“†ͺ π’œπ“π’Ύ",
 description: "Upload video or media to Google Drive and return shareable URL.",
 category: "utility",
 countDown: 5
};

module.exports.onStart = async function({ api, event, args }) {
 let inputUrl = null;

 if (event.messageReply?.attachments?.length > 0) {
 inputUrl = event.messageReply.attachments[0].url;
 } else if (args.length > 0) {
 inputUrl = args[0];
 }

 if (!inputUrl) {
 return api.sendMessage(
 "❌ | Please reply to a media message or provide a valid media URL.",
 event.threadID,
 event.messageID
 );
 }

 try {
 const apikey = "ArYAN";
 const apiURL = `https://aryan-xyz-google-drive.vercel.app/drive?url=${encodeURIComponent(inputUrl)}&apikey=${apikey}`;
 const res = await axios.get(apiURL);

 const data = res.data || {};
 const driveLink = data.driveLink || data.driveLIink;

 if (driveLink) {
 const successMsg = `βœ… make by Sujon-Boss| File successfully uploaded to Google Drive!\n\nπŸ”— Drive URL: ${driveLink}`;
 return api.sendMessage(successMsg, event.threadID, event.messageID);
 }

 return api.sendMessage(
 `❌ | Failed to upload the file.\n${data.error || "No additional information available."}`,
 event.threadID,
 event.messageID
 );

 } catch (error) {
 console.error("Google Drive Upload Error:", error.message);
 return api.sendMessage(
 "❌ | An unexpected error occurred during upload. Please try again later.",
 event.threadID,
 event.messageID
 );
 }
};

View raw file