This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
1670 lines (1501 loc) · 73.1 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 EmbedBuilder = require('eris-embed-builder');
const Eris = require("eris");
const hypixel = require("./api");
const fs = require("fs");
const utils = require("./utils");
const vals = require("./config.json");
// const leechserver = require("./leechserver");
const http = require('http');
let EggSi = require('./eggsi')
let url = require('url');
let querystring = require('querystring');
const c = require('centra');
require('dotenv').config()
const {
NodeVM
} = require('vm2');
//Hmmmmm
const {
JsonDB
} = require('node-json-db');
const {
Config
} = require('node-json-db/dist/lib/JsonDBConfig');
const stringCompare = require("fast-levenshtein");
const {
listenerCount
} = require('process');
// The second argument is used to tell the DB to save after each push
// If you put false, you'll have to call the save() method.
// The third argument is to ask JsonDB to save the database in an human readable format. (default false)
// The last argument is the separator. By default it's slash (/)
const db = new JsonDB(new Config("upsiDatabase", true, true, '/'));
let guildMemberList = null;
let bazaar = {};
let scammerlist = Object.create(null); //INITIALIZED EMPTY CAUSE FUCK IT! I AM NOT WRAPPING EVERYTHING IN A BLOCK! LETS WAIT FOR TOP LEVEL AWAIT TO BE IMPLEMENTED.
function refreshLocalScammerList(){
try{
let scammerobj = db.getData("/scammer");
Object.assign(scammerlist, scammerobj); //UwU
}catch(e){
console.log(e);
}
}
async function getScammerList(){
let res = await c("https://raw.githubusercontent.com/skyblockz/pricecheckbot/master/scammer.json").send();
if (res.statusCode===200) jason = await res.json();
try{
for(uuid of db.getData("/scammerBypass")){
try{
delete jason[uuid];
}catch(e){
//mehhh
}
}
}catch(e){
console.log(e);
}
Object.assign(scammerlist, jason); //UwU
}
refreshLocalScammerList();
getScammerList();
setInterval(getScammerList,1000*60*60*24) //A scammer List fetcha day, keeps the scammers away!
let tokens = {
main: process.env.mainToken,
scraper: process.env.scraperToken,
hypixel: process.env.hypixelToken,
hypixel2: process.env.hypixelToken2,
eggsi: process.env.eggsiToken
};
if (Object.values(tokens).includes(undefined))
throw "Tokens are missing!";
console.log(`Using tokens\nMain: ${tokens.main.slice(0, 5)}* \nScraper: ${tokens.scraper.slice(0, 5)}* \nhypixel: ${tokens.hypixel.slice(0, 5)}*\nEggsi: ${tokens.main.slice(0, 5)}*`);
const api = new hypixel.Client(tokens.hypixel);
const api2 = new hypixel.Client(tokens.hypixel2);
const [bot, scraperbot] = [new Eris.CommandClient(tokens.main, {
restMode: true
}, {
description: "A bot.",
owner: "Anunay (and Refusings for those lovely embeds)",
prefix: "~"
}), Eris(tokens.scraper)];
let eggsi = new EggSi(db, api2, scammerlist,tokens.eggsi, {
restMode: true
}, {
description: "Totally not Upsi with a mask",
owner: "Anunay",
prefix: "-"
})
eggsi.connect().then(() => {
console.log("Logged in! Eggsi");
}).catch(() => {
throw "Unable to connect";
});
bot.connect().then(() => {
console.log("Logged in!");
}).catch(() => {
throw "Unable to connect";
});
// scraperbot.connect().catch(() => {
// throw "Unable to connect";
// });
// http.createServer(queryHandler).listen(42069,"0.0.0.0");
console.log('Server running on port 42069');
// async function queryHandler(req, res) {
// res.setHeader('Content-Type', 'application/json;charset=utf-8');
// res.setHeader("Cache-Control", "no-cache, must-revalidate");
// try {
// let urlParsed = url.parse(req.url, true);
// if (urlParsed.query.uuid === undefined || urlParsed.query.key === undefined) {
// res.writeHead(400);
// res.end(`{"error":"Missing key/UUID"}`);
// return;
// }
// try {
// if (!Object.keys(db.getData("/apikeys")).includes(urlParsed.query.uuid) || db.getData(`/apikeys/${urlParsed.query.uuid}`) !== urlParsed.query.key) {
// res.writeHead(403);
// res.end(`{"error":"Invalid UUID/Key"}`);
// return;
// }
// } catch (e) {
// res.writeHead(500);
// res.end();
// }
// if (urlParsed.pathname == '/subscribe') {
// leechserver.onSubscribe(req, res);
// return;
// }
// if (urlParsed.pathname == '/getStats') {
// if (urlParsed.query.username === undefined) {
// res.writeHead(400);
// res.end(`{"error":"Missing username"}`);
// return;
// }
// try {
// var stats = await getStats(urlParsed.query.username);
// let skill = 0;
// for (let name of ["combat", "angler", "gatherer", "excavator", "harvester", "augmentation", "concoctor", "domesticator"]) {
// skill += stats.hyplayer.player.achievements["skyblock_" + name];
// }
// skill /= 8;
// if (skill === NaN) skill = 0;
// let slayer = 0;
// for (profile of Object.keys(stats.stats)) {
// if (stats.stats[profile].skills > skill) skill = stats.stats[profile].skills;
// if (stats.stats[profile].slayer !== undefined && stats.stats[profile].slayer.xp > slayer) slayer = stats.stats[profile].slayer.xp;
// }
// response = {
// skill,
// slayer
// };
// } catch (e) {
// console.error(e);
// console.error(urlParsed.query.username);
// res.writeHead(500);
// res.end();
// return;
// }
// res.end(JSON.stringify(response));
// return;
// }
// res.end(`What you are looking for is not here, please don't DDoS me`);
// } catch (e) {
// console.error(e);
// res.writeHead(500);
// res.end();
// }
// }
// class Spammer{
// constructor(bot,bot2){
// this.doSpam = false;
// this.bot = bot;
// this.bot2 = bot2;
// this.bot.registerCommand("spam", function(msg){
// if (!["366719661267484672", "314197872209821699", "213612539483914240", "260470661732892672"].includes(msg.author.id)) return "I am afraid you don't have the permession to do that.";
// this.doSpam = !this.doSpam;
// if(this.doSpam){ //Not perfect, but works for now
// this.loop();
// }
// return this.doSpam;
// }.bind(this), {
// description: "",
// argsRequired: false
// });
// }
// async loop(){
// while(this.doSpam){
// this.bot.createMessage("756687524402823228","<@!314197872209821699> https://cdn.discordapp.com/attachments/656853907611320330/692785688806162502/OVERFLUX.png");
// this.bot2.createMessage("756687524402823228","<@!314197872209821699> https://cdn.discordapp.com/attachments/656853907611320330/692785688806162502/OVERFLUX.png");
// await new Promise(r => setTimeout(r, 2000));
// }
// }
// }
// try{
// let spambot = new Spammer(bot,eggsi);
// }catch(e){
// console.log(e);
// }
async function updateLeaderboardsCheck(msg) {
if (!["366719661267484672", "314197872209821699", "213612539483914240", "260470661732892672"].includes(msg.author.id)) return "I am afraid you don't have the permession to do that.";
bot.createMessage(msg.channel.id, "Updating...");
await updateLeaderboards();
bot.createMessage(msg.channel.id, `@${msg.author.username} Updated leaderboards`);
}
// async function genAPIKey(msg, args) {
// bot.sendChannelTyping(msg.channel.id);
// let player = null,
// hyplayer = null,
// sbp = null;
// guild = null;
// try {
// player = await api.getPlayer(args[0]);
// hyplayer = await api.gethypixelPlayer(player.id);
// guild = await api.getGuildByUserID(player.id);
// sbp = hyplayer.player;
// } catch (err) {
// console.log(err);
// return "Invalid username!";
// }
// let whitelist = db.getData("/modWhitelist");
// if ((guild === null || guild._id !== vals.guildID) && !whitelist.includes(player.id)) return ("You are not whitelisted or a member of the guild");
// if (hyplayer.player.socialMedia.links == undefined || hyplayer.player.socialMedia.links.DISCORD.toLowerCase().replace(" ", "_") !== `${msg.author.username.toLowerCase().replace(" ","_")}#${msg.author.discriminator}`) return ("Please connect your Hypixel account to discord.")
// try {
// if (!args.includes("new") && Object.keys(db.getData("/apikeys")).includes(player.id)) {
// return ("You seem to already have a key, try `~api <username> new` if you want a new key, remember your old key will be invalidated")
// }
// } catch (e) {
// }
// const apiKey = utils.genuuid();
// db.push(`/apikeys/${player.id}`, apiKey); // TEST
// (await bot.getDMChannel(msg.author.id)).createMessage("Here is your API key, Remember to keep it safe and do not share it with anyone.\n```\n" + apiKey + "```");
// return ("Your api key has been Direct Messaged to you");
// }
// bot.registerCommand("api", genAPIKey, {
// description: "Genenrate Api key for upsimod",
// argsRequired: true,
// usage: "<username>"
// });
bot.registerCommand("apply", apply, {
description: "Apply for guild",
argsRequired: true,
usage: "<username>",
cooldown: 10 * 1000,
cooldownMessage: "Sorry, You sent a application recently. Please try Again later"
});
bot.registerCommand("borb", (msg)=>{
const birbs = ["https://media.discordapp.net/attachments/704632414391238757/752816581754617897/image0.gif","https://media.discordapp.net/attachments/704632414391238757/752816582954057799/image3.gif","https://media.discordapp.net/attachments/704632414391238757/752816582492815420/image1.gif","https://media.discordapp.net/attachments/704632414391238757/752816583117897738/image4.gif","https://media.discordapp.net/attachments/704632414391238757/752816582723371028/image2.gif","https://media.discordapp.net/attachments/704632414391238757/752816583314767913/image5.gif"]
const randomElement = birbs[Math.floor(Math.random() * (birbs.length-0.5))];
if(Math.random()<=0.00238095238) return "https://media.discordapp.net/attachments/749299172779360307/756167459744120962/image0.gif";
if(Math.random()<=0.0002) return "https://cdn.discordapp.com/emojis/393622342581878785.gif"
if(msg.author.id === "213612539483914240") return "https://media.discordapp.net/attachments/704632414391238757/752816583314767913/image5.gif";
return randomElement;
}, {
description: "birb",
argsRequired: false,
usage: ""
});
async function apply(msg, args, apply = true) {
let messages = bot.getMessages(vals.waitListChannel)
let timeStart = Date.now();
bot.sendChannelTyping(msg.channel.id);
let player = null,
hyplayer = null,
sbp = null;
guild = null;
try {
player = await api.getPlayer(args[0]);
hyplayer = await api.gethypixelPlayer(player.id);
sbp = hyplayer.player;
} catch (err) {
console.log(err);
return "Invalid username!";
}
if (apply) { //Yes I know I can use &&, Do I care no.
if (hyplayer.player.socialMedia == undefined || hyplayer.player.socialMedia.links == undefined || hyplayer.player.socialMedia.links.DISCORD.toLowerCase().replace(" ", "_") !== `${msg.author.username.toLowerCase().replace(" ","_")}#${msg.author.discriminator}`) return ("Please connect your Hypixel account to discord.")
// messages = await messages;
if ((await messages).filter((msg) => msg.embeds.length > 0 && msg.author.id === bot.user.id).map((msg) => msg.embeds[0].author.name).includes(player.name))
return "Please Chill, You already have a Application Open";
}
let stats = await getStats(player,hyplayer);
if (typeof (stats) !== typeof ({})) {
let timeTaken = new Date(Date.now() - timeStart);
await bot.createEmbed(msg.channel.id).title("Stats").author(args[0]).description(stats).color("#FF0000").footer(`Done in ${(timeTaken.getSeconds() + (timeTaken.getMilliseconds() / 1000)).toFixed(2)}!`).send();
return;
}
let embed = bot.createEmbed();
let maxSlayer = 0;
let maxSkill = 0;
let bypassReqs = false;
let dungeonlvl = null;
if (stats.hyplayer.player.achievements !== undefined) {
for (let name of ["combat", "angler", "gatherer", "excavator", "harvester", "augmentation", "concoctor", "domesticator"]) {
maxSkill += stats.hyplayer.player.achievements["skyblock_" + name];
}
maxSkill /= 8;
if(stats.hyplayer.player.achievements.skyblock_dungeoneer) {
dungeonlvl = stats.hyplayer.player.achievements.skyblock_dungeoneer;
if(stats.hyplayer.player.achievements.skyblock_dungeoneer>=25)
bypassReqs = true;
}
}
if (maxSkill === NaN) maxSkill = 0;
for (let profile in stats.stats) {
// let prof = stats.stats[profId];
if (stats.stats[profile].skills > maxSkill) maxSkill = stats.stats[profile].skills;
if (stats.stats[profile].slayer !== undefined && stats.stats[profile].slayer.xp > maxSlayer) maxSlayer = stats.stats[profile].slayer.xp;
}
let score = parseFloat(((maxSkill ** 4) * (1 + (maxSlayer / 100000)) / 10000).toFixed(2));
let timeTaken = new Date(Date.now() - timeStart);
let discord = "Unknown";
if (hyplayer.player.socialMedia && hyplayer.player.socialMedia.links && hyplayer.player.socialMedia.links.DISCORD) {
discord = bot.guilds.get("682608242932842559").members.find((obj) => `${obj.username}#${obj.discriminator}`.toLowerCase().replace(" ", "_") === hyplayer.player.socialMedia.links.DISCORD.toLowerCase().replace(" ", "_"));
if (discord === undefined)
discord = hyplayer.player.socialMedia.links.DISCORD;
else
discord = discord.mention;
}
embed.author(stats.player.name, `https://crafatar.com/avatars/${stats.player.id}?overlay`);
embed.field("Discord", discord, false)
embed.field(`Score ${score > vals.score ? ":green_circle:" : ":red_circle:" }`, score.toFixed(2), true)
embed.field(`Skill`, maxSkill.toFixed(2), true)
embed.field(`Slayer`, maxSlayer.toLocaleString(), true)
if(dungeonlvl) embed.field(`Dungeon` + (dungeonlvl >= 25 ? ":green_apple:" : ""), dungeonlvl, true);
embed.footer(`Done in ${(timeTaken.getSeconds() + (timeTaken.getMilliseconds() / 1000)).toFixed(2)}s!`);
embed.timestamp(new Date());
if ((score > vals.score || bypassReqs) && !scammerlist[player.id]) {
embed.color(0x00ff00);
if (apply) {
let msg = await embed.send(bot, vals.waitListChannel);
bot.addMessageReaction(msg.channel.id, msg.id, "✅")
bot.addMessageReaction(msg.channel.id, msg.id, "❌")
embed.description("Your application is under review. If accepted, you will be contacted.\nPlease leave your current guild so we can streamline the process.\nThanks!")
}
} else {
embed.description("Sorry, You do not meet Guild Requirements.")
embed.color(0xff0000);
}
if(scammerlist[player.id]){
embed.description(`☢️ This Player is a known **SCAMMMER** ☢️\nOffence: ${scammerlist[player.id].reason}`);
embed.color(0xffff00);
}
await embed.send(bot, msg.channel.id);
return;
}
bot.registerCommand("stats", stat, {
description: "Stats",
argsRequired: true,
usage: "<username>",
cooldown: 10 * 1000,
cooldownMessage: "..."
});
async function stat(msg, args) {
let messages = bot.getMessages(vals.waitListChannel)
let timeStart = Date.now();
bot.sendChannelTyping(msg.channel.id);
let player = null,
hyplayer = null,
sbp = null;
guild = null;
try {
player = await api.getPlayer(args[0]);
hyplayer = await api.gethypixelPlayer(player.id);
sbp = hyplayer.player;
} catch (err) {
console.log(err);
return "Invalid username!";
}
let stats = await getStats(player,hyplayer);
if (typeof (stats) !== typeof ({})) {
let timeTaken = new Date(Date.now() - timeStart);
await bot.createEmbed(msg.channel.id).title("Stats").author(args[0]).description(stats).color("#FF0000").footer(`Done in ${(timeTaken.getSeconds() + (timeTaken.getMilliseconds() / 1000)).toFixed(2)}!`).send();
return;
}
let embed = bot.createEmbed();
let maxSlayer = 0;
let maxSkill = 0;
if (stats.hyplayer.player.achievements !== undefined) {
for (let name of ["combat", "angler", "gatherer", "excavator", "harvester", "augmentation", "concoctor", "domesticator"]) {
maxSkill += stats.hyplayer.player.achievements["skyblock_" + name];
}
maxSkill /= 8;
}
if (maxSkill === NaN) maxSkill = 0;
let bestprofile = null;
for (let profile in stats.stats) {
// let prof = stats.stats[profId];
// if (stats.stats[profile].skills > maxSkill) maxSkill = stats.stats[profile].skills;
if (stats.stats[profile].slayer !== undefined && stats.stats[profile].slayer.xp > maxSlayer) {
maxSlayer = stats.stats[profile].slayer.xp;
bestprofile = stats.stats[profile]
}
}
let score = parseFloat(((maxSkill ** 4) * (1 + (maxSlayer / 100000)) / 10000).toFixed(2));
let timeTaken = new Date(Date.now() - timeStart);
let discord = "Unknown";
if (hyplayer.player.socialMedia && hyplayer.player.socialMedia.links && hyplayer.player.socialMedia.links.DISCORD) {
discord = bot.guilds.get("682608242932842559").members.find((obj) => `${obj.username}#${obj.discriminator}`.toLowerCase().replace(" ", "_") === hyplayer.player.socialMedia.links.DISCORD.toLowerCase().replace(" ", "_"));
if (discord === undefined)
discord = hyplayer.player.socialMedia.links.DISCORD;
else
discord = discord.mention;
}
embed.author(stats.player.name, `https://crafatar.com/avatars/${stats.player.id}?overlay`);
embed.field("Discord", discord, false)
embed.field(`Score ${score > vals.score ? ":green_circle:" : ":red_circle:" }`, score.toFixed(2), true)
embed.field(`Skill`, maxSkill.toFixed(2), true)
embed.field(`Slayer`, maxSlayer.toLocaleString(), true)
embed.field(`🐺`, bestprofile.slayer.w.toLocaleString(), true)
embed.field(`🕸️`, bestprofile.slayer.s.toLocaleString(), true)
embed.field(`:zombie:`, bestprofile.slayer.z.toLocaleString(), true)
embed.footer(`Done in ${(timeTaken.getSeconds() + (timeTaken.getMilliseconds() / 1000)).toFixed(2)}s!`);
embed.timestamp(new Date());
if (score > vals.score) {
embed.color(0x00ff00);
} else if(scammerlist[player.id]){
embed.description(`☢️ This Player is a known **SCAMMMER** ☢️\nOffence: ${scammerlist[player.id].reason}`);
embed.color(0xffff00);
}else{
embed.color(0xff0000);
}
await embed.send(bot, msg.channel.id);
return;
}
bot.on("messageReactionAdd", async (msg, emoji, userid) => {
if (msg.channel.id === vals.waitListChannel && ["✅", "❌"].includes(emoji.name) && userid !== bot.user.id) {
msg = await bot.getMessage(msg.channel.id, msg.id);
if (!(await bot.getRESTGuildMember("682608242932842559", userid)).roles.includes("691021789031301131")) {
bot.removeMessageReaction(msg.channel.id, msg.id, emoji.name, userid);
return;
}
if (msg.author.id === bot.user.id) {
let userid = msg.embeds[0].fields[0].value.slice(3, -1);
if (emoji.name === "✅") {
(await bot.getDMChannel(userid)).createMessage("Your application has been Accepted, if you haven't already been invited to guild contact a staff members in discord.");
// bot.addGuildMemberRole("682608242932842559", userid, "691292794605797407", "Application Accepted")
let embed = msg.embeds[0];
embed.description = "Waiting for user to join Guild";
bot.editMessage(msg.channel.id, msg.id, {
embed
});
msg.removeMessageReactionEmoji("✅");
} else if (emoji.name === "❌") {
(await bot.getDMChannel(userid)).createMessage("Sorry your application has been Rejected");
bot.deleteMessage(msg.channel.id, msg.id);
let embed = msg.embeds[0];
embed.color = 0xff0000;
embed.description = "";
embed.author.name += "- REJECTED";
bot.createMessage(vals.applicationLogs, {
embed
});
}
}
}
});
bot.registerCommand("slm", (msg, args) => `https://sky.lea.moe/stats/${args[0]}` + (args[1] ? `/${args[1]}` : ""), {
description: "Link Sky.lea.moe",
argsRequired: true,
usage: "<username> [profile]"
});
bot.registerCommand("ssm", (msg, args) => `https://sky.shiiyu.moe/stats/${args[0]}` + (args[1] ? `/${args[1]}` : ""), {
description: "Link Sky.lea.moe",
argsRequired: true,
usage: "<username> [profile]"
});
async function runInVm(msg) {
if (msg.author.id !== "213612539483914240" && msg.author.id !== "260470661732892672" && msg.author.id !== "314197872209821699") return "No.";
// TODO Ask refusings to make this look better.
let reg = msg.content.match(/```(.*?)```/s);
if (reg === null) reg = msg.content.match(`${msg.prefix}run (.*)`);
if (reg === null) return "Cannot Read Code";
const vm = new NodeVM({
console: 'redirect',
timeout: 30000,
sandbox: {}
});
vm.freeze(api, 'api');
vm.freeze(config, 'config');
let output = await bot.createMessage(msg.channel.id, "Output:").catch(e => console.log(e));
vm.on('console.log', (data) => {
output.edit(output.content += `\n${JSON.stringify(data)}`);
});
try {
vm.run(reg[1]);
} catch (err) {
output.edit(output.content += `\nERROR: ${JSON.stringify(err)}`);
}
}
bot.registerCommand("run", runInVm, {
description: "Run code, badly..",
fullDescription: "Arbitary Code execution hehehe",
requirements: {
userIDs: ["213612539483914240", "260470661732892672"]
},
permissionMessage: "BOOOOOO!",
argsRequired: true,
usage: "run <code>"
});
bot.registerCommand("say", say, {
description: "Say...",
fullDescription: "Lets hope this does not destroy the server",
argsRequired: true,
usage: "<What to say>"
});
// bot.registerCommand("addleech", addleech, {
// description: "Add Leech Channel",
// fullDescription: "Add a server to leech bot",
// argsRequired: true,
// usage: "<channelid> <server invite>"
// });
// bot.registerCommand("removeleech", removeleech, {
// description: "Remove a Leech Channel",
// argsRequired: true,
// usage: "<channelid>"
// });
// async function removeleech(msg,arg){
// if(!["213612539483914240","314197872209821699","260470661732892672"].includes(msg.author.id)) return "You're not allowed to do that";
// if(arg[0].match(/^[0-9]{18}$/)===null) return "Invalid Channel ID";
// try{
// db.delete("/splashSendChannels[" + db.getIndex("/splashSendChannels", arg[0]) + "]");
// splashHandler.refreshList();
// return("YEETED!");
// }catch(e){
// return("That channel is not in the list");
// }
// }
// async function addleech(msg,arg){
// if(!["213612539483914240","314197872209821699","260470661732892672","366719661267484672"].includes(msg.author.id)) return "You're not allowed to do that";
// if(arg[0].match(/^[0-9]{18}$/)===null) return "Invalid Channel ID";
// if(splashHandler.splashSendChannels.includes(arg[0])) return("Channel Already in Splash Leech")
// if(arg[1]!==undefined){
// let match = arg[1].match(/^(https?\:\/\/)?(.*\/)?([a-z0-9-]{2,32})$/i);
// if(match ===null || match[3] === undefined) return "Invalid Invite";
// let request = await c(`https://discord.com/api/v8/invites/${match[3]}`, 'POST').header({
// 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0',
// 'Authorization': tokens.scraper,
// 'Origin': 'https://discord.com',
// 'Connection': 'keep-alive',
// 'Accept':'*/*'
// }).body({}).send();
// if([403,404].includes(request.statusCode)){
// const message = (await request.json()).message;
// return message;
// }
// else if(request.statusCode !== 200) return "Some Unknown Error Occoured";
// await msg.channel.createMessage(`Joined ${(await request.json()).guild.name}`)
// }
// db.push("/splashSendChannels[]",arg[0]);
// splashHandler.splashSendChannels.push(arg[0]);
// try{
// let channel = await scraperbot.getChannel(arg[0]);
// if(channel===undefined) return "That channel doesn't exist";
// }catch(e){
// console.log(e);
// return "Some unknown error occured";
// }
// return "Successfully Added Server to list";
// }
bot.registerCommand("score", (msg,args) => {
switch(args[1].slice(-1)){
case 'k':
case 'K':
args[1] = parseFloat(args[1].slice(0,-1))*1000;
break;
case 'm':
case 'M':
args[1] = parseFloat(args[1].slice(0,-1))*1000000;
break;
default:
break;
}
let score = ((args[0] ** 4) * (1 + ( args[1] / 100000)) / 10000).toFixed(2)
return(score);
}, {
description: "Calculate Score (for Lazy people)",
argsRequired: true,
usage: "<skill> <slayer>"
});
function say(msg) {
if (msg.author.bot === true) return;
// replace(/<(:\w+:)[0-9]+>/g, "$1")
return("<:fuckyou:674969920261586945>")
// return (msg.content.replace(msg.prefix + msg.command.label, ""));
}
// class splashNotifier {
// constructor() {
// this.pastMessages = {};
// this.duplicate = Object.create(null);
// try{
// this.splashSendChannels = db.getData("/splashSendChannels");
// this.splashReceiveChannels = db.getData("/splashReceiveChannels");
// }catch(e){
// this.splashSendChannels = [];
// this.splashReceiveChannels = [];
// }
// }
// refreshList(){
// try{
// this.splashSendChannels = db.getData("/splashSendChannels");
// this.splashReceiveChannels = db.getData("/splashReceiveChannels");
// }catch(e){
// this.splashSendChannels = [];
// this.splashReceiveChannels = [];
// }
// }
// sendSplashNotification(msgList) {
// // const totalmsg = msgList.reduce((total, now) => {
// // if(now.embeds.length>0)
// // return now.cleanContent + "\n" + total;
// // }, "");
// let totalmsg = "";
// let embed = bot.createEmbed();
// let hasEmbed = null;
// for (let msg of msgList) {
// if (msg.embeds.length > 0 && msg.embeds[0].type !== "image" && msg.embeds[0].type !== "gifv") {
// hasEmbed = msg.embeds[0];
// totalmsg += msg.cleanContent + (msg.embeds[0].description || "");
// } else if (msg.embeds.length > 0 && msg.embeds[0].type === "image") {
// totalmsg = msg.cleanContent + "\n" + totalmsg;
// embed.image(msg.embeds[0].url);
// } else {
// totalmsg = msg.cleanContent + "\n" + totalmsg;
// }
// }
// if (hasEmbed !== null) {
// hasEmbed.author = {
// name: msgList[0].author.username,
// icon_url: `https://cdn.discordapp.com/avatars/${msgList[0].author.id}/${msgList[0].author.avatar}.png`
// };
// hasEmbed.footer = {
// text: `This Message was sent in ${msgList[0].channel.guild.name}`
// };
// hasEmbed.timestamp = new Date();
// hasEmbed.color = 0x00ffff;
// hasEmbed.description = totalmsg;
// let isDemi = false;
// if (hasEmbed.fields !== undefined) {
// for (let field of hasEmbed.fields) {
// let title = (field.name + " " + field.value).match(/((party|p) join \w+|(dungeon|d|dung|dun)?\s?HUB\s?\d+)/i);
// isDemi = isDemi || (field.name + " " + field.value).toLowerCase().includes("demi");
// if (title !== null) {
// hasEmbed.title = title[0];
// }
// }
// }
// let title = hasEmbed.description.match(/((party|p) join \w+|(dungeon|d|dung|dun)?\s?HUB\s?\d+)/i);
// if (title !== null) {
// hasEmbed.title = title[0];
// }
// isDemi = isDemi || hasEmbed.description.toLowerCase().includes("demi");
// hasEmbed.title += (isDemi ? " - DEMI" : "");
// //if(isDemi) hasEmbed.color = 0xC0C0C0;
// if (isDemi) return;
// if (hasEmbed.title.match(/((party|p) join \w+|(dungeon|d|dung|dun)?\s?HUB\s?\d+)/i) !== null && !Object.keys(this.duplicate).includes(hasEmbed.title)) {
// this.duplicate[hasEmbed.title] = true;
// setTimeout(function(){
// delete this.duplicate[hasEmbed.title];
// console.log(`Deleted ${hasEmbed.title}`);
// }.bind(this),90000)
// leechserver.publish({
// type: (hasEmbed.title.match(/(party|p) join \w+/i) ? "party" : "hub"),
// place: hasEmbed.title,
// message: hasEmbed.description + (hasEmbed.fields ? hasEmbed.fields.map(function (obj) {
// return (`${obj.name}:${obj.value}`);
// }).join("\n") : "")
// });
// } else {
// return;
// }
// if(msgList[0].channel.id === "675381164990529546") return;
// for (let splashReceiveChannel of this.splashReceiveChannels) {
// bot.createMessage(splashReceiveChannel, {
// embed: hasEmbed
// });
// }
// return;
// }
// if (totalmsg.match(/\d+\s?K/i) !== null) return;
// const isDemi = totalmsg.toLowerCase().includes("demi");
// if (isDemi) return; //SOFT-REMOVED DEMI
// const title = totalmsg.match(/((party|p) join \w+|(dungeon|d|dung|dun)?\s?HUB\s?\d+)/i);
// if (title !== null && !Object.keys(this.duplicate).includes(title[0])) {
// this.duplicate[title[0]] = true;
// setTimeout(function(){
// delete this.duplicate[title[0]];
// console.log(`Deleted ${title[0]}`);
// }.bind(this),30000)
// embed.title(title[0] + (isDemi ? " - DEMI" : ""));
// leechserver.publish({
// type: (totalmsg.match(/(party|p) join \w+/i) ? "party" : "hub"),
// place: title[0],
// message: totalmsg
// });
// } else
// return;
// // embed.title((isDemi ? "DEMI " : "") + "Splash");
// if(msgList[0].channel.id === "675381164990529546") return;
// embed.description(totalmsg);
// embed.color(isDemi ? "#C0C0C0" : "#00FFFF");
// embed.timestamp(new Date());
// embed.author(msgList[0].author.username, `https://cdn.discordapp.com/avatars/${msgList[0].author.id}/${msgList[0].author.avatar}.png`);
// embed.footer(`This Message was sent in ${msgList[0].channel.guild.name}`);
// for (let splashReceiveChannel of this.splashReceiveChannels) {
// embed.send(bot, splashReceiveChannel).catch(error => console.log(error));
// }
// }
// async scrapeHandler(msg) {
// if (this.splashSendChannels.includes(msg.channel.id)) {
// if (msg.roleMentions.length > 0 || msg.mentionEveryone || msg.embeds.length > 0 || (msg.cleanContent.match(/((party|p) join \w+|(dungeon|d|dung|dun)?\s?HUB\s?\d+)/i) && (msg.cleanContent.toLowerCase().includes("god") || msg.cleanContent.toLowerCase().includes("splash")))) {
// let msgList;
// if (msg.embeds.length > 0)
// msgList = [msg]
// else
// msgList = (await scraperbot.getMessages(msg.channel.id, 10)).filter((obj) => (obj.timestamp > msg.timestamp - 180000) && obj.author === msg.author);
// this.sendSplashNotification(msgList);
// this.pastMessages[msg.author.id] = msg.id;
// setTimeout((that, id) => {
// delete that.pastMessages[id];
// }, 1000 * 300, this, msg.author.id);
// } else if (Object.keys(this.pastMessages).includes(msg.author.id)) {
// for (let splashReceiveChannel of this.splashReceiveChannels) {
// let msgtoEdit = (await bot.getMessages(splashReceiveChannel)).filter((arr) => {
// if (arr.embeds.length > 0 && arr.embeds[0].author !== undefined)
// return arr.embeds[0].author.name === msg.author.username;
// })[0];
// if(!msgtoEdit) return;
// if (msg.embeds.length > 0 && msg.embeds[0].type !== "image" && msg.embeds[0].type !== "gifv") {
// msg.embeds[0].description = msgtoEdit.embeds[0].description;
// msgtoEdit.embeds[0] = msg.embeds[0];
// } else if (msg.embeds.length > 0 && msg.embeds[0].type === "image") {
// msgtoEdit.embeds[0].description = msgtoEdit.embeds[0].description + "\n" + msg.cleanContent;
// msgtoEdit.embeds[0].image = {
// url: msg.embeds[0].url
// };
// const title = msg.cleanContent.match(/((party|p) join \w+|(dungeon|d|dung|dun)?\s?HUB\s?\d+)/i);
// if (title !== null) msgtoEdit.embeds[0].title = title[0];
// } else {
// msgtoEdit.embeds[0].description = msgtoEdit.embeds[0].description + "\n" + msg.cleanContent;
// const title = msg.cleanContent.match(/((party|p) join \w+|(dungeon|d|dung|dun)?\s?HUB\s?\d+)/i);
// if (title !== null) msgtoEdit.embeds[0].title = title[0];
// }
// try {
// await bot.editMessage(msgtoEdit.channel.id, msgtoEdit.id, {
// embed: msgtoEdit.embeds[0]
// });
// } catch (e) {
// console.error(e);
// }
// }
// } else {
// // So you don't do the bit after every time
// return;
// }
// }
// }
// }
// let splashHandler = new splashNotifier();
// scraperbot.on("messageCreate", splashHandler.scrapeHandler.bind(splashHandler));
// scraperbot.on("messageCreate", (msg) => {
// if (["720642093181042690", "720602273461567509", "736220160616038471", "728287548321038346"].includes(msg.channel.id)) {
// bot.createMessage("736211540772126780", {
// content: msg.cleanContent,
// embed: msg.embeds[0]
// });
// }
// });
bot.on("messageCreate", (msg) => {
if (msg.content.toLowerCase().startsWith("-req") || msg.content.toLowerCase().startsWith("-apply"))
bot.createMessage(msg.channel.id, "Please for the love of life its a `~` (tilde), [Usually look in left-upper corner key below escape for it] ")
});
//SAD You will be missed, nvm I am bringing it back, No stay the way you are
// bot.on("messageCreate", (msg) => {
// if (msg.author.bot) return;
// let content = msg.cleanContent.match(/\b(I'm|I am|I\s?m)\s(.*)/i);
// if (content !== null) bot.createMessage(msg.channel.id, `Hi ${content[2]}, I am ᴉsd∩`);
// });
bot.registerCommand("ping", "Pong!", { // Make a ping command
// Responds with "Pong!" when someone says "!ping"
description: "Pong!",
fullDescription: "This command could be used to check if the bot is up. Or entertainment when you're bored."
});
bot.registerCommand("req", checkRequirementsnew, {
description: "Check Requirements!!",
fullDescription: "Dude that literally ^",
argsRequired: true,
usage: `<username>`,
cooldown: 1000,
cooldownMessage: "Slow down!!"
});
bot.registerCommand("scammer", scammer, {
description: "Add a Scammer to Scammer DB",
fullDescription: "",
argsRequired: true,
usage: `<username> <reason>`,
cooldown: 1000,
cooldownMessage: "Slow down!!"
});
bot.registerCommand("unscammer", unscammer, {
description: "Remove a scammer from scammer DB",
fullDescription: "",
argsRequired: true,
usage: `<username>`,
cooldown: 1000,
cooldownMessage: "Slow down!!"
});
async function unscammer(msg,args){
if (!(await bot.getRESTGuildMember("682608242932842559", msg.author.id)).roles.includes("691021789031301131"))
return "Naaaah"
try {
player = await api.getPlayer(args[0]);
} catch (err) {
return "Invalid username!";
}
try{
db.delete(`/scammer/${player.id}`);
}catch(e){
}
try{
delete scammerlist[player.id];
}catch(e){
}
db.push("/scammerBypass[]",player.id);
return "Removed Player from Scammer List";
}
async function scammer(msg,args){
if (!(await bot.getRESTGuildMember("682608242932842559", msg.author.id)).roles.includes("691021789031301131"))
return "Naaaah"
try {
player = await api.getPlayer(args[0]);
} catch (err) {
return "Invalid username!";
}
db.push(`/scammer/${player.id}`,{
operated_staff:msg.author.username+"#"+msg.author.discriminator,
uuid:player.id,
reason: args.slice(1).join(" ")
})
scammerlist[player.id] = {
operated_staff:msg.author.username+"#"+msg.author.discriminator,
uuid:player.id,
reason: args.slice(1).join(" ")
}
// refreshLocalScammerList();
return("Added that user to scammer list");
}
async function checkRequirementsnew(msg, args) {
return (await apply(msg, args, false));
}
// async function checkRequirements(msg, args) {
// // if (args[0] === undefined) return "Invalid Usage! do req <username>";
// bot.sendChannelTyping(msg.channel.id);
// let timeStart = Date.now();
// // let newReqs = args.join("").includes("new");
// let newReqs = !args.join("").includes("old");
// let current = args.join("").includes("old");
// let embed = bot.createEmbed(msg.channel.id);
// let res = await getStats(args[0]);
// if (typeof (res) !== typeof ({})) {
// let timeTaken = new Date(Date.now() - timeStart);
// await bot.createEmbed(msg.channel.id).title("Stats").author(args[0]).description(res).color("#FF0000").footer(`Done in ${(timeTaken.getSeconds() + (timeTaken.getMilliseconds() / 1000)).toFixed(2)}!`).send();
// return;
// }
// let values = utils.deepCopy(vals);
// if (current || newReqs) {
// if (current) {
// values.slayer = values.slayerOld;
// values.skills = values.skillsOld;
// }
// for (let profId in res.stats) {
// let prof = res.stats[profId];
// let slayerCheck = false;
// if (values.slayer.minimumAsAll) slayerCheck = (prof.slayer.z >= values.slayer.minimumHighestSlayer && prof.slayer.s >= values.slayer.minimumHighestSlayer && prof.slayer.w >= values.slayer.minimumHighestSlayer);
// else slayerCheck = (prof.slayer.z >= values.slayer.minimumHighestSlayer || prof.slayer.s >= values.slayer.minimumHighestSlayer || prof.slayer.w >= values.slayer.minimumHighestSlayer);
// if (values.slayer.xpAndMinimum) slayerCheck = (slayerCheck && prof.slayer.xp >= values.slayer.xp);
// else slayerCheck = (slayerCheck || prof.slayer.xp >= values.slayer.xp);
// embed = createRequirementField(embed, profId, prof, values, slayerCheck, newReqs);
// }
// embed.color("#FFA500");
// let timeTaken = new Date(Date.now() - timeStart);
// embed.footer(`Done in ${(timeTaken.getSeconds() + (timeTaken.getMilliseconds() / 1000)).toFixed(2)}s!`);
// await embed.send();
// return;
// } else {
// let mainColor = "#FF0000";
// for (let profId in res.stats) {
// let prof = res.stats[profId];
// let slayerCheck = false;
// if (vals.slayerOld.minimumAsAll) slayerCheck = (prof.slayer.z >= vals.slayerOld.minimumHighestSlayer && prof.slayer.s >= vals.slayerOld.minimumHighestSlayer && prof.slayer.w >= vals.slayerOld.minimumHighestSlayer);
// else slayerCheck = (prof.slayer.z >= vals.slayerOld.minimumHighestSlayer || prof.slayer.s >= vals.slayerOld.minimumHighestSlayer || prof.slayer.w >= vals.slayerOld.minimumHighestSlayer);
// if (vals.slayerOld.xpAndMinimum) slayerCheck = (slayerCheck && prof.slayer.xp >= vals.slayerOld.xp);
// else slayerCheck = (slayerCheck || prof.slayer.xp >= vals.slayerOld.xp);