From 7c7931c7f8697bb9be8dd5d1b4c21df52d9635fe Mon Sep 17 00:00:00 2001 From: JonnyBro Date: Thu, 30 Dec 2021 00:53:09 +0500 Subject: [PATCH] setbirthdays --- commands/Administration/setbirthdays.js | 45 +++++++++++++++++++ .../ru-RU/administration/setbirthdays.json | 7 +++ 2 files changed, 52 insertions(+) create mode 100644 commands/Administration/setbirthdays.js create mode 100644 languages/ru-RU/administration/setbirthdays.json diff --git a/commands/Administration/setbirthdays.js b/commands/Administration/setbirthdays.js new file mode 100644 index 00000000..67d8175c --- /dev/null +++ b/commands/Administration/setbirthdays.js @@ -0,0 +1,45 @@ +const Command = require("../../base/Command.js"), + Resolvers = require("../../helpers/resolvers"); + +class Setbirthdays extends Command { + constructor(client) { + super(client, { + name: "setbirthdays", + dirname: __dirname, + enabled: true, + guildOnly: true, + aliases: [], + memberPermissions: ["MANAGE_GUILD"], + botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], + nsfw: false, + ownerOnly: false, + cooldown: 2000 + }); + } + + async run(message, args, data) { + const areBirthdaysEnabled = Boolean(data.guild.plugins.birthdays); + const sentChannel = await Resolvers.resolveChannel({ + message, + search: args.join(" "), + channelType: "text" + }); + + if (!sentChannel && areBirthdaysEnabled) { + data.guild.plugins.birthdays = null; + data.guild.markModified("plugins.birthdays"); + await data.guild.save(); + return message.success("administration/setbirthdays:SUCCESS_DISABLED"); + } else { + const channel = sentChannel || message.channel; + data.guild.plugins.birthdays = channel.id; + data.guild.markModified("plugins.birthdays"); + await data.guild.save(); + return message.success("administration/setbirthdays:SUCCESS_ENABLED", { + channel: channel.toString() + }); + }; + } +}; + +module.exports = Setbirthdays; \ No newline at end of file diff --git a/languages/ru-RU/administration/setbirthdays.json b/languages/ru-RU/administration/setbirthdays.json new file mode 100644 index 00000000..425a2022 --- /dev/null +++ b/languages/ru-RU/administration/setbirthdays.json @@ -0,0 +1,7 @@ +{ + "DESCRIPTION": "Установить канал для поздравлений с днём рождения!", + "USAGE": "{{prefix}}setbirthdays (#канал)", + "EXAMPLES": "{{prefix}}setbirthdays #дни-рождения\n{{prefix}}setbirthdays", + "SUCCESS_ENABLED": "Поздравления включены в канале **{{channel}}**!", + "SUCCESS_DISABLED": "Поздравления отключены!" +} \ No newline at end of file