goat
command
namaz
No description
0
views
0
likes
0
installs
Aliases: prayer, salah
raw source
const axios = require("axios");
module.exports = {
config: {
name: "namaz",
aliases: ["prayer", "salah"],
version: "2.1",
author: "Efx Asif",
countDown: 5,
role: 0,
category: "Islamic",
guide: "{pn} <city>\nExample: {pn} Dhaka"
},
onStart: async function ({ message, args }) {
const city = args.join(" ") || "Dhaka";
try {
const url =
`https://api.aladhan.com/v1/timingsByCity` +
`?city=${encodeURIComponent(city)}` +
`&country=Bangladesh&method=1`;
const response = await axios.get(url);
if (
!response.data ||
response.data.code !== 200 ||
!response.data.data
) {
return message.reply(
`╭━━━〔 ❌ ERROR 〕━━━╮\n` +
`┃ 📍 Location: ${city}\n` +
`┃ ⚠️ Prayer times not found.\n` +
`╰━━━━━━━━━━━━━━━━━━╯`
);
}
const data = response.data.data;
const t = data.timings;
const date = data.date;
// Remove timezone text like "(+06)"
const clean = time => time.replace(/\s*\(.+?\)/, "");
const now = new Date();
const prayers = [
{ name: "Fajr", time: clean(t.Fajr), icon: "🌅" },
{ name: "Dhuhr", time: clean(t.Dhuhr), icon: "🕌" },
{ name: "Asr", time: clean(t.Asr), icon: "🌇" },
{ name: "Maghrib", time: clean(t.Maghrib), icon: "🌆" },
{ name: "Isha", time: clean(t.Isha), icon: "🌙" }
];
// Current time
const currentTime = now.toLocaleTimeString("en-US", {
hour: "2-digit",
minute: "2-digit",
hour12: true
});
// Find next prayer
let nextPrayer = "Fajr";
let nextTime = prayers[0].time;
for (const prayer of prayers) {
const [hour, minute] = prayer.time.split(":").map(Number);
const prayerDate = new Date();
prayerDate.setHours(hour, minute, 0, 0);
if (prayerDate > now) {
nextPrayer = prayer.name;
nextTime = prayer.time;
break;
}
}
const output = `
╭━━━━━━━━━━━━━━━━━━━━━━╮
┃ 🌙 𝗡𝗔𝗠𝗔𝗭 𝗣𝗔𝗡𝗘𝗟 ┃
╰━━━━━━━━━━━━━━━━━━━━━━╯
╭─〔 📍 𝗟𝗢𝗖𝗔𝗧𝗜𝗢𝗡 〕──────╮
│ 🌍 City : ${city}
│ 📅 Date : ${date.readable}
│ 🗓️ Hijri : ${date.hijri.date}
╰──────────────────────╯
╭─〔 🕌 𝗣𝗥𝗔𝗬𝗘𝗥 𝗧𝗜𝗠𝗘𝗦 〕─╮
│
│ 🌅 Fajr ┃ ${clean(t.Fajr)}
│ 🕌 Dhuhr ┃ ${clean(t.Dhuhr)}
│ 🌇 Asr ┃ ${clean(t.Asr)}
│ 🌆 Maghrib ┃ ${clean(t.Maghrib)}
│ 🌙 Isha ┃ ${clean(t.Isha)}
│
╰──────────────────────╯
╭─〔 ⏰ 𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗦𝗧𝗔𝗧𝗨𝗦 〕─╮
│ 🕐 Time Now : ${currentTime}
│ ➡️ Next Namaz : ${nextPrayer}
│ ⏱️ Time : ${nextTime}
╰──────────────────────╯
╭─〔 🕋 𝗝𝗨𝗠𝗠𝗔𝗛 〕────────╮
│ 🕌 Jummah : ${clean(t.Dhuhr)}
╰──────────────────────╯
╭━━━━━━━━━━━━━━━━━━━━━━╮
┃ ✨ 𝗘𝗳𝘅 𝗔𝘀𝗶𝗳 • 𝗡𝗮𝗺𝗮𝘇 ┃
╰━━━━━━━━━━━━━━━━━━━━━━╯
`;
return message.reply(output);
} catch (error) {
console.error("Namaz Error:", error);
return message.reply(
`╭━━━〔 ❌ ERROR 〕━━━╮
┃ নামাজের সময় আনতে সমস্যা হয়েছে।
┃ কিছুক্ষণ পর আবার চেষ্টা করুন।
╰━━━━━━━━━━━━━━━━━━╯`
);
}
}
};