forked from ninjamuffin99/FulpTronJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
1600 lines (1335 loc) · 50 KB
/
index.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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const fs = require('fs');
const rp = require('request-promise');
const path = require('path');
const cheerio = require('cheerio');
const nodemailer = require('nodemailer');
// require the discord.js module
const Discord = require('discord.js');
// create a new Discord client
const client = new Discord.Client();
const https = require('https');
const request = require('request');
const {Util} = require('discord.js');
const GoogleSpreadsheet = require('google-spreadsheet');
const {promisify} = require('util');
//command set up
client.commands = new Discord.Collection();
//extra shit
const ytdl = require('ytdl-core-discord');
// consts
const nonDiscordUserMsg = 'you need to be using Discord to get this feature!';
// NOTE IMPORTANT READ THIS
// This line is commented in the master/heroku version, but it is needed if you were to run the code locally
let {prefix, token, clientID, luckyGuilds, luckyChannels, ownerID, NGappID, NGencKey, spreadsheetID, GOOGLE_API_KEY, MMappID} = require('./config.json');
let gCreds = require('./fulpGdrive.json');
if (process.env.prefix) prefix = process.env.prefix;
if (process.env.clientID) clientID = process.env.clientID;
if (process.env.ownerID) ownerID = process.env.ownerID;
if (process.env.token) token = process.env.token;
if (process.env.NGappID) NGappID = process.env.NGappID;
if (process.env.NGencKey) NGencKey = process.env.NGencKey;
if (process.env.spreadsheetID) spreadsheetID = process.env.spreadsheetID;
if (process.env.GOOGLE_API_KEY) GOOGLE_API_KEY = process.env.GOOGLE_API_KEY;
if (process.env.MMappID) MMappID = process.env.MMappID;
if (process.env.private_key_id) gCreds.private_key_id = process.env.private_key_id;
if (process.env.private_key) gCreds.private_key = process.env.private_key.replace(/\\n/g, '\n');
// Music bot shit
const YouTube = require(`simple-youtube-api`);
const youtube = new YouTube(GOOGLE_API_KEY);
const queue = new Map();
// gets filled later
const fulpPics = [];
let shoomOCound = 2;
async function prepPics()
{
await getImages('fulp');
await console.log('Fulp shit');
await getImages('dogl');
await console.log('dogl shit');
await getImages('delete');
await console.log('delete shit');
}
// when the client is ready, run this code
// this event will trigger whenever your bot:
// - finishes logging in
// - reconnects after disconnecting
client.on('ready', () =>
{
prepPics();
console.log('Ready!');
console.log(`....................................................................................................
.............................................'''''''''''............................................
.........................................'''' ''' '''''''''.......................................
.....................................'''''''''''' '''''''''''''''...................................
...................................'''''''.'''.''...........''.'''''................................
...............................'''''''...-..--:----.-:--..........'''''.............................
............................'''''....---::-::///::::::::----::----....''''..........................
................................-:--::::/://////////::::::::::/::::....'''''........................
..........................---:-::--://////////////:::.--:::---://///:-...' ''......................
.........................-:-:::-...::-:::::::-.-:---.'-.-----:-----://:/:-''' ''....................
........................-::::-.''---...-----.''...''''''......------::::::-.'''''...................
.....................-.-::--.'''.-.''''.....''..''''''''....'....---:-::://:-''' '..................
.....................-.::--. ''..''''''.'.''...'' '''''....' ''.....--::-::/:.''' '.................
....................-::/-..'''..''''''''''''..''''' '.'''''' '........-:--:/:..'' '................
....................:+/--.''''.' '' ''''' ''''''''''''' '.''.'....----//-...'''...............
...................://:... '''' ''''.:-''' '' ' '' ''''....---:/:--...''..............
..................-/+:.'.' '' '.:' ''.--:+:' ''' ' ' '''''''..---/:-:...''..............
................:/:/:.'..' :so:' ./+osssyo' ..'./' ' ' ''''' ''''.::-:...................
.............../sy:/-.'.' '-yh/.''.-ohhhyyyy/' '/+o:+yd: ''. '' ' ''.-.--...................
.............-+yys::-'''' :dyoyysyhmmddhhhy:'':yhhyydmmh.''::-+:'.. ''''.....................
............:oysss-..' '::.ymmmmmmmNNNNmmmh:-oyddddmmmmmmy- '/yhdo-s/' '..--.--...............
...........:oyssss-.'' :hdsso+::--:+shdmmmhydmdddmmNNNNNNmd/''odmmsyyo. ''''.-:.-s/-..............
..........-oysssss-.'' odh+/::::::::::/+sdmmmmdmmddyysosyyhhyo/hmmhysy: ''.-::.:yy+..............
.........-+yssssss:.' .yhyyyyyyo/:-:oys++shdmmmdss+//::--.-:/osdmmdhyy/ ''.-:-.-syy:.............
........./yyssssss/.' 'sdddhhysyo''-'/yhy++hdmNhsssssssoo++ososyyhmddhyo ''.::.'-syh+.............
........:oyssssssso. 'odddmhhhyso-''-ydhyosdmNNh+oysso+'' .-+ydhddmmhyys' ''--..+ssho-............
........+yyssssssss'' :ymmmmmdhhyyyyyyyyysoyhmNNy/shysys'. 'omdddmdmdhhhs' ''..'/sssyy:............
.......:oysssssssssy/'/hdmmmmmmmmddhhhhhhdshdmNNyyhhhhso/:/+syyhdmmmdhhhs. ''-osssyh/............
......./sysssssssssmy:yddmmmmmmmmmmNmmmmmmshdNNmshmmddhhyyhhhhyhdmmmmdhhy' '-oossssyh+-...........
.......+hysssssssssdmhyddmmmmmNmmmmmmmmmmdyydNNmhdmmmmmmmmmmmmmmmmmmmddds' './shsssssyh+............
......-ohsssssssssssdhyddmdmNMMNmmmmmmmddhshdmNNmmmmmmmmmmmmNNNNmmmmmmmdo' .oodssssssyh/............
......:syssssssssssssyyhdddmNNNNmmmmmmsyyyhmmmmNNmmddmdddddmNNNNmmmmmmmmo.:yohyssssssyh/............
....../yyssssssssssssssyhddmmmmmmmmmdooyyhhdddmmNmmyymmddddmNNNmmmmmmmdhssyyyhsssssssyy/............
......:yysssssssssssssssyhddmmmmmmmyo///-/yhhhysshd+/sdmmddmmmmmmmmmmdhyyhddyssssssssys:............
......:sysssssssssssssoooyddmmmmmmysys//.-:osys::sysoshmmddmmmmmmmmddhsshddssssssssssh+-............
......:shssssssssssssss/+shdddmmmdyhdmddhdhyydddddddyhhdmmmdmmdmddhhhs+sssssssssssssys/.............
......-+hsssssssssssssso/oyhhhdmdhhdmmmmmmdhhddddmdddhhhmmmmmmmddhyys+ssssssssssssssyo/.............
......./hyssssssssssssss++shhhhhyyhdmmmdddddddddddddddhydmddmmmdhyys+osssssssssssssss+-.............
.......:yhsssssssssssssso/+yhhhss++++/++syyssysssyhhhhy+hmdmmmdhyys/sssssssssssssssy+/..............
........ohyssssssssssssss+/oyddddmdyssysoo++++++////+oo:ydmmmmdys+/ossssssssssssssyo+-..............
........-yhyssssssssssssso/+ohddmmmddhhhddhhhhhhhyyyyhdymmmmmdy+/ohsssssssssssssssy+:...............
.........:yyssoo++/+///::-.:osdddmmmmmdhhhhhhhhhdddmmmmmNmddhs/+yhdssssssssssssssy+/................
..........-/-..''''''''' '''/syhddmmmmmdhyyyyhdddmmmmmmmmdhs+/oyhdd+-:+oosssssssyo/-................
..''''' ' '''''''''''''' '''o+oyhddmmmmmhsosyhddmmmmmmmmdyo//syhddd/''''.-/oosyy+:..................
' '''''''''''''''''''' ''.sh++oshdddddddhhhdmmmmmmmddyo/:yhyhhddd:'''''' '.:+/....................
'''''''''''''''''''''''' ''-ssohyo+syyhhhhhhhddddddhso+//sshmhddddh.' '''''''''''...................
'''''''''''''''''''''''''''-soyddhs//oosyyyyyyyyyss+///+hhyydmmddh:'' '''''''''' '''................
''''''''''''''''''''''''' ''ssdmddho/+++o+++++++ooossooydddhdmmdh/''''''''''''''''''''..............
''''''''''''''''''''''''''''/sdmmmdy+ooyyyyyhhhhddddysyddmmmmmdh:''''''''''''''''''''''''...........
'''''''''''''''''''''''''' '.oymmmmmyshdddddddddddddyshmmmmmmdy:''''''''''''''''''''''''''''........
''''''''''''''''''''''''''''''oydmmmdydmmmmNNNNNmmmmyhmmmmmdhs.''''''''''''''''''''''''''''''''.....
'''''''''''''''''''''''''''' '-syhdmmmdmmdddmmmmmmmmmmmmmmdy+''''''''''''''''''''''''''''''''''''''.
''''..'''''''''''''''''''''''''.oyyddmmmmmmmNNNmmmmmmmmmmhs-''''''''''''''''''''''''''''''''''''''''
'....'''''''''''''''''''''''''''./ssyhdmmmmmmmmmmmmmmmmdy/''''' ''''''''''''''''''''''''''''''''''''
....''''''''''''''''''''''''''''''./+syyhddddmmmdddddhs:'''' '''''''''''''''''''''''''''''''''''''
....'''''' ''''''''''''''''''' ''''.:+oyyyyyyyso+/:.'''' '''''''''''''''''''''''''''''...''''''''
..''''''' ''''''''''''''''''' ''''''''....''''''''' ''''''''''''' '''' '''''''''''......'''''''
.'.'''' '''''''''''''''''''''''''''''''''''''' '''''''''' ''''''''''.......'''''''`);
console.info("FULPTRON IS ONLINE");
console.info(`FulpTron is on ${client.guilds.size} servers!`);
console.info(client.guilds.map(g => g.name).join("\n"));
});
let ngRef = ['Cock joke. username is here', 'username, just do what comes natural -T', 'le username has arrived', 'username, do you remember what a tardigrade is?',
'Angels sang out in an immaculate chorus, down from the heavends decended username', 'username was blammed for this post', 'username has nice titties for a lil boy',
"Aw gee whiz I hope a username doesn't totally come out of nowhere and own me.", 'Cryptic metaphor -username', 'What the hell is private username doing in there?'];
client.on('guildMemberAdd', async member =>
{
// code specific to the Flash Holes server
if (member.guild.id == 283807027720093697)
{
let curRole = member.guild.roles.find("name", "Flash Hole");
member.addRole(curRole);
}
//G
let guildIndex = luckyGuilds.indexOf(member.guild.id);
if (guildIndex != -1)
{
let infoPart = '*\nYou can use the command `fulpNGLogin` to sign into the Newgrounds API, and `fulpAddRole <role>` to give yourself other roles(`fulpRoles` to see all roles, and `fulpHelp` for more info)'
let intro = ngRef[Math.floor(Math.random() * ngRef.length)];
intro = intro.replace('username', "**" + member.user.username + "**");
return member.guild.channels.find('id', `{luckyChannels[guildIndex][0]}`).send("*" + intro + infoPart);
}
});
client.on('message', async message =>
{
// Don't respond to messages made by the bot itself
if (message.author.id == clientID) return;
let isInGuild = message.guild != null;
let isDiscordUser = !message.author.bot;
//RATING EMOTES ON NG SERVER
let guildIndex = isInGuild ? luckyGuilds.indexOf(message.guild.id) : -1;
if (guildIndex != -1 && luckyChannels[guildIndex].includes(message.channel.id))
{
if (!message.content.startsWith('[noreact]'))
{
if (message.attachments.size > 0 || message.content.startsWith("https://www.newgrounds.com/art/view") || message.content.startsWith('https://www.newgrounds.com/audio/listen/') || message.content.startsWith('https://www.newgrounds.com/portal/view/'))
{
let picoSuffix = "";
if (Math.random() > 0.5)
picoSuffix = "pico"
message.react(message.guild.emojis.find('name', "0stars" + picoSuffix))
.then(react => message.react(message.guild.emojis.find('name', "1star" + picoSuffix)))
.then(react => message.react(message.guild.emojis.find('name', "2stars" + picoSuffix)))
.then(react => message.react(message.guild.emojis.find('name', "3stars" + picoSuffix)))
.then(react => message.react(message.guild.emojis.find('name', "4stars" + picoSuffix)))
.then(react => message.react(message.guild.emojis.find('name', "5stars" + picoSuffix)));
}
}
}
if (message.content.toLowerCase() === "are we talking about tom fulp?" || message.content.toLowerCase() === "are we talking about tom fulp?" )
{
// message.reply basically the same as message.channel.send, but @'s the person who sent it
message.reply("I **LOVE** talking about Tom Fulp!");
}
else if (message.content.toLowerCase() === "can i get a rip in chat?")
{
// message.reply basically the same as message.channel.send, but @'s the person who sent it
message.reply("\nRIP\nRIP\nRIP");
}
//Automate Welcome Channel WIP
/*if(message.content.toLowerCase() === "test" || message.channel.id() === "read-the-rules-for-access"){
//message.member.addRole("NG");
message.reply("works");
let usr = args[0];
if (usr == undefined)
{
return message.channel.send("Go to Newgrounds.com!\nhttps://newgrounds.com")
}
//let usr = args[0];
//`https://${usr}.newgrounds.com`
if(class === "level-${}-${}"){
}
}*/
else if(message.content.toLowerCase() === "monster mashing"){
message.reply("Did someone say M0NSTER MASHING!?\nhttps://www.newgrounds.com/portal/view/707498");
}
//IF IT DOESNT START WITH "FULP" then IT DONT REGISTER PAST THIS POINT
else if (!message.content.toLowerCase().startsWith(prefix)) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
// this message(and all others below it) does need a prefix, because it's after the if statement, and also needs the other info above, like command and args
if (command == 'ping')
{
// var emoji = Discord.emoji.from
let pang = Math.round(client.ping);
message.channel.send(`Pong! Ping: ${pang}ms`);
}
else if (command == 'shame')
{
message.channel.send('**SHAAAAAME**');
}
else if(command == 'die'){
message.channel.send(`(^A^) ̿ ̿'̿'\̵͇̿̿\з`);
}
else if (command == 'help')
{
message.channel.send("https://github.com/ninjamuffin99/FulpTronJS/blob/master/COMMANDS.md");
}
else if (command == 'emotetest')
{
if (!isInGuild) return;
message.channel.guild.createEmoji('./pics/luis/luis.jpg', 'luis', [message.guild.roles.find('name', 'Newgrounder')])
}
else if (command == 'screenshare' || command =='share')
{
if (!isInGuild) return;
if (!isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
const { voiceChannel } = message.member;
if (!voiceChannel) {
return message.reply('please join a voice channel first!');
}
return message.channel.send('http://www.discordapp.com/channels/' + message.guild.id + '/' + voiceChannel.id)
}
const serverQueue = isInGuild ? queue.get(message.guild.id) : null;
console.log(serverQueue);
if (command == 'play' || command == 'join')
{
if (!isInGuild) return;
if (!isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
//return message.channel.send("WOOPS if you are reading this fulpPlay is BUSTED right now. Ur boy ninjamuffin already knows this and is tryin to fix it");
const searchString = args.slice(0).join(" ");
const url = args[0] ? args[0].replace(/<(.+)>/g, '$1') : '';
if (message.channel.type !== 'text') return;
const { voiceChannel } = message.member;
if (!voiceChannel) {
return message.reply('please join a voice channel first!');
}
const permissions = voiceChannel.permissionsFor(message.client.user);
/*
if (!message.member.speaking)
{
return message.channel.send('You are muted, so it is likely you should not be using me!');
}
*/
if (!permissions.has('CONNECT'))
{
return message.channel.send("I can't join that voice channel with my current roles :(");
}
if (!permissions.has('SPEAK'))
{
return message.channel.send('I cannot speak in this voice channel with my current permissions :(');
}
if (!message.member.voiceChannel.memberPermissions(message.member).has('SPEAK'))
{
return message.channel.send('You do not have permission to speak in this channel, so it is likely you should not be using me either!');
}
if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/))
{
const playlist = await youtube.getPlaylist(url);
const videos = await playlist.getVideos();
for (const video of Object.values(videos))
{
const video2 = await youtube.getVideoByID(video.id); // eslint-disable-line no-await-in-loop
await handleVideo(video2, message, voiceChannel, true); // eslint-disable-line no-await-in-loop
}
return message.channel.send(`✅ Playlist: **${playlist.title}** has been added to the queue!`);
}
else
{
try
{
var video = await youtube.getVideo(url);
}
catch (error)
{
try
{
var videos = await youtube.searchVideos(searchString, 10);
let index = 0;
message.channel.send(`
__**Song selection:**__
${videos.map(video2 => `**${++index} -** ${video2.title}`).join('\n')}
**Please provide a value to select one of the search results ranging from 1-10.**
`);
// eslint-disable-next-line max-depth
try
{
var response = await message.channel.awaitMessages(message2 => message2.content > 0 && message2.content < 11, {
maxMatches: 1,
time: 10000,
errors: ['time']
});
}
catch (err) {
console.error(err);
return message.channel.send('No or invalid value entered, cancelling video selection.');
}
const videoIndex = parseInt(response.first().content);
var video = await youtube.getVideoByID(videos[videoIndex - 1].id);
}
catch (err)
{
console.error(err);
return message.channel.send('🆘 I could not obtain any search results.');
}
}
return handleVideo(video, message, voiceChannel);
}
} else if (command === 'skip') {
if (!isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
if (!message.member.voiceChannel) return message.channel.send('You are not in a voice channel!');
if (!message.member.voiceChannel.memberPermissions(message.member).has('SPEAK'))
{
return message.channel.send('You do not have permission to speak in this channel, so it is likely you should not be using me either!');
}
if (!serverQueue) return message.channel.send('There is nothing playing that I could skip for you.');
serverQueue.connection.dispatcher.end('Skip command has been used!');
return undefined;
} else if (command === 'stop') {
if (!isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
if (!message.member.voiceChannel) return message.channel.send('You are not in a voice channel!');
if (!message.member.voiceChannel.memberPermissions(message.member).has('SPEAK'))
{
return message.channel.send('You do not have permission to speak in this channel, so it is likely you should not be using me either!');
}
if (!serverQueue) return message.channel.send('There is nothing playing that I could stop for you.');
serverQueue.songs = [];
serverQueue.connection.dispatcher.end('Stop command has been used!');
return undefined;
} else if (command === 'volume') {
if (!isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
if (!message.member.voiceChannel) return message.channel.send('You are not in a voice channel!');
if (!message.member.voiceChannel.memberPermissions(message.member).has('SPEAK'))
{
return message.channel.send('You do not have permission to speak in this channel, so it is likely you should not be using me either!');
}
if (!serverQueue) return message.channel.send('There is nothing playing.');
if (!args[0]) return message.channel.send(`The current volume is: **${serverQueue.volume}**`);
if (args[0] > 200) return message.channel.send('pls do not use FulpTron for evil (max volume is 200)');
serverQueue.volume = args[0];
serverQueue.connection.dispatcher.setVolumeLogarithmic(args[0] / 100);
return message.channel.send(`I set the volume to: **${args[0]}**`);
} else if (command === 'np' || command === 'nowplaying') {
if (!serverQueue) return message.channel.send('There is nothing playing.');
return message.channel.send(`🎶 Now playing: **${serverQueue.songs[0].title}**`);
} else if (command === 'queue' || command === 'q') {
if (!serverQueue) return message.channel.send('There is nothing playing.');
return message.channel.send(`
__**Song queue:**__
${serverQueue.songs.map(song => `**-** ${song.title}`).join('\n')}
**Now playing:** ${serverQueue.songs[0].title}
`);
} else if (command === 'pause') {
if (!isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
if (serverQueue && serverQueue.playing) {
serverQueue.playing = false;
serverQueue.connection.dispatcher.pause();
return message.channel.send('⏸ Paused the music for you!');
}
if (!message.member.voiceChannel.memberPermissions(message.member).has('SPEAK'))
{
return message.channel.send('You do not have permission to speak in this channel, so it is likely you should not be using me either!');
}
return message.channel.send('There is nothing playing.');
} else if (command === 'resume') {
if (!isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
if (serverQueue && !serverQueue.playing)
{
serverQueue.playing = true;
serverQueue.connection.dispatcher.resume();
return message.channel.send('▶ Resumed the music for you!');
}
return message.channel.send('There is nothing playing.');
}
// STUPID JS NOTE: MAKE SURE YOU USE ` BACKTICKS LIKE THIS, INSTEAD OF ' APOSTROPHES LIKE THIS
// IF YOU WANT TO USE EZ VARIABLES AND SHIT
else if (command == 'server')
{
if (!isInGuild) return;
message.channel.send(`This server's name is: ${message.guild.name}
Total members: ${message.guild.memberCount}
Server Region: ${message.guild.region}
FulpTron joined this server at: ${message.guild.joinedAt}
The Owner is: ${message.guild.owner.user.username}`);
}
else if (command == 'invite')
{
message.channel.send(`Use this link to invite FulpTron to a server that you have admin access on! https://discordapp.com/oauth2/authorize?client_id=${clientID}&scope=bot&permissions=8`);
}
else if (command == 'discord')
{
message.channel.send("https://discord.gg/HzvnXfZ");
}
else if (command == 'kick')
{
if (!isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
if (!message.member.permissions.has("KICK_MEMBERS"))
{
return message.reply("you don't have permission to kick u doof!");
}
if (!message.mentions.users.size)
{
return message.reply('you need to @ someone to kick em')
}
const taggedUser = message.mentions.users.first();
message.channel.send(`You wanted to kick: ${taggedUser.username}`);
}
else if (command == 'prune' || command == 'purge')
{
if (!isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
if (!message.member.hasPermission('MANAGE_MESSAGES'))
{
return message.channel.send("You need to have the permission 'Manage Messages' enabled for one of your roles!");
}
const amount = parseInt(args[0]) + 1;
if (isNaN(amount))
{
return message.reply('that does not seem to be a valid number');
}
else if (amount <= 1 || amount > 100)
{
return message.reply('you need to input a number between 1 and 99');
}
message.channel.bulkDelete(amount, true).catch(err =>
{
console.error(err);
message.channel.send("OOPSIE WOOPSIE!! Uwu We madea fucky wucky!! A wittle fucko boingo! The code monkeys at our headquarters are working VEWY HAWD to fix this!");
message.channel.send("acutally there was just an error trying to prune message oopsies");
})
}
else if (command == "uptime"){
//message.reply(`Current uptime is : ${client.uptime.toPrecision(2) * 0.001} seconds`)
let totalSeconds = (client.uptime / 1000);
let hours = Math.floor(totalSeconds / 3600);
totalSeconds %= 3600;
let minutes = Math.floor(totalSeconds / 60);
let seconds = totalSeconds % 60;
let sec = Math.floor(seconds);
let uptime = `${hours} hours, ${minutes} minutes and ${sec} seconds`;
message.reply("Current uptime is : " + uptime);
}
else if (command == "points")
{
if (!isInGuild) return;
let score = client.getScore.get(message.author.id, message.guild.id);
if (!score)
{
score = {id: `${message.guild.id}-${message.author.id}`, user: message.author.id, guild: message.guild.id, points: 0, level: 1 };
}
score.points++;
const curLevel = Math.floor(0.1 * Math.sqrt(score.points));
if(score.level < curLevel)
{
score.level++;
message.reply(`You've leveled up to level **${curLevel}**! Ain't that dandy?`);
}
console.log(`level status: ${curLevel} / ${score.level}`);
client.setScore.run(score);
console.log(score);
}
else if (command == "picarto")
{
let username = args[0];
let url = `https://api.picarto.tv/v1/channel/name/${username}`;
https.get(url, (resp) =>
{
let data = '';
// A chunk of data has been recieved.
resp.on('data', (chunk) => {
data += chunk;
});
resp.on('end', () => {
console.log(JSON.parse(data));
JSON.parse(data, (key, value) =>
{
if (key == "online")
{
if (value)
{
message.channel.send(`${username} is streaming!`)
}
else
message.channel.send(`${username} is not streaming :(`)
}
});
});
});
}
else if (command == "quiz")
{
// https://opentdb.com/api.php?amount=1
let url = `https://opentdb.com/api.php?amount=1`;
https.get(url, (resp) =>
{
let data = '';
// A chunk of data has been recieved.
resp.on('data', (chunk) => {
data += chunk;
});
resp.on('end', () => {
let theQuiz = JSON.parse(data).results[0];
console.log(JSON.parse(data).results[0])
let messageSending = theQuiz.category + "\n" + unescapeHTML(theQuiz.question);
let answerArray = theQuiz.incorrect_answers;
let correctAnswerPos = Math.floor(Math.random() * (theQuiz.incorrect_answers.length + 1));
console.log("Answer is " + correctAnswerPos);
answerArray.splice(correctAnswerPos, 0, theQuiz.correct_answer)
for (let a = 0; a < answerArray.length; a++)
{
messageSending += "\n" + (a + 1) + ". " + answerArray[a];
}
message.channel.send(messageSending).then(() =>
{
message.channel.awaitMessages(mess => mess.content.startsWith(correctAnswerPos + 1), {
max: 1,
time: 20000,
errors: ['time'],
})
.then((collected) => {
message.reply(`You got the right answer i think, ${theQuiz.correct_answer}`);
})
.catch(() => {
message.channel.send(`Ran outta time, the correct answer was ${(correctAnswerPos + 1) + ". " + theQuiz.correct_answer}`);
});
});
// message.channel.awaitMessages(message2 => message2.content > 0 && message2.content < 11, {
});
});
}
else if (command == 'roles')
{
if (!isInGuild) return;
let roleList = message.guild.roles.map(r => {
if (["Admins", 'Moderators', "@everyone", 'BrenBot', 'Mr. Fulp', 'Contributor', 'Nitro Booster'].indexOf(r.name) > -1 || r.name.endsWith('Collab'))
return "";
else
return r.name;
}).join("--");
message.channel.send("Roles on " + message.guild.name + "\n " + roleList)
}
//Cam you do it
else if (command == "addrole"){
if (!isInGuild) return;
if (!isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
let role = args.slice(0).join(" ");
if (role.endsWith('Collab'))
return message.reply('Message the collab organizer if you would like to participate in this collab!');
if (['Admins', "Moderators", 'BrenBot', 'Contributor', 'james'].indexOf(role) > -1)
return message.reply('Hey stop that!');
if (["Newgrounder", 'Supporter'].indexOf(role) > -1)
return message.reply('the role "' + role + '" requires you to log into the Newgrounds API. Use the command `fulpNGLogin`');
let curRole = message.guild.roles.find("name", role);
if (!message.guild.roles.exists("name", role))
{
return message.reply(`This server doesn't seem to have ${role} as a role... you should know that the roles are case sensitive!`)
}
if (message.member.roles.exists("name", role))
{
return message.reply(`you already have the ${curRole.name} role!`)
}
message.member.addRole(curRole);
message.reply(`just got the ${curRole.name} role!`);
}
else if (command == "removerole")
{
if (!isInGuild) return;
if (!isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
let role = args.slice(0).join(" ");
if (['Blammed'].indexOf(role) > -1)
return message.reply('lol dummy');
let curRole = message.guild.roles.find('name', role);
if (!message.guild.roles.exists("name", role))
{
return message.reply(`This server doesn't seem to have ${role} as a role... you should know that the roles are case sensitive!`)
}
if (!message.member.roles.exists("name", role))
{
return message.reply(`you already had the ${curRole.name} role removed!`)
}
message.member.removeRole(curRole).then(message.reply(`removed your ${curRole.name} role!`))
}
/*
if (command == "timeout" && message.author.role("mod"))
{
if (!isInGuild) return;
if (!isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
let usr = args[0];
if (!message.guild.roles.exists("name", role))
{
return message.reply(`This server doesn't seem to have ${role} as a role... you should know that the roles are case sensitive!`)
}
if (message.member.roles.exists("name", role))
{
return message.reply(`you alread have the ${curRole.name} role!`)
}
message.member.addRole(curRole);
//message.reply('just got the ${curRole.name} role!');
}
*/
else if (command == 'args-info')
{
if (!args.length)
{
return message.channel.send(`You didn't provide any arguments, ${message.author}`);
}
message.channel.send(`Command name: ${command}\nArgumenets: ${args}`);
}
else if (command === "asl")
{
let age = args[0]; // Remember arrays are 0-based!.
let sex = args[1];
let location = args[2];
message.reply(`Hello ${message.author.username}, I see you're a ${age} year old ${sex} from ${location}. Wanna date?`);
}
else if (command == 'cringe' || command == 'snap')
{
message.channel.send('brandyCringe.png', {file: "pics/brandy/brandyCringe.png"});
}
else if (command == 'dogl' || command == 'dogg')
{
let curPic = randomFromArray(1);
console.log("THE PIC");
console.log(curPic);
message.channel.send(curPic, {file: "pics/dogl/" + curPic});
}
else if ( command == 'delete' || command == 'delet' || command == 'gun')
{
let curPic = randomFromArray(2);
console.log("THE PIC");
console.log(curPic);
message.channel.send(curPic, {file: "pics/delete/" + curPic});
}
if (command == `pic`)
{
if (args[0] == "luis")
{
return message.channel.send("luis.jpg", {file: "pics/luis/" + "luis.jpg"});
}
if (args[0] == 'dogl' || args[0] == "dogg")
{
let curPic = randomFromArray(1);
console.log("THE PIC");
console.log(curPic);
return message.channel.send(curPic, {file: "pics/dogl/" + curPic});
}
let curPic = randomFromArray(0);
console.log("THE PIC");
console.log(curPic);
message.channel.send(curPic, {file: "pics/fulp/" + curPic});
}
else if (command == "watching")
{
let text = args.slice(0).join(" ");
client.user.setActivity(text, { type: 'WATCHING'});
}
else if (command == 'playing')
{
let text = args.slice(0).join(" ");
client.user.setActivity(text, { type: 'PLAYING' })
.then(presence => console.log(`Activity set to ${presence.game ? presence.game.name : 'none'}`))
.catch(console.error);
}
else if (command == "shoom" || command == "jojo")
{
let shoomBeginning = "**SH";
for (i = shoomOCound; i > 0; i--)
{
shoomBeginning += "O";
}
shoomBeginning += "M**";
shoomBeginning += `\nO Amount: ${shoomOCound}`
shoomOCound += 1;
message.channel.send(shoomBeginning);
}
else if (command === 'say')
{
let text = args.slice(0).join(" ");
message.delete();
message.channel.send(text);
console.log(message.author.username + " says: " + text);
}
else if (command == 'roll')
{
let min = 1;
let max = parseInt(args[0]);
if (isNaN(max))
max = 20;
message.channel.send(`🎲 You rolled a: ${Math.floor(Math.random() * (max - min + 1)) + min}`)
}
else if (command == 'ngfollow')
{
let usr = args[0];
if (usr == undefined)
{
return message.channel.send("Go to Newgrounds.com!\nhttps://newgrounds.com")
}
else
{
if (usr == 'Tom' || usr == 'TomFulp')
{
return message.channel.send("Go follow Tom Fulp himself on Newgrounds!\nhttps://TomFulp.newgrounds.com")
}
message.channel.send(`Go follow ${usr} on Newgrounds!\nhttps://${usr}.newgrounds.com`)
}
}
else if (command == 'loli')
{
message.channel.send({ files: ['https://cdn.discordapp.com/attachments/422660110830272514/446516094006460417/unknown.png']})
.then(message.channel.send('**inb4 BAN**'))
.then(message.channel.send({ files: ['https://cdn.discordapp.com/attachments/422660110830272514/446516105880535041/unknown.png']}));
}
else if (command == 'source' || command == 'sourcecode' || command == 'github')
{
message.channel.send("Dig through my code on Github: \nhttps://github.com/ninjamuffin99/FulpTronJS");
}
// WARNING VERY DANGEROUS COMMAND THAT CAN RUIN THE BOT'S HOST IF IN THE WRONG HANDS
// BUT IM CODING IT IN FOR THE LOLS LMAOOO
// make sure you set 'ownerID' as your discord ID (the numbers and shit) to make sure that no goon besides the host uses it
else if (command == 'eval')
{
if (message.author.id !== ownerID) return;
try
{
const code = args.join(" ");
let evaled = eval(code);
if (typeof evaled !== "string")
evaled = require("util").inspect(evaled);
message.channel.send(clean(evaled), {code:"xl"});
}
catch(err)
{
message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
}
}
else if (command == 'ngplay')
{
if (!isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
if (!message.member.voiceChannel.memberPermissions(message.member).has('SPEAK'))
{
return message.channel.send('You do not have permission to speak in this channel, so it is likely you should not be using me either!');
}
let songUrl = args[0];
if (songUrl == undefined)
return message.channel.send("Please leave a link to a Newgrounds audio submission!")
if (songUrl.startsWith('https://www.newgrounds.com/playlists'))
{
const options = {
uri: songUrl,
transform: function (body) {
return cheerio.load(body);
}
};
rp(options)
.then(($) => {
let songList = $('.itemlist.alternating').find('li');
for (let i = 0; i < songList.toArray().length; i++)
{
let daSong = songList.toArray()[i].children[1].children[1].attribs.href;
daSong = daSong.slice(2, daSong.length);
daSong = "https://" + daSong;
handleNGSongs(daSong, message, message.member.voiceChannel, true);
}
});
}
else
{
handleNGSongs(songUrl, message, message.member.voiceChannel);
}
}
// cheerio.js scraping help and info:
// https://codeburst.io/an-introduction-to-web-scraping-with-node-js-1045b55c63f7
// also check out the cheerio.js github and website
else if (command == "ngscrape" || command == 'scrape' || command == 'stats')
{
//return message.channel.send("woops this command is busted right now sorry lolol");
let usr = args[0];
if (usr === undefined)
return message.reply("please input a newgrounds username!");
// Buuilds the embed
let embed = new Discord.RichEmbed()
.setURL(`https://${usr}.newgrounds.com`)
.setTitle(`${usr}'s stats on Newgrounds`, )
.setTimestamp()
.setColor(0xfda238)
.setThumbnail("https://i.ytimg.com/vi/ZRFIqusuqN8/maxresdefault.jpg");
// Dont want this stinky footer image
// .setImage("https://desu-usergeneratedcontent.xyz/g/image/1499/80/1499801793392.png");