-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
378 lines (246 loc) · 7.88 KB
/
bot.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
//Packages
var Discord = require('discord.js');
var fs = require('fs');
//Keys
const crow = '127651916254543872';
const tree = '85614143951892480';
const yourself = '429357061126750208';
const uberbot = '85614143951892480';
const mkFile = 'mk_file.json';
//Json
var auth = require('./auth.json');
var names = require('./names.json');
var emotes = require('./emotes.json');
//Objects
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('message', msg => {
if (msg.content.toLowerCase().includes('!help')){
msg.channel.send('\n ```Commands:\n 1. Randomize me captain\n 2. Strip me \n 3. Cowboy baby \n 4. Knock Me Off \n 5. Pole rider \n 6. Allstar me bruh\n 7. Killed by Millennials```');
}
if (msg.member.id !== yourself && msg.content.toLowerCase().includes('fire truck') || msg.content.toLowerCase().includes('firetruck')) {
msg.channel.send('[Visibly excited] FIRE TRUCK');
}
if (msg.content.toLowerCase().includes('!killed') && msg.member.id !== yourself){
mkMap(msg);
}
if (msg.content.toLowerCase().includes('millennial') && (msg.member.id !== yourself && msg.member.id !== uberbot)){
mkRandom(msg.channel);
}
if (msg.content.toLowerCase().includes('!randomize me captain') && msg.member.id !== tree && msg.member.id !== crow) {
var name = randName();
try{
msg.member.setNickname(name);
msg.channel.send('Shazam! You\'re now: '+ name + '.');
}
catch(err){
}
}
if (msg.content.toLowerCase().includes('!strip me') && msg.member.id !== tree && msg.member.id !== crow) {
var name = randStripper();
try{
msg.member.setNickname(name);
msg.channel.send('Well helllllo there '+ name + '.');
}
catch(err){
}
}
if (msg.content.toLowerCase().includes('!cowboy baby') && msg.member.id !== tree && msg.member.id !== crow) {
var name = randCountry();
try{
msg.member.setNickname(name);
msg.channel.send('Yeeehaw! Give a rowdy howdy to ' + name + '.');
}
catch(err){
}
}
if (msg.content.toLowerCase().includes('!knock me off') && msg.member.id !== tree && msg.member.id !== crow) {
var name = randPepper();
try{
msg.member.setNickname(name);
msg.channel.send('Try a cool, refreshing ' + name + '.');
}
catch(err){
}
}
if (msg.content.toLowerCase().includes('!pole rider') && msg.member.id !== tree && msg.member.id !== crow) {
var name = randStripperCountry();
try{
msg.member.setNickname(name);
msg.channel.send('Save a horse, ride a '+ name + '.');
}
catch(err){
}
}
if (msg.content.toLowerCase().includes('!allstar me bruh') && msg.member.id !== tree && msg.member.id !== crow) {
var name = randAllstar();
try{
msg.member.setNickname(name);
msg.channel.send('<:multithonk:351969196349063168> uR nOw: '+ name + '.');
}
catch(err){
}
}
//Probably Ultragunner's ID?
if(msg.content.toLowerCase().includes('ultragunner') && msg.member.id !== '429357061126750208'){
msg.channel.send( '<:I1:454503952369844244> ULTRAGUNNER <:I1:454503952369844244>' );
}
});
client.login(auth.token);
function mkMap(msg){
var content = msg.content;
content = content.split(" ");
if(content.length > 1){
//Content [1] must be a valid operation
switch(content[1].toLowerCase()) {
case "add":
mkAdd(content.slice(1, content.length), msg.channel);
break;
case "remove":
mkRemove(content[2], msg.channel);
break;
case "list":
mkList(msg.channel);
break;
case "random":
mkRandom(msg.channel);
break;
default:
msg.channel.send('Milennials just killed me.\nThanks Obama. <:jeb:245823943854784523>\nProper syntax is `!killed [add, remove, list].`');
}
}
else {
msg.channel.send('Milennials just killed me.\nThanks Obama. <:jeb:245823943854784523>\nProper syntax is `!killed [add, remove, list].`');
}
//!killed add "Blah blah" URL
//killed list
//killed random?
//Milennial mention + random milkill fact
}
function mkAdd(contentArr, channel){
if(contentArr.length < 2){
channel.send("Proper add format is `!killed add {whatever milennials killed this time} {URL proving they killed it}`");
return 0;
}
var milkill = readMK();
var url = contentArr[contentArr.length - 1];
var toJoin = contentArr.slice(1,contentArr.length - 1);
var content = toJoin.join(" ");
url = fixURL(url);
milkill.killed[milkill.keyIndex] =
{
content: content,
url: url
};
outputMK(channel, milkill, milkill.keyIndex);
milkill.keyIndex = milkill.keyIndex + 1;
writeMK(milkill);
}
function fixURL(url){
if (!/^(f|ht)tps?:\/\//i.test(url)) {
url = "https://" + url;
}
return url;
}
function mkRemove(id, channel){
var milkill = readMK();
delete milkill.killed[id];
channel.send("Deleted ID:" + id);
writeMK(milkill);
}
function mkList(channel){
var milkill = readMK();
var output = "";
for (key in milkill.killed){
if(milkill.killed.hasOwnProperty(key)) {
var datum = milkill.killed[key];
//outputMK(channel, milkill, key);
output += "\n" + structureMKString(channel, milkill, key);
}
}
channel.send(output);
}
function mkRandom(channel){
var milkill = readMK();
var randIndex = Math.floor(Math.random() * Object.keys(milkill.killed).length);
var index = 0;
for (key in milkill.killed){
if(index === randIndex){
//outputMK(channel, milkill, key);
var datum = milkill.killed[key];
channel.send("Damn millennials, did you know they killed " + datum.content + "? No seriously, I have proof! <" + datum.url + ">");
return 0;
}
else{
index = index + 1;
}
}
}
function outputMK(channel, milkill, id){
var output = structureMKString(channel, milkill, id);
//var datum = milkill.killed[id];
//channel.send("`" + id + "` " + datum.content + " <" + datum.url + ">");
channel.send(output);
}
function structureMKString(channel, milkill, id){
var datum = milkill.killed[id];
return "`" + id + "` " + datum.content + " <" + datum.url + ">";
}
function readMK(){
var mk = fs.readFileSync('./mk_file.json');
var parsed = JSON.parse(mk);
return parsed;
}
function writeMK(milkill){
fs.writeFileSync('./mk_file.json', JSON.stringify(milkill));
}
function randName(){
var index = Math.floor(Math.random()*names.arr.length);
return names.arr[index];
}
function randStripper(){
var i0 = Math.floor(Math.random()*names.combo0_stripper.length);
var i1 = Math.floor(Math.random()*names.combo1_stripper.length);
var i2 = Math.floor(Math.random()*names.combo2_stripper.length);
var name = names.combo0_stripper[i0] + ' ' + names.combo1_stripper[i1] + names.combo2_stripper[i2];
if(name.length > 32){
return randStripper();
}
return name;
}
function randCountry(){
var i0 = Math.floor(Math.random()*names.combo0_country.length);
var i1 = Math.floor(Math.random()*names.combo1_country.length);
var i2 = Math.floor(Math.random()*names.combo2_country.length);
var name = names.combo0_country[i0] + ' \"' + names.combo1_country[i1] + '\" ' + names.combo2_country[i2];
if(name.length > 32){
return randCountry();
}
return name;
}
function randStripperCountry(){
var i0 = Math.floor(Math.random()*names.combo0_country.length);
var i1 = Math.floor(Math.random()*names.combo1_stripper.length);
var i2 = Math.floor(Math.random()*names.combo2_stripper.length);
var i3 = Math.floor(Math.random()*names.combo2_country.length);
var name = names.combo0_country[i0] + ' \"' + names.combo1_stripper[i1] + names.combo2_stripper[i2] + '\" ' + names.combo2_country[i3];
if(name.length > 32){
return randStripperCountry();
}
return name;
}
function randPepper(){
var i0 = Math.floor(Math.random()*names.combo0_pepper.length);
var i1 = Math.floor(Math.random()*names.combo1_pepper.length);
var name = names.combo0_pepper[i0] + ' ' + names.combo1_pepper[i1];
if(name.length > 32){
return randPepper();
}
return name;
}
function randAllstar(){
var index = Math.floor(Math.random()*names.allstar.length);
return names.allstar[index];
}