-
Notifications
You must be signed in to change notification settings - Fork 0
/
bloonsBot.js
88 lines (79 loc) · 2.74 KB
/
bloonsBot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const Discord = require("discord.js");
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] });
client.login("OTU4NDQxNjkzNDQ1NzgzNjM0.YkNYYg.eMXplkm4Q_rthwafwWSjpPlnbyg");
client.on("ready", on_ready);
function on_ready() {
let bot = client.user;
bot.setActivity(" Bloons TD Battles 2");
}
client.on("messageCreate", on_message);
const upgrades = require("./upgrades.json");
const names = [
["dart monkey", "dart"],
["boomerang", "boomerang monkey", "boomer"],
["bomb shooter", "bomb", "bomb tower", "bomber"],
["tack shooter", "tack"],
["ice", "ice monkey", "ice tower"],
["glue gunner", "glue"],
["sniper monkey", "sniper"],
["monkey sub", "sub", "submarine", "monkey submarine"],
["buccaneer", "monkey buccaneer", "bucc", "pirate"],
["ace", "monkey ace"],
["heli pilot", "heli", "helicopter"],
["mortar", "mortar monkey", "mortar tower"],
["dartling", "dartling gunner", "dartling monkey"],
["wiz", "wizard monkey", "wizard"],
["super", "super monkey"],
["ninja", "ninj", "ninja monkey"],
["alchemist", "alc", "alch"],
["druid"],
["banana farm", "farm"],
["spike factory", "spike", "spact"],
["monkey village", "village"],
["engineer monkey", "engineer", "engi"],
];
function on_message(message) {
if (message.author.bot === false) {
let msg = message.content.toLowerCase();
let reply = "empty";
if (msg === "quincy") {
reply = "I never miss!";
} else if (msg === "gwen") {
reply = "We have ignition!";
} else if (msg === "obyn") {
reply = "Feel nature's wrath!";
} else if (msg === "striker") {
reply = "Prepare for liberation!";
} else if (msg === "help") {
reply =
"Type a tower name, followed by the singular path you would like to see the description of. For example: 'sniper x3x'";
} else {
let tower = msg.substring(0, msg.search(/[x12345]/) - 1).toLowerCase();
let fullPath = msg.substring(msg.search(/[x12345]/));
let path = fullPath.search(/[^x]/);
let upgrade = fullPath.charAt(path) - 1; //-1 to convert from number to index
let towerIndex = -1;
for (let i = 0; i < names.length; i++) {
if (names[i].includes(tower)) {
towerIndex = i;
}
}
if (towerIndex === -1) {
reply = "This tower does not exist.";
} else {
upgrade = upgrades[towerIndex * 15 + path * 5 + upgrade];
reply =
upgrade.title +
"\nCost: " +
upgrade.cost +
"\nDescription: " +
upgrade.description +
"\nEffect: " +
upgrade.effect;
}
}
if (reply != "empty") {
message.reply(reply);
}
}
}