OminduAnjana Junior Developer
const { command, isPrivate } = require(“../../lib/”);
const axios = require(“axios”);
const apilink = “https://dark-yasiya-news-apis.vercel.app/api/hiru”;
command(
{
pattern: “hiru”,
fromMe: isPrivate,
desc: “Get Hiru news”,
type: “news”,
},
async (message, match, m) => {
try {
const response = await axios.get(apilink);
const news = response.data;
let image = `${news.result.image}`
await message.sendMessage(message.jid, image, { caption: `* Title – ${news.result.title}\n\n* News – ${news.result.desc}\n\n* Link – ${news.result.url}\n\n*Β© πππ΄π΄π½ ππΏππΈπΊπ ππ·π°ππ΄ππ°πΏπΏ π±πΎπ*` }, “image”);
} catch (error) {
console.error(“Error:”, error.message);
await message.reply(“Error fetching Hiru news.”);
}
}
);