Skip to content

Commit

Permalink
Merge pull request #540 from RitaBot-Project/RitaBot
Browse files Browse the repository at this point in the history
Update master branch
  • Loading branch information
ArtanisTheOne authored Feb 3, 2022
2 parents 6e8bcf1 + 4bd81c6 commit abbd29c
Show file tree
Hide file tree
Showing 23 changed files with 1,250 additions and 1,001 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ MESSAGE_DEBUG=0
//Not Used Currently
DISCORD_BOT_OWNER_ID=BOT OWNER ID 1,BOT OWNER ID 2
DISCORD_INVITE_URL="DISCORD INVITE URL"

TOPGG_TOKEN="top.gg token here"
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
* Major code changes, new code implementations will change the DB and produce errors on first build, but this is a safe version to update to. Follow the below instructions.
* Step 1: Make a pull request and update from **Master** branch.
* Once you update the bot and it initializes you WILL get a db error, this is normal. (we are working on suppressing these)
* Step 2: `!t settings updatedb`
* Step 2: `!tr settings updatedb`
* This will throw another error but it will build the missing columns.
* The default value for embed is on and botbot is off.
* Running this multiple times will cause error to be posted to webhook chan, this is a "Value exists" error. Preventing you from destroying the DB
Expand All @@ -231,7 +231,7 @@
* Various Security vulnerabilities fixed.
* Dev Dependencies core to this bot, the `google-transalte-api` & `google-transalte-token` & `gulp-watch`have been updated
* `eslint` has been replaced with `babel-eslint`
* `!t settings updatebot` Has been **DISABLED** - This is not needed as of yet and with the similarities to the `!t settings updatedb` command it may cause issues.
* `!tr settings updatebot` Has been **DISABLED** - This is not needed as of yet and with the similarities to the `!tr settings updatedb` command it may cause issues.
* Deploy with Heroku Setup and integration.

## 1.2.0
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
worker: node --optimize_for_size --max_old_space_size=980 src/bot.js
worker: node --optimize_for_size --max_old_space_size=3072 src/bot.js
1,801 changes: 964 additions & 837 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "ritabot",
"version": "1.2.6-14",
"version": "1.2.6-20",
"engines": {
"node": "16.2.0"
"node": "16.11.1"
},
"description": "Real-Time Interchangeable Translating Assistant bot built using discord.js and Google Translate API.",
"main": "src/bot.js",
"license": "MIT",
"scripts": {
"start": "node --optimize_for_size --max_old_space_size=460 src/bot.js",
"start": "node --optimize_for_size --max_old_space_size=3072 src/bot.js",
"build": "gulp build",
"coveralls": "gulp coveralls",
"dev": "gulp watch",
Expand Down Expand Up @@ -39,6 +39,7 @@
"homepage": "https://ritabot.gg/",
"bugs": "https://github.com/RitaBot-Project/RitaBot/issues",
"dependencies": {
"@top-gg/sdk": "^3.1.3",
"common-tags": "^1.8.0",
"discord.js": "^12.5.3",
"dotenv": "^10.0.0",
Expand All @@ -48,11 +49,13 @@
"path": "^0.12.7",
"pg": "^8.7.1",
"pg-hstore": "^2.3.4",
"rita-google-translate-api": "^3.1.1",
"rita-google-translate-api": "github:vkedwardli/google-translate-api#translate_a/t",
"rita-seconds-converter": "^1.3.0",
"sequelize": "^6.6.5",
"sqlite3": "^5.0.2",
"webhook-discord": "^3.7.8"
"topgg-autoposter": "^2.0.1",
"webhook-discord": "^3.7.8",
"iconv-lite": "^0.6.3"
},
"devDependencies": {
"@kollavarsham/gulp-coveralls": "^0.3.4",
Expand All @@ -65,5 +68,6 @@
"gulp-line-ending-corrector": "^1.0.3",
"gulp-uglify-es": "^2.0.0",
"rita-gulp-watch": "^5.1.4"
}
}
},
"nodeVersion": "16.11.1"
}
30 changes: 30 additions & 0 deletions src/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,39 @@ const client = new discord.Client({
});
const auth = require("./core/auth");

/*
const {AutoPoster} = require("topgg-autoposter");
// your discord.js or eris client
const topggLogin = auth.topggToken;
if (!topggLogin)
{
console.log("no top.gg token present");
}
else
{
// eslint-disable-next-line new-cap
const poster = AutoPoster(topggLogin, client);
// optional
poster.on("posted", (stats) =>
// ran when succesfully posted
{
console.log(`Posted stats to Top.gg | ${stats.serverCount} servers`);
});
}
*/

