|
|
|
const { cmd } = require("../command"); |
|
const moment = require("moment"); |
|
|
|
let botStartTime = Date.now(); |
|
const ALIVE_IMG = "https://cdn.ironman.my.id/i/2du3i5.jpg"; |
|
|
|
cmd({ |
|
pattern: "alive", |
|
desc: "Check if the bot is active.", |
|
category: "info", |
|
react: "🤖", |
|
filename: __filename |
|
}, async (conn, mek, m, { reply, from }) => { |
|
try { |
|
const pushname = m.pushName || "User"; |
|
const currentTime = moment().format("HH:mm:ss"); |
|
const currentDate = moment().format("dddd, MMMM Do YYYY"); |
|
|
|
const runtimeMilliseconds = Date.now() - botStartTime; |
|
const runtimeSeconds = Math.floor((runtimeMilliseconds / 1000) % 60); |
|
const runtimeMinutes = Math.floor((runtimeMilliseconds / (1000 * 60)) % 60); |
|
const runtimeHours = Math.floor(runtimeMilliseconds / (1000 * 60 * 60)); |
|
|
|
const formattedInfo = ` |
|
🌟 *ALI MD STATUS* 🌟 |
|
Hey 👋🏻 ${pushname} |
|
🕒 *Time*: ${currentTime} |
|
📅 *Date*: ${currentDate} |
|
⏳ *Uptime*: ${runtimeHours} hours, ${runtimeMinutes} minutes, ${runtimeSeconds} seconds |
|
|
|
*🤖sᴛᴀᴛᴜs*: *ᴀʟɪ-ᴍᴅ ᴀʟɪᴠᴇ ᴀɴᴅ ʀᴇᴀᴅʏ* |
|
|
|
*🤍ᴍᴀᴅᴇ ᴡɪᴛʜ ʟᴏᴠᴇ* |
|
`.trim(); |
|
|
|
|
|
if (!ALIVE_IMG || !ALIVE_IMG.startsWith("http")) { |
|
throw new Error("Invalid ALIVE_IMG URL. Please set a valid image URL."); |
|
} |
|
|
|
|
|
await conn.sendMessage(from, { |
|
image: { url: ALIVE_IMG }, |
|
caption: formattedInfo, |
|
contextInfo: { |
|
mentionedJid: [m.sender], |
|
forwardingScore: 999, |
|
isForwarded: true, |
|
forwardedNewsletterMessageInfo: { |
|
newsletterJid: '120363318387454868@newsletter', |
|
newsletterName: '𝐀ɭι̇ι̇ 𝐌Ɗ 🍁', |
|
serverMessageId: 143 |
|
} |
|
} |
|
}, { quoted: mek }); |
|
|
|
} catch (error) { |
|
console.error("Error in alive command: ", error); |
|
|
|
|
|
const errorMessage = ` |
|
❌ An error occurred while processing the alive command. |
|
🛠 *Error Details*: |
|
${error.message} |
|
|
|
Please report this issue or try again later. |
|
`.trim(); |
|
return reply(errorMessage); |
|
} |
|
}); |
|
|
|
|