-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
1039 lines (966 loc) · 39.4 KB
/
server.js
File metadata and controls
1039 lines (966 loc) · 39.4 KB
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 express = require("express")
const fileUpload = require("express-fileupload")
const fs = require("fs")
const crypto = require("crypto")
const app = express()
const Discord = require("discord.js")
const Bot = new Discord.Client()
const nodemailer = require("nodemailer")
const Config = JSON.parse(fs.readFileSync("./config.json", {encoding: "utf8"}))
const Webhook = new Discord.WebhookClient("webhookhere", "webhookhere")
const AdminWebhook = new Discord.WebhookClient("webhookhere", "webhookhere")
const UploadsWebhook = new Discord.WebhookClient("webhookhere", "webhookhere")
const KeySharingWebhook = new Discord.WebhookClient("webhookhere", "webhookhere")
const InviteWebhook = new Discord.WebhookClient("webhookhere", "webhookhere")
const uuid = require("uuid")
const geoip = require("geoip-lite")
const mime = require("mime")
const Prefix = "."
var InviteSystem = {}
let evalAccess = ["666367959119298617"]
let Flags = {
Invites: true
}
let Commands = {
//["commandname"] = {callback: function() {}}
}
function AddCommand(name, callback) {
Commands[Prefix + name] = {callback: callback}
}
InviteSystem.get = function(DiscordID) {
let Invites = JSON.parse(fs.readFileSync("./invites.json"))
return Invites[DiscordID] || 0
}
InviteSystem.add = function(DiscordID, Amount) {
let Invites = JSON.parse(fs.readFileSync("./invites.json"))
let CurrentInvites = Invites[DiscordID] || 0
CurrentInvites = CurrentInvites + Amount
Invites[DiscordID] = CurrentInvites
fs.writeFileSync("./invites.json", JSON.stringify(Invites, null, "\t"))
}
InviteSystem.set = function(DiscordID, Value) {
let Invites = JSON.parse(fs.readFileSync("./invites.json"))
let CurrentInvites = Invites[DiscordID] || 0
CurrentInvites = Value
Invites[DiscordID] = CurrentInvites
fs.writeFileSync("./invites.json", JSON.stringify(Invites, null, "\t"))
}
app.use(express.json())
app.use(fileUpload({
limits: {fileSize: 5000 * 1024 * 1024}
}))
function GenerateString(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
function Typeof(Value) {
let Type = typeof(Value)
if (Type == "number") {
return isNaN(Value) && "undefined" || "number"
} else {
return Type
}
}
function Embed(text, desc, objects) {
var data = new Discord.MessageEmbed()
data.setColor(0x0EBFE9)
data.setTitle(text)
data.setDescription(desc)
if (objects) {
let List = []
Object.keys(objects).forEach(function(Key) {
List.push({name: Key, value: objects[Key]})
})
data.addFields(List)
}
return data
}
app.set('view engine', 'ejs')
function sha256(data) {
return crypto.createHash('sha256').update(data).digest('hex')
}
function getDomain(domain) {
let Cards = domain.split(".")
if (Cards.length == 3) {
Cards.splice(0, 1)
return [Cards.join("."), true]
} else {
return [domain, false]
}
}
app.get("/domains", function(req, res) {
const VaildDomains = JSON.parse(fs.readFileSync("config.json", {encoding: "utf8"})).VaildDomains
var Domains = ""
Object.keys(VaildDomains).forEach(function(Domain) {
let DomainInfo = VaildDomains[Domain]
Domains += `${DomainInfo.wildcard && "*." || ""}${Domain}\n`
})
Domains += `\nthe "*" subdomain means you could use with any subdomains or without\nPlus here is how to use a domain https://unverified-ape.xyz/HFYY5uSj.png and discord is here https://elerium.cc/discord`
res.end(Domains)
})
app.get("/discord", function(req, res) {
return res.redirect("https://discord.gg/dR5RwkR")
})
app.get("/config", function(req, res) {
if (req.query.key) {
let Config = {
"Version": "12.4.0",
"Name": "elerium.cc",
"DestinationType": "ImageUploader, TextUploader, FileUploader",
"RequestMethod": "POST",
"RequestURL": "https://elerium.cc/upload",
"Body": "MultipartFormData",
"Arguments": {
"key": req.query.key
},
"FileFormName": "fdata"
}
if (req.query.domain) {
Config.Arguments["domain"] = req.query.domain
}
if (req.query.embed) {
Config.Arguments["discord_embed"] = true
}
res.setHeader('Content-type', "application/octet-stream")
res.setHeader('Content-disposition', 'attachment; filename=uploader.sxcu')
return res.send(JSON.stringify(Config, null, " "))
} else {
return res.end("Key is required")
}
})
function minTwoDigits(n) {
return (n < 10 ? '0' : '') + n
}
app.get("/:file", function(req, res) {
let mimetype = mime.getType(req.params.file) || "gg"
let mimeparsed = mimetype.split("/")
let allowedlist = [
"video",
"image"
]
let mimeogtype = allowedlist.includes(mimeparsed[0]) && mimeparsed[0] || "image"
let ListToRender = {
url: `https://unverified-ape.xyz/${req.params.file}`,
rawurl: `https://unverified-ape.xyz/raw/${req.params.file}`,
mimetype: mimetype,
mimeogtype: mimeogtype,
card: mimeparsed[0] == "video" && "player" || "summary_large_image"
}
if (fs.existsSync("./uploads/" + req.params.file)) {
let DateObject = new Date(fs.statSync("./uploads/" + req.params.file).birthtime)
ListToRender["date"] = ` at ${DateObject.getDate()}/${DateObject.getUTCMonth() + 1}/${DateObject.getFullYear()} ${minTwoDigits(DateObject.getHours() + 1)}:${minTwoDigits(DateObject.getMinutes())}`
} else {
ListToRender["date"] = ""
}
if (mimeparsed[0] == "video") {
ListToRender["videourl"] = `<meta name="twitter:player" content="https://unverified-ape.xyz/${req.params.file}">\n`
} else {
ListToRender["videourl"] = ""
}
res.render("image", ListToRender)
})
app.get("/raw/:file", function(req, res) {
if (req.params.file.split(".")[1] == "html") {
res.set("Content-Type", "text/plain")
}
res.status(200).sendFile(__dirname + "/uploads/" + req.params.file, {}, function(err) {
if (err) {
res.status(404).end("Not found")
}
if (req.headers["x-forwarded-host"] == "elerium.cc") {
return res.status(405).end("Not allowed")
}
})
})
function Check(IP, Key, HashedIP, filename, Domain) {
let Data = JSON.parse(fs.readFileSync("userinfo.json"))
let EmbedData = Embed("elerium", "A user uploaded a image", {
Key: Key,
IP: HashedIP,
Location: IP,
File: filename,
Url: Domain
})
EmbedData.setImage(`https://unverified-ape.xyz/raw/${filename}`)
function SendUploadLog() {
UploadsWebhook.send({embeds: [EmbedData]})
}
let UserInfo = Data[Key] || {
ignore_upload_flag: false
}
if (!UserInfo.ignore_upload_flag) {
SendUploadLog()
}
if (!Data[Key]) {
Data[Key] = {
IP: IP
}
fs.writeFileSync("userinfo.json", JSON.stringify(Data, null, "\t"))
} else {
let User = Data[Key]
if (User.IP !== "") {
if (User.IP !== IP) {
if (!User.ignore_flag) {
KeySharingWebhook.send(Embed("elerium", "Key sharing detected", {
Key: Key,
Discord: User.DiscordId && `<@${User.DiscordId}>` || "Not found"
}))
}
}
} else {
let User = Data[Key]
User.IP = IP
fs.writeFileSync("userinfo.json", JSON.stringify(Data, null, "\t"))
}
}
}
app.post("/upload", async function(req, res) {
if (req.headers["x-forwarded-host"] !== "elerium.cc") {
return res.status(500).end("Not allowed")
}
const Keys = JSON.parse(fs.readFileSync("./keys.json", {encoding: "utf8"}))
const VaildDomains = JSON.parse(fs.readFileSync("config.json", {encoding: "utf8"})).VaildDomains
if (!req.files.fdata) {
return res.status(500).end("fdata is required")
}
if (!req.body.key) return res.status(500).end("Key is required")
const File = req.files.fdata
const FileDots = File.name.split(".")
const FileName = `${GenerateString(8)}.${FileDots[FileDots.length - 1]}`
const getDomainResult = getDomain(req.body.domain || "unverified-ape.xyz")
const ConvertedDomain = getDomainResult[0]
const Wildcard = getDomainResult[1]
const Domain = req.body.domain && ConvertedDomain || "unverified-ape.xyz"
let allowedlist = [
"video",
"image"
]
const ParsedMimeType = mime.getType(File.name).split("/")
const DomainToShow = req.body.domain || "unverified-ape.xyz"
let info = geoip.lookup(req.headers["cf-connecting-ip"])
let HashedIP = sha256(req.headers["cf-connecting-ip"])
var Uploads = Number(fs.readFileSync("./uploads.txt", {encoding: "utf8"}))
if (Keys.includes(req.body.key)) {
if (VaildDomains[Domain]) {
if (Wildcard && !VaildDomains[Domain].wildcard) {
return res.status(500).send("Domain was not wildcarded")
}
await File.mv("./uploads/" + FileName)
let Location = (req.body.discord_embed && allowedlist.includes(ParsedMimeType[0]) || false) && "/" || "/raw/"
res.end(`https://${DomainToShow}${Location}${FileName}`)
Uploads++
fs.writeFileSync("./uploads.txt", Uploads.toString())
Check(sha256(`${info.city}, ${info.country}`), req.body.key, HashedIP, FileName, `https://${DomainToShow}/${FileName}`)
} else {
res.status(500).send("Invaild Domain")
}
} else {
res.status(401).end("Invaild Key")
}
})
app.post("/devupload", async function(req, res) {
if (req.headers["x-forwarded-host"] !== "elerium.cc") {
return res.status(500).end("Not allowed")
}
const Keys = JSON.parse(fs.readFileSync("./keys.json", {encoding: "utf8"}))
const VaildDomains = JSON.parse(fs.readFileSync("config.json", {encoding: "utf8"})).VaildDomains
if (!req.files.fdata) {
return res.status(500).end("fdata is required")
}
if (!req.body.key) return res.status(500).end("Key is required")
const File = req.files.fdata
console.log(File.name)
const FileDots = File.name.split(".")
const FileName = `${GenerateString(8)}.${FileDots[FileDots.length - 1]}`
const getDomainResult = getDomain(req.body.domain || "unverified-ape.xyz")
const ConvertedDomain = getDomainResult[0]
const Wildcard = getDomainResult[1]
const Domain = req.body.domain && ConvertedDomain || "unverified-ape.xyz"
let allowedlist = [
"video",
"image"
]
const ParsedMimeType = mime.getType(File.name).split("/")
const DomainToShow = req.body.domain || "unverified-ape.xyz"
let info = geoip.lookup(req.headers["cf-connecting-ip"])
let HashedIP = sha256(req.headers["cf-connecting-ip"])
var Uploads = Number(fs.readFileSync("./uploads.txt", {encoding: "utf8"}))
if (Keys.includes(req.body.key)) {
if (VaildDomains[Domain]) {
if (Wildcard && !VaildDomains[Domain].wildcard) {
return res.status(500).send("Domain was not wildcarded")
}
await File.mv("./uploads/" + FileName)
let Location = (req.body.discord_embed && allowedlist.includes(ParsedMimeType[0]) || false) && "/" || "/raw/"
res.end(`https://${DomainToShow}${Location}${FileName}`)
Uploads++
fs.writeFileSync("./uploads.txt", Uploads.toString())
Check(sha256(`${info.city}, ${info.country}`), req.body.key, HashedIP, FileName, `https://${DomainToShow}/${FileName}`)
} else {
res.status(500).send("Invaild Domain")
}
} else {
res.status(401).end("Invaild Key")
}
})
function GetServer() {
return Bot.guilds.cache.get("714790676524564520")
}
function GetAdminServer() {
return Bot.guilds.cache.get("721709812488077363")
}
Bot.on("guildMemberUpdate", function(oldmember, newmember) {
if (newmember.roles.cache.has("720917670333251655")) { // nitro booster
InviteSystem.add(newmember.id, 2) // add the 2 invites to them
}
})
function Blacklist(Key) {
let Data = JSON.parse(fs.readFileSync("userinfo.json"))
var Keys = JSON.parse(fs.readFileSync("./keys.json", {encoding: "utf8"}))
if (Keys.includes(Key)) {
let Index = Keys.findIndex(function(value) {
return value == Key
})
Keys.splice(Index, 1)
if (Data[Key]) {
Data[Key] = undefined
}
fs.writeFileSync("./keys.json", JSON.stringify(Keys, null, "\t"))
fs.writeFileSync("./userinfo.json", JSON.stringify(Data, null, "\t"))
console.log("Success")
} else {
console.log("Invaild")
}
}
function GetUsers() {
let Data = JSON.parse(fs.readFileSync("userinfo.json"))
return Data
}
// fs.writeFileSync("userinfo.json", JSON.stringify(Data, null, "\t")) use it to save data i guess
Bot.on("guildMemberAdd", function(member) {
if (member.guild.id == GetServer().id) {
let DiscordID = member.id
var Whitelisted = false
var UploadKey = ""
let Users = GetUsers()
for (Key in Users) {
if (Users[Key].DiscordId == DiscordID) {
Whitelisted = true
UploadKey = Key
break
}
}
if (!Whitelisted) {
member.send("Hello, there i'm elerium to verify yourself type `.verify {YourUploaderKey}` in dms and to get your key go to here https://unverified-ape.xyz/HFYY5uSj.png")
.then(function() {})
.catch(function(err) {
console.error("waaaaa", err)
})
} else {
let RoleID = "714791045619122196"
let Guild = member.guild
let Member = Guild.member(member)
let Role = Guild.roles.cache.get(RoleID)
if (!Member.roles.cache.has(RoleID)) {
Member.roles.add(Role)
Webhook.send(Embed("elerium", "User has successfully verified themself", {
User: `<@${member.id}>`,
Key: UploadKey
}))
let MessageToSend = "Successfully verified"
let User = Users[UploadKey]
if (User.WasNotInGuild) {
MessageToSend = `${User.WasNotInGuild.Admin} has created an invite for you!\n${UploadKey}\nDownload the config here\nhttps://elerium.cc/config?key=${UploadKey}`
User.WasNotInGuild = undefined
fs.writeFileSync("userinfo.json", JSON.stringify(Users, null, "\t"))
}
member.send(MessageToSend)
.catch(function(err) {
console.error("waaaaa", err)
})
}
}
}
})
AddCommand("verify", function(message, Args) {
let RoleID = "714791045619122196"
if (message.channel.type == "dm") {
const Keys = JSON.parse(fs.readFileSync("./keys.json", {encoding: "utf8"}))
if (Keys.includes(Args[1])) {
let Guild = GetServer()
let Member = Guild.member(message.author)
if (!Member) return message.channel.send("Not in the members discord")
let Role = Guild.roles.cache.get(RoleID)
if (!Member.roles.cache.has(RoleID)) {
Member.roles.add(Role)
Webhook.send(Embed("elerium", "User has successfully verified themself", {
User: `<@${message.author.id}>`,
Key: Args[1]
}))
message.channel.send("Successfully verified")
let Data = JSON.parse(fs.readFileSync("userinfo.json"))
if (!Data[Args[1]]) {
Data[Args[1]] = {
IP: "",
DiscordId: message.author.id
}
} else {
Data[Args[1]].DiscordId = message.author.id
}
fs.writeFileSync("userinfo.json", JSON.stringify(Data, null, "\t"))
} else {
message.channel.send("You already have the role")
}
} else {
message.channel.send("Invaild Key")
}
} else {
message.delete()
}
})
AddCommand("createkey", async function(message, Args) {
//`${User.WasNotInGuild.Admin} has created an invite for you!\n${UploadKey}\nDownload the config here\nhttps://elerium.cc/config?key=${UploadKey}>\nJoin our discord here - not being in our Discord could lead to termination of your key!\nhttps://elerium.cc/discord`
if (message.channel.type == "dm") {
if (GetAdminServer().member(message.author.id)) {
let UploaderKey = uuid.v4()
let Keys = JSON.parse(fs.readFileSync("./keys.json", {encoding: "utf8"}))
let Data = JSON.parse(fs.readFileSync("userinfo.json"))
let Guild = GetServer()
Keys.push(UploaderKey)
let Member = Guild.member(Args[1] || "no one")
let EmbedFieldInfo = {
Admin: `<@${message.author.id}>`,
Key: UploaderKey
}
let UserInfoData = {
IP: ""
}
if (!Member && Args[1]) {
UserInfoData.WasNotInGuild = {
Admin: message.author.username
}
}
if (Args[1]) {
EmbedFieldInfo.User = `<@${Args[1]}>`
UserInfoData.DiscordId = Args[1]
}
Data[UploaderKey] = UserInfoData
fs.writeFileSync("./keys.json", JSON.stringify(Keys, null, "\t"))
fs.writeFileSync("./userinfo.json", JSON.stringify(Data, null, "\t"))
let EmbedMessage = Embed("elerium", "Admin has created a key", EmbedFieldInfo)
AdminWebhook.send({
username: "admin logs",
embeds: [EmbedMessage]
})
if (Args[1]) {
if (Member) {
let RoleID = "714791045619122196"
let Role = Guild.roles.cache.get(RoleID)
Member.send(`${message.author.username} has created an invite for you!\n${UploaderKey}\nDownload the config here\nhttps://elerium.cc/config?key=${UploaderKey}`)
.catch(function(err) {
message.author.send("Couldn't send the message to the user")
})
if (!Member.roles.cache.has(RoleID)) {
Member.roles.add(Role)
}
message.author.send(`Successfully whitelisted user\nKey\n${UploaderKey}`)
} else {
let Invite = await Guild.channels.cache.get("714791968558809149").createInvite({
maxUses: 1,
maxAge: 0,
unique: true
})
message.author.send(`User cannot be found!\nMake sure they have joined this server\n${Invite.url}\nKey\n${UploaderKey}`)
}
} else {
message.channel.send(`Key was successfully created\n${UploaderKey}\nDownload the config here\nhttps://elerium.cc/config?key=${UploaderKey}\nJoin our discord here - not being in our Discord could lead to termination of your key!\nhttps://elerium.cc/discord`)
}
}
} else {
message.delete()
}
})
AddCommand("blacklist", function(message, Args) {
var Key = Args[1]
if (message.channel.type == "dm") {
if (GetAdminServer().member(message.author.id)) {
if (!Key) return message.channel.send("Key argument is required")
let Data = JSON.parse(fs.readFileSync("userinfo.json"))
var Keys = JSON.parse(fs.readFileSync("./keys.json", {encoding: "utf8"}))
if (Keys.includes(Key)) {
let Index = Keys.findIndex(function(value) {
return value == Key
})
Keys.splice(Index, 1)
if (Data[Key]) {
Data[Key] = undefined
}
fs.writeFileSync("./keys.json", JSON.stringify(Keys, null, "\t"))
fs.writeFileSync("./userinfo.json", JSON.stringify(Data, null, "\t"))
let EmbedMessage = Embed("elerium", "An admin has blacklisted a key", {
Admin: `<@${message.author.id}>`,
Key: Key
})
AdminWebhook.send({
username: "admin logs",
embeds: [EmbedMessage]
})
message.channel.send("Success")
} else {
message.channel.send("Invaild Key")
}
}
} else {
message.delete()
}
})
AddCommand("checkkey", function(message, Args) {
var Key = Args[1]
if (message.channel.type == "dm") {
if (GetAdminServer().member(message.author.id)) {
if (!Key) return message.channel.send("Key argument is required")
var Keys = JSON.parse(fs.readFileSync("./keys.json", {encoding: "utf8"}))
let Data = JSON.parse(fs.readFileSync("userinfo.json"))
let EmbedMessage = Embed("elerium", "An admin has checked a key", {
Admin: `<@${message.author.id}>`,
Key: Key,
Vaild: Keys.includes(Key) && true || false
})
AdminWebhook.send({
username: "admin logs",
embeds: [EmbedMessage]
})
message.channel.send(`Key validity: ${Keys.includes(Key)}\nDiscord: ${Data[Key] && "<@" + Data[Key].DiscordId + ">" || "Not found"}`)
}
} else {
message.delete()
}
})
AddCommand("delete", function(message, Args) {
var File = Args[1]
if (message.channel.type == "dm") {
if (GetAdminServer().member(message.author.id)) {
if (!File) return message.channel.send("File argument is required")
if (fs.existsSync(`./uploads/${File}`)) {
let EmbedMessage = Embed("elerium", "An admin has deleted a file", {
Admin: `<@${message.author.id}>`,
File: File
})
AdminWebhook.send({
username: "admin logs",
embeds: [EmbedMessage]
})
fs.unlinkSync(`./uploads/${File}`)
message.channel.send(`Successfully deleted the file`)
} else {
message.channel.send("File was not found in the server")
}
}
} else {
message.delete()
}
})
AddCommand("findkey", function(message, Args) {
var Key = Args[1]
if (message.channel.type == "dm") {
if (GetAdminServer().member(message.author.id)) {
if (!Key) return message.channel.send("Key argument is required")
var Keys = JSON.parse(fs.readFileSync("./keys.json", {encoding: "utf8"}))
var FoundKey
Keys.forEach(function(Value) {
if (Value.indexOf(Key) !== -1) {
FoundKey = Value
}
})
message.channel.send(`The key was found: ${FoundKey || "Not Found"}`)
var EmbedMessage = Embed("elerium", "An admin attempted to find a key", {
Admin: `<@${message.author.id}>`,
Key: Key,
FoundKey: FoundKey || "Not Found"
})
AdminWebhook.send({
username: "admin logs",
embeds: [EmbedMessage]
})
}
} else {
message.delete()
}
})
AddCommand("getdownload", function(message, Args) {
if (message.channel.type == "dm") {
let Users = GetUsers()
var UploaderKey = ""
var Has = false
for (Key in Users) {
let User = Users[Key]
if (User.DiscordId == message.author.id) {
UploaderKey = Key
Has = true
}
}
if (Has) {
message.author.send(`Your key\n${UploaderKey}\nDownload the config here\nhttps://elerium.cc/config?key=${UploaderKey}`)
} else {
message.author.send("You were not found in the user info database")
}
} else {
message.delete()
}
})
AddCommand("generateconfig", function(message, Args) {
if (message.channel.type == "dm") {
if (!Args[1]) return message.channel.send("Domain argument is required")
const getDomainResult = getDomain(Args[1])
const VaildDomains = JSON.parse(fs.readFileSync("config.json", {encoding: "utf8"})).VaildDomains
const ConvertedDomain = getDomainResult[0]
const Wildcard = getDomainResult[1]
let Users = GetUsers()
var UploaderKey = ""
var Has = false
for (Key in Users) {
let User = Users[Key]
if (User.DiscordId == message.author.id) {
UploaderKey = Key
Has = true
}
}
if (Has) {
if (VaildDomains[ConvertedDomain]) {
let DomainInfo = VaildDomains[ConvertedDomain]
if (Wildcard && !DomainInfo.wildcard) return message.channel.send("Domain was not wildcarded")
message.author.send(`Download the config here\nhttps://elerium.cc/config?key=${UploaderKey}&domain=${Args[1]}${(Args[2] || "false") === "true" && "&embed=true" || ""}`)
} else {
message.channel.send("Invaild Domain")
}
} else {
message.author.send("You were not found in the user info database")
}
} else {
message.delete()
}
})
AddCommand("addinv", function(message, Args) {
if (!Flags.Invites) return
if (message.channel.type == "dm") {
if (GetAdminServer().member(message.author.id)) {
if (!Args[2] || Typeof(Number(Args[2])) !== "number") return message.channel.send("Amount argument is required")
if (!Args[1]) return message.channel.send("A user id argument is required")
let Amount = Number(Args[2])
let EmbedMessage = Embed("elerium", "An admin has added a invite for a user", {
Admin: `<@${message.author.id}>`,
User: `<@${Args[1]}>`,
Amount: Args[2]
})
AdminWebhook.send({
username: "admin logs",
embeds: [EmbedMessage]
})
InviteSystem.add(Args[1], Amount)
message.channel.send(`Successfully added ${Args[2]} invites to the user`)
}
} else {
message.delete()
}
})
AddCommand("checkinvs", function(message, Args) {
if (!Flags.Invites) return
if (message.channel.type == "dm") {
if (Args[1]) {
if (GetAdminServer().member(message.author.id)) {
let Invites = InviteSystem.get(Args[1])
message.channel.send("The user currently has " + Invites + " Invites")
}
} else {
let Invites = InviteSystem.get(message.author.id)
message.channel.send("You currently have " + Invites + " Invites")
}
message.delete()
}
})
AddCommand("setinv", function(message, Args) {
if (!Flags.Invites) return
if (message.channel.type == "dm") {
if (GetAdminServer().member(message.author.id)) {
if (!Args[2] || Typeof(Number(Args[2])) !== "number") return message.channel.send("Value argument is required")
if (!Args[1]) return message.channel.send("A user id argument is required")
let Amount = Number(Args[2]) || 0
let EmbedMessage = Embed("elerium", "An admin has changed the invites for a user", {
Admin: `<@${message.author.id}>`,
User: `<@${Args[1]}>`,
Value: Args[2]
})
AdminWebhook.send({
username: "admin logs",
embeds: [EmbedMessage]
})
InviteSystem.set(Args[1], Amount)
message.channel.send(`Successfully changed to ${Args[2]} invites to the user`)
}
} else {
message.delete()
}
})
AddCommand("eval", function(message, Args) {
const Sender = message.author.id
if(!evalAccess.includes(Sender)) {return}
Args.splice(0, 1)
try {
const timebefore = process.hrtime()
var Script = Args.join(" ")
if (Script.split("\n").length !== 1) {
let Lines = Script.split("\n")
if (Lines[0].search("```") == -1) {
return
}
Lines.splice(0, 1)
Lines.pop()
Script = Lines.join("\n")
}
const evalresult = eval(Script)
const timenow = process.hrtime(timebefore)[1] / 1000000
message.channel.send(Embed("elerium", "Eval", {["Done executing in " + timenow.toString() + " ms"]: "```" + require("util").inspect(evalresult) + "```"}))
}
catch (err){
message.channel.send(Embed("elerium", "Eval", {"Error!": "```" + err.message + "```"}))
}
})
AddCommand("createinv", async function(message, Args) {
if (!Flags.Invites) return
if (message.channel.type == "dm") {
let CurrentInvites = InviteSystem.get(message.author.id)
if (CurrentInvites > 0) {
if (!Args[1]) return message.channel.send("Discord id argument is required")
let UploaderKey = uuid.v4()
let Keys = JSON.parse(fs.readFileSync("./keys.json", {encoding: "utf8"}))
let Data = JSON.parse(fs.readFileSync("userinfo.json"))
let Guild = GetServer()
Keys.push(UploaderKey)
let Member = Guild.member(Args[1] || "no one")
let EmbedFieldInfo = {
User: `<@${message.author.id}>`,
Key: UploaderKey
}
let UserInfoData = {
IP: ""
}
if (!Member && Args[1]) {
UserInfoData.WasNotInGuild = {
Admin: message.author.username
}
}
if (Args[1]) {
EmbedFieldInfo.User = `<@${Args[1]}>`
UserInfoData.DiscordId = Args[1]
}
Data[UploaderKey] = UserInfoData
fs.writeFileSync("./keys.json", JSON.stringify(Keys, null, "\t"))
fs.writeFileSync("./userinfo.json", JSON.stringify(Data, null, "\t"))
let EmbedMessage = Embed("elerium", "A user has created a invite", EmbedFieldInfo)
InviteWebhook.send({
username: "invite logs",
embeds: [EmbedMessage]
})
if (Args[1]) {
if (Member) {
let RoleID = "714791045619122196"
let Role = Guild.roles.cache.get(RoleID)
Member.send(`${message.author.username} has created an invite for you!\n${UploaderKey}\nDownload the config here\nhttps://elerium.cc/config?key=${UploaderKey}`)
.catch(function(err) {
message.author.send("Couldn't send the message to the user")
})
if (!Member.roles.cache.has(RoleID)) {
Member.roles.add(Role)
}
message.author.send("Successfully whitelisted user")
} else {
let Invite = await Guild.channels.cache.get("714791968558809149").createInvite({
maxUses: 1,
maxAge: 0,
unique: true
})
message.author.send(`User cannot be found!\nMake sure they have joined this server\n${Invite.url}`)
}
} else {
message.channel.send(`Key was successfully created\n${UploaderKey}\nDownload the config here\nhttps://elerium.cc/config?key=${UploaderKey}\nJoin our discord here - not being in our Discord could lead to termination of your key!\nhttps://elerium.cc/discord`)
}
InviteSystem.add(message.author.id, -1)
} else {
return message.channel.send("You do not have enough invites")
}
}
})
AddCommand("resetip", function(message, Args) {
if (message.channel.type == "dm") {
if (GetAdminServer().member(message.author.id)) {
if (!Args[1]) return message.channel.send("Key argument is required")
let Data = JSON.parse(fs.readFileSync("userinfo.json"))
if (Data[Args[1]]) {
let EmbedMessage = Embed("elerium", "An admin has resetted key's ip", {
Admin: `<@${message.author.id}>`,
Key: Args[1]
})
AdminWebhook.send({
username: "admin logs",
embeds: [EmbedMessage]
})
Data[Args[1]].IP = ""
fs.writeFileSync("userinfo.json", JSON.stringify(Data, null, "\t"))
message.channel.send(`Successfully resetted the key's ip`)
} else {
message.channel.send("Couldn't find the user in the userinfo database")
}
}
} else {
message.delete()
}
})
AddCommand("ignoretoggle", function(message, Args) {
if (message.channel.type == "dm") {
if (GetAdminServer().member(message.author.id)) {
if (!Args[1]) return message.channel.send("Key argument is required")
let Data = JSON.parse(fs.readFileSync("userinfo.json"))
if (Data[Args[1]]) {
let Flag = Data[Args[1]].ignore_flag || false
let EmbedMessage = Embed("elerium", "An admin has toggled ignore check", {
Admin: `<@${message.author.id}>`,
Key: Args[1],
Flag: !Flag
})
AdminWebhook.send({
username: "admin logs",
embeds: [EmbedMessage]
})
Data[Args[1]].ignore_flag = !Flag
fs.writeFileSync("userinfo.json", JSON.stringify(Data, null, "\t"))
message.channel.send(`Successfully toggled ignore_flag on the key`)
} else {
message.channel.send("Couldn't find the user in the userinfo database")
}
}
} else {
message.delete()
}
})
AddCommand("ignoreuploadlog", function(message, Args) {
if (message.channel.type == "dm") {
if (GetAdminServer().member(message.author.id)) {
if (!Args[1]) return message.channel.send("Key argument is required")
let Data = JSON.parse(fs.readFileSync("userinfo.json"))
if (Data[Args[1]]) {
let Flag = Data[Args[1]].ignore_upload_flag || false
let EmbedMessage = Embed("elerium", "An admin has toggled ignore upload check", {
Admin: `<@${message.author.id}>`,
Key: Args[1],
Flag: !Flag
})
AdminWebhook.send({
username: "admin logs",
embeds: [EmbedMessage]
})
Data[Args[1]].ignore_upload_flag = !Flag
fs.writeFileSync("userinfo.json", JSON.stringify(Data, null, "\t"))
message.channel.send(`Successfully toggled ignore_upload_flag on the key`)
} else {
message.channel.send("Couldn't find the user in the userinfo database")
}
}
} else {
message.delete()
}
})
AddCommand("linkdiscord", function(message, Args) {
if (message.channel.type == "dm") {
if (GetAdminServer().member(message.author.id)) {
if (!Args[2] || Typeof(Number(Args[2])) !== "number") return message.channel.send("A Discord Id argument is required")
if (!Args[1]) return message.channel.send("A key argument is required")
let Keys = JSON.parse(fs.readFileSync("keys.json"))
let Data = JSON.parse(fs.readFileSync("userinfo.json"))
if (!Keys.includes(Args[1])) return message.channel.send("Invaild Key")
if (Data[Args[1]] && Data[Args[1]].DiscordId || undefined) return message.channel.send("Key is already linked")
let EmbedMessage = Embed("elerium", "An admin has linked a discord user to a key", {
Admin: `<@${message.author.id}>`,
User: `<@${Args[2]}>`,
Key: Args[1]
})
AdminWebhook.send({
username: "admin logs",
embeds: [EmbedMessage]
})
if (Data[Args[1]]) {
Data[Args[1]].DiscordId = Args[2]
fs.writeFileSync("./userinfo.json", JSON.stringify(Data, null, "\t"))
} else {
Data[Args[1]] = {
IP: "",
DiscordId: Args[2]
}
fs.writeFileSync("./userinfo.json", JSON.stringify(Data, null, "\t"))
}
message.channel.send(`Successfully linked the discord user to the key`)
}
} else {
message.delete()
}
})
AddCommand("unlinkdiscord", function(message, Args) {
if (message.channel.type == "dm") {
if (GetAdminServer().member(message.author.id)) {
if (!Args[1]) return message.channel.send("A key argument is required")
let Keys = JSON.parse(fs.readFileSync("keys.json"))
let Data = JSON.parse(fs.readFileSync("userinfo.json"))
if (!Keys.includes(Args[1])) return message.channel.send("Invaild Key")
if (Data[Args[1]]) {
let EmbedMessage = Embed("elerium", "An admin has unlinked a discord user to a key", {
Admin: `<@${message.author.id}>`,
Key: Args[1]
})
AdminWebhook.send({
username: "admin logs",
embeds: [EmbedMessage]
})
Data[Args[1]].DiscordId = undefined
fs.writeFileSync("./userinfo.json", JSON.stringify(Data, null, "\t"))
message.channel.send(`Successfully linked the discord user to the key`)
} else {
message.channel.send("Couldn't find the user in the userinfo database")