// code from goatstore // api: https://store.agi.bd const fs = require("fs-extra"); const moment = require("moment-timezone"); const downloader = require("image-downloader"); module.exports = { config: { name: "time4", version: "2.1.0", author: "𝐒𝐡𝐚𝐨𝐧 𝐏𝐫𝐨𝐣𝐞𝐜𝐭", countDown: 0, role: 0, shortDescription: { en: "Show Bangladesh date, time and bot uptime" }, description: { en: "Shows current Bangladesh date, time, day and bot uptime" }, category: "utility", guide: { en: "{pn}" } }, onStart: async function ({ message, event, usersData }) { let imagePath = null; try { // User name let name = "User"; try { if (usersData && typeof usersData.getName === "function") { name = await usersData.getName(event.senderID); } } catch (e) { name = "User"; } if (!name) { name = "User"; } // Bangladesh time const now = moment.tz("Asia/Dhaka"); const date = now.format("D/MM/YYYY"); const time = now.format("hh:mm:ss A"); const year = now.format("YYYY"); const englishDay = now.format("dddd"); const days = { Sunday: "রবিবার", Monday: "সোমবার", Tuesday: "মঙ্গলবার", Wednesday: "বুধবার", Thursday: "বৃহস্পতিবার", Friday: "শুক্রবার", Saturday: "শনিবার" }; const day = days[englishDay] || englishDay; // Bot uptime const seconds = Math.floor(process.uptime()); const hours = String(Math.floor(seconds / 3600)).padStart(2, "0"); const minutes = String( Math.floor((seconds % 3600) / 60) ).padStart(2, "0"); const secs = String(seconds % 60).padStart(2, "0"); const uptime = `${hours}:${minutes}:${secs}`; // Cache directory const cacheDir = `${__dirname}/cache`; await fs.ensureDir(cacheDir); // Facebook profile picture const imageUrl = `https://graph.facebook.com/${event.senderID}/picture?height=720&width=720&access_token=6628568379%7Cc1e620fa708a1d5696fb991c1bde5662`; imagePath = `${cacheDir}/time3_${event.senderID}_${Date.now()}.jpg`; // Download profile picture try { await downloader.image({ url: imageUrl, dest: imagePath }); } catch (downloadError) { console.error( "TIME3 PROFILE IMAGE ERROR:", downloadError.message ); imagePath = null; } const body = `🌀 𝐇𝐞𝐥𝐥𝐨: ${name} 🌀 𝐅𝐚𝐜𝐞𝐛𝐨𝐨𝐤: ${name} 🌀 𝐇𝐨𝐮𝐫: ${time} 🌀 𝐃𝐚𝐲: ${date} ${day} 🌀 𝐘𝐞𝐚𝐫: ${year} 🌀 𝐑𝐮𝐧𝐧𝐢𝐧𝐠: ${uptime} ━━━━━━━━━━━━━━━━━━ 🌿ᥫ᭡፝֟፝֟ ϻꫝɪ֟፝ꜱʜꫝ ᥫ᭡፝֟፝֟𓍯_ 𝐌>🌷🌿`; // Send with image if available if (imagePath && await fs.pathExists(imagePath)) { await message.reply({ body, attachment: fs.createReadStream(imagePath) }); } else { await message.reply(body); } // Delete image after 1 minute if (imagePath) { setTimeout(async () => { try { await fs.remove(imagePath); } catch (e) {} }, 60000); } } catch (error) { console.error( "TIME3 COMMAND ERROR:", error && error.stack ? error.stack : error ); // Cleanup if an image was created if (imagePath) { try { await fs.remove(imagePath); } catch (e) {} } return message.reply( "❌ | Time3 command চালাতে সমস্যা হয়েছে!" ); } } };