-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
1411 lines (1174 loc) · 45.7 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');
const Keyv = require('keyv');
// 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');
//command set up
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
//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, mongoURI} = require('./config.json');
let {prefix, token, clientID, luckyGuilds, luckyChannels, ownerID, NGappID, NGencKey, spreadsheetID, GOOGLE_API_KEY, MMappID, mongoURI} = require('./config.example.json');
// THIS IS FOR HEROKU SHIT
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.mongoURI) mongoURI = process.env.mongoURI;
exports.prefix = prefix;
exports.MMappID = MMappID;
// Music bot shit
const YouTube = require(`simple-youtube-api`);
const youtube = new YouTube(GOOGLE_API_KEY);
// TODO add process.env shit for heroku
const keyv = new Keyv(mongoURI);
keyv.on('error', err => console.error('Keyv connection error:', err));
const queue = new Map();
// gets filled later
// see prepPics() like 5 lines lower to see the bullshit im trying to do lmao
const fulpPics = [];
let shoomOCound = 1;
function prepPics()
{
getImages('fulp');
console.log('Fulp shit');
getImages('dogl');
console.log('dogl shit');
getImages('delete');
console.log('delete shit');
}
// ID's for server, and announcement channel in NG server
// used for caching shit and role reactions
const ngServerID = '578313756015329281';
const ngChannelID = '578314067752779796';
// when the client is ready, run this code
// this event will trigger whenever your bot:
// - finishes logging in
// - reconnects after disconnecting
client.on('ready', async () =>
{
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.cache.size} servers!`);
console.info(client.guilds.cache.map(g => g.name + " " + g.memberCount).join("\n"));
// Specific code for newgrounds server, that finds the announcements channel, and caches the messages
// Swap this with something for general purpose reacts later
let ngServer = client.guilds.cache.find(ngGuild => ngGuild.id === ngServerID);
let announcements = ngServer.channels.cache.find(announc => announc.id === ngChannelID);
announcements.messages.fetchPinned();
console.info("LUCKY GUILDS" + luckyGuilds);
var memberShit = await keyv.get('fulptron');
if (memberShit != undefined)
{
memberShit = JSON.parse(memberShit);
memberShit.usersAPI.every(function(apiUser)
{
var inputData = {
"app_id": NGappID,
"debug": true,
"call": {
"component": "Gateway.ping",
"parameters": {},
}
};
request.post(
'https://www.newgrounds.io/gateway_v3.php',
{ form: {input: JSON.stringify(inputData)} },
async function (error, response, body)
{
let parsedResp = JSON.parse(response.body);
console.log(apiUser + ": " + parsedResp.result.data.success);
});
});
}
});
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.cache.find(darole => darole.name === "Flash Hole");
member.roles.add(curRole);
}
if (member.guild.id == 791394250557358111) {
let curRole = member.guild.roles.cache.find(darole => darole.name === "funkhead");
member.roles.add(curRole);
}
//G
let guildIndex = luckyGuilds.indexOf(member.guild.id);
console.log(guildIndex);
if (guildIndex != -1)
{
//REFRESHES CACHE FOR ROLE REACTIONS FOR NEW PEOPLE?
let ngServer = client.guilds.cache.find(ngGuild => ngGuild.id === ngServerID);
let announcements = ngServer.channels.cache.find(announc => announc.id === ngChannelID);
announcements.messages.fetchPinned();
console.log("SOMEONE JOINED NG SERVER??");
let infoPart = '*\nYou can use the command `fulpNG` to sign into the Newgrounds API, roles can be added in the <#578314067752779796> 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.cache.find(channel => channel.id === '578313756015329283').send("*" + intro + infoPart);
}
});
var emojiname = ["🎮", "🖥️", "🎵", "🎙️", "🎞️", "🎨", "✍️", "💩"],
rolename = ["Game Developer", "Programmer", "Musician", "Voice Actor", "Animator", "Illustrator", "Writer", "Shitposter"];
client.on("messageReactionAdd", (e, user) => {
if (user && !user.bot && e.message.channel.guild)
for (let o in emojiname)
if (e.emoji.name == emojiname[o]) {
let i = e.message.guild.roles.cache.find(e => e.name == rolename[o]);
e.message.guild.member(user).roles.add(i).catch(console.error);
// console.log('added role');
}
});
client.on("messageReactionRemove", (e, n) => {
if (n && !n.bot && e.message.channel.guild)
for (let o in emojiname)
if (e.emoji.name == emojiname[o]) {
let i = e.message.guild.roles.cache.find(e => e.name == rolename[o]);
e.message.guild.member(n).roles.remove(i).catch(console.error)
// console.log('removed role');
}
});
client.on('message', async message =>
{
// Don't respond to messages made by the bot itself
if (message.author.id == client.user.id) 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)
{
if (!message.content.startsWith('[noreact]') && luckyChannels[guildIndex].includes(message.channel.id))
{
let regShit = new RegExp('((\.png|\.jpg|\.jpeg)|newgrounds\.com\/(art|audio|portal)\/(view|listen))', 'gi');
if (message.attachments.size > 0 || regShit.test(message.content))
{
let picoSuffix = "";
if (Math.random() > 0.5)
picoSuffix = "pico"
message.react(message.guild.emojis.cache.find(emoji => emoji.name === "0stars" + picoSuffix))
.then(react => message.react(message.guild.emojis.cache.find(emoji => emoji.name === "1star" + picoSuffix)))
.then(react => message.react(message.guild.emojis.cache.find(emoji => emoji.name === "2stars" + picoSuffix)))
.then(react => message.react(message.guild.emojis.cache.find(emoji => emoji.name === "3stars" + picoSuffix)))
.then(react => message.react(message.guild.emojis.cache.find(emoji => emoji.name === "4stars" + picoSuffix)))
.then(react => message.react(message.guild.emojis.cache.find(emoji => emoji.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");
}
var daServerMetadata = await keyv.get(message.guild.id);
if (daServerMetadata != undefined)
{
daServerMetadata = JSON.parse(daServerMetadata);
if (!daServerMetadata.bannedWords.every(function(bannedWord)
{
return !message.content.toLowerCase().includes(bannedWord.toLowerCase())
}))
{
console.log('Deleted message in ' + message.guild.name + " by " + message.author.username + ": " + message.content);
return message.delete();
}
}
// if (message.content.includes())
//Automate Welcome Channel WIP
/*if(message.content.toLowerCase() === "test" || message.channel.id() === "read-the-rules-for-access"){
//message.roles.add("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-${}-${}"){
}
}*/
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
if (!message.content.toLowerCase().startsWith(prefix)) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
console.log(args);
console.log(args.length);
// uncomment when all the commands are implemented
// if (!client.commands.has(command))
try {
const daCommand = client.commands.get(command)
|| client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(command));
if (daCommand != undefined)
{
// Commands that need arguments
if (daCommand.args && !args.length)
{
let reply = "You didn't provide any arguments!"
if (daCommand.usage)
{
reply += `\nThe proper usage would be: \`${prefix}${daCommand.name} ${daCommand.usage}\``
}
return message.channel.send(reply);
}
// If needs to be discord user
if (daCommand.discord && !isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
// Commands that need to be in a server
if (daCommand.guildOnly && message.channel.type !== 'text') {
return message.reply('I can\'t execute that command inside DMs!');
}
daCommand.execute(message, args)
}
} catch (err)
{
console.error(err);
message.reply(' there was an error trying to execute that command!');
}
// 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
const serverQueue = isInGuild ? queue.get(message.guild.id) : null;
console.log(serverQueue);
if (command == 'rolesetup')
{
if (!message.member.hasPermission('MANAGE_MESSAGES'))
return;
let rolesEmbed = new Discord.MessageEmbed()
.setTitle('NEWGROUNDS SERVER ROLE MANAGER')
.setDescription('REACT WITH EMOTE TO GET ROLE U WANT')
.setColor(0xfda238);
var daString = "";
var i;
for (i = 0; i < emojiname.length; i++)
{
daString += `${rolename[i]} - ${emojiname[i]}\n`;
}
rolesEmbed.addField('ROLES', daString);
let daMessage = await message.channel.send(rolesEmbed);
message.delete();
//"🎮", "🖥️", "🎵", "🎙️", "🎞️", "🎨", "✍️", "💩"
daMessage.react("🎮")
.then(react => daMessage.react("🖥️"))
.then(react => daMessage.react("🎵"))
.then(react => daMessage.react("🎙️"))
.then(react => daMessage.react("🎞️"))
.then(react => daMessage.react("🎨"))
.then(react => daMessage.react("✍️"))
.then(react => daMessage.react("💩"));
}
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 { channel } = message.member.voice;
if (!channel) {
return message.reply('please join a voice channel first!');
}
const permissions = channel.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.voice.channel.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, channel, 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
{
console.log("selection: " + message.content);
var filter = m => m.content.startsWith('!vote');
var response = await message.channel.awaitMessages(filter, {
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, channel);
}
} else if (command === 'skip') {
if (!isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
if (!message.member.voice.channel) return message.channel.send('You are not in a voice channel!');
if (!message.member.voice.channel.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.');
console.log('skip has been used');
serverQueue.connection.dispatcher.end();
return undefined;
} else if (command === 'stop') {
if (!isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
if (!message.member.voice.channel) return message.channel.send('You are not in a voice channel!');
if (!message.member.voice.channel.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();
return undefined;
} else if (command === 'volume') {
if (!isDiscordUser)
{
return message.reply(nonDiscordUserMsg);
}
if (!message.member.voice.channel) return message.channel.send('You are not in a voice channel!');
if (!message.member.voice.channel.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.');
else
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.voice.channel.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.');
}
else if (command == 'discord')
{
message.channel.send("https://discord.gg/HzvnXfZ");
}
/*
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.roles.add(curRole);
//message.reply('just got the ${curRole.name} role!');
}
*/
else if (command == 'cringe' || command == 'snap')
{
message.channel.send('brandyCringe.png', {files: [{
attachment: "pics/brandy/brandyCringe.png",
name: 'brandyCringe.png'
}]});
}
else if ( command == 'delete' || command == 'delet' || command == 'gun')
{
let curPic = randomFromArray(2);
message.channel.send(curPic, {files: [{attatchment: "pics/delete/" + curPic, name: curPic}]});
}
if (command == `pic`)
{
if (args[0] == "luis")
{
return message.channel.send("luis.jpg", {files: [{attachment: "pics/luis/" + "luis.jpg", name: 'luis.jpg'}]});
}
let curPic = randomFromArray(0);
message.channel.send(curPic, {files: [{attachment: `pics/fulp/${curPic}`, name: 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 == '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.voice.channel.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.voice.channel, true);
}
});
}
else
{
handleNGSongs(songUrl, message, message.member.voice.channel);
}
}
// 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.MessageEmbed()
.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");
const options = {
uri: `https://${usr}.newgrounds.com`,
transform: function (body) {
return cheerio.load(body);
}
};
rp(options)
.then(($) => {
let ngInfo = $('.user-header').text();
let ngArray = ngInfo.split("\n");
let ngInfo2 = $('.stats-general').text();
let ngArray2 = ngInfo2.split("\n");
infoClean(ngArray);
infoClean(ngArray2);
function infoClean(curList)
{
// NOTE This needs alot of cleaning up. Currently the ngArray just slices out the first few bits, and the embed doesn't account
// for if the user doesn't have a certain submission type, so currrently the embed is commented out
let listOfShit = curList;
let secondArray = [];
// CLEANS THE ARRAY
for (var i=0; i < listOfShit.length; i++)
{
listOfShit[i] = listOfShit[i].trim();
listOfShit[i] = listOfShit[i].replace(/\t/g, "");
}
listOfShit = listOfShit.filter(function(value, index, arr)
{
return value != "";
});
listOfShit[listOfShit.length - 1] = listOfShit[listOfShit.length - 1].replace("Medals", " Medals");
listOfShit[listOfShit.length - 1] = listOfShit[listOfShit.length - 1].replace("Supporter", " Supporter");
let trophMedSupps = listOfShit[listOfShit.length - 1].split(" ");
listOfShit.pop();
trophMedSupps.forEach(function(shit)
{
/*
if (shit.toLowerCase().trim().startsWith("supporter"))
{
console.log("CLEANED SUPP SHIT LAOSADKOASD");
shit.concat(trophMedSupps[trophMedSupps.length - 2]);
shit.concat(trophMedSupps[trophMedSupps.length - 1]);
trophMedSupps.pop();
trophMedSupps.pop();
listOfShit.pop();
listOfShit.pop();
}
*/
listOfShit.push(shit)
});
for (var i=0; i < listOfShit.length; i++)
{
let dumb = listOfShit[i].trim();
dumb = dumb.replace(/:/g, ": ");
dumb = dumb.replace("Medals", " Medals");
dumb = dumb.replace("Supporter", " Supporter");
if (dumb.length > 0)
secondArray.push(dumb);
}
let splitShit = secondArray.join('\n');
embed.addField(`Submission stats`, `${splitShit}`, true);
}
message.channel.send({embed});
// message.channel.send($('.stats-general').text());
})
.catch((err) => {
console.log(err);
message.channel.send(`an error occured.. did you enter in an actual Newgrounds user??` );
});
}
else if (command == "nglogout")
{
if (!isInGuild) return;
await keyv.delete(message.author.id);
return message.reply("all your base are belong back to you.");
}
else if (command == 'curblacklist')
{
if (!isInGuild || !message.member.hasPermission('MANAGE_MESSAGES')) return;
var serverInfo = await keyv.get(message.guild.id);
if (serverInfo == undefined)
{
serverInfo = initServerShit();
}
else
serverInfo = JSON.parse(serverInfo);
return message.channel.send(serverInfo.bannedWords);
}
else if (command == 'blacklist')
{
if (!isInGuild) return;
if (!message.member.hasPermission('MANAGE_MESSAGES'))
{
return message.channel.send('You do not have permissions to add words to the blacklist!');
}
if (args.length < 1)
return message.channel.send("Please input a word to blacklist!");
var serverInfo = await keyv.get(message.guild.id);
if (serverInfo == undefined)
{
serverInfo = initServerShit();
}
else
serverInfo = JSON.parse(serverInfo);
let text = args.slice(0).join(" ");
serverInfo.bannedWords.push(text);
await keyv.set(message.guild.id, JSON.stringify(serverInfo));
return message.delete();
// console.log(serverInfo);
}
else if (command == "nglogin" || command == 'ng' || command == 'login')
{
if (!isInGuild) return;
var isLoggedIn = await keyv.get(message.author.id);
if (isLoggedIn)
{
// console.log(message.author.username + ' EXISTS IN DATABASE');
isLoggedIn = JSON.parse(isLoggedIn);
// console.log(isLoggedIn);
var inputData = {
"app_id": NGappID,
"debug": true,
"session_id": isLoggedIn.session.id,
"call": {
"component": "App.checkSession",
"parameters": {},
}
};
// console.log('DA INPUT');
// console.log(inputData);
request.post(
'https://www.newgrounds.io/gateway_v3.php',
{ form: {input: JSON.stringify(inputData)} },
async function (error, response, body)
{
let parsedResp = JSON.parse(response.body);
console.log(JSON.parse(response.body));
var memberInfo = await keyv.get(message.author.id);
memberInfo = JSON.parse(memberInfo);