const axios = require('axios'); module.exports = { config: { name: "cat", aliases: ["catimg"], version: "1.2.0", author: "xalman", countDown: 5, role: 0, shortDescription: "Get random cat images or check list count", category: "media", guide: "{pn} or {pn} list" }, onStart: async function ({ api, event, args }) { const { threadID, messageID } = event; const BASE_URL = "https://xalman-apis.vercel.app/api/cat"; if (args[0] === "list" || args[0] === "total") { try { const info = await axios.get(`${BASE_URL}?list=true`); return api.sendMessage( `🐾 š—–š—”š—§ š——š—”š—§š—”š—•š—”š—¦š—˜ š—œš—”š—™š—¢\n━━━━━━━━━━━━━━━━━━\n` + `Total Images: ${info.data.total_images}\n` + `Status: Active`, threadID, messageID ); } catch (e) { return api.sendMessage("āœ• Could not fetch the cat image list.", threadID, messageID); } } api.setMessageReaction("🐱", messageID, () => {}, true); try { const res = await axios.get(BASE_URL); const imageUrl = res.data.url; const imageStream = await axios.get(imageUrl, { responseType: 'stream' }); api.setMessageReaction("āœ…", messageID, () => {}, true); return api.sendMessage({ body: "ā– š—–š—Øš—§š—˜ š—–š—”š—§ ā–\n━━━━━━━━━━━━━━━━━━", attachment: imageStream.data }, threadID, messageID); } catch (error) { console.error(error); api.setMessageReaction("āŒ", messageID, () => {}, true); return api.sendMessage("āœ• Failed to load the cat image!", threadID, messageID); } } };