mirror of
https://github.com/JonnyBro/JaBa.git
synced 2025-01-01 16:23:02 +05:00
Compare commits
2 commits
8b677f9ec4
...
4728258071
Author | SHA1 | Date | |
---|---|---|---|
4728258071 | |||
6ad65e7019 |
2 changed files with 48 additions and 41 deletions
|
@ -58,13 +58,13 @@ class CommandHandler extends BaseEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
client.logger.cmd(
|
client.logger.cmd(
|
||||||
`User ${interaction.user.getUsername()} used ${command.command.name} in ${interaction.guild ? interaction.guild.name : "DM"} with arguments: ${
|
`[${interaction.guild ? interaction.guild.name : "DM"}]: [${interaction.user.getUsername()}] => /${command.command.name}${
|
||||||
interaction.options.data.length > 0
|
interaction.options.data.length > 0
|
||||||
? interaction.options.data
|
? ", args: " + interaction.options.data
|
||||||
.map(arg => {
|
.map(arg => {
|
||||||
return `${arg.name}: ${arg.value}`;
|
return `${arg.name}: ${arg.value}`;
|
||||||
}).join(", ")
|
}).join(", ")
|
||||||
: "no args"
|
: ""
|
||||||
}`,
|
}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -7,50 +7,57 @@ const { CronJob } = require("cron");
|
||||||
module.exports.init = async client => {
|
module.exports.init = async client => {
|
||||||
const cronjob = new CronJob("0 5 * * *", async function () {
|
const cronjob = new CronJob("0 5 * * *", async function () {
|
||||||
client.guilds.cache.forEach(async guild => {
|
client.guilds.cache.forEach(async guild => {
|
||||||
const guildData = await client.getGuildData(guild.id);
|
try {
|
||||||
const channel = guildData.plugins.birthdays ? await client.channels.fetch(guildData.plugins.birthdays) : null;
|
console.log(`Checking birthdays for "${guild.name}"`);
|
||||||
|
|
||||||
if (channel) {
|
const guildData = await client.getGuildData(guild.id);
|
||||||
const date = new Date(),
|
const channel = guildData.plugins.birthdays ? await client.channels.fetch(guildData.plugins.birthdays) : null;
|
||||||
currentDay = date.getDate(),
|
|
||||||
currentMonth = date.getMonth() + 1,
|
|
||||||
currentYear = date.getFullYear();
|
|
||||||
|
|
||||||
client.usersData.find({ birthdate: { $gt: 1 } }).then(async users => {
|
if (channel) {
|
||||||
for (const user of users) {
|
const date = new Date(),
|
||||||
if (!guild.members.cache.find(m => m.id === user.id)) return;
|
currentDay = date.getDate(),
|
||||||
|
currentMonth = date.getMonth() + 1,
|
||||||
|
currentYear = date.getFullYear();
|
||||||
|
|
||||||
const userDate = new Date(user.birthdate * 1000),
|
client.usersData.find({ birthdate: { $gt: 1 } }).then(async users => {
|
||||||
day = userDate.getDate(),
|
for (const user of users) {
|
||||||
month = userDate.getMonth() + 1,
|
if (!guild.members.cache.find(m => m.id === user.id)) return;
|
||||||
year = userDate.getFullYear(),
|
|
||||||
age = currentYear - year;
|
|
||||||
|
|
||||||
if (currentMonth === month && currentDay === day) {
|
const userDate = new Date(user.birthdate * 1000),
|
||||||
const embed = client.embed({
|
day = userDate.getDate(),
|
||||||
author: client.user.getUsername(),
|
month = userDate.getMonth() + 1,
|
||||||
fields: [
|
year = userDate.getFullYear(),
|
||||||
{
|
age = currentYear - year;
|
||||||
name: client.translate("economy/birthdate:HAPPY_BIRTHDAY", null, guildData.language),
|
|
||||||
value: client.translate("economy/birthdate:HAPPY_BIRTHDAY_MESSAGE", {
|
|
||||||
user: user.id,
|
|
||||||
age: `**${age}** ${client.functions.getNoun(
|
|
||||||
age,
|
|
||||||
client.translate("misc:NOUNS:AGE:1", null, guildData.language),
|
|
||||||
client.translate("misc:NOUNS:AGE:2", null, guildData.language),
|
|
||||||
client.translate("misc:NOUNS:AGE:5", null, guildData.language),
|
|
||||||
)}`,
|
|
||||||
}, guildData.language),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
channel.send({
|
if (currentMonth === month && currentDay === day) {
|
||||||
embeds: [embed],
|
const embed = client.embed({
|
||||||
}).then(m => m.react("🎉"));
|
author: client.user.getUsername(),
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: client.translate("economy/birthdate:HAPPY_BIRTHDAY", null, guildData.language),
|
||||||
|
value: client.translate("economy/birthdate:HAPPY_BIRTHDAY_MESSAGE", {
|
||||||
|
user: user.id,
|
||||||
|
age: `**${age}** ${client.functions.getNoun(
|
||||||
|
age,
|
||||||
|
client.translate("misc:NOUNS:AGE:1", null, guildData.language),
|
||||||
|
client.translate("misc:NOUNS:AGE:2", null, guildData.language),
|
||||||
|
client.translate("misc:NOUNS:AGE:5", null, guildData.language),
|
||||||
|
)}`,
|
||||||
|
}, guildData.language),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
channel.send({
|
||||||
|
embeds: [embed],
|
||||||
|
}).then(m => m.react("🎉"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (err.code === 10003) console.log("Unknown channel");
|
||||||
|
else throw err;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue