From 58d8aef80737aec2c8990902d5c1d6b1ca34a18d Mon Sep 17 00:00:00 2001 From: JonnyBro Date: Thu, 30 Dec 2021 01:47:55 +0500 Subject: [PATCH] fix --- helpers/birthdays.js | 30 +++++++++++++++----------- languages/en-US/economy/birthdate.json | 2 +- languages/ru-RU/economy/birthdate.json | 4 ++-- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/helpers/birthdays.js b/helpers/birthdays.js index 1ff71bd1..6dbad901 100644 --- a/helpers/birthdays.js +++ b/helpers/birthdays.js @@ -2,11 +2,12 @@ const CronJob = require("cron").CronJob, Discord = require("discord.js"); async function init(client) { - new CronJob("0 14 23 * * *", async function () { + new CronJob("0 8 * * *", async function () { client.guilds.cache.forEach(async (guild) => { const date = new Date(); - const currentMonth = date.getMonth() + 1; const currentDay = date.getDate(); + const currentMonth = date.getMonth(); + const currentYear = date.getFullYear(); const guildData = await client.findOrCreateGuild({ id: guild.id }); @@ -18,18 +19,25 @@ async function init(client) { .find({ birthdate: { $gt: 1 } }) .then(async (users) => { for (const user of users) { - console.log(new Date(user.birthdate)) - const month = user.birthdate.getUTCMonth() + 1; - const day = user.birthdate.getUTCDate(); + const userDate = new Date(user.birthdate); + const day = userDate.getDate(); + const month = userDate.getMonth(); + const year = userDate.getFullYear(); + if (currentMonth === month && currentDay === day) { const embed = new Discord.MessageEmbed() - .setAuthor(message.guild.name, message.guild.iconURL()) + .setAuthor(client.user.username, client.user.displayAvatarURL({ + size: 512, + dynamic: true, + format: "png" + })) .setColor(client.config.embed.color) .setFooter(client.config.embed.footer) - .addField(message.translate("economy/birthdate:HAPPY_BIRTHDAY"), message.translate("economy/birthdate:HAPPY_BIRTDAY_MESSAGE", { - user: user.id + .addField(client.translate("economy/birthdate:HAPPY_BIRTHDAY"), client.translate("economy/birthdate:HAPPY_BIRTHDAY_MESSAGE", { + user: user.id, + age: currentYear - year })); - const msg = await channel.send(embed); + const msg = await channel.send("@everyone", { embed }); await msg.react("🎉"); }; }; @@ -40,6 +48,4 @@ async function init(client) { }, null, true, "Europe/Moscow"); }; -module.exports = { - init -}; \ No newline at end of file +module.exports = { init }; \ No newline at end of file diff --git a/languages/en-US/economy/birthdate.json b/languages/en-US/economy/birthdate.json index 870ac7c1..daaf711d 100644 --- a/languages/en-US/economy/birthdate.json +++ b/languages/en-US/economy/birthdate.json @@ -7,7 +7,7 @@ "INVALID_DATE_FORMAT": "You must use the following date format: DD/MM/YYYY. For example, `December 1, 2000` will be `01/12/2000`.", "DATE_TOO_HIGH": "More than 80 years old? :eyes:", "DATE_TOO_LOW": "Humm, nop! You must be born!", - "HAPPY_BIRTHDAY": "Today is someone's birthday!", + "HAPPY_BIRTHDAY": "Happy birthday!", "HAPPY_BIRTHDAY_MESSAGE": "Happy birthday, <@{{user}}>!", "SUCCESS": "Your birthday has been set on {{date}}!" } \ No newline at end of file diff --git a/languages/ru-RU/economy/birthdate.json b/languages/ru-RU/economy/birthdate.json index a36ce0d6..25a6a8d4 100644 --- a/languages/ru-RU/economy/birthdate.json +++ b/languages/ru-RU/economy/birthdate.json @@ -7,7 +7,7 @@ "INVALID_DATE_FORMAT": "Используйте данный формат: ДД/ММ/ГГГГ. Например, `1 января 2010` будет `01/01/2010`.", "DATE_TOO_HIGH": "Вам больше 80 лет? :eyes:", "DATE_TOO_LOW": "Хммм... Вы ещё не родились!", - "HAPPY_BIRTHDAY": "Сегодня у кого-то день рождения!", - "HAPPY_BIRTHDAY_MESSAGE": "С днём рождения, <@{{user}}> :3", + "HAPPY_BIRTHDAY": "С днём рождения!", + "HAPPY_BIRTHDAY_MESSAGE": "С днём рождения, <@{{user}}>. Ему(ей) исполнилось **{{age}}** лет(год/года)!", "SUCCESS": "Ваш день рождения установлен на {{date}}!" } \ No newline at end of file