diff --git a/CHANGELOG.md b/CHANGELOG.md index 17638d5e9..6c0077b4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,31 @@ +## 1.2.6 Change Log +* RITA is now at 6400 servers, This is just Amazing. + +### 1.2.6 Major Changes +* Sharding is now automatic, this should auto scale to the needed amount. +* A Major memory leak causing rita to restart every few hours has now been fixed. + +### 1.2.6 Bug Fixes +* `!tr announce on/off` has been fixed. +* `!tr settings` has been unrestricted. +* `!tr blacklist {ServerID}` has been fixed. +* `!tr channel from {lang} to {lang}` no longer defaults to a DM task. + +### 1.2.5 Command Changes +* `!tr react on/off` now turns on and off flag reactions. + +### 1.2.6 Database Changes +* Added in 3 new columns ready for auto-warn and eject management + > Servers will be allowed 10 Permission Errors Before a Warning + + > Server will be given a Maximum of 3 Warning before they are Ejected + + > If your server should be Ejected a second time it will be blacklisted + +### 1.2.6 Misc. Changes +* Sooooooo Many spelling mistakes corrected that it would be too many to list here. +* Help Menu updated with new commands. + ## 1.2.5 Change Log * Since the launch of 1.2.4 Rita has grown by 800 servers, This is Amazing. From all the RITA Dev Team, We cant thank you enough. diff --git a/package-lock.json b/package-lock.json index 28d17e0bf..e0efdca69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ritabot", - "version": "1.2.5-15", + "version": "1.2.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ritabot", - "version": "1.2.5-15", + "version": "1.2.6", "license": "MIT", "dependencies": { "common-tags": "^1.8.0", diff --git a/package.json b/package.json index 1b9505696..73abd4cee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ritabot", - "version": "1.2.5-15", + "version": "1.2.6", "engines": { "node": "16.2.0" }, diff --git a/src/commands/args.js b/src/commands/args.js index 2099f8451..056ae6a81 100644 --- a/src/commands/args.js +++ b/src/commands/args.js @@ -32,6 +32,7 @@ const cmdMisc = require("./info_commands/misc"); const cmdPerms = require("./utility_commands/perm"); const cmdPrefix = require("./settings_commands/prefix"); const cmdSettings = require("./settings_commands/settings"); +const cmdReact = require("./settings_commands/react"); const cmdStats = require("./info_commands/stats"); const cmdTranslateLast = require("./translation_commands/translate.last"); const cmdTranslateThis = require("./translation_commands/translate.this"); @@ -374,6 +375,7 @@ module.exports = function run (data) "newbot": cmdJoin.newBot, "prefix": cmdPrefix, "proc": cmdMisc.proc, + "react": cmdReact, "settings": cmdSettings, "shards": cmdMisc.shards, "stats": cmdStats, diff --git a/src/commands/info_commands/history.js b/src/commands/info_commands/history.js index baf04f650..da2fef6b5 100644 --- a/src/commands/info_commands/history.js +++ b/src/commands/info_commands/history.js @@ -282,6 +282,14 @@ function getHistory (data) `# Version 1.2.5-5 - Release Date: 05/09/2021 \n` + `# Version 1.2.5-6 - Release Date: 07/09/2021 \n` + `# Version 1.2.5-7 - Release Date: 08/09/2021 \n` + + `# Version 1.2.5-8 - Release Date: 09/09/2021 \n` + + `# Version 1.2.5-9 - Release Date: 12/09/2021 \n` + + `# Version 1.2.5-10 - Release Date: 15/09/2021 \n` + + `# Version 1.2.5-11 - Was not published. \n` + + `# Version 1.2.5-12 - Release Date: 23/09/2021 \n` + + `# Version 1.2.5-13 - Was not published. \n` + + `# Version 1.2.5-14 - Release Date: 24/09/2021 \n` + + `# Version 1.2.5-15 - Was not published \n\n` + "```\n"; // ------------- @@ -292,6 +300,28 @@ function getHistory (data) }; + const v126History = function v126History (data) + { + + // ------------- + // Command Code + // ------------- + + data.color = "info"; + data.text = `**V1.2.6**\n` + + "```md\n" + + `# Version 1.2.6 - Release Date: 01/10/2021 \n` + + "```\n"; + + // ------------- + // Send message + // ------------- + + return sendMessage(data); + + }; + + const guilds = function guilds (data) { @@ -306,53 +336,38 @@ function getHistory (data) `# Unified RITA Launched - 01/04/2021 \n` + `# 100 Guilds - 25/04/2021 \n` + `# Discord Verified - 27/05/2021 \n` + - `# 200 Guilds - 04/06/2021 \n` + - `# 300 Guilds - 08/06/2021 \n` + - `# 400 Guilds - 11/06/2021 \n` + - `# 500 Guilds - 14/06/2021 \n` + - `# 600 Guilds - 19/06/2021 \n` + - `# 700 Guilds - 21/06/2021 \n` + - `# 800 Guilds - 24/06/2021 \n` + - `# 900 Guilds - 27/06/2021 \n` + - `# 1000 Guilds - 29/06/2021 \n` + - `# 1100 Guilds - 01/07/2021 \n` + - `# 1200 Guilds - 04/07/2021 \n` + - `# 1300 Guilds - 07/07/2021 \n` + - `# 1400 Guilds - 09/07/2021 \n` + - `# 1500 Guilds - 11/07/2021 \n` + - `# 1600 Guilds - 14/07/2021 \n` + - `# 1700 Guilds - 17/07/2021 \n` + - `# 1800 Guilds - 19/07/2021 \n` + - `# 1900 Guilds - 21/07/2021 \n` + - `# 2000 Guilds - 24/07/2021 \n` + - `# 2100 Guilds - 26/07/2021 \n` + - `# 2200 Guilds - 28/07/2021 \n` + - `# 2300 Guilds - 30/07/2021 \n` + - `# 2400 Guilds - 02/08/2021 \n` + - `# 2500 Guilds - 03/08/2021 \n` + - `# 2600 Guilds - 05/08/2021 \n` + - `# 2700 Guilds - 08/08/2021 \n` + - `# 2800 Guilds - 09/08/2021 \n` + - `# 2900 Guilds - 11/08/2021 \n` + - `# 3000 Guilds - 13/08/2021 \n` + - `# 3100 Guilds - 15/08/2021 \n` + - `# 3200 Guilds - 17/08/2021 \n` + - `# 3300 Guilds - 18/08/2021 \n` + - `# 3400 Guilds - 19/08/2021 \n` + - `# 3500 Guilds - 22/08/2021 \n` + - `# 3600 Guilds - 23/08/2021 \n` + - `# 3700 Guilds - 25/08/2021 \n` + - `# 3800 Guilds - 26/08/2021 \n` + - `# 3900 Guilds - 27/08/2021 \n` + - `# 4000 Guilds - 28/08/2021 \n` + - `# 4100 Guilds - 30/08/2021 \n` + - `# 4200 Guilds - 31/08/2021 \n` + - `# 4300 Guilds - 01/09/2021 \n` + - `# 4400 Guilds - 03/09/2021 \n` + - `# 4500 Guilds - 05/09/2021 \n` + - `# 4600 Guilds - 06/09/2021 \n` + - `# 4700 Guilds - 07/09/2021 \n` + - `# 4800 Guilds - 09/09/2021 \n` + + `# 200 Guilds - 04/06/2021 / 300 Guilds - 08/06/2021\n` + + `# 400 Guilds - 11/06/2021 / 500 Guilds - 14/06/2021\n` + + `# 600 Guilds - 19/06/2021 / 700 Guilds - 21/06/2021\n` + + `# 800 Guilds - 24/06/2021 / 900 Guilds - 27/06/2021\n` + + `# 1000 Guilds - 29/06/2021 / 1100 Guilds - 01/07/2021\n` + + `# 1200 Guilds - 04/07/2021 / 1300 Guilds - 07/07/2021\n` + + `# 1400 Guilds - 09/07/2021 / 1500 Guilds - 11/07/2021\n` + + `# 1600 Guilds - 14/07/2021 / 1700 Guilds - 17/07/2021\n` + + `# 1800 Guilds - 19/07/2021 / 1900 Guilds - 21/07/2021\n` + + `# 2000 Guilds - 24/07/2021 / 2100 Guilds - 26/07/2021\n` + + `# 2200 Guilds - 28/07/2021 / 2300 Guilds - 30/07/2021\n` + + `# 2400 Guilds - 02/08/2021 / 2500 Guilds - 03/08/2021\n` + + `# 2600 Guilds - 05/08/2021 / 2700 Guilds - 08/08/2021 \n` + + `# 2800 Guilds - 09/08/2021 / 2900 Guilds - 11/08/2021 \n` + + `# 3000 Guilds - 13/08/2021 / 3100 Guilds - 15/08/2021 \n` + + `# 3200 Guilds - 17/08/2021 / 3300 Guilds - 18/08/2021 \n` + + `# 3400 Guilds - 19/08/2021 / 3500 Guilds - 22/08/2021 \n` + + `# 3600 Guilds - 23/08/2021 / 3700 Guilds - 25/08/2021 \n` + + `# 3800 Guilds - 26/08/2021 / 3900 Guilds - 27/08/2021 \n` + + `# 4000 Guilds - 28/08/2021 / 4100 Guilds - 30/08/2021 \n` + + `# 4200 Guilds - 31/08/2021 / 4300 Guilds - 01/09/2021 \n` + + `# 4400 Guilds - 03/09/2021 / 4500 Guilds - 05/09/2021 \n` + + `# 4600 Guilds - 06/09/2021 / 4700 Guilds - 07/09/2021 \n` + + `# 4800 Guilds - 09/09/2021 / 4900 Guilds - 10/09/2021 \n` + + `# 5000 Guilds - 11/09/2021 / 5100 Guilds - 13/09/2021 \n` + + `# 5200 Guilds - 14/09/2021 / 5300 Guilds - 15/09/2021 \n` + + `# 5400 Guilds - 16/09/2021 / 5500 Guilds - 18/09/2021 \n` + + `# 5600 Guilds - 19/09/2021 / 5700 Guilds - 21/09/2021 \n` + + `# 5800 Guilds - 22/09/2021 / 5900 Guilds - 23/09/2021 \n` + + `# 6000 Guilds - 25/09/2021 / 6100 Guilds - 26/09/2021 \n` + + `# 6200 Guilds - 27/09/2021 / 6300 Guilds - 29/09/2021 \n` + + `# 6400 Guilds - 30/09/2021 / \n` + "```\n"; // ------------- @@ -376,6 +391,7 @@ function getHistory (data) "1.2.3": v123History, "1.2.4": v124History, "1.2.5": v125History, + "1.2.6": v126History, "guild": guilds }; @@ -396,7 +412,7 @@ function getHistory (data) data.color = "error"; data.text = - `:warning: **\`${data.cmd.params}\`** is not a valid history option. \nPlease use 1.0 / 1.1 / 1.2.0 / 1.2.1 / 1.2.2 / 1.2.3 / 1.2.4`; + `:warning: **\`${data.cmd.params}\`** is not a valid history option. \nPlease use 1.0 / 1.1 / 1.2.0 / 1.2.1 / 1.2.2 / 1.2.3 / 1.2.4 / 1.2.5 / 1.2.6`; // ------------- // Send message @@ -443,7 +459,8 @@ module.exports = function run (data) `# Version 1.2.2 - Release Date: 25/04/2021 \n` + `# Version 1.2.3 - Release Date: 24/05/2021 \n` + `# Version 1.2.4 - Release Date: 09/06/2021 \n` + - `# Version 1.2.5 - Release Date: 09/06/2021 \n` + + `# Version 1.2.5 - Release Date: 05/07/2021 \n` + + `# Version 1.2.6 - Release Date: 01/10/2021 \n` + `* There are ?? iterations of this Version\n\n` + "```\n"; diff --git a/src/commands/settings_commands/embed.js b/src/commands/settings_commands/embed.js index c4e43a037..c353418c9 100644 --- a/src/commands/settings_commands/embed.js +++ b/src/commands/settings_commands/embed.js @@ -39,7 +39,8 @@ function embed (data) } const output = "**```Embedded Translation```**\n" + - `Embedded Message translation is now turned : ${commandVariable1}\n\n`; + `Embedded Message translation is now turned : \`${commandVariable1}\`\n\n` + + `\n`; data.color = "info"; data.text = output; diff --git a/src/commands/settings_commands/react.js b/src/commands/settings_commands/react.js new file mode 100644 index 000000000..e50743a63 --- /dev/null +++ b/src/commands/settings_commands/react.js @@ -0,0 +1,139 @@ +// ----------------- +// Global variables +// ----------------- + +// Codebeat:disable[LOC,ABC,BLOCK_NESTING,ARITY] +const logger = require("../../core/logger"); +const db = require("../../core/db"); +const sendMessage = require("../../core/command.send"); + +// ------------------------------ +// React varible command handler +// ------------------------------ + +function react (data) +{ + + const commandVariable = data.cmd.params.split(" ")[0].toLowerCase(); + + if (commandVariable === "on" || commandVariable === "off") + { + + let value = false; + if (commandVariable === "on") + { + + value = true; + + } + + // console.log(`DEBUG: React variable ${commandVariable}`); + return db.updateServerTable(data.message.guild.id, "react", value, function error (err) + { + + if (err) + { + + return logger( + "error", + err, + "command", + data.message.channel.guild.name + ); + + } + const output = + "**```Flag Reactions```**\n" + + `Translations by Flag Reactions is now turned : \`${commandVariable}\`\n\n` + + `\n`; + data.color = "info"; + data.text = output; + + // ------------- + // Send message + // ------------- + + return sendMessage(data); + + }); + + } + + data.color = "error"; + data.text = + `:warning: **\`${commandVariable + }\`** is not a valid react option.\n`; + + // ------------- + // Send message + // ------------- + + return sendMessage(data); + +} + +// ------------- +// Command Code +// ------------- + +module.exports = function run (data) + +{ + + // ------------------------------- + // Command allowed by admins only + // ------------------------------- + + Override: if (!process.env.DISCORD_BOT_OWNER_ID.includes(data.message.author.id)) + { + + if (data.message.isAdmin === false) + { + + { + + data.color = "warn"; + + } + data.text = ":cop: This command is reserved for server adminis."; + + // ------------- + // Send message + // ------------- + + return sendMessage(data); + + } + break Override; + + } + + // -------------------------------- + // Error if react param is missing + // -------------------------------- + + if (!data.cmd.params) + { + + data.color = "error"; + data.text = + ":warning: Missing `react` parameter. Use `" + + `${data.config.translateCmdShort} help react\` to learn more.`; + + // ------------- + // Send message + // ------------- + + return sendMessage(data); + + } + + // ---------------- + // Execute setting + // ---------------- + + return react(data); + +}; + + diff --git a/src/commands/settings_commands/settings.js b/src/commands/settings_commands/settings.js index ff6ea6451..92f8d60ab 100644 --- a/src/commands/settings_commands/settings.js +++ b/src/commands/settings_commands/settings.js @@ -425,9 +425,10 @@ module.exports = function run (data) data.text = `**\`\`\`${data.message.channel.guild.name} - Server Settings` + `\`\`\`**\n:information_source: Your current prefix is: **\`${db.server_obj[data.message.guild.id].db.prefix}\`**\n\n` + - `:tada: Annocement Messages: **\`${data.cmd.server[0].announce}\`**\n\n` + + `:tada: Allow Annocement Messages: **\`${data.cmd.server[0].announce}\`**\n\n` + `:inbox_tray: Embedded Message Style: **\`${data.cmd.server[0].embedstyle}\`**\n\n` + `:robot: Bot to Bot Translation Status: **\`${data.cmd.server[0].bot2botstyle}\`**\n\n` + + `:flags: Translation by Flag Reactions: **\`${data.cmd.server[0].react}\`**\n\n` + `:pause_button: Help Menu Persistance: **\`${data.cmd.server[0].persist}\`**\n\n` + `:wrench: Webhook Debug Active State: **\`${data.cmd.server[0].webhookactive}\`**`; diff --git a/src/commands/translation_commands/translate.react.js b/src/commands/translation_commands/translate.react.js index f4ead6319..25412d1d3 100644 --- a/src/commands/translation_commands/translate.react.js +++ b/src/commands/translation_commands/translate.react.js @@ -34,98 +34,124 @@ module.exports = function run (data, client) // Stop proccessing if country has no langs / null // ------------------------------------------------ - if (!countryLangs[emoji].langs) - { + const serverID = data.guild_id; - return; + db.getServerInfo( + serverID, + function getServerInfo (server) + { - } + if (server[0].react === true) + { - // ----------------- - // Get message data - // ----------------- + if (!countryLangs[emoji].langs) + { - fn.getMessage( - client, - data.message_id, - data.channel_id, - data.user_id, - (message, err) => - { + return; - if (err) - { + } - return logger( - "error", - err, - "command", - data.guild_id - ); + // ----------------- + // Get message data + // ----------------- - } + fn.getMessage( + client, + data.message_id, + data.channel_id, + data.user_id, + (message, err) => + { - // Ignore bots + if (err) + { - if (message.author.bot) - { + return logger( + "error", + err, + "command", + data.guild_id + ); - return; + } - } + // Ignore bots - message.content = message.content. - replace(/<@.*?>/g, ""). - replace(/@everyone/gi, ""). - replace(/@here/gi, ""); + if (message.author.bot) + { + return; - const flagExists = message.reactions.cache.get(emoji); + } - // Prevent flag spam + message.content = message.content. + replace(/<@.*?>/g, ""). + replace(/@everyone/gi, ""). + replace(/@here/gi, ""); - if (flagExists.count > 1) - { - return; + const flagExists = message.reactions.cache.get(emoji); - } + // Prevent flag spam - // Translate data + if (flagExists.count > 1) + { - data.translate = { - "from": langCheck("auto"), - "multi": true, - "original": message.content, - "to": langCheck(countryLangs[emoji].langs) - }; + return; - // Message data + } - data.message = message; - delete data.message.attachments; - data.member.displayColor = fn.getRoleColor(data.message.member); - data.canWrite = true; + // Translate data - // ------------------ - // Start translation - // ------------------ - const col = "react"; - let id = "bot"; - db.increaseStatsCount(col, id); + data.translate = { + "from": langCheck("auto"), + "multi": true, + "original": message.content, + "to": langCheck(countryLangs[emoji].langs) + }; - if (message.channel.type === "text") - { + // Message data - id = data.message.guild.id; + data.message = message; + delete data.message.attachments; + data.member.displayColor = fn.getRoleColor(data.message.member); + data.canWrite = true; - } + // ------------------ + // Start translation + // ------------------ + const col = "react"; + let id = "bot"; + db.increaseStatsCount(col, id); + + if (message.channel.type === "text") + { + + id = data.message.guild.id; + + } + + db.increaseStatsCount(col, id); + translate(data); + + } + ); - db.increaseStatsCount(col, id); - translate(data); + } } - ); + ).catch((err) => + { + + console.log( + "error", + err, + "warning", + serverID + ); + + }); + } diff --git a/src/commands/utility_commands/eject.js b/src/commands/utility_commands/eject.js index dbd6f1c38..a74c62f32 100644 --- a/src/commands/utility_commands/eject.js +++ b/src/commands/utility_commands/eject.js @@ -26,6 +26,10 @@ module.exports.eject = async function eject (data) data.color = "warn"; data.text = `\`\`\`${serverID} - Server connection terminated\`\`\``; + + const col = "ejectcount"; + db.increaseServersCount(col, serverID); + if (!target) { @@ -175,6 +179,10 @@ module.exports.warn = async function warn (data) // ------------- data.color = "warn"; data.text = `\`\`\`Owner: ${target.owner.user.tag}\nServer: ${target.name} \nServer ID: ${serverID}\nServer Owner Has Been Warned\`\`\``; + + const col = "warncount"; + db.increaseServersCount(col, serverID); + await db.updateServerTable( serverID, "warn", diff --git a/src/commands/utility_commands/help.js b/src/commands/utility_commands/help.js index 1a746dc81..1ece56e11 100644 --- a/src/commands/utility_commands/help.js +++ b/src/commands/utility_commands/help.js @@ -44,6 +44,7 @@ function helpMessage (config, param) const info = `**For a full command list and usage examples,**\n` + `**please review our [documentation]()**\n\n` + + "```md\n" + `# For a full list of commands, enter the following:\n` + `* ${cmd} help commands\n` + @@ -119,17 +120,20 @@ function helpMessage (config, param) `* ${cmd} help last\n` + `* ${cmd} help this\n\n` + "```" + + "```md\n" + `# Translation Style Modules\n` + `* ${cmd} help embed\n` + `* ${cmd} help bot2bot\n\n` + "```" + + "```md\n" + `# Information Modules\n` + `* ${cmd} help stats\n` + `* ${cmd} help tasks\n` + `* ${cmd} help settings (Dev Only)\n\n` + "```" + + "```md\n" + `# Other Modules\n` + `* ${cmd} help misc\n` + @@ -175,6 +179,7 @@ function helpMessage (config, param) const commands = `__**All Available Commands**__\n\n` + `This is a list of all available commands\n` + + "```md\n" + `# Translation Commands\n` + `* ${cmd} this from [lang] to [lang]: [msg]\n` + @@ -183,6 +188,7 @@ function helpMessage (config, param) `* ${cmd} auto to [lang] for [me/@/#]\n` + `* ${cmd} stop for [me/@/#]\n\n` + "```" + + "```md\n" + `# Information Commands\n` + `* ${cmd} tasks\n` + @@ -193,12 +199,15 @@ function helpMessage (config, param) `* ${cmd} id\n` + `* ${cmd} list\n` + "```" + + "```md\n" + `# Style Commands\n` + `* ${cmd} embed [on/off]\n` + `* ${cmd} bot2bot [on/off]\n` + + `* ${cmd} react [on/off]\n` + `* ${cmd} prefix [prefix]\n\n` + "```" + + "```md\n" + `# Misc Commands\n` + `* ${cmd} invite\n` + @@ -207,11 +216,13 @@ function helpMessage (config, param) `* ${cmd} create [channelName]\n` + `* ${cmd} history \n\n` + "```" + + "```md\n" + `# Debug Commands\n` + `* ${cmd} debug [on/off]\n` + `* ${cmd} stats debug (Admin Only)\n\n` + "```" + + "```md\n" + `# Want to Support RITA\n` + `* ${cmd} donate [oc/github]\n\n` + @@ -230,12 +241,14 @@ function helpMessage (config, param) `* ${cmd} this: [msg] \n` + `* ${cmd} this from [lang] to [lang]: [msg] \n\n` + "```" + + "```md\n" + `# Parameters\n` + `* to [lang] - defaults to server default language\n` + `* to [lang, lang, ...] - translates to multiple languages\n` + `* from [lang] - defaults to automatic detection\n\n` + "```" + + "```md\n" + `# Examples\n` + `* ${cmd} this: bonjour \n` + @@ -249,11 +262,26 @@ function helpMessage (config, param) // -------------------- const react = + `__**Translate by reaction**__\n\n` + + `Add a message reaction with the flag of the language you wish to translate to.\n\n` + + `Please note that only official country flags are registered.\n` + "```md\n" + - `# Add a message reaction with the flag of the language you wish to translate to\n\n` + - ` Please note that only official country flags are registered\n` + + `# Command\n` + + `* ${cmd} react [on/off] \n\n` + + "```" + + + "```md\n" + + `# Parameters\n` + + `* on - Turns on Translations by Flag Reactions\n` + + `* off - Turns off Translations by Flag Reactions\n\n` + + "```" + + + "```md\n" + + `# Examples\n` + + `* ${cmd} react on \n` + + `* ${cmd} react off \n\n` + "```\n"; // -------------------- // Last Message (last) @@ -267,11 +295,13 @@ function helpMessage (config, param) "```md\n" + `# Due to a technical fault, this command is disabled until further notice. Sorry for any inconvenience this may cause.` + "```\n" + + "```md\n" + `# Command\n` + `* ${cmd} last \n` + `* ${cmd} last [n] from [lang] to [lang] \n\n` + "```" + + "```md\n" + `# Parameters\n` + `* to [lang] - defaults to server default language\n` + @@ -280,6 +310,7 @@ function helpMessage (config, param) `* [n] - number of chains to translate, default is 1\n` + `* [-n] - negative number means only one chain is translated\n\n` + "```" + + "```md\n" + `# Examples\n` + `* ${cmd} last 2 \n` + @@ -304,12 +335,14 @@ function helpMessage (config, param) `* ${cmd} channel from [lang] to [lang] for [me/@/#] \n` + `* ${cmd} stop for [me/@/#] \n\n` + "```" + + "```md\n" + `# Parameters\n` + `* to [lang] - defaults to server default language\n` + `* from [lang] - language to translate from, includes 'auto'\n` + `* for [me/@/#] - admins can set for other users \n\n` + "```" + + "```md\n" + `# Examples\n` + `* ${cmd} channel from english to chinese for me\n` + @@ -330,6 +363,7 @@ function helpMessage (config, param) `# Displays translation tasks of the current channel\n` + `* ${cmd} tasks\n\n` + "```" + + "```md\n" + `# Displays translation tasks of specified channel\n` + `* COMING IN FUTURE UPDATE \n` + @@ -350,10 +384,12 @@ function helpMessage (config, param) `* ${cmd} stop \n` + `* ${cmd} stop for [me/@/#/all] \n\n` + "```" + + "```md\n" + `# Parameters\n` + `* for [me/@/#/all] - defaults to "me" \n\n` + "```" + + "```md\n" + `# Examples\n` + `* ${cmd} stop \n` + @@ -375,30 +411,37 @@ function helpMessage (config, param) `* ${cmd} help\n` + `* ${cmd} help [command]\n\n` + "```" + + "```md\n" + `# Links\n` + `* ${cmd} invite\n\n` + "```" + + "```md\n" + `# Supported Languages\n` + `* ${cmd} list\n\n` + "```" + + "```md\n" + `# Permission Check\n` + `* ${cmd} checkperms [user/bot]\n\n` + "```" + + "```md\n" + `# Donate\n` + `* ${cmd} donate [oc/github]\n\n` + "```" + + "```md\n" + `# Prefix\n` + `* ${cmd} prefix\n\n` + "```" + + "```md\n" + `# ID Info\n` + `* ${cmd} id\n\n` + "```" + + "```md\n" + `# Other Commands\n` + `* ${cmd} announce [on/off]\n` + @@ -416,6 +459,7 @@ function helpMessage (config, param) `# Set default server language\n` + `* ${cmd} settings setLang to [lang]\n\n` + "```" + + "```md\n" + `# Style settings\n` + `* ${cmd} embed [on/off]\n\n` + @@ -428,6 +472,7 @@ function helpMessage (config, param) `* ${cmd} embed on \n` + `* ${cmd} embed off \n` + "```" + + "```md\n" + `# Help menu auto deletion\n` + `* ${cmd} settings persist [on/off]\n` + @@ -449,11 +494,13 @@ function helpMessage (config, param) `* ${cmd} stats global \n` + `* ${cmd} stats server \n\n` + "```" + + "```md\n" + `* Admin Only - Do not use in public channels\n` + `* ${cmd} stats server [ServerID]\n` + `* ${cmd} stats debug \n\n` + "```" + + "```md\n" + `# Parameters\n` + `* [ServerID] - Raw Server ID\n\n` + @@ -470,11 +517,13 @@ function helpMessage (config, param) `# Command\n` + `* ${cmd} embed [on/off]\n\n` + "```" + + "```md\n" + `# Parameters\n` + `* on - Turns on Embed Translation\n` + `* off - Turns on Webhook Translation Sending\n\n` + "```" + + "```md\n" + `# Examples\n` + `* ${cmd} embed on \n` + @@ -493,11 +542,13 @@ function helpMessage (config, param) `# Command\n` + `* ${cmd} bot2bot [on/off]\n\n` + "```" + + "```md\n" + `# Parameters\n` + `* on - Turns on Bot2Bot Translations\n` + `* off - Turns off Bot2Bot Translations\n\n` + "```" + + "```md\n" + `# Examples\n` + `* ${cmd} bot2bot on \n` + @@ -515,11 +566,13 @@ function helpMessage (config, param) `# Command\n` + `* ${cmd} debug [on/off]\n\n` + "```" + + "```md\n" + `# Parameters\n` + `* on - Turns debug webhook on\n` + `* off - Turns debug webhook off\n\n` + "```" + + "```md\n" + `# Examples\n` + `* ${cmd} debug on \n` + @@ -538,11 +591,13 @@ function helpMessage (config, param) `* ${cmd} prefix [prefix]\n` + `* ${long} prefix [prefix]\n\n` + "```" + + "```md\n" + `# Parameters\n` + `* [prefix] - Changes the prefix of your bot commands\n` + `* reset - Reset your prefix back to default\n\n` + "```" + + "```md\n" + `# Examples\n` + `* ${cmd} prefix $tr - your prefix would now be $tr \n` + @@ -584,10 +639,12 @@ function helpMessage (config, param) `* ${cmd} create [channelName]\n` + `* ${long} create [channelName]\n\n` + "```" + + "```md\n" + `# Parameters\n` + `* [channelName] - sets name of new channel\n\n` + "```" + + "```md\n" + `# Examples\n` + `* ${cmd} create bob - your new channel would now be bob \n` + @@ -614,10 +671,12 @@ function helpMessage (config, param) `* ${cmd} settings listservers\n` + `* ${cmd} invite server [ServerID]\n\n` + "```" + + "```md\n" + `# Parameters\n` + `* [ServerID] - Raw Server ID\n\n` + "```" + + "```md\n" + `# Examples\n` + `* ${cmd} eject [ServerID] - Eject Rita from [ServerID]\n` + diff --git a/src/core/command.send.js b/src/core/command.send.js index 0a92ef7aa..b6d4fdf93 100644 --- a/src/core/command.send.js +++ b/src/core/command.send.js @@ -56,6 +56,10 @@ function sendMessage (data) if (err.code && err.code === error.perm || error.access) { + const col = "errorcount"; + const id = data.message.sourceID; + db.increaseServersCount(col, id); + // console.log("Error 50013"); logger( "custom", diff --git a/src/core/db.js b/src/core/db.js index 5a0615bb0..856cfc3c1 100644 --- a/src/core/db.js +++ b/src/core/db.js @@ -175,11 +175,26 @@ const Servers = db.define( "type": Sequelize.BOOLEAN, "defaultValue": false }, + "react": { + "type": Sequelize.BOOLEAN, + "defaultValue": true + }, "owner": { "type": Sequelize.STRING(255), "defaultValue": "Unknown" + }, + "errorcount": { + "type": Sequelize.INTEGER, + "defaultValue": 0 + }, + "warncount": { + "type": Sequelize.INTEGER, + "defaultValue": 0 + }, + "ejectcount": { + "type": Sequelize.INTEGER, + "defaultValue": 0 } - } ); @@ -504,6 +519,10 @@ exports.updateColumns = async function updateColumns () await this.addTableColumn("servers", serversDefinition, "announce", Sequelize.BOOLEAN, true); await this.addTableColumn("servers", serversDefinition, "persist", Sequelize.BOOLEAN, false); await this.addTableColumn("servers", serversDefinition, "owner", Sequelize.STRING(255), "Unknown"); + await this.addTableColumn("servers", serversDefinition, "errorcount", Sequelize.INTEGER, 0); + await this.addTableColumn("servers", serversDefinition, "warncount", Sequelize.INTEGER, 0); + await this.addTableColumn("servers", serversDefinition, "ejectcount", Sequelize.INTEGER, 0); + await this.addTableColumn("servers", serversDefinition, "react", Sequelize.BOOLEAN, true); // console.log("DEBUG: All Columns Checked or Added"); // For older version of RITA, must remove old unique index @@ -796,12 +815,12 @@ exports.addTask = function addTask (task) // ------------- // Increase the count in Servers table -exports.increaseServersCount = function increaseServersCount (id) +exports.increaseServersCount = function increaseServersCount (col, id) { // console.log("DEBUG: Stage Update count in Servers table"); return Servers.increment( - "count", + col, {logging: false, "where": {id}} ); diff --git a/src/core/send.js b/src/core/send.js index 54d97465c..48fd29cd5 100644 --- a/src/core/send.js +++ b/src/core/send.js @@ -128,6 +128,11 @@ function checkPerms (data, sendBox) // -------------------------------------------------------------- // console.log("DEBUG: Error 50013 - Destination"); + + const col = "errorcount"; + const id = data.message.sourceID; + db.increaseServersCount(col, id); + logger("custom", { "color": "ok", "msg": `:exclamation: Write Permission Error - Destination\n @@ -382,6 +387,10 @@ function embedOn (data) if (err.code && err.code === error.perm || error.access) { + const col = "errorcount"; + const id = data.message.sourceID; + db.increaseServersCount(col, id); + // console.log("DEBUG: Error 50013 - Origin"); return logger("custom", { "color": "ok", diff --git a/src/core/translate.js b/src/core/translate.js index 797d778fd..9e0dc671e 100644 --- a/src/core/translate.js +++ b/src/core/translate.js @@ -360,7 +360,7 @@ function updateServerStats (message) id = message.channel.guild.id; } - db.increaseServersCount(id); + db.increaseServersCount("count", id); db.increaseStatsCount(col, id); }