-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbot.js
7269 lines (6949 loc) · 365 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
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
/**
* Murder Mystery Bot
* V1.4.0b
* By FireMario211
*/
// debugging stuff
/**
* 123717 = === true)
* 321827 = === false)
*
* Mode Ids:
* 1 - Regular
* 2 - Murder Party
* 3 - 1v1
* 4 - Humans VS Bots
* 5 - Unlimited Mode
* 6 - N/A (wat how did i skip that)
* 7 - Bot 1v1
* 8 - Short roles
* 9 - Time Mode
* 10 - Insane Mode
* 11 - Sandbox Mode
* 12 - Zombie Mode
*
* Role Ids:
* 1 - Murderer
* 2 - Detective
* 3 - Healer
* 4 - Radio Person
* 5 - Assassin
* 6 - Jailor
* 7 - Zombie
*/
const {
Client,
RichEmbed,
Collection
} = require('discord.js') // Discord.JS Module
const blapi = require("blapi");
blapi.setLogging(true);
var globalGamesDir = "./cogs/GlobalGames.js"
const bot = new Client({
disableEveryone: true,
disabledEvents: ["RELATIONSHIP_ADD", "RELATIONSHIP_REMOVE", "VOICE_SERVER_UPDATE", "VOICE_STATE_UPDATE", "TYPING_START", "GUILD_UPDATE", "CHANNEL_DELETE", "CHANNEL_UPDATE", "CHANNEl_CREATE", "MESSAGE_DELETE_BULK"] // Reduce RAM with this.
}) // Discord Client Constructor (Class)
const snekfetch = require('snekfetch')
const translate = require('../translations.json')
const fs = require('fs')
// GITHUB UPDATE CHECKER
var checkUpdate = require('check-update-github');
var pkg = require('./package.json');
const cooldowns = new Collection();
updatedata()
let langarray;
let blacklituser;
let blacklitguild;
var appealsa;
checkUpdate({
name: pkg.name,
currentVersion: pkg.version,
user: 'FireMario211',
branch: 'master'
}, function (err, latestVersion, defaultMessage) {
if (!err) {
console.log(defaultMessage);
}
});
// GITHUB UPDATE CHECKER
//const random = require('random-number-generator')
var gameid = 0
//var gamesession = []
var enablechat = 0
var debugmode = 1
let rolerandomizer = {
1: [1, 2, 3, 4, 5, 6],
2: [-1, -2],
3: [1, 2],
4: [-1, -2],
5: [1, 2, 3, 4, 5, 6],
6: [-1, -2],
7: [1, 2],
8: [1, 2, 3, 4],
11: [1, 2, 3, 4, 5, 6],
12: [1, 2, 3, 5, 6, 7]
}
/*
gamemodes array object thing
gamemodeName > Name of the gamemode, for when users type the categorya
modeId > Mode ID
modeStatus > Status of the Gamemode (If it's available, or only available for certain people, or not available at all)
minPlayers > Minimum players needed to start the game
maxPlayers > Maximum of how many players can join
allowedShop > If users can use shop commands
allowedInnocent > If Innocents can be considered a role
allowedRoles > An array containing of what roles are in the gamemode (Will be randomized and the roles will depend on what channels will be created)
createChannels > An array containing of what channels can be created (IDs: 0 > #murdergame | 5 > #shop | 1 > #murderer | 2 > #detective | 3 > #healer | 4 > #radio | 6 > #jailor and #jail | 7 > #zombie)
start obj >
modeName > No description provided
roleName > No description provided
extra obj >
allow > If the gamemode has extra options (Default: false)
botsAllowed > Will enable it so that bots will be in the game (Default: false)
executeRoleCommands > What time users can enter in role commands (Default: "night" or just false)
timeCycle > If the gamemode disallows a day/night cycle (Default: false)
noAction > If (when users enter role commands) it should say that they cannot enter in the command again. (Default: false)
*/
let gamemodes = [{
gamemodeName: "regular",
modeId: 1,
modeStatus: 0,
minPlayers: 6,
maxPlayers: 8,
allowedShop: true,
allowedInnocent: true,
allowedRoles: [1, 2, 3, 4, 5, 6],
createChannels: [0, 5, 1, 2, 3, 4, 6],
start: {
modeName: "Regular",
roleName: "Classic Mode",
desc: "Classic Murder Mystery!",
credit: {
userTag: "Noahs Gaming and More#9436",
userId: "281397352177074177"
}
}
}, {
gamemodeName: "murderparty",
modeId: 2,
modeStatus: 0,
minPlayers: 2,
maxPlayers: 8,
allowedShop: false,
allowedInnocent: false,
allowedRoles: [1],
createChannels: [0, 1],
start: {
modeName: "Murder Party",
roleName: "Murder Party",
desc: "Everyone is a murderer!",
credit: {
userTag: "betterface ツ#1983",
userId: "204270560501432320"
}
},
}, {
gamemodeName: "1v1",
modeId: 3,
modeStatus: 0,
minPlayers: 2,
maxPlayers: 2,
allowedShop: true,
allowedInnocent: false,
allowedRoles: [1, 2],
createChannels: [0, 5, 1, 2],
start: {
modeName: "1v1 Mode",
roleName: "1v1 Mode",
desc: "1 Detective and 1 Murderer, ONLY 2 People play on this mode.",
credit: {
userTag: "FireMario211#2948",
userId: "126119057232625664"
}
}
}, {
gamemodeName: "humansvsbots",
modeId: 4,
modeStatus: 2,
minPlayers: 1,
maxPlayers: 8,
allowedShop: true,
allowedInnocent: true,
allowedRoles: [1, 2, 3, 4, 5, 6],
createChannels: [0, 5, 1, 2, 3, 4, 6],
start: {
modeName: "Humans VS Bots",
roleName: "Humans VS Bots",
desc: "Murder Mystery except with extra bots!",
credit: {
userTag: "Noahs Gaming and More#9436",
userId: "281397352177074177"
}
},
extra: {
allow: true,
botsAllowed: true,
botBehavior: {
}
}
}, {
gamemodeName: "unlimitedmode",
modeId: 5,
modeStatus: 0,
minPlayers: 6,
maxPlayers: -1,
allowedShop: true,
allowedInnocent: true,
allowedRoles: [1, 2, 3, 4, 5, 6],
createChannels: [0, 5, 1, 2, 3, 4, 6],
start: {
modeName: "Regular (Unlimited Players Mode)",
roleName: "Unlimited Players Mode",
desc: "Have more than 8 people? this is the mode for you! You can have an \"unlimited\" amount of players!",
credit: {
userTag: "FireMario211#2948",
userId: "126119057232625664"
}
}
}, {
gamemodeName: "killermode",
modeId: 6,
modeStatus: 3,
minPlayers: 3,
maxPlayers: 6,
allowedShop: true,
allowedInnocent: true,
allowedRoles: [1, 2],
createChannels: [0, 5, 1, 2, 3, 4, 6],
start: {
modeName: "Killer Mode",
roleName: "Killer Mode",
desc: "There is one Detective and Everyone is a murderer",
credit: {
userTag: "Noahs Gaming and More#9436",
userId: "281397352177074177"
}
}
}, {
gamemodeName: "bot1v1",
modeId: 7,
modeStatus: 0,
minPlayers: 2,
maxPlayers: 2,
allowedShop: true,
allowedInnocent: false,
allowedRoles: [1, 2, 3],
createChannels: [0, 5, 1, 2, 3],
start: {
modeName: "Bot 1v1 Mode",
roleName: "Bot 1v1 Mode",
desc: "A mode that requires 2 players but in reality there are 3 since the bot joins, the bot is either a Murderer, Detective, or Healer.",
credit: {
userTag: "FireMario211#2948",
userId: "126119057232625664"
}
},
extra: {
allow: true,
botsAllowed: true,
botBehavior: {
bots: 1,
chatBehavior: {}
}
}
}, {
gamemodeName: "shortroles",
modeId: 8,
modeStatus: 0,
minPlayers: 4,
maxPlayers: 8,
allowedShop: true,
allowedInnocent: true,
allowedRoles: [1, 2, 3, 4],
createChannels: [0, 5, 1, 2, 3, 4],
start: {
modeName: "Short Roles",
roleName: "Short Roles Mode",
desc: "Want to play Murder Mystery with just 4 roles and 4 people? This is the mode!",
credit: {
userTag: "FireMario211#2948",
userId: "126119057232625664"
}
}
}, {
gamemodeName: "timemode",
modeId: 9,
modeStatus: 0,
minPlayers: 6,
maxPlayers: 8,
allowedShop: true,
allowedInnocent: true,
allowedRoles: [1, 2, 3, 4, 5, 6],
createChannels: [0, 5, 1, 2, 3, 4, 6],
start: {
modeName: "Time Mode",
roleName: "Time Mode",
desc: "In the day time, the Murderer can attack, but in the night they cant.",
credit: {
userTag: "betterface ツ#1983",
userId: "204270560501432320"
}
},
extra: {
allow: true,
executeRoleCommands: "day"
}
}, {
gamemodeName: "insane",
modeId: 10,
modeStatus: 0,
minPlayers: 6,
maxPlayers: 8,
allowedShop: true,
allowedInnocent: true,
allowedRoles: [1, 2, 3, 4, 5, 6],
createChannels: [0, 5, 1, 2, 3, 4, 6],
start: {
modeName: "Insane Mode",
roleName: "Insane Mode",
desc: "Always day, murder can kill anytime and sheriff",
credit: {
userTag: "giorno requiem#6428",
userId: "253659143523532801"
}
},
extra: {
allow: true,
timeCycle: true,
executeRoleCommands: "day",
noAction: true
}
}, {
gamemodeName: "sandbox",
modeId: 11,
modeStatus: 0,
minPlayers: 2,
maxPlayers: 2,
allowedShop: true,
allowedInnocent: true,
allowedRoles: [1, 2, 3, 4, 5, 6],
createChannels: [0, 5, 1, 2, 3, 4, 6],
createChannels: [0, 5, 1, 2, 3, 4, 6],
start: {
modeName: "Sandbox Mode",
roleName: "Sandbox Mode",
desc: "You have access to everything.",
credit: {
userTag: "betterface ツ#1983",
userId: "204270560501432320"
}
}
}, {
gamemodeName: "zombie",
modeId: 12,
modeStatus: 0,
minPlayers: 6,
maxPlayers: 8,
allowedShop: true,
allowedInnocent: true,
allowedRoles: [1, 2, 3, 4, 5, 7],
createChannels: [0, 5, 1, 2, 3, 4, 7],
start: {
modeName: "Zombie Mode",
roleName: "Zombie Mode",
desc: "A mode but with zombies that invade the world by infecting others!",
credit: {
userTag: "FireMario211#2948",
userId: "126119057232625664"
}
}
}, {
gamemodeName: "chaosity",
modeId: 13,
modeStatus: 0,
minPlayers: 5,
maxPlayers: 10,
allowedShop: true,
allowedInnocent: true,
allowedRoles: [1, 1, 1, 2, 2],
createChannels: [0, 5, 1, 2],
start: {
modeName: "Chaos'ity Mode",
roleName: "Chaos'ity Mode",
desc: "A mode with 3 murderers, and 2 detectives. The rest however are innocents.",
credit: {
userTag: "miro#9638",
userId: "260024428723830784"
}
}
}]
/*
switch (categorya) {
case "regular":
modeName = "Regular"
roleName = "Classic Mode"
modeId = 1
break;
case "murderparty":
modeName = "Murder Party"
roleName = modeName
modeId = 2
break;
case "1v1":
modeName = "1v1 Mode"
roleName = modeName
modeId = 3
break;
case "humansvsbots":
modeName = "Humans VS Bots"
roleName = modeName
modeId = 4
break;
case "unlimitedmode":
modeName = "Regular (Unlimited Players Mode)"
roleName = "Unlimited Players Mode"
modeId = 5
break;
case "killermode":
modeStatus = 1
return;
modeName = "Killer Mode"
roleName = modeName
modeId = 6
break;
case "bot1v1":
modeName = "Bot 1v1 Mode"
roleName = modeName
modeId = 7
break;
case "shortroles":
modeName = "Short Roles"
roleName = "Short Roles Mode"
modeId = 8
break;
case "timemode":
modeName = "Time Mode"
roleName = modeName
modeId = 9
break;
case "insane":
modeName = "Insane Mode"
roleName = modeName
modeId = 10
break;
case "sandbox":
modeName = "Sandbox Mode"
roleName = modeName
modeId = 11
break;
case "zombie":
modeName = "Zombie Mode"
roleName = modeName
modeId = 12
break;
default:
modeStatus = 3
}
*/
/*
"detective": "Detective",
"healer": "Healer",
"radioperson": "Radio Person",
"assassin": "Assassin",
"jailor": "Jailor",
"innocent": "Innocent"
*/
function random(number) {
return Math.floor(Math.random() * number)
}
function objectMap(object, mapFn) {
// credit https://stackoverflow.com/a/14810722
return Object.keys(object).reduce(function (result, key) {
result[key] = mapFn(object[key])
return result
}, {})
}
function turnToArray(object) {
var result = [];
for (var key in object) {
result.push({
obj: key,
value: object[key]
});
}
return result
}
function getRoleId(roleId, lang) {
switch (roleId) {
default:
return translate[lang].roles.innocent;
break;
case 1:
return translate[lang].roles.murderer;
break;
case 2:
return translate[lang].roles.detective;
break;
case 3:
return translate[lang].roles.healer;
break;
case 4:
return translate[lang].roles.radioperson;
break;
case 5:
return translate[lang].roles.assassin;
break;
case 6:
return translate[lang].roles.jailor;
break;
case 7:
return translate[lang].roles.zombie
break;
}
}
bot.gameid = 0
const sql = require('sqlite')
const config = require('./config.json')
let gamesss = config.playing
//gamesss = gamesss.replace("%guild.size%", bot.guilds.size)
if (config.sharding === 1) {
bot.shard.broadcastEval('this.guilds.size').then(results => {
let guildcount = 0
results.map(x => {
guildcount = guildcount + x
})
//let guildcount = results.reduce((prev, val) => prev + val, 0)
gamesss = gamesss.replace("%shard.id%", bot.shard.id)
gamesss = gamesss.replace("%shard.count%", bot.shard.count)
gamesss = gamesss.replace("%prefix%", config.prefix)
gamesss = gamesss.replace("%guild.size%", guildcount)
setTimeout(function () {
gamesss = gamesss.replace("0", guildcount)
}, 1000)
})
}
sql.open('./murdermystery.sqlite')
var version = "1.3.0b"
var botnames = ["Jake", "Jeff", "OhMan", "Noah", "William", "John", "Bob", "Ryan", "Logan", "Aiden", "Ross", "Mark", "Steve", "Landon", "Daniel", "Dan", "Charley", "James", "Charles", "Mario", "Derek", "Luigi", "Michael", "Yukko", "Luca", "Lucas", "Alfred", "Alex", "Mike", "Henry", "Jacob", "Emily", "Mio-chan", "Yumi", "Joshua", "Matthew", "Christopher", "Andrew", "Ethan", "Joseph", "Anthony", "David", "Alexander", "Madison", "Emma", "Olivia", "Hannah", "Abigail", "Isabella", "Samantha", "Elizabeth", "Ashley", "Alexis", "Sarah", "Sophia", "Amy", "Sora", "Alan", "Parker", "August", "Jason", "Aaron", "Jayden", "Kyle", "Alex", "Carlos", "Steven", "Cody", "Seth", "Blade", "Blake", "Wessel", "Nadeko", "An Unknown Person", "Mikan", "NobleShyGuy", "Etzer", "HtD", "FireMario211", "Krazyman50", "KyleMC1912", "JJking_1", "Sov", "Phase", "FaZe", "Anonymous", "FaZe_Banks", "oklookitsAugust", "Phineas", "AugustBoat", "KEEL"]
var botquotes = ["Hi guys", "Uh..", "LMAO", "Oh no...", "Rip", "Lol", "LOL", "Hmmm <:Thinkhung:320597771310727169>", "Its him!", "Its her!", "Im scared...", "Whos gonna die...?", "Im the Healer!", "Im the Detective!", "Im the Broadcaster!", "Ur ded", "first, oh wait... am i?", "when is time to scream?", "EVERYONE VOTEHANG HIM/HER!!!", "hey guys!", "how yer doin?", "Im the murderer! pls dont kill me ;(", "hi ;)", "hi....", "hello...?", "lol", "rip you all", "where is andrew?", "where did i come from?", "im definetly not gonna die", "Your gonna die tonight :)", "Maybe I will die? xD", "Is it September or August?"]
var rarequotes = ["Hehehehehehhehehhehehe", "You know i have one spooky part in THIS movie ;)", "you cant find me", "wessel was here... >:)", "i bet fire is in this game he made us xdxdxdxdx", "i i KILL HUMANZ", "~~im on meth~~", "You better watch out ;)", "i know your secrets... ;) ;D", "OhMan on meth", "Noble hacked this bot ;) (not rly)", "I will find you and kill you ;)", "IM GOING TO KEEL YOU (define KEEL in DMS and you will be in the bot names. DM me FireMario211#2948) I'll tell you if you are right or wrong. You can only DM me once for that then thats it, so be wise... *use alts*)"]
function updatedata() {
langarr()
blacklistedguilddata()
blacklisteduserdata()
appealthing()
}
function appealthing() {
appealsa = JSON.parse(fs.readFileSync("./appeals.json", "utf8"));
}
function langarr() {
let arr;
snekfetch.get(`https://raw.githubusercontent.com/FireMario211/Murder-Mystery-Bot/master/locales/langarray.json`).then(r => {
fs.writeFileSync("./langarray.json", JSON.stringify(JSON.parse(r.text)));
langarray = JSON.parse(fs.readFileSync("./langarray.json", "utf8"));
})
}
String.prototype.replaceAll = function (search, replacement) {
var target = this;
return target.split(search).join(replacement);
};
function blacklistedguilddata() {
snekfetch.get(`https://raw.githubusercontent.com/FireMario211/mmbblacklist/master/blacklistedguilds.json`)
.then(r => {
//let assssaaaa = new Buffer.from(JSON.stringify(r.body).data);
//let bufferOriginal = JSON.parse(assssaaaa.toString('utf8'))
blacklitguild = JSON.parse(fs.readFileSync("./blacklistguilds.json", "utf8"));
fs.writeFileSync("./blacklistguilds.json", JSON.stringify(JSON.parse(r.text)));
}).catch(e => {
throw new Error(e)
});
}
function blacklisteduserdata() {
snekfetch.get(`https://raw.githubusercontent.com/FireMario211/mmbblacklist/master/blacklistedusers.json`)
.then(r => {
//let assssaaaa = new Buffer.from(JSON.stringify(r.body).data);
//let bufferOriginal = JSON.parse(assssaaaa.toString('utf8'))
fs.writeFileSync("./blacklistusers.json", JSON.stringify(JSON.parse(r.text)));
blacklituser = JSON.parse(fs.readFileSync("./blacklistusers.json", "utf8"));
}).catch(e => {
throw new Error(e)
});
}
//var arr = [];
//var targetassassin = []
//let mmgame = JSON.parse(fs.readFileSync('./mmgame.json', 'utf8'));
//let mmplayers = JSON.parse(fs.readFileSync('./mmplayers.json', 'utf8'))
//let preventjoin = JSON.parse(fs.readFileSync('./preventjoin.json', 'utf8'))
//let verifyt = JSON.parse(fs.readFileSync('./verificationids.json', 'utf8'));
let aaa = JSON.parse(fs.readFileSync('./aaa.json', 'utf8'));
//var isAdmin = user_id => bot.guilds.get(config.guildid).roles.get(config.adminroleid).members.map(member => member.id).indexOf(user_id) > -1;
if (config.sharding === 1) {
if (bot.shard.id === 0) {
var isAdmin = user_id => bot.guilds.get(config.guildid).roles.get(config.adminroleid).members.map(member => member.id).indexOf(user_id) > -1;
var isBugTrackers = user_id => bot.guilds.get(config.guildid).roles.get(config.bugroleid).members.map(member => member.id).indexOf(user_id) > -1;
}
}
/*
if (config.sharding === 1) {
bot.shard.broadcastEval("this.guilds").then(result => {
let guildobj = result
for (let i = 0; i < shards.length; i++) {
if (shards[i].get(config.guildid)) {
guildobj = shards[i].get(config.guildid);
break;
}
}
isAdmin = user_id => guildobj.roles.get(config.adminroleid).members.map(member => member.id).indexOf(user_id) > -1;
isBugTrackers = user_id => guildobj.roles.get(config.guildid).roles.get(config.bugroleid).members.map(member => member.id).indexOf(user_id) > -1;
})
}
*/
var blacklisteduser = user_id => blacklituser.indexOf(user_id) > -1;
var blacklistedguild = user_id => blacklitguild.indexOf(user_id) > -1;
/*
let verifyid = Math.random().toString(36).substr(2, 5)
if (!verifyt[verifyid]) verifyt[verifyid] = {
userid: "",
verifycode: ""
};
let verifyData = verifyt[verifyid]
*/
bot.login(config.tokens.bot)
function postapi() {
console.log(`[SHARD ${bot.shard.id}] POST API FUNCTION`)
if (config.enabledblpost === 1) {
if (config.sharding === 1) {
function dblpost() {
snekfetch.post(`https://discordbots.org/api/bots/${bot.user.id}/stats`)
.set('Authorization', config.tokens.dbl)
.send({
server_count: bot.guilds.size,
shard_count: bot.shard.count,
shard_id: bot.shard.id
})
.then(console.log('Updated dboats.org status.'))
.catch(e => console.warn('dboats.org is daown spammmmm @olay'))
}
function dbbpost() {
const {
post
} = require("superagent");
const postBody = {
shards: bot.shard.id,
guilds: bot.guilds.size
};
post(`https://discordsbestbots.xyz/api/bots/${client.user.id}`)
.send(postBody)
.set("Authorization", "Your token")
.then(r => console.log(r.body))
.catch(console.error)
}
} else {
snekfetch.post(`https://discordbots.org/api/bots/${bot.user.id}/stats`)
.set('Authorization', config.tokens.dbl)
.send({
server_count: bot.guilds.size
})
.then(console.log('Updated dboats.org status.'))
.catch(e => console.warn('dboats.org is daown spammmmm @olay'))
}
}
}
if (config.enabledblpost === 1) {
blapi.handle(bot, config.tokens.apiKeys, 5);
}
/*
setInterval(() => {
if (config.enabledblpost === 0) return;
postapi()
}, 100000)
*/
function defgame() {
/*
%guild.size% = bot.guilds.size
%shard.id% = bot.shard.id
%prefix% = config.prefix
%shard.count% = bot.shard.count
*/
bot.user.setPresence({
game: {
//name: `${config.playing}${bot.guilds.size} servers\n - Shard ID [${bot.shard.id}]\n - Shard Count [${bot.shard.count}]`,
name: gamesss,
type: 0
}
});
/*
bot.user.setPresence({
game: {
name: `Murder Mystery Bot Alpha!`,
type: 0
}
});
*/
}
// The END
let ownerids = ["126119057232625664", "280158289667555328", "281397352177074177"]
bot.on('error', (e) => console.error(e));
bot.on("warn", (e) => console.warn(e));
//bot.on('debug', (e) => console.info(e));
bot.on('ready', () => {
console.log('Logged in as ' + bot.user.username + ' and I am on ' + bot.guilds.size + ' guilds! (' + bot.user.id + ')')
});
// defgame fix \/\/\/
bot.on('guildCreate', guild => {
defgame()
})
bot.on('guildDelete', guild => {
defgame()
})
// defgame fix ^^^
function insertGuild(guildId) {
sql.run(`INSERT INTO murderMystery (guildId, hostRoleID, rank, murderWins, innocentWins, murderchannelid, healchannelid, sheriffchannelid, murdergamechannelid, radiochannelid, host, gameStarted, spectatorchannelid, isDay, isNight, isStopcycle, murdermysteryRoleID, jailorchannelid, jailchannelid, shopchannelid, zombiechannelid, players, modeId, startcmd, gameid, lang, playerInsert, defaultChannel, randomizer, day, daytimelen, nighttimelen, categoryChannelId, gameData, prefix) VALUES ("${guildId}", "0", "0", 0, 0, "0", "0", "0", "0", "0", "0", 0, "0", "0", "0", "0", 0, 0, 0, 0, 0, 0, 0, 0, 0, "English", 0, "0", "0", 0, 55, 60, '0', '', 'mm!')`);
}
bot.on("guildCreate", guild => {
bot.shard.broadcastEval(`let discord = require('discord.js')
this.channels.has('350984977371889664') && this.channels.get('350984977371889664').send({
embed: new discord.RichEmbed().setTitle(':inbox_tray: New Server added!').setAuthor('Server Name: ${guild.name} (${guild.id})'${(guild.iconURL == null) ? ")" : `, '${guild.iconURL}').setThumbnail('${guild.iconURL}')`}.addField('Server Owner ID:', '${guild.ownerID}', true).addField('Member Count:', '${guild.memberCount}', true).setColor(0xFFDF00).setDescription('I am now in ${bot.guilds.size} Servers!').setTimestamp()
});`)
.catch(err => console.log(`GUILDHANDLER.DELETE ERR: ${err.stack}`))
insertGuild(guild.id)
console.log(`SHARD [${bot.shard.id}] ` + 'Server Name: ' + guild.name + ' (' + guild.id + ')' + ' New Server added! ' + 'I am now in ' + bot.guilds.size + ' Servers!')
defgame()
//bot.user.setGame(config.playing + bot.guilds.size + " servers")
});
bot.on('guildMemberAdd', (member) => {
const guild = member.guild;
return;
if (["264445053596991498", "110373943822540800"].includes(guild.id)) return;
if (bot.guilds.has('319583713262436354')) {
if (isAdmin === undefined) return;
if (!isAdmin(member.id) || !ownerids.includes(member.id)) return;
}
if (bot.guilds.has('319583713262436354')) {
sql.get(`SELECT * FROM murderMystery WHERE guildId ='${guild.id}'`).then(row => {
if (!row) {
if (ownerids.includes(member.id)) {
guild.defaultChannel.send({
embed: new RichEmbed().setDescription("👑 The Bot Owner `" + member.user + "` has joined your server! 👑")
})
return;
}
if (isAdmin(member.id)) {
guild.defaultChannel.send({
embed: new RichEmbed().setDescription(":gear: A Bot Administrator `" + member.user + "` has joined your server! :gear:")
})
return;
}
} else {
if (ownerids.includes(member.id)) {
guild.defaultChannel.send({
embed: new RichEmbed().setDescription(translate[row.lang].botownerjoin + member.user + translate[row.lang].botownerjointwo)
})
return;
}
if (isAdmin(member.id)) {
guild.defaultChannel.send({
embed: new RichEmbed().setDescription(translate[row.lang].botadminjoin + member.user + translate[row.lang].botadminjointwo)
})
return;
}
}
})
}
})
bot.on('guildDelete', guild => {
bot.shard.broadcastEval(`let discord = require('discord.js')
this.channels.has('350984977371889664') && this.channels.get('350984977371889664').send({
embed: new discord.RichEmbed().setTitle(':outbox_tray: Bot was removed from a server :(').setAuthor('Server Name: ${guild.name} (${guild.id})'${(guild.iconURL == null) ? ")" : `, '${guild.iconURL}').setThumbnail('${guild.iconURL}')`}.setColor(0xFFDF00).setDescription('I am now in ${bot.guilds.size} Servers!').setTimestamp()
})`)
.catch(err => console.log(`GUILDHANDLER.DELETE ERR: ${err.stack}`))
console.log(`SHARD [${bot.shard.id}] ` + 'Server Name: ' + guild.name + ' (' + guild.id + ')' + ' Bot was removed from a server :( ' + 'I am now in ' + bot.guilds.size + ' Servers!')
sql.run(`DELETE FROM murderMystery WHERE guildId ='${guild.id}'`)
defgame()
})
/*
bot.on("guildMemberAdd", (member) => {
const guild = member.guild;
if (guild.id !== '319583713262436354') return;
bot.channels.get('319590345052520448').send("<@" + member.user.id + "> Please check your DMS for a Verification code!")
verifyData.userid = member.user.id
verifyData.verifycode = verifyid
member.user.send('Please follow these steps\nIn <#319589323894816789>, you will have to type this command:\nmm!verify `' + verifyid + "`\nThen you will be verified!")
//member.guild.defaultChannel.sendEmbed(new RichEmbed().setTitle('Welcome to ' + guild.name + '!').setAuthor(member.user.username + '#' + member.user.discriminator, member.user.avatarURL).setThumbnail(guild.iconURL).setColor(0x00FF3C).setDescription('Hope you have a great time here!').setTimestamp());
fs.writeFile('./verificationids.json', JSON.stringify(verifyt), (err) => {
if (err) console.error(err)
});
});
*/
/*
bot.on("guildMemberRemove", (member) => {
const guild = member.guild;
member.guild.defaultChannel.sendEmbed(new RichEmbed().setTitle('Has left ' + guild.name + '!').setAuthor(member.user.username + '#' + member.user.discriminator, member.user.avatarURL).setThumbnail(guild.iconURL).setColor(0xFF0000).setDescription('Rest in pieces :(').setTimestamp());
});
*/
function shuffle(array) {
var currentIndex = array.length,
temporaryValue, randomIndex;
//While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
function randomizearrayroles() {
// Used like so
rolerandomizer[1] = shuffle(rolerandomizer[1]);
rolerandomizer[2] = shuffle(rolerandomizer[2]);
rolerandomizer[3] = shuffle(rolerandomizer[3]);
rolerandomizer[4] = shuffle(rolerandomizer[4]);
rolerandomizer[5] = shuffle(rolerandomizer[5]);
rolerandomizer[6] = shuffle(rolerandomizer[6]);
rolerandomizer[7] = shuffle(rolerandomizer[7]);
rolerandomizer[8] = shuffle(rolerandomizer[8]);
rolerandomizer[11] = shuffle(rolerandomizer[11]);
rolerandomizer[12] = shuffle(rolerandomizer[12]);
}
randomizearrayroles()
console.log(rolerandomizer)
//console.log(rolerandomizer[1])
bot.on('message', message => {
if (message.channel.type == 'dm') return;
sql.get(`SELECT * FROM murderMystery WHERE guildId ='${message.guild.id}'`).then(guildData => {
var isstopcycle = 0
var gameDataTemp = []
let gameData;
//murdergame,shop,murderer,detective,healer,radio,jailor,jail,zombie#zombieids
if (guildData) {
if (guildData.gameData.length < 1) {
gameData = ""
}
if (guildData.gameData.length > 0) {
gameData = guildData.gameData.split("#")
}
isstopcycle = guildData.isStopcycle
}
function createGameChannel(name, data) {
if (!guildData) throw new Error("I cannot find Guild Data!")
const findGamemode = gamemodes.find(function (gm) {
return gm.modeId == guildData.modeId
})
if (!findGamemode) return console.trace("ERROR AT createGameChannel")
return new Promise(resolve => {
switch (name) {
case "murderer":
sql.all(`SELECT * FROM murderMysteryPlayers WHERE roleId =1 AND guildId ='${message.guild.id}'`).then(row1 => {
if (row1.length < 1) {
message.reply("Error at create murder channel :thonk:")
} else {
message.guild.createChannel('murderer', 'text').then(async function (c) {
var await0 = await c.overwritePermissions(message.guild.id, {
READ_MESSAGES: false
})
if (data.isMurderParty !== 1) {
await row1.forEach(async function (userd) {
var await1 = await c.overwritePermissions(userd.userId, {
READ_MESSAGES: true
})
})
}
var await2 = await c.overwritePermissions(bot.user, {
READ_MESSAGES: true
})
if (data.isMurderParty == 1) {
var await3 = await c.overwritePermissions(guildData.murdermysteryRoleID, {
READ_MESSAGES: true
})
}
if (guildData.categoryChannelId !== "0") {
var await4 = await c.setParent(guildData.categoryChannelId)
}
gameDataTemp.push(c.id)
//var await5 = await sql.run(`UPDATE murderMystery SET murderchannelid = "${guildData.murderchannelid = c.id}" WHERE guildId = '${message.guild.id}'`)
if (data.isMurderParty === 1) {
var await6 = await c.send(translate[guildData.lang].jobchannelmsgs.murderer.channel.replace("%prefix%", guildData.prefix))
var await7 = await c.send("@everyone" + translate[guildData.lang].jobchannelmsgs.murderer.channel4)
} else {
sql.get(`SELECT * FROM murderMysteryPlayers WHERE roleId = 5 AND guildId ='${message.guild.id}'`).then(async (row6) => {
var await8 = await c.send(translate[guildData.lang].jobchannelmsgs.murderer.channel.replace("%prefix%", guildData.prefix))
let itemz = ""
//let itemz2 = translate[guildData.lang].shopitemdesc
let thingsss = translate[guildData.lang].darkshop
var await11 = await (function () {
for (let i = 0; i < translate[guildData.lang].darkshopitems.length; i++) {
itemz += `Name: ${translate[guildData.lang].darkshopitems[i].name}\nDescription: ${translate[guildData.lang].darkshopitems[i].description}\nPrice: ${translate[guildData.lang].darkshopitems[i].price}<:darkgold:385205541955174401>\nID: ${translate[guildData.lang].darkshopitems[i].id}\n\n`
}
thingsss = thingsss.replace("%item%", itemz)
})()
thingsss = thingsss.replaceAll("%prefix%", guildData.prefix)
var await10 = await c.send(thingsss)
var await12 = await (function () {
if (debugmode === 1) {
console.log("[DEBUG] Add Dark Shop Items")
}
})()
let strthing = `${(row6) ? `<@${row6.userId}>${translate[guildData.lang].jobchannelmsgs.murderer.channel2}` : ""}${row1.map(x=>`<@${x.userId}>`).join(", ")}${translate[guildData.lang].jobchannelmsgs.murderer.channel3}`
//var await9 = await c.send("<@" + row6.userId + ">" + translate[guildData.lang].jobchannelmsgs.murderer.channel2 + "<@" + row1.userId + ">" + translate[guildData.lang].jobchannelmsgs.murderer.channel3)
var await9 = await c.send(strthing)
if (!row6) {
if (findGamemode.allowedRoles.includes(5)) {
return message.channel.send("`ERROR` Assassin not found!")
}
}
})
}
if (1 == findGamemode.createChannels[findGamemode.createChannels.length - 1]) return resolve(gameDataTemp)
resolve(-1)
})
}
})
break;
case "detective":
if (debugmode === 1) {
console.log("[DEBUG] CHECK IF SHERIFF IN cREATEDETECTIVECHANNEl")
}
sql.all(`SELECT * FROM murderMysteryPlayers WHERE roleId = 2 AND guildId ='${message.guild.id}'`).then(row1 => {
if (row1.length < 1) {
message.channel.send("Error Code 496 at createdetectivechannel")
console.error("[Murder Mystery Error] Error Code 496 at createdetectivechannel")
} else {
message.guild.createChannel('detective', 'text').then(async function (c) {
var await0 = await c.overwritePermissions(message.guild.id, {
READ_MESSAGES: false
})
if (data.isHumansvsbots !== 2) {
await row1.forEach(async function (userd) {
var await1 = await c.overwritePermissions(userd.userId, {
READ_MESSAGES: true
})
})
}
var await2 = await c.overwritePermissions(bot.user, {
READ_MESSAGES: true
})
if (guildData.categoryChannelId !== "0") {
var await3 = await c.setParent(guildData.categoryChannelId)
}
//c.send("Hello there, You are a **Detective**, You will try to find out who the Murderer is! The best option is to not trust anyone, Be sure to try your best to find out who the Murderer is, If you die, then there may be a new Detective, If you shoot someone, you cannot get your gun back, You've messed up buddy. If you die that means you can chat in the #general (or the main chat) (if the owner/admin has setup a thing where players with murder mystery role cant chat)\nIn order to search someone to see if they are murderer, Type mm!search `@user`\n(or mm!searchnumber `(playerid)`)\nTo shoot someone, type mm!shoot `@user`\n(or mm!shootnumber `(playerid)`)\nBut don't abuse your gun!\nThats all, hope you find out who the murderer is!")
var await4 = await c.send(translate[guildData.lang].jobchannelmsgs.detective.channel.replaceAll("%prefix%", guildData.prefix))
var await5 = await c.send(row1.map(x => `<@${x.userId}>`).join(", "))
//var await6 = await sql.run(`UPDATE murderMystery SET sheriffchannelid = "${guildData.sheriffchannelid = c.id}" WHERE guildId = '${message.guild.id}'`)
gameDataTemp.push(c.id)
if (2 == findGamemode.createChannels[findGamemode.createChannels.length - 1]) return resolve(gameDataTemp)
resolve(-1)
})
}
})
break;
case "healer":
sql.get(`SELECT * FROM murderMysteryPlayers WHERE roleId = 3 AND guildId ='${message.guild.id}'`).then(row1 => {
if (!row1) {
message.channel.send("Error Code 497 at createhealerchannel")
console.error("[Murder Mystery Error] Error Code 497 at createhealerchannel")
} else {
message.guild.createChannel('healer', 'text').then(async function (c) {
var await0 = await c.overwritePermissions(message.guild.id, {
READ_MESSAGES: false
})
var await1 = await c.overwritePermissions(row1.userId, {
READ_MESSAGES: true
})
var await2 = await c.overwritePermissions(bot.user, {
READ_MESSAGES: true
})
var await3 = await c.send(translate[guildData.lang].jobchannelmsgs.healer.channel.replace("%prefix%", guildData.prefix))
var await4 = await c.send("<@" + row1.userId + ">")
if (guildData.categoryChannelId !== "0") {
var await5 = await c.setParent(guildData.categoryChannelId)
}
//var await6 = await sql.run(`UPDATE murderMystery SET healchannelid = ${guildData.healchannelid = c.id} WHERE guildId = '${message.guild.id}'`)
gameDataTemp.push(c.id)
if (3 == findGamemode.createChannels[findGamemode.createChannels.length - 1]) return resolve(gameDataTemp)
resolve(-1)
//c.send("Hello there, You are a **Healer**, You are a person that heals people that are dead! If you die, you cannot heal anyone anymore, Quick tip is try to not talk and say anything about your role. If you want to heal someone, just type\n" + config.prefix + "heal `@user`\nand you will be able to heal someone! Hope you avoid being murdered! Have a great game!")
})
}
})
break;