From 0b8dc1de0e8f98017fba8640d12cf02d37782511 Mon Sep 17 00:00:00 2001 From: JonnyBro Date: Mon, 13 Dec 2021 18:27:54 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D0=B0=D1=8F=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BC=D0=B0=D0=BD=D0=B4=D0=B0=20say?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/Owner/eval.js | 3 +- commands/Owner/say.js | 57 +++++++++++++++++++++++++++++++++ events/message.js | 4 +-- helpers/autoUpdateDocs.js | 2 +- languages/ru-RU/owner/eval.json | 2 +- languages/ru-RU/owner/say.json | 5 +++ 6 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 commands/Owner/say.js create mode 100644 languages/ru-RU/owner/say.json diff --git a/commands/Owner/eval.js b/commands/Owner/eval.js index e6a85e0f..8619322a 100644 --- a/commands/Owner/eval.js +++ b/commands/Owner/eval.js @@ -27,10 +27,11 @@ class Eval extends Command { const result = new Promise((resolve) => resolve(eval(content))); return result.then((output) => { - if (typeof output !== "string") output = require("util").inspect(output, { depth: 0 }); + if (typeof output != "string") output = require("util").inspect(output, { depth: 0 }); if (output.includes(this.client.token)) output = output.replace(this.client.token, "T0K3N"); message.channel.send(output, { code: "js" }); }).catch((err) => { + console.error(err); err = err.toString(); if (err.includes(this.client.token)) err = err.replace(this.client.token, "T0K3N"); message.channel.send(err, { code: "js" }); diff --git a/commands/Owner/say.js b/commands/Owner/say.js new file mode 100644 index 00000000..644a613d --- /dev/null +++ b/commands/Owner/say.js @@ -0,0 +1,57 @@ +const Command = require("../../base/Command.js"); + +class Say extends Command { + constructor (client) { + super(client, { + name: "say", + dirname: __dirname, + enabled: true, + guildOnly: false, + aliases: [], + memberPermissions: [], + botPermissions: [ "SEND_MESSAGES", "EMBED_LINKS" ], + nsfw: false, + ownerOnly: true, + cooldown: 3000 + }); + } + + async run (message, args, data) { + // Arguments split + let split = "++"; + args = args.join(" ").split(split); + for (var i = 0; i < args.length; i++) args[i] = args[i].trim(); + + if (!args[0]) return message.delete(); + + if (args[1] && !args[2]) { + message.delete(); + const saychannel = message.guild.channels.cache.find(channel => channel.name == args[1] || channel.id == args[1]); + saychannel.startTyping(); + + setTimeout(function() { + saychannel.send(args[0]); + saychannel.stopTyping(); + }, 2000); + } else if (args[2]) { + const saychannel = this.client.guilds.cache.find(guild => guild.name == args[2] || guild.id == args[2]).channels.cache.find(channel => channel.name == args[1] || channel.id == args[1]); + saychannel.startTyping(); + + setTimeout(function() { + saychannel.send(args[0]); + saychannel.stopTyping(); + }, 2000); + } else { + message.delete(); + const saychannel = message.channel; + saychannel.startTyping(); + + setTimeout(function() { + saychannel.send(args[0]); + saychannel.stopTyping(); + }, 2000); + }; + } +}; + +module.exports = Say; \ No newline at end of file diff --git a/events/message.js b/events/message.js index c77b8346..340a86c3 100644 --- a/events/message.js +++ b/events/message.js @@ -142,7 +142,7 @@ module.exports = class { if (!cmd.conf.enabled) return message.error("misc:COMMAND_DISABLED"); - if (cmd.conf.ownerOnly && message.author.id !== client.config.owner.id)return message.error("misc:OWNER_ONLY"); + if (cmd.conf.ownerOnly && message.author.id !== client.config.owner.id) return message.error("misc:OWNER_ONLY"); let uCooldown = cmdCooldown[message.author.id]; if (!uCooldown) { @@ -153,7 +153,7 @@ module.exports = class { if (time && (time > Date.now())) return message.error("misc:COOLDOWNED", { seconds: Math.ceil((time-Date.now())/1000) }); cmdCooldown[message.author.id][cmd.help.name] = Date.now() + cmd.conf.cooldown; - client.logger.log(`${message.author.username} (${message.author.id}) ran command ${cmd.help.name} on ${message.guild.name}`, "cmd"); + client.logger.log(`${message.author.username} (${message.author.id}) ran command ${cmd.help.name} ${message.guild ? `on ${message.guild.name}` : "in DM"}`, "cmd"); const log = new this.client.logs({ commandName: cmd.help.name, diff --git a/helpers/autoUpdateDocs.js b/helpers/autoUpdateDocs.js index 14de81c0..db4b8e02 100644 --- a/helpers/autoUpdateDocs.js +++ b/helpers/autoUpdateDocs.js @@ -36,7 +36,7 @@ module.exports = { }; }).forEach((cmd) => { arrCat.push([ - `**${cmd.help.name}**`, + `**${cmd.help.name}** ${cmd.help.aliases.length ? `**(${cmd.help.aliases.join(", ")})**` : ""}`, client.translate(`${cmd.help.category.toLowerCase()}/${cmd.help.name}:DESCRIPTION`), client.translate(`${cmd.help.category.toLowerCase()}/${cmd.help.name}:USAGE`), Math.ceil(cmd.conf.cooldown / 1000)+" секунд(а/ы)" diff --git a/languages/ru-RU/owner/eval.json b/languages/ru-RU/owner/eval.json index 85567e25..b20b1c2a 100644 --- a/languages/ru-RU/owner/eval.json +++ b/languages/ru-RU/owner/eval.json @@ -1,5 +1,5 @@ { "DESCRIPTION": "Выполнить код!", "USAGE": "{{prefix}}eval [код]", - "EXAMPLES": "{{prefix}}eval message.author.send(message.client.token)" + "EXAMPLES": "{{prefix}}eval message.channel.send(\"Hello World!\")" } \ No newline at end of file diff --git a/languages/ru-RU/owner/say.json b/languages/ru-RU/owner/say.json new file mode 100644 index 00000000..e5594600 --- /dev/null +++ b/languages/ru-RU/owner/say.json @@ -0,0 +1,5 @@ +{ + "DESCRIPTION": "Написать сообщение от имени бота!", + "USAGE": "{{prefix}}say [текст] ++ (ID/название_канала) ++ (ID/название_сервера)", + "EXAMPLES": "{{prefix}}say Hello World!\n{{prefix}}say Hello World! ++ 123456789098765432" +} \ No newline at end of file