Skip to content

Commit d8e6c22

Browse files
committed
v5 Update 8 Part 2
* Added profile command. * Allow users to opt-out now. * Fixed several bugs. * Added several new functions to app.functions. * Added verification command * Updated about command a little. * Took the EULA/EOA out of the 'eula.js' file and make it it's own json ('eula-data.json'). * Added more comments on what is doing what in 'bootloader.js' * Added .catch() to send statements in 'messageDelete', 'messageDeleteBulk', and 'messageUpdate'. * Remove unneeded and update existing dependencies. 'messageDelete', 'messageDeleteBulk', and 'messageUpdate' now check if the message in question is not in cache and handle as appropriate.
1 parent d6edbfb commit d8e6c22

21 files changed

Lines changed: 1119 additions & 451 deletions

package-lock.json

Lines changed: 180 additions & 284 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
"ascii-table": "^0.0.9",
2121
"async-queue": "^0.1.0",
2222
"canvas": "^2.8.0",
23-
"cli-progress": "^3.9.0",
24-
"colors": "^1.4.0",
2523
"discord.js": "^13.3.1",
2624
"node-fetch": "^2.6.1",
2725
"node-os-utils": "^1.3.6",

src/app/cfg/app.js

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,24 @@ const app = {
123123
app.logger.warn("DB", `Server data for ${id} removed from database!`);
124124

125125
return serverSetting;
126+
},
127+
128+
createVerification: async function(serverID, userID, messageID, codeGenerated) {
129+
const verificationSetting = await app.DBs.verification.create({
130+
serverID: serverID,
131+
userID: userID,
132+
messageID: messageID,
133+
userCode: codeGenerated
134+
});
135+
app.logger.success("DB", `Verification started for ${userID} in ${serverID} with code ${codeGenerated}!`);
136+
137+
return verificationSetting;
138+
},
139+
deleteVerification: async function(serverID, userID) {
140+
const verificationSetting = await app.DBs.verification.destroy({ where: { userID: userID, serverID: serverID } });
141+
app.logger.warn("DB", `Verification data for ${userID} in ${serverID} removed from database!`);
142+
143+
return verificationSetting;
126144
}
127145
},
128146
downloadAttachments: async function(message, attachments) {
@@ -172,7 +190,7 @@ const app = {
172190
command.permissions != "BOT_OWNER" && message.member.permissions.has(command.permissions))
173191
},
174192

175-
missingPerms: function(message, cantdo, command) {
193+
missingPerms: function(message, edit, cantdo, command) { // 0 = Send, 1 = Edit
176194
var lackedPerms = [];
177195
if (command) {
178196
for (var i = 0; i < command.permissions.length; i++) {
@@ -196,14 +214,23 @@ const app = {
196214
description: `You're lacking ${lackedPerms} to ${cantdo}.\nSorry about that...`,
197215
footer: { text: app.config.system.footerText }
198216
}]
199-
}, 0, true);
217+
}, edit, true);
200218
},
201219
msgHandler: async function(message, options, action = 0, doReply = false, callback = null) { // action: 0 = Send, 1 = Edit
220+
if (options["author"] != null) {
221+
var author = options["author"];
222+
if (author.id)
223+
options.embeds[0]["author"] = { name: `Hello, ${author.tag}!`, icon_url: author.displayAvatarURL({ format: 'png', dynamic: true, size: 1024 }) };
224+
delete options["author"];
225+
};
226+
202227
if (action == 0) {
203228
if (doReply) options["reply"] = { messageReference: message.id };
204229
message.channel.send(options).then(msg => { if (callback != null) callback(msg); });
205-
} else if (action == 1)
206-
message.edit(options).then(msg => { if (callback != null) callback(msg); });
230+
} else if (action == 1) {
231+
if (message.edit) message.edit(options).then(msg => { if (callback != null) callback(msg); });
232+
else if (message.update) message.update(options).then(msg => { if (callback != null) callback(msg); });
233+
};
207234
},
208235

209236
RemoveReactions: function(app, msg) {
@@ -280,6 +307,13 @@ const app = {
280307
return;
281308
},
282309

310+
generateRandomCode: function(length, random = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") { // random could be set to "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"@#$%^&()-=+[{]}"
311+
var code = "";
312+
for (var i = 0; i < length; i++) { code += random.charAt(Math.floor(Math.random() * random.length)); };
313+
return code;
314+
},
315+
getID: function(string) { return string.replace(/[<#@&!>]/g, ''); },
316+
doesArrayStartsWith: function(string, array) { return array.findIndex((item) => { return item.startsWith(string); }, string) != -1; },
283317

284318
clearCache: function(module) {
285319
if (module == null)
@@ -324,6 +358,16 @@ const app = {
324358
else ++i;
325359
return arr;
326360
},
361+
getParameters: function(array, chars) {
362+
if (typeof array != "object" || !array.length) return "gimme a array, not whatever that was!";
363+
else if (typeof chars != "string" || !chars) return "What am I supposed to split?? Gimme a string!";
364+
var parameters = [];
365+
for (var i = 0; i < array.length; i++) {
366+
var parameter = array[i].split(chars)[1];
367+
if (parameter) parameters.push(parameter);
368+
};
369+
return parameters;
370+
},
327371
RPSSystem: function(app, action) {
328372
if (app.client == undefined) { return "RPS failed to attach to client! Create Discord Client first." } else if (app.config == undefined) { return "RPS failed to attach to client: Missing config data."; };
329373

@@ -422,9 +466,9 @@ const app = {
422466
{ name: "node-fetch", required: true },
423467
{ name: "discord.js", required: true },
424468
{ name: "sequelize", required: true },
425-
{ name: "os", required: true},
426-
{ name: "node-os-utils", required: true},
427-
{ name: "canvas", required: false }
469+
{ name: "http", required: false },
470+
{ name: "canvas", required: false },
471+
{ name: "os", required: true }
428472
]
429473
}
430474

src/app/cmds/Fun/explode.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
module.exports = {
2+
name: "explode",
3+
description: "MAKE THAT THING GO KABOOM!",
4+
guildOnly: false,
5+
authorizedGuilds: [],
6+
hidden: false,
7+
permissions: ["DEFAULT"],
8+
cooldown: 3,
9+
aliases: [],
10+
syntax: [],
11+
execute: async(app, message, args) => {
12+
var target = message.mentions.users.first() || args[0],
13+
sender = message.author;
14+
if (!target) return app.functions.msgHandler(message, { content: "You need to add something to explode!!" }, 0, true);
15+
else if (target == sender) return app.functions.msgHandler(message, { content: "Why would you want to send a bomb to yourself???" }, 0, true);
16+
17+
var img = "error";
18+
const res = await app.modules["node-fetch"](app.config.system.imgAPI + "explosion");
19+
20+
if (res.status != 200) {
21+
// In the future, we'll use a "fallback" instance
22+
// where it will send a local image or maybe just the message
23+
// w/o an image.
24+
throw new Error(res.status);
25+
} else {
26+
const body = await res.json();
27+
if (body["url"] != null)
28+
img = body["url"];
29+
else
30+
img = "error";
31+
};
32+
return app.functions.msgHandler(message, {
33+
embeds: [{
34+
author: { name: `Bomb sent by ${sender.tag}`, icon_url: sender.displayAvatarURL({ format: 'png', dynamic: true, size: 1024 }) },
35+
color: app.config.system.embedColors.blue,
36+
fields: [
37+
{ name: "BOOM!", value: `${target} has been kaboom'd!` },
38+
{ name: "But, uh...", value: "That explosion made a huge mess..." }
39+
],
40+
image: { url: img },
41+
footer: app.config.system.footerText
42+
}]
43+
});
44+
45+
// TODO:
46+
// write better image detection or something. Yeah. That.
47+
}
48+
}

src/app/cmds/Fun/pat.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module.exports = {
2+
name: "pat",
3+
description: "There, there! Wholesome pats for everyone!",
4+
guildOnly: false,
5+
authorizedGuilds: [],
6+
hidden: false,
7+
permissions: ["DEFAULT"],
8+
cooldown: 3,
9+
aliases: [],
10+
syntax: [],
11+
execute: async(app, message, args) => {
12+
var target = message.mentions.users.first() || args[0],
13+
sender = message.author;
14+
if (!target) return app.functions.msgHandler(message, { content: "You need to tag someone to pat!" }, 0, true);
15+
else if (target == sender) return app.functions.msgHandler(message, { content: "There there, here's a personal pat. :)" }, 0, true);
16+
17+
var img = "error";
18+
const res = await app.modules["node-fetch"](app.config.system.imgAPI + "pat");
19+
20+
if (res.status != 200) {
21+
// In the future, we'll use a "fallback" instance
22+
// where it will send a local image or maybe just the message
23+
// w/o an image.
24+
throw new Error(res.status);
25+
} else {
26+
const body = await res.json();
27+
if (body["url"] != null)
28+
img = body["url"];
29+
else
30+
img = "error";
31+
};
32+
return app.functions.msgHandler(message, {
33+
embeds: [{
34+
color: app.config.system.embedColors.purple,
35+
description: `**${sender}** pats **${target}**!`,
36+
image: { url: img },
37+
footer: app.config.system.footerText
38+
}]
39+
});
40+
41+
// TODO:
42+
// write better image detection or something. Yeah. That.
43+
}
44+
}

src/app/cmds/General/about.js

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
name: "about",
3-
description: `Get info about me, ${app.client.user.tag}!`,
3+
description: `Get info about me!`,
44
guildOnly: false,
55
authorizedGuilds: [],
66
hidden: false,
@@ -9,35 +9,34 @@ module.exports = {
99
aliases: ["botinfo", "aboutme"],
1010
syntax: [],
1111
execute: async(app, message, args) => {
12-
const os = app.modules["os"]; // Welcome to os(u)~!
13-
app.functions.msgHandler(message, {
14-
embeds: [{
15-
title: app.config.system.emotes.information + ` All about your favorite bot, **${app.client.user.tag}**!`,
16-
color: app.config.system.embedColors.blue,
17-
thumbnail: { url: app.client.user.displayAvatarURL({ format: 'png', dynamic: true, size: 1024 }) },
18-
fields: [
19-
{ name: "Bot Information", value: "** **" },
20-
{ name: "User Tag", value: `${app.client.user.tag}`, inline: true},
21-
{ name: "User ID", value: `${app.client.user.id}`, inline: true},
22-
{ name: "Bot Version", value: app.version.toFullString(), inline: true},
23-
{ name: "Bot Uptime", value: app.functions.TStoHR(app.client.uptime), inline: true},
24-
{ name: "Emote Count", value: `${Object.keys(app.config.system.emotes).length} total`, inline: true},
25-
{ name: "Embed Color Count", value: `${Object.keys(app.config.system.embedColors).length} total`, inline: true},
26-
{ name: "RPS Count", value: `${Object.keys(app.config.system.rotatingStatus.statuses).length} total`, inline: true},
27-
{ name: "Bot Memory Usage", value: (Math.round(process.memoryUsage().heapUsed / 1024 / 1024 * 100) / 100) + " MiB", inline: true },
28-
{ name: "Servers I'm In", value: app.client.guilds.cache.size + " total", inline: true},
29-
{ name: "Host System Information", value: "** **" },
30-
{ name: "Node Version", value: `${process.version}`, inline: true },
31-
{ name: "Node Uptime", value: app.functions.TStoHR(process.uptime()* 1000), inline: true },
32-
{ name: "Node Execution Path", value: `${process.execPath}`, inline: true},
33-
{ name: "Process PID", value: `${process.pid}`, inline: true},
34-
{ name: "System Platform", value: `${process.platform}`, inline: true},
35-
{ name: ((process.platform == "linux") ? "Kernel Version" : "System Version"), value: os.version(), inline: true }
36-
// I'd like to have this show the current CPU usage, I'm open to ideas on how to get it to work. - IDeletedSystem64
37-
],
38-
footer: { text: app.config.system.footerText }
39-
}]
40-
});
41-
}
42-
}
43-
12+
const os = app.modules["os"]; // Welcome to os(u)~!
13+
return app.functions.msgHandler(message, {
14+
embeds: [{
15+
title: app.config.system.emotes.information + ` All about your favorite bot, **${app.client.user.tag}**!`,
16+
color: app.config.system.embedColors.blue,
17+
thumbnail: { url: app.client.user.displayAvatarURL({ format: 'png', dynamic: true, size: 1024 }) },
18+
fields: [
19+
{ name: "Bot Information", value: "** **" },
20+
{ name: "User Tag", value: `${app.client.user.tag}`, inline: true },
21+
{ name: "User ID", value: `${app.client.user.id}`, inline: true },
22+
{ name: "Bot Version", value: app.version.toFullString(), inline: true },
23+
{ name: "Bot Uptime", value: app.functions.TStoHR(app.client.uptime), inline: true },
24+
{ name: "Emote Count", value: `${Object.keys(app.config.system.emotes).length} total`, inline: true },
25+
{ name: "Embed Color Count", value: `${Object.keys(app.config.system.embedColors).length} total`, inline: true },
26+
{ name: "RPS Count", value: `${Object.keys(app.config.system.rotatingStatus.statuses).length} total`, inline: true },
27+
{ name: "Bot Memory Usage", value: (Math.round(process.memoryUsage().heapUsed / 1024 / 1024 * 100) / 100) + " MiB", inline: true },
28+
{ name: "Servers I'm In", value: app.client.guilds.cache.size + " total", inline: true },
29+
{ name: "Host System Information", value: "** **" },
30+
{ name: "Node Version", value: `${process.version}`, inline: true },
31+
{ name: "Node Uptime", value: app.functions.TStoHR(process.uptime() * 1000), inline: true },
32+
{ name: "Node Execution Path", value: `${process.execPath}`, inline: true },
33+
{ name: "Process PID", value: `${process.pid}`, inline: true },
34+
{ name: "System Platform", value: `${process.platform}`, inline: true },
35+
{ name: ((process.platform == "linux") ? "Kernel Version" : "System Version"), value: os.version(), inline: true }
36+
// I'd like to have this show the current CPU usage, I'm open to ideas on how to get it to work. - IDeletedSystem64
37+
],
38+
footer: { text: app.config.system.footerText }
39+
}]
40+
});
41+
}
42+
}

src/app/cmds/General/help.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = {
4747
if (category == categoryName && app.functions.hasPermissions(message, cmd) && !cmd.hidden)
4848
commands.push("`" + cmd.name + "`");
4949
});
50-
if (commands.length < 1) { return app.functions.missingPerms("view help on " + categoryName, command); };
50+
if (commands.length < 1) { return app.functions.missingPerms(message, 0, "view help on " + categoryName, command); };
5151

5252
fields.push({ name: categoryName, value: commands.join(", ") });
5353

@@ -65,7 +65,7 @@ module.exports = {
6565
function commandHelp(commandName) {
6666
var command = app.commands.get(commandName) || app.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
6767

68-
if (!app.functions.hasPermissions(message, command)) { return app.functions.missingPerms("view help on " + commandName, command); };
68+
if (!app.functions.hasPermissions(message, command)) { return app.functions.missingPerms(message, 0, "view help on " + commandName, command); };
6969
var fields = [
7070
{ name: "Category", value: command.category || "Uncategorized", inline: true },
7171
{ name: "Server Only?", value: (command.guildOnly ? "Yes" : "No"), inline: true },

0 commit comments

Comments
 (0)