Skip to content

Commit 3f79d72

Browse files
committed
v5 Release Milestone 2
* Added answer command * Corrected cuddle, explode, hug, kiss, and pat commands to include a syntax * Help command description updated * Correct messageDelete event audit log checking data * Overhaul the invite caching system in ready event * Speaking of invites, check out the new inviteinfo command that gets info on a invite! How cool! * Changed eula-data to be more simple as the EULA has been moved to the TCB website. * Fixed a spelling mistake in eula.js (special thanks to IDeletedSystem64 for pointing that out) * Dependenices for Extras now load in Extras * Corrected verify command to check permissions correctly * Corrected config command to check permissions correctly * Updated cuddle, explode, hug, kiss, and pat commands to include the new image sending system. * Fixed a possibly in the app.js that when logging to the console the time it took that it may return a negative value and sometimes completely incorrect values.
1 parent d0ca1bc commit 3f79d72

18 files changed

Lines changed: 269 additions & 154 deletions

File tree

src/app/cfg/app.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,19 +312,19 @@ const app = {
312312
if (message.channel)
313313
message.channel.send(options).then(msg => {
314314
if (message.createdTimestamp)
315-
app.logger.debug("DISCORD", `[MESSAGE] Got message in ${(currTime - message.createdTimestamp) / 1000}ms. | Responded in ${(currTime - msg.createdTimestamp) / 1000}ms.`);
315+
app.logger.debug("DISCORD", `[MESSAGE] Got message in ${(currTime - message.createdTimestamp)}ms. | Responded in ${(msg.createdTimestamp - currTime)}ms.`);
316316
if (callback != null) callback(msg);
317317
}).catch(err => { app.logger.warn("DISCORD", `[MESSAGE] Message failed to send! Error: ${err.message}`) });
318318
else
319319
message.send(options).then(msg => { if (callback != null) callback(msg); }).catch(err => { app.logger.warn("DISCORD", `[MESSAGE] Message failed to send! Error: ${err.message}`) });
320320
} else if (action == 1) {
321321
if (!message.channel) return; // Hate to break it, but you can't edit a channel as a message. 💀 (imagine that)
322322
if (message.edit) message.edit(options).then(msg => {
323-
if (message.editedTimestamp) app.logger.debug("DISCORD", `[MESSAGE] Edited message in ${(currTime - msg.editedTimestamp) / 1000}ms.`);
323+
if (message.editedTimestamp) app.logger.debug("DISCORD", `[MESSAGE] Edited message in ${(msg.editedTimestamp - currTime)}ms.`);
324324
if (callback != null) callback(msg);
325325
}).catch(err => { app.logger.warn("DISCORD", `[MESSAGE] Message failed to edit! Error: ${err.message}`) });
326326
else if (message.update) message.update(options).then(msg => {
327-
if (message.editedTimestamp) app.logger.debug("DISCORD", `[MESSAGE] Edited message in ${(currTime - msg.editedTimestamp) / 1000}ms.`);
327+
if (message.editedTimestamp) app.logger.debug("DISCORD", `[MESSAGE] Edited message in ${(msg.editedTimestamp - currTime)}ms.`);
328328
if (callback != null) callback(msg);
329329
}).catch(err => { app.logger.warn("DISCORD", `[MESSAGE] Message failed to update! Error: ${err.message}`) });
330330
};
@@ -581,7 +581,6 @@ const app = {
581581
{ name: "node-fetch", required: true },
582582
{ name: "discord.js", required: true },
583583
{ name: "sequelize", required: true },
584-
{ name: "http", required: false },
585584
{ name: "canvas", required: false },
586585
{ name: "os", required: true }
587586
]

src/app/cmds/Fun/answer.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = {
2+
name: "answer",
3+
description: "The true meaning of life.",
4+
guildOnly: false,
5+
authorizedGuilds: [],
6+
hidden: false,
7+
permissions: ["DEFAULT"],
8+
cooldown: 2,
9+
aliases: [],
10+
syntax: [],
11+
execute: async(app, message, args) => {
12+
// SHAME ON YOU FOR LOOKING INTO THIS CODE!!! REVEALS SPOILERS AAAAAAAA!
13+
14+
var rnd = Math.random(), // Math.random() isn't exactly true random but it works ig.
15+
answer = "42"; // Normal response.
16+
17+
if (rnd < 0.01) // 0.1% chance of sending this >:)
18+
answer = "Nekos"; // I swear I'm going to get hate for this. Just accept it.
19+
else if (rnd < 0.05) // 0.5% chance of sending this >:)
20+
answer = "Niko"; // OneShot joke ig, because why not.
21+
app.functions.msgHandler(message, answer); // Return response
22+
23+
}
24+
};

src/app/cmds/Fun/cuddle.js

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,35 @@ module.exports = {
77
permissions: ["DEFAULT"],
88
cooldown: 3,
99
aliases: [],
10-
syntax: [],
10+
syntax: [" <@MentionOrUserID>"],
1111
execute: async(app, message, args) => {
1212
var target = message.mentions.users.first() || args[0],
1313
sender = message.author;
1414
if (!target) return app.functions.msgHandler(message, { content: "You need to tag someone to cuddle!" }, 0, true);
1515
else if (target == sender) return app.functions.msgHandler(message, { content: "There there, here's a personal cuddle. :)" }, 0, true);
1616

17-
var img = "error";
18-
const res = await app.modules["node-fetch"](app.config.system.imgAPI + "cuddle");
17+
var embed = {
18+
color: app.config.system.embedColors.lime,
19+
description: `**${sender} **cuddles** ${target}**!`
20+
},
21+
url = (app.config.system.imgAPI + "cuddle");
22+
23+
const res = await app.modules["node-fetch"](url);
24+
try {
25+
if (res.status != 200) {
26+
throw new Error(res.status);
27+
} else {
28+
const body = await res.json();
29+
if (body["url"] != null)
30+
embed["image"] = { url: body["url"] };
1931

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";
32+
};
33+
} catch (Ex) {
34+
app.logger.error("SYS", `Failed fetch of image: ${(url)} | ${Ex.message}`);
3135
};
3236
return app.functions.msgHandler(message, {
33-
embeds: [{
34-
color: app.config.system.embedColors.lime,
35-
description: `**${sender}** cuddles **${target}**!`,
36-
image: { url: img }
37-
}]
37+
embeds: [embed]
3838
});
3939

40-
// TODO:
41-
// write better image detection or something. Yeah. That.
4240
}
4341
}

src/app/cmds/Fun/explode.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,31 @@ module.exports = {
1414
if (!target) return app.functions.msgHandler(message, { content: "You need to add something to explode!!" }, 0, true);
1515
else if (target == sender) return app.functions.msgHandler(message, { content: "Why would you want to send a bomb to yourself???" }, 0, true);
1616

17-
var img = "error";
18-
const res = await app.modules["node-fetch"](app.config.system.imgAPI + "explosion");
1917

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: [{
18+
var embed = {
3419
author: { name: `Bomb sent by ${sender.tag}`, icon_url: sender.displayAvatarURL({ format: 'png', dynamic: true, size: 1024 }) },
3520
color: app.config.system.embedColors.blue,
3621
fields: [
3722
{ name: "BOOM!", value: `${target} has been kaboom'd!` },
3823
{ name: "But, uh...", value: "That explosion made a huge mess..." }
39-
],
40-
image: { url: img }
41-
}]
42-
});
24+
]
25+
},
26+
url = (app.config.system.imgAPI + "explosion");
4327

44-
// TODO:
45-
// write better image detection or something. Yeah. That.
28+
const res = await app.modules["node-fetch"](url);
29+
try {
30+
if (res.status != 200) {
31+
throw new Error(res.status);
32+
} else {
33+
const body = await res.json();
34+
if (body["url"] != null)
35+
embed["image"] = { url: body["url"] };
36+
};
37+
} catch (Ex) {
38+
app.logger.error("SYS", `Failed fetch of image: ${(url)} | ${Ex.message}`);
39+
};
40+
return app.functions.msgHandler(message, {
41+
embeds: [embed]
42+
});
4643
}
4744
}

src/app/cmds/Fun/hug.js

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,33 @@ module.exports = {
77
permissions: ["DEFAULT"],
88
cooldown: 3,
99
aliases: [],
10-
syntax: [],
10+
syntax: [" <@MentionOrUserID>"],
1111
execute: async(app, message, args) => {
1212
var target = message.mentions.users.first() || args[0],
1313
sender = message.author;
1414
if (!target) return app.functions.msgHandler(message, { content: "You need to tag someone to hug!" }, 0, true);
1515
else if (target == sender) return app.functions.msgHandler(message, { content: "There there, here's a personal hug. :)" }, 0, true);
1616

17-
var img = "error";
18-
const res = await app.modules["node-fetch"](app.config.system.imgAPI + "hug");
17+
var embed = {
18+
color: app.config.system.embedColors.blue,
19+
description: `**${sender} **hugs** ${target}**!`
20+
},
21+
url = (app.config.system.imgAPI + "hug");
1922

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";
23+
const res = await app.modules["node-fetch"](url);
24+
try {
25+
if (res.status != 200) {
26+
throw new Error(res.status);
27+
} else {
28+
const body = await res.json();
29+
if (body["url"] != null)
30+
embed["image"] = { url: body["url"] };
31+
};
32+
} catch (Ex) {
33+
app.logger.error("SYS", `Failed fetch of image: ${(url)} | ${Ex.message}`);
3134
};
3235
return app.functions.msgHandler(message, {
33-
embeds: [{
34-
color: app.config.system.embedColors.blue,
35-
description: `**${sender}** gave **${target}**, a hug!`,
36-
image: { url: img }
37-
}]
36+
embeds: [embed]
3837
});
39-
40-
// TODO:
41-
// write better image detection or something. Yeah. That.
4238
}
4339
}

src/app/cmds/Fun/kiss.js

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,33 @@ module.exports = {
77
permissions: ["DEFAULT"],
88
cooldown: 3,
99
aliases: [],
10-
syntax: [],
10+
syntax: [" <@MentionOrUserID>"],
1111
execute: async(app, message, args) => {
1212
var target = message.mentions.users.first() || args[0],
1313
sender = message.author;
1414
if (!target) return app.functions.msgHandler(message, { content: "You need to tag someone to kiss!" }, 0, true);
1515
else if (target == sender) return app.functions.msgHandler(message, { content: "There there, here's a personal kiss. :)" }, 0, true);
1616

17-
var img = "error";
18-
const res = await app.modules["node-fetch"](app.config.system.imgAPI + "kiss");
17+
var embed = {
18+
color: app.config.system.embedColors.red,
19+
description: `**${sender} **kisses** ${target}**!`
20+
},
21+
url = (app.config.system.imgAPI + "kiss");
1922

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";
23+
const res = await app.modules["node-fetch"](url);
24+
try {
25+
if (res.status != 200) {
26+
throw new Error(res.status);
27+
} else {
28+
const body = await res.json();
29+
if (body["url"] != null)
30+
embed["image"] = { url: body["url"] };
31+
};
32+
} catch (Ex) {
33+
app.logger.error("SYS", `Failed fetch of image: ${(url)} | ${Ex.message}`);
3134
};
3235
return app.functions.msgHandler(message, {
33-
embeds: [{
34-
color: app.config.system.embedColors.red,
35-
description: `**${sender}** kisses **${target}**!`,
36-
image: { url: img }
37-
}]
36+
embeds: [embed]
3837
});
39-
40-
// TODO:
41-
// write better image detection or something. Yeah. That.
4238
}
4339
}

src/app/cmds/Fun/pat.js

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,33 @@ module.exports = {
77
permissions: ["DEFAULT"],
88
cooldown: 3,
99
aliases: [],
10-
syntax: [],
10+
syntax: [" <@MentionOrUserID>"],
1111
execute: async(app, message, args) => {
1212
var target = message.mentions.users.first() || args[0],
1313
sender = message.author;
1414
if (!target) return app.functions.msgHandler(message, { content: "You need to tag someone to pat!" }, 0, true);
1515
else if (target == sender) return app.functions.msgHandler(message, { content: "There there, here's a personal pat. :)" }, 0, true);
1616

17-
var img = "error";
18-
const res = await app.modules["node-fetch"](app.config.system.imgAPI + "pat");
17+
var embed = {
18+
color: app.config.system.embedColors.purple,
19+
description: `**${sender} **pats** ${target}**!`
20+
},
21+
url = (app.config.system.imgAPI + "pat");
1922

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";
23+
const res = await app.modules["node-fetch"](url);
24+
try {
25+
if (res.status != 200) {
26+
throw new Error(res.status);
27+
} else {
28+
const body = await res.json();
29+
if (body["url"] != null)
30+
embed["image"] = { url: body["url"] };
31+
};
32+
} catch (Ex) {
33+
app.logger.error("SYS", `Failed fetch of image: ${(url)} | ${Ex.message}`);
3134
};
3235
return app.functions.msgHandler(message, {
33-
embeds: [{
34-
color: app.config.system.embedColors.purple,
35-
description: `**${sender}** pats **${target}**!`,
36-
image: { url: img }
37-
}]
36+
embeds: [embed]
3837
});
39-
40-
// TODO:
41-
// write better image detection or something. Yeah. That.
4238
}
4339
}

src/app/cmds/General/about.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ module.exports = {
3838
}]
3939
});
4040
}
41-
}
41+
}

src/app/cmds/General/help.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
name: "help",
3-
description: "Get some nice help. From a command to all comands! Yeaaah we got it! (Help! Help!)",
3+
description: "I need somebody (Help!) Not just anybody (Help!) From a command to all commands (Help!)",
44
guildOnly: false,
55
authorizedGuilds: [],
66
hidden: false,

0 commit comments

Comments
 (0)