// ---------------
// Event Listener
// ---------------

const events = require("./events");

events.listen(client);
Expand Down
9 changes: 7 additions & 2 deletions src/commands/future_commands/mod.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,12 @@ module.exports.kick = function kick (data)
}

}
data.text = ":cop: This command is reserved for server admins and owners only.\n";
return sendMessage(data);
else
{

data.text = ":cop: This command is reserved for server admins and owners only.\n";
return sendMessage(data);

}

};
2 changes: 1 addition & 1 deletion src/commands/info_commands/join.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ module.exports = async function run (guild, config)
},
{
"name": ":lock: Permissions",
"value": `Rita has many functions, These all need different permissions to work. To check that RITA has all the permissions she needs to functions correctly please use the **!tr checkperms bot** command.`
"value": `Rita has many functions, These all need different permissions to work. To check that RITA has all the permissions she needs to functions correctly please use the **!tr check** command.`
},
{
"name": ":moneybag: On a side note.",
Expand Down
52 changes: 49 additions & 3 deletions src/commands/info_commands/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module.exports = function run (data)

data.color = "info";

// Special case: !t stats global
// Special case: !tr stats global
if (data.cmd.params && data.cmd.params.toLowerCase().includes("global"))
{

Expand All @@ -132,7 +132,7 @@ module.exports = function run (data)

}

// Only '!t stats global' is allowed with dm
// Only '!tr stats global' is allowed with dm
if (data.message.channel.type === "dm")
{

Expand Down Expand Up @@ -168,7 +168,7 @@ module.exports = function run (data)

}

// Case: !t stats server
// Case: !tr stats server
if (data.cmd.params && data.cmd.params.toLowerCase().includes("server"))
{

Expand Down Expand Up @@ -284,6 +284,52 @@ module.exports = function run (data)

}

if (data.cmd.params && data.cmd.params.toLowerCase().includes("bot"))
{

const serverID = "bot";

db.getServerInfo(
serverID,
function getServerInfo (server)
{

if (server.length === 0)
{

data.text = `\`\`\`${serverID} ERROR\n\n\`\`\``;
return sendMessage(data);

}

const targetServer = `:bar_chart: In total **\`${server[0].errorcount}\`** messages have failed to translate.\n\n`;

data.text = `${targetServer}\n\n`;

// -------------
// Send message
// -------------

return sendMessage(data);

}
).catch((err) =>
{

console.log(
"error",
err,
"warning",
serverID
);

data.text = `\`\`\`Critical Stats Bot Error, Zycore Broke it.\n\n\`\`\``;
return sendMessage(data);

});

}

if (data.cmd.params && data.cmd.params.toLowerCase().includes("debug"))
{

Expand Down
2 changes: 1 addition & 1 deletion src/commands/settings_commands/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function react (data)
return logger(
"error",
err,
"command",
"react",
data.message.channel.guild.name
);

Expand Down
2 changes: 1 addition & 1 deletion src/commands/settings_commands/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ function getSettings (data)
}

// -----------------
// Server Tags
// Lang Detect
// -----------------

async function langDetect (data)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/translation_commands/translate.auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ module.exports = function run (data)
// Log task data (dev)
// --------------------

logger("dev", data.task);
// logger("dev", data.task);

// ------------------------------------------
// Error if non-manager sets channel as dest
Expand Down
10 changes: 3 additions & 7 deletions src/commands/translation_commands/translate.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = function run (data, client)
ServerID: **${data.guild_id || "Unknown"}** \n
Chan ID: **${data.channel_id || "Unknown"}**\n
Message ID **${data.message_id || "Unknown"}**\n
User ID: **$${data.member.user.id || "Unknown"}**\n
User ID: **${data.member.user.id || "Unknown"}**\n
Emoji: **${data.emoji.name || "Unknown"}**\n`
});

Expand Down Expand Up @@ -85,7 +85,7 @@ module.exports = function run (data, client)
return logger(
"error",
err,
"command",
"react",
data.guild_id
);

Expand Down Expand Up @@ -139,18 +139,14 @@ module.exports = function run (data, client)
// ------------------
// Start translation
// ------------------
const col = "react";
let id = "bot";
db.increaseStatsCount(col, id);

if (message.channel.type === "text")
{

id = data.message.guild.id;
db.increaseStatsCount("react", data.message.guild.id);

}

db.increaseStatsCount(col, id);
translate(data);
if (server[0].flagpersist === false || server[0].flagpersist === 0)
{
Expand Down
4 changes: 4 additions & 0 deletions src/commands/utility_commands/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ function getCheck (data)
const owner = await target.members.fetch(target.ownerID);
const tag = `${owner.user.username}#${owner.user.discriminator}`;
const perms = bot.permissions.serialize();
const currentShard = `${target.shardID + 1} / ${data.message.client.options.shardCount}`;
const botResult1 =
`__**Permission Checker - Target Server**__\n\n` +
"```md\n" +
`# Server Checker - Targeted Server\n` +
`* Targeted Server: ${target.name}\n` +
`* Targeted ID: ${target.id}\n` +
`* Current Shard: ${currentShard}\n` +
`* Owner: ${tag || "Unknown"}\n` +
`* Command prefix is: ${db.server_obj[serverID].db.prefix}\n\n` +
"```" +
Expand Down Expand Up @@ -314,12 +316,14 @@ module.exports = function run (data)
const owner = await target.members.fetch(target.ownerID);
const tag = `${owner.user.username}#${owner.user.discriminator}`;
const perms = bot.permissions.serialize();
const currentShard = `${target.shardID + 1} / ${data.message.client.options.shardCount}`;
const botResult1 =
`__**Permission Checker - This Server**__\n\n` +
"```md\n" +
`# Server Checker - This Server\n` +
`* Server Name: ${target.name}\n` +
`* Server ID: ${target.id}\n` +
`* Current Shard: ${currentShard}\n` +
`* Owner: ${tag || "Unknown"}\n` +
`* Command prefix is: ${db.server_obj[data.message.guild.id].db.prefix}\n\n` +
"```" +
Expand Down
20 changes: 16 additions & 4 deletions src/commands/utility_commands/create.channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,23 @@ function channelName (data)
// Arguments to set the channel name
const channelName = data.cmd.params.split(" ")[0].toLowerCase();

data.message.guild.channels.create(channelName, {
// This create a text channel, you can make a voice one too, by changing "text" to "voice"
data.message.guild.channels.create(channelName).
then((channel) =>
{

const category = data.message.guild.channels.cache.find((c) => c.type === "category");

const catID = data.cmd.num;
if (!category)
{

throw new Error("Category channel does not exist");

}
channel.setParent(catID);

"type": "text"
});
}).
catch(console.error);

data.color = "ok";
data.text =
Expand Down
17 changes: 14 additions & 3 deletions src/commands/utility_commands/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function helpMessage (config, param)
`# Misc Commands\n` +
`* ${cmd} invite\n` +
`* ${cmd} help modules\n` +
`* ${cmd} check [me/channel]n` +
`* ${cmd} check [me/channel]\n` +
`* ${cmd} create [channelName]\n` +
`* ${cmd} history \n\n` +
"```" +
Expand Down Expand Up @@ -350,6 +350,12 @@ function helpMessage (config, param)
`* ${cmd} channel from en to de for #englishChannel \n` +
`* ${cmd} channel from de to fr for @steve \n` +
`* ${cmd} channel from en to es for #ch1, #ch2, #usr1 \n` +
"```" +

"```md\n" +
`# Notes:\n` +
`* All translation commands are a per channel basis.\n` +
`* The @user function sends translations to the user via DM.\n` +
"```\n";

// --------------
Expand Down Expand Up @@ -684,18 +690,23 @@ function helpMessage (config, param)
"```md\n" +
`# Command\n` +
`* ${cmd} create [channelName]\n` +
`* ${long} create [channelName]\n\n` +
`* ${long} create [channelName]\n` +
`* ${cmd} create [channelName] [categoryID]\n` +
`* ${long} create [channelName] [categoryID]\n\n` +
"```" +

"```md\n" +
`# Parameters\n` +
`* [channelName] - sets name of new channel\n\n` +
`* [channelName] - sets name of new channel\n` +
`* [categoryID] - sets category for the new channel\n\n` +
"```" +

"```md\n" +
`# Examples\n` +
`* ${cmd} create bob - your new channel would now be bob \n` +
`* ${long} create bob - your new channel would now be bob \n` +
`* ${cmd} create bob 914747144461843234 - your new channel would now be bob in the designated category \n` +
`* ${long} create bob 914747144461843234 - your new channel would now be bob in the designated category\n\n` +
"```\n";

// ---------------
Expand Down
Loading

0 comments on commit abbd29c

Please sign in to comment.