From 8f0ac0cc6450fae918e7a5a013b1ae449ac87ee7 Mon Sep 17 00:00:00 2001 From: JonnyBro Date: Thu, 4 Aug 2022 19:41:28 +0500 Subject: [PATCH] =?UTF-8?q?4.0pre3=20=D0=9A=D0=B0=D0=BD=D0=B0=D0=BB=20?= =?UTF-8?q?=D1=81=20=D0=BD=D0=BE=D0=B2=D0=BE=D1=81=D1=82=D1=8F=D0=BC=D0=B8?= =?UTF-8?q?=20(=D0=B2=20=D0=B1=D1=83=D0=B4=D1=83=D1=89=D0=B5=D0=BC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TO REWRITE/Administration/setnews.js | 44 +++++++++++++++++++++ base/Guild.js | 1 + commands/Owner/announcement.js | 2 +- config.sample.js | 3 +- languages/ru-RU/administration/setnews.json | 7 ++++ package-lock.json | 4 +- package.json | 2 +- 7 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 TO REWRITE/Administration/setnews.js create mode 100644 languages/ru-RU/administration/setnews.json diff --git a/TO REWRITE/Administration/setnews.js b/TO REWRITE/Administration/setnews.js new file mode 100644 index 00000000..dbd5d062 --- /dev/null +++ b/TO REWRITE/Administration/setnews.js @@ -0,0 +1,44 @@ +const Command = require("../../base/Command"); + +class Setnews extends Command { + constructor(client) { + super(client, { + name: "setnews", + dirname: __dirname, + enabled: true, + guildOnly: true, + aliases: [], + memberPermissions: ["MANAGE_GUILD"], + botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], + nsfw: false, + ownerOnly: false, + cooldown: 1000 + }); + } + + async run(message, args, data) { + const areNewsEnabled = Boolean(data.guild.plugins.news); + const sentChannel = await Resolvers.resolveChannel({ + message, + search: args.join(" "), + channelType: "GUILD_TEXT" + }); + + if (areNewsEnabled && !sentChannel) { + data.guild.plugins.news = null; + data.guild.markModified("plugins.news"); + await data.guild.save(); + return message.success("administration/setnews:DISABLED"); + } else { + const channel = sentChannel || message.channel; + data.guild.plugins.news = channel.id; + data.guild.markModified("plugins.news"); + await data.guild.save(); + return message.success("administration/setnews:ENABLED", { + channel: channel.toString() + }); + } + } +} + +module.exports = Setnews; \ No newline at end of file diff --git a/base/Guild.js b/base/Guild.js index c39bdc2a..0847c62e 100644 --- a/base/Guild.js +++ b/base/Guild.js @@ -34,6 +34,7 @@ module.exports = mongoose.model("Guild", new Schema({ kick: false, ban: false }, + news: false, suggestions: false, modlogs: false, birthdays: false, diff --git a/commands/Owner/announcement.js b/commands/Owner/announcement.js index bd5c3067..e41c3579 100644 --- a/commands/Owner/announcement.js +++ b/commands/Owner/announcement.js @@ -51,7 +51,7 @@ class Announcement extends BaseCommand { client.guilds.cache.forEach(async guild => { if (guild.id === "568120814776614924") return; - const channel = guild.channels.cache.find(g => g.id === guild?.data.plugins.welcome.channel); + const channel = guild.channels.cache.get(guild?.data.plugins.news); await channel.send({ content: "||@everyone|| ВАЖНОЕ ОБЪЯВЛЕНИЕ!", embeds: [embed] diff --git a/config.sample.js b/config.sample.js index e263f1da..1913090e 100644 --- a/config.sample.js +++ b/config.sample.js @@ -4,7 +4,8 @@ module.exports = { /* ID of Bot's user */ user: "XXXXXXXXXXX", /* For the support server */ - production: true, // Set to true for production + /* Set to true for production */ + production: true, support: { id: "XXXXXXXXXXX", // The ID of the support server logs: "XXXXXXXXXXX", // And the ID of the logs channel of your server (new servers for example) diff --git a/languages/ru-RU/administration/setnews.json b/languages/ru-RU/administration/setnews.json new file mode 100644 index 00000000..13414c44 --- /dev/null +++ b/languages/ru-RU/administration/setnews.json @@ -0,0 +1,7 @@ +{ + "DESCRIPTION": "Установить канал для новостей бота", + "USAGE": "setnews (#канал)", + "EXAMPLES": "setnews #bot-news\nsetnews", + "ENABLED": "Поздравления включены в канале **{{channel}}**!", + "DISABLED": "Поздравления отключены!" +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 77edc8fe..6995dd94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "jaba", - "version": "4.0pre1", + "version": "4.0pre3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "jaba", - "version": "4.0pre1", + "version": "4.0pre3", "license": "ISC", "dependencies": { "@discord-player/extractor": "^3.0.2", diff --git a/package.json b/package.json index 7e038f4f..df9dedd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jaba", - "version": "4.0pre1", + "version": "4.0pre3", "description": "My Discord Bot", "main": "index.js", "private": true,