goat
command
age
সঠিকভাবে বয়স গণনা করুন
0
views
0
likes
0
installs
raw source
const moment = require("moment-timezone");
module.exports = {
config: {
name: "age",
version: "2.0.0",
author: "SUJON-BOSS",
countDown: 5,
role: 0,
shortDescription: "সঠিকভাবে বয়স গণনা করুন",
longDescription: "জন্ম তারিখ দিয়ে সঠিকভাবে বয়স গণনা করুন",
category: "utility",
guide: {
body: "{pn} [dd/mm/yyyy]"
}
},
onStart: async function ({ message, args }) {
try {
const input = args[0];
if (!input) {
return message.reply(
"❌ দয়া করে আপনার জন্ম তারিখ DD/MM/YYYY ফরম্যাটে লিখুন।"
);
}
const [day, month, year] = input
.split("/")
.map(i => parseInt(i));
// Day check
if (!day || day < 1 || day > 31) {
return message.reply(
"❌ দিনের সংখ্যা ভুল হয়েছে!"
);
}
// Month check
if (!month || month < 1 || month > 12) {
return message.reply(
"❌ মাসের সংখ্যা ভুল হয়েছে!"
);
}
// Year check
if (
!year ||
year > new Date().getFullYear()
) {
return message.reply(
"❌ বছরের সংখ্যা ভুল হয়েছে!"
);
}
// Current Bangladesh time
const now = moment.tz("Asia/Dhaka");
// Birth date
const birthDate = moment.tz(
`${year}-${month}-${day}`,
"YYYY-MM-DD",
"Asia/Dhaka"
);
// Invalid date check
if (!birthDate.isValid()) {
return message.reply(
"❌ অবৈধ জন্ম তারিখ! দয়া করে সঠিক তারিখ লিখুন।"
);
}
// Future date check
if (now.isBefore(birthDate)) {
return message.reply(
"❌ জন্ম তারিখ ভবিষ্যতের হতে পারে না!"
);
}
// Calculate total duration
const totalSeconds = now.diff(
birthDate,
"seconds"
);
const totalMinutes = Math.floor(
totalSeconds / 60
);
const totalHours = Math.floor(
totalMinutes / 60
);
const totalDays = Math.floor(
totalHours / 24
);
const totalWeeks = Math.floor(
totalDays / 7
);
const totalMonths = now.diff(
birthDate,
"months"
);
const totalYears = now.diff(
birthDate,
"years"
);
// Remaining units
const remainingMonths =
totalMonths % 12;
const remainingDays = Math.floor(
now.diff(
birthDate.clone().add(totalMonths, "months"),
"days"
)
);
const remainingHours = now.diff(
birthDate
.clone()
.add(totalMonths, "months")
.add(remainingDays, "days"),
"hours"
);
const remainingMinutes = now.diff(
birthDate
.clone()
.add(totalMonths, "months")
.add(remainingDays, "days")
.add(remainingHours, "hours"),
"minutes"
);
const remainingSeconds = now.diff(
birthDate
.clone()
.add(totalMonths, "months")
.add(remainingDays, "days")
.add(remainingHours, "hours")
.add(remainingMinutes, "minutes"),
"seconds"
);
const messageBody =
`•┄┅════❁🌺❁════┅┄•
┏━━━━━━━━━━━━━━━━━┓
┃ OWNER : SUJON-BOSS
┗━━━━━━━━━━━━━━━━━┛
📅 আপনার জন্ম তারিখ: ${day}/${month}/${year}
🕰️ বয়সের বিশদ বিবরণ:
┏━━━━━━━━━━━━━━━━━┓
┃ 📅 বছর: ${totalYears} বছর ${remainingMonths} মাস
┃ 🌙 মোট মাস: ${totalMonths} মাস
┃ 📆 মোট সপ্তাহ: ${totalWeeks} সপ্তাহ
┃ 🗓️ মোট দিন: ${totalDays} দিন
┃ ⏳ মোট ঘন্টা: ${totalHours} ঘন্টা
┃ 🕒 মোট মিনিট: ${totalMinutes} মিনিট
┃ ⏱️ মোট সেকেন্ড: ${totalSeconds} সেকেন্ড
┗━━━━━━━━━━━━━━━━━┛
✨ আল্লাহ আপনার عمر বরকতময় করুন! আমীন ✨
•┄┅════❁🌺❁════┅┄•`;
return message.reply(messageBody);
} catch (error) {
console.error("AGE COMMAND ERROR:", error);
return message.reply(
"❌ বয়স গণনা করতে সমস্যা হয়েছে। দয়া করে আবার চেষ্টা করুন।"
);
}
}
};