diff --git a/base/Guild.js b/base/Guild.js index 4c81cd48..8bfbf0b4 100644 --- a/base/Guild.js +++ b/base/Guild.js @@ -51,6 +51,7 @@ module.exports = mongoose.model("Guild", new Schema({ }, suggestions: false, // the channel in which the suggestions will be sent modlogs: false, // the channel in which the moderation logs (mute, kick, ban, etc...) will be sent + birthdays: false, // the channel in which birtdays announcements will be sent reports: false, // the channel in which the reports will be sent fortniteshop: false, // the channel in which the fortnite shop image will be sent at 2.05am logs: false // the channel in which the logs (message deleted, etc...) will be sent diff --git a/commands/General/translate.js b/commands/General/translate.js index 3f894071..235c6ee6 100644 --- a/commands/General/translate.js +++ b/commands/General/translate.js @@ -49,7 +49,7 @@ class Translate extends Command { }); const resEmbed = new Discord.MessageEmbed() - .setAuthor("Translator", this.client.user.displayAvatarURL({ + .setAuthor("Переводчик", this.client.user.displayAvatarURL({ size: 512, dynamic: true, format: "png" diff --git a/events/ready.js b/events/ready.js index 45f6844d..cc81aca0 100644 --- a/events/ready.js +++ b/events/ready.js @@ -17,6 +17,10 @@ module.exports = class { const discordtogether = require("../helpers/discordTogether"); discordtogether.init(client); + // Birthday Announce + const birthdays = require("../helpers/birthdays"); + birthdays.init(client); + // DiscordBots.org STATS const discordbotsorg = require("../helpers/discordbots.org"); discordbotsorg.init(client); diff --git a/helpers/birthdays.js b/helpers/birthdays.js new file mode 100644 index 00000000..be065cb5 --- /dev/null +++ b/helpers/birthdays.js @@ -0,0 +1,44 @@ +const CronJob = require("cron").CronJob, + Discord = require("discord.js"); + +async function init(client) { + new CronJob("0 0 8 * * *", async function () { + client.guilds.cache.forEach(async (guild) => { + const date = new Date(); + const currentMonth = date.getMonth() + 1; + const currentDay = date.getDate(); + const guildData = await client.findOrCreateGuild({ + id: guild.id + }); + + if (guildData.plugins.birthdays) { + const channel = client.channels.cache.get(guildData.plugins.birthdays); + if (channel) { + client.usersData + .find({ birthdate: { $gt: 1 } }) + .then((users) => { + for (const user of users) { + const month = user.birthdate.getUTCMonth() + 1; + const day = user.birthdate.getUTCDate(); + if (currentMonth === month && currentDay === day) { + const embed = new Discord.MessageEmbed() + .setAuthor(message.guild.name, message.guild.iconURL()) + .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 + })); + const msg = await channel.send(embed); + await msg.react("🎉"); + }; + }; + }); + }; + }; + }); + }, null, true, "Europe/Moscow"); +}; + +module.exports = { + init +}; \ No newline at end of file diff --git a/languages/en-US/administration/configuration.json b/languages/en-US/administration/configuration.json index 28f2a912..a1c6c6d8 100644 --- a/languages/en-US/administration/configuration.json +++ b/languages/en-US/administration/configuration.json @@ -28,8 +28,8 @@ "DASHBOARD_TITLE": "Edit your configuration:", "DASHBOARD_CONTENT": "Click here to go on the dashboard!", "AUTO_SANCTIONS": "Automatic sanctions", - "KICK_CONTENT": "__Kick:__ After **{{count}}** warnings.", - "KICK_NOT_DEFINED": "__Kick:__ Not defined.", - "BAN_CONTENT": "__Ban:__ After **{{count}}** warnings.", - "BAN_NOT_DEFINED": "__Ban:__ Not defined." + "KICK_CONTENT": "Kick: After **{{count}}** warnings.", + "KICK_NOT_DEFINED": "Kick: Not defined.", + "BAN_CONTENT": "Ban: After **{{count}}** warnings.", + "BAN_NOT_DEFINED": "Ban: Not defined." } diff --git a/languages/en-US/economy/birthdate.json b/languages/en-US/economy/birthdate.json index 2ef837fd..870ac7c1 100644 --- a/languages/en-US/economy/birthdate.json +++ b/languages/en-US/economy/birthdate.json @@ -7,5 +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_MESSAGE": "Happy birthday, <@{{user}}>!", "SUCCESS": "Your birthday has been set on {{date}}!" } \ No newline at end of file diff --git a/languages/ru-RU/administration/configuration.json b/languages/ru-RU/administration/configuration.json index 3b96fbe9..f4ab408e 100644 --- a/languages/ru-RU/administration/configuration.json +++ b/languages/ru-RU/administration/configuration.json @@ -28,8 +28,8 @@ "DASHBOARD_TITLE": "Изменить настройки:", "DASHBOARD_CONTENT": "Нажмите сюда, чтобы перейти в панель управления!", "AUTO_SANCTIONS": "Автоматические наказания", - "KICK_CONTENT": "__Кик:__ После **{{count}}** предупреждений.", - "KICK_NOT_DEFINED": "__Кик:__ Не назначено.", - "BAN_CONTENT": "__Бан:__ После **{{count}}** предупреждений.", - "BAN_NOT_DEFINED": "__Бан:__ Не назначено." + "KICK_CONTENT": "Кик: После **{{count}}** предупреждений.", + "KICK_NOT_DEFINED": "Кик: Не назначено.", + "BAN_CONTENT": "Бан: После **{{count}}** предупреждений.", + "BAN_NOT_DEFINED": "Бан: Не назначено." } \ No newline at end of file diff --git a/languages/ru-RU/economy/birthdate.json b/languages/ru-RU/economy/birthdate.json index 8dafe693..a36ce0d6 100644 --- a/languages/ru-RU/economy/birthdate.json +++ b/languages/ru-RU/economy/birthdate.json @@ -5,7 +5,9 @@ "MISSING_DATE": "Пожалуйста, укажите правильную дату! Например, 20/11/2003", "INVALID_DATE": "Используйте данный формат: ДД/ММ/ГГГГ. Например, `1 января 2010` будет `01/01/2010`.", "INVALID_DATE_FORMAT": "Используйте данный формат: ДД/ММ/ГГГГ. Например, `1 января 2010` будет `01/01/2010`.", - "DATE_TOO_HIGH": "Вы старше 80 лет? :eyes:", + "DATE_TOO_HIGH": "Вам больше 80 лет? :eyes:", "DATE_TOO_LOW": "Хммм... Вы ещё не родились!", + "HAPPY_BIRTHDAY": "Сегодня у кого-то день рождения!", + "HAPPY_BIRTHDAY_MESSAGE": "С днём рождения, <@{{user}}> :3", "SUCCESS": "Ваш день рождения установлен на {{date}}!" } \ No newline at end of file