Skip to content

Commit 1a7b889

Browse files
authored
RELEASE THE BOT
RELEASE THE BOT
2 parents d0ca1bc + 21b275c commit 1a7b889

24 files changed

Lines changed: 502 additions & 163 deletions

src/app/cfg/app.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ const app = {
109109
}
110110
},
111111

112+
isAnimated: function(str) {
113+
return str.substring(0, 2) === 'a_';
114+
},
115+
112116
sleep: function(ms) {
113117
return new Promise(resolve => setTimeout(resolve, ms));
114118
},
@@ -312,19 +316,19 @@ const app = {
312316
if (message.channel)
313317
message.channel.send(options).then(msg => {
314318
if (message.createdTimestamp)
315-
app.logger.debug("DISCORD", `[MESSAGE] Got message in ${(currTime - message.createdTimestamp) / 1000}ms. | Responded in ${(currTime - msg.createdTimestamp) / 1000}ms.`);
319+
app.logger.debug("DISCORD", `[MESSAGE] Got message in ${(currTime - message.createdTimestamp)}ms. | Responded in ${(msg.createdTimestamp - currTime)}ms.`);
316320
if (callback != null) callback(msg);
317321
}).catch(err => { app.logger.warn("DISCORD", `[MESSAGE] Message failed to send! Error: ${err.message}`) });
318322
else
319323
message.send(options).then(msg => { if (callback != null) callback(msg); }).catch(err => { app.logger.warn("DISCORD", `[MESSAGE] Message failed to send! Error: ${err.message}`) });
320324
} else if (action == 1) {
321325
if (!message.channel) return; // Hate to break it, but you can't edit a channel as a message. 💀 (imagine that)
322326
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.`);
327+
if (message.editedTimestamp) app.logger.debug("DISCORD", `[MESSAGE] Edited message in ${(msg.editedTimestamp - currTime)}ms.`);
324328
if (callback != null) callback(msg);
325329
}).catch(err => { app.logger.warn("DISCORD", `[MESSAGE] Message failed to edit! Error: ${err.message}`) });
326330
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.`);
331+
if (message.editedTimestamp) app.logger.debug("DISCORD", `[MESSAGE] Edited message in ${(msg.editedTimestamp - currTime)}ms.`);
328332
if (callback != null) callback(msg);
329333
}).catch(err => { app.logger.warn("DISCORD", `[MESSAGE] Message failed to update! Error: ${err.message}`) });
330334
};
@@ -581,7 +585,6 @@ const app = {
581585
{ name: "node-fetch", required: true },
582586
{ name: "discord.js", required: true },
583587
{ name: "sequelize", required: true },
584-
{ name: "http", required: false },
585588
{ name: "canvas", required: false },
586589
{ name: "os", required: true }
587590
]

src/app/cfg/system.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"Playing Never Gonna Give You Up",
4848
"Playing Visual Studio Code",
4949
"Playing Visual Studio 2022",
50+
"Playing You are now manually breathing.",
5051

5152
"Watching anime kill hot toast",
5253
"Watching アニメ",
@@ -58,6 +59,7 @@
5859
"Watching all of your commands coming in",
5960
"Watching time; it's just an illusion.",
6061
"Watching you",
62+
"Watching myself",
6163

6264
"Listening to Matt's Keyboard AMSR",
6365
"Listening to *wholesome sounds*",

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/Fun/uwu.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
name: "uwu",
3+
description: "UwUify some messages... for some reason..?",
4+
guildOnly: false,
5+
authorizedGuilds: [],
6+
hidden: false,
7+
permissions: ["DEFAULT"],
8+
cooldown: 10,
9+
aliases: ["uwuify"],
10+
syntax: [],
11+
execute: async(app, message, args) => {
12+
if (!args[0]) return app.functions.msgHandler(message, "uwu");
13+
14+
function UwUify(msg) {
15+
msg = msg.toLowerCase(); // Convert the message to lowercase for now
16+
const flipList = "ay:ey,ck:cc,ing:in,or:aw,ou:ow,ro:wo,tha:da,the:de,thi:di,wh:w,wr:w,you:yu,mn:m,mb:m,l:w,r:w".split(",").map(i => i.split(":"))
17+
for (let pair of flipList)
18+
msg = msg.split(pair[0]).join(pair[1]);
19+
return msg + ((!msg.endsWith("uwu")) ? " uwu" : "");
20+
};
21+
22+
for (var i = 0; i < args.length; i++) {
23+
if (args[i].includes("<@&") && args[i].includes(">"))
24+
args[i] = message.guild.roles.cache.get(args[i].replace(/[<@&>]/g, '')).name;
25+
};
26+
app.functions.msgHandler(message, UwUify(args.join(" ")) || "Something went wrong :(");
27+
}
28+
};

0 commit comments

Comments
 (0)