-
Notifications
You must be signed in to change notification settings - Fork 5
/
server.js
3144 lines (2516 loc) · 82.9 KB
/
server.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 express = require("express");
const Nuggies = require("nuggies");
const managerdb = require("./Database/main.js");
const manager = new managerdb("./all.json");
const Discord2 = require("discord.js");
const Client2 = new Discord2.Client();
const Util = require("./util/eventloader.js")(Client2);
const tools = require("./greesyapi.js");
const mongoose = require("mongoose");
const tailwindcss = require('tailwindcss')
//app.use('/assets', express.static('server/web/html/'))
const backup = () => {
fs.copyFile(
"./json.sqlite",
`./backups/ • ${moment().format("D-M-YYYY • H.mm.ss")} • nego.sqlite`,
err => {
if (err) return console.log(err);
console.log("Database Backuped.");
var Embid = new discord.MessageEmbed()
.setTitle("Greesy")
.setColor("#3437eb").setDescription(`
Greesy Database Manager
** Database Backuped **
By : System
Time: ${moment().format("D-M-YYYY • H.mm.ss")}
`);
nico.channels.cache.get("868378969140002816").send(Embid);
}
);
}; //Nuggies.giveaways.connect(process.env.mongoURI);
// CUSTOM CLIENTS
//var dc2 = require("discord.js");
//const clientDash = new discord.Client();
//Dashboard Ping
/*
setInterval(function(){
var pingDash = nico.ws.ping+2;
var request = require("request");
request("https://greesy.negodev.tk/");
nico.ws.ping+2
db.set(`dashPing`,pingDash);
}, 5);*/
//LOADERS
console.clear();
console.log(`
□□□□□□□□□□□□□□□
GREESY
□□□□□□□□□□□□□□□
Loading Project ....
□□□□□□□□□□□□□□□
`);
console.log("");
console.log(`
□□□□□□□□□□□□□□□
Greesy Loaded !
□□□□□□□□□□□□□□□
`);
console.log("");
console.log("");
console.log("");
console.log("");
console.log("");
console.log("");
console.log("");
console.log("");
console.log("Loaded Greesy Api");
console.log("");
console.log("");
console.log("");
console.log("");
console.log("");
/*
MONGO DB
*/
mongoose
.connect(
"mongodb+srv://greesy:greesydb1@greesymongo.4jmok.mongodb.net/myFirstDatabase?retryWrites=true&w=majority",
{
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
useFindAndModify: false,
autoIndex: false
}
)
.then(() => {
console.log("[Greesy]: Mongoose successfully connected.");
})
.catch(err =>
console.log("[Greesy]: An error occurred while connecting mongoose.", err)
);
const app = express();
const _ = require("lodash");
const discord = require("discord.js");
//require('discord-buttons')(nico);
const nico = new discord.Client();
const logs = require("discord-logs");
logs(nico);
const path = require("path");
const { Player } = require("discord-player");
// Create a new Player (you don't need any API Key)
const player = new Player(nico);
nico.player = player;
const fs = require("fs");
const url = require("url");
const db = require("quick.db");
const moment = require("moment");
//db.add("kull",1);
require("discord-buttons")(nico);
const { GiveawaysManager } = require("discord-giveaways");
const cekilis = new GiveawaysManager(nico, {
storage: "./giveaways.json",
updateCountdownEvery: 10000,
default: {
botsCanWin: false,
embedColor: "RANDOM",
reaction: "🎉"
}
});
nico.giveawaysManager = cekilis;
var bodyParser = require("body-parser");
app.use(bodyParser.json());
app.use(
bodyParser.urlencoded({
extended: true
})
);
app.use("/assets", express.static("server/web/css/"));
/*
* CUSTOM SETTINGS
*/
//require("./testserver.js")(nico);
require("./custom_discord/inlineReply");
/*
* Rastgele Kod Oluşturma
*/
function Random(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 userFetch(id) {
if (!id) return "kullanici id gir";
var res = nico.users.cache.get(id);
return res;
}
function createRole(roleName, rolePermissions, roleColor, guildID) {
let sunucu = nico.guilds.cache.get(guildID);
sunucu.roles.create({
data: {
name: roleName,
color: roleColor,
permissions: rolePermissions
}
});
return "Created Role";
}
var Ddos = require('ddos')
var ddos = new Ddos({burst:3,limit:4,maxcount:15,maxexpiry:120,checkinterval:1,testmode:false,responseStatus:429,errormessage:'Greesy Bot DDOS Protocole Active ! '});
app.use(ddos.express);
app.use(async (req, res, next) => {
var getIP = require("ipware")().get_ip;
var ipInfo = getIP(req);
var geoip = require("geoip-lite");
var ip = ipInfo.clientIp;
var geo = geoip.lookup(ip);
if (geo) {
//let sitedatas = require("./server/mongodb/countrydb.js")
//await sitedatas.updateOne({ id: config.clientID }, {$inc: {[`country.${geo.country}`]: 1} }, { upsert: true})
/* var sDt = {
country : `country.${geo.country}`
}
await db.push(`country`,{sDt});*/
}
return next();
});
const http = require("http").createServer(app);
const io = require("socket.io")(http);
io.on("connection", socket => {
io.emit("userCount", io.engine.clientsCount);
});
/*http.listen(3000, () => {
console.log("[Greesy]: Website running on 80 port.")
});*/
//Routes
const authRouter = require("./server/auth.js");
//const serverRouter = require("./server/index.js");
//*******
//CONFIG
const ayar = {
durum: "💥 Greesy | !help & !stat | 👥 Autorole & Counter | ⚡ Plugins And More...."
};
const config = {
siteismi: "Greesy | Best Utility Bot",
sunucuid: "858052041507209266",
callback: "https://greesy.negodev.tk/l/callback",
secret: "IWgw_oextZSp83XJabSRnTqD759LMQB3",
clientID: "817456729558220812",
logkanalid: "859899078624149516",
kurucurolid: "682607343707488388",
admins: ["682607343707488388", "682607343707488388", "852830717037510687"],
evalyetki: "682607343707488388",
evalyetki1: "",
evalyetki2: "852853360612605952",
evalyetki3: "",
logkanalid: "859899078624149516",
prefix: "!",
embedbanner:
"https://i.pinimg.com/originals/30/88/a3/3088a3ebaf713600adacd00397ee410d.png"
};
//Server
//BOT
nico.on("ready", () => {
//require("./testserver.js")(nico)
const Discord = require("discord.js");
nico.user.setActivity(ayar.durum, { type: "WATCHING" });
/* const kategori = "869293230942994473";
var kontrol = kategori
.forEach(x => {
x.name > "Channels |";
})*/
const kanalone = "869297523062358036";
kanalone
.setName(`Channels - ${nico.channels.cache.size}`)
.then(presence => {
/*
var mesajj = mesaj;
if(mesajj){
.replace("")
} */
const embed = new Discord.MessageEmbed()
.setColor("#0099ff")
.setTitle("**Durum Bildirgesi**")
.setDescription(
`Durumum **${nico.user.presence.activities[0].name}** \n Tür **${nico.user.presence.activities[0].type}** olarak belirlendi.`
)
.setTimestamp();
// .setImage(`${nico.user.avatarURL}`);
// .replace("WATCHING", "izliyor")
// channel.send(embed);
nico.channels.cache
.get("859899078624149516")
.send("Succes!", { embed: embed });
}); //burda replace yi nasıl yapmalıyım arkadaşlaar
/* console.log(`
****************
Server Başlatıldı PORT ${process.env.PORT}
Bot ${nico.user.username} Ismiyle Discorda Bağlandı
*************
`);*/
// nico.user.setActivity(`🌎 !help | !stat `);
setInterval(() => backup(), 1000 * 60 * 60 * 24); // Günde bir kere yedekler.
});
nico.on("guildCreate", guild => {
if (db.has(`blacklist.${guild.ownerID}`)) return guild.leave();
});
nico.on("guildDelete", guild => {
fs.copyFile(
"./json.sqlite",
`./Backups_Database/ • ${moment().format("D-M-YYYY • H.mm.ss")} • ${
guild.name
}.sqlite`,
err => {
if (err) return console.log(err);
console.log("Database Backuped.");
}
);
var calc =
db.fetch(`counterAdd_${guild.id}`) +
db.fetch(`counterNum_${guild.id}`) +
db.fetch(`counter_${guild.id}`);
db.delete(`counterAdd_${guild.id}`);
db.delete(`counter_${guild.id}`);
db.delete(`counterNum_${guild.id}`);
var nego = new discord.MessageEmbed()
.setTitle("Greesy")
.setDescription(
`
** Greesy Database Manager **
== ${guild.name} Named Server Database Has Been reset
== Reason : The Server Was Reset For Deletion To Keep Memory In The Database ==
== Note: Contact Moderators to Get Data Back! ==
== Deleted Server's Information ==
Owner : \`<@${guild.ownerID}>\`
MemberCount: \`${guild.memberCount}\`
Roles Size : ${guild.roles.cache.size}
Space Size of the Server in the Database: ${calc}
== ==
`
)
.setColor("#3437eb");
nico.channels.cache.get("868378969140002816").send(nego);
});
nico.on("clickbutton", dugme => {
Nuggies.giveaways.buttonclick(nico, dugme);
});
/*
* Command Handler
*/
const log = message => {
console.log(`${message}`);
};
/*=======================================================================================*/
require("events").EventEmitter.prototype._maxListeners = 100;
nico.komutlar = new discord.Collection();
nico.aliases = new discord.Collection();
fs.readdir("./komutlar/", (err, files) => {
if (err) console.error(err);
console.log(`(!) Bota ${files.length} komut başarıyla yüklendi.`);
files.forEach(f => {
if (!f.endsWith(".js")) return;
let props = require(`./komutlar/${f}`);
if (!props.help) return;
nico.komutlar.set(props.help.name, props);
props.conf.aliases.forEach(alias => {
nico.aliases.set(alias, props.help.name);
global.commands = files;
});
});
});
nico.on("message", async message => {
let p = config.prefix;
let client = message.client;
if (message.author.bot) return;
if (!message.content.startsWith(p)) return;
let command = message.content.split(" ")[0].slice(p.length);
let params = message.content.split(" ").slice(1);
let cmd;
if (client.komutlar.has(command)) {
cmd = client.komutlar.get(command);
} else if (client.aliases.has(command)) {
cmd = client.komutlar.get(client.aliases.get(command));
}
if (cmd) {
const karaliste = db.fetch(`blacklist.${message.author.id}`);
const serverkara = db.fetch(`blacklist.${message.guild.id}.sunucu`)
const xd = require("discord-buttons");
const buton1 = new xd.MessageButton()
.setStyle("url", "green")
.setLabel("Contact")
.setURL("https://greesy.negodev.tk/ticket/");
if (karaliste == true)
return message.channel.send(
`<:hayirbei:867465654960128010> | **You Have Been Blacklisted by My Owners! If this may be wrong, contact Support**. `,
{ buttons: buton1 }
);
if(serverkara == true) return message.channel.send("<:hayirbei:867465654960128010> | **This Server Have Been BlackListed in My Owners**! \n `Members Not Use My Commands!` ", {buttons: buton1})
const kapalımıkardesbu = await db.fetch(
`kapalı.${cmd.help.name}.${message.guild.id}`
);
if (kapalımıkardesbu) return;
// db.fetch(`karaliste_${message.author.id}` === true ) // message.reply("")
/* } else {
const laura = [];
client.commands.forEach(dropinnem => {
laura.push(dropinnem.help.name);
dropinnem.conf.aliases.forEach(abcdef => laura.push(abcdef));
});
const rifleman = require('string-similarity').findBestMatch(command, laura);
message.channel.send(`That's What You Mean ? ${rifleman.bestMatch.target}`)
*/
}
cmd.run(client, message, params, p);
});
const clean = text => {
if (typeof text === "string")
return text
.replace(/`/g, "`" + String.fromCharCode(8203))
.replace(/@/g, "@" + String.fromCharCode(8203));
else return text;
};
nico.on("message", async message => {
const args = message.content.split(" ").slice(1);
if (message.content.startsWith("!eval")) {
if (
![
config.evalyetki,
config.evalyetki1,
config.evalyetki2,
config.evalyetki3,
"661827402069966869"
].includes(message.author.id)
)
return;
try {
const code = args.join(" ");
let evaled = eval(code);
if (message.content.includes("nico.token"))
return message.reply("al `31313313131311`");
if (typeof evaled !== "string")
evaled = await require("util").inspect(evaled);
await message.channel.send(clean(evaled), { code: "xl" });
} catch (err) {
await message.channel.send(
`\`Hata Oluştu \n \` \`\`\`xl\n${clean(err)}\n\`\`\``
);
}
}
});
const Strategy = require("passport-discord").Strategy;
const session = require("express-session");
const passport = require("passport");
app.use('/assets', express.static('server/web/html/css/'))
app.use(express.static(path.join(__dirname, 'public')));
/*
* Burayi Degismiyin
*/
//settings
app.set(express.json());
//Rate Limit
const rateLimit = require("express-rate-limit");
var MongoStore = require("rate-limit-mongo");
const reqLimitter = rateLimit({
store: new MongoStore({
uri:
"mongodb+srv://greesy:greesydb1@greesymongo.4jmok.mongodb.net/myFirstDatabase?retryWrites=true&w=majority",
collectionName: "rate-limit",
expireTimeMs: 60 * 60 * 1000,
resetExpireDateOnChange: true
}),
windowMs: 60 * 60 * 1000,
max: 4,
message: {
error: true,
message:
"Too many requests, you have been rate limited. Please try again in one hour."
}
});
function gGiris(req, res, next) {
if (req.isAuthenticated()) return next();
req.session.backURL = req.url;
res.redirect("/l/");
}
function bakimCheck(req, res, next) {
var bakimDB = db.fetch(`bakim`);
if (bakimDB == false) return next();
if (bakimDB == true) {
render(res, req, "bakim.ejs");
}
}
function karalisteCheck(req, res, next) {
if (req.isAuthenticated()) {
var karalisteDB = db.fetch(`karaliste_${req.user.id}`);
if (karalisteDB == true) {
render(res, req, "karaliste.ejs");
}
}
if (karalisteDB == false) {
next();
}
}
function adminCheck(req, res, next) {
if (req.isAuthenticated()) {
var ussr = req.user.id;
if (ussr == config.kurucurolid.includes())
return (
res.redirect("/404") && db.add(`adminpanel_izinsiz_giris_sayi`, +1)
);
next();
db.add(`adminpanel_giris_sayi`, +1);
}
}
const dataDir = path.resolve(`${process.cwd()}${path.sep}server`);
const templateDir = path.resolve(
`${dataDir}${path.sep}web${path.sep}html${path.sep}`
);
const render = (res, req, template, data = {}) => {
const baseData = {
bot: nico,
path: req.path,
user: req.isAuthenticated() ? req.user : null
};
res.render(
path.resolve(`${templateDir}${path.sep}${template}`),
Object.assign(baseData, data)
);
};
app.set("view engine", "ejs");
//AUTH
passport.use(
new Strategy(
{
clientID: "817456729558220812",
clientSecret: config.secret,
callbackURL: config.callback,
scope: ["identify", "guilds", "guilds.join"]
},
(accessToken, refreshToken, profile, done) => {
process.nextTick(() => done(null, profile));
}
)
);
passport.serializeUser((user, done) => {
done(null, user);
});
passport.deserializeUser((obj, done) => {
done(null, obj);
});
app.use(
session({
secret: "kardespro",
resave: false,
saveUninitialized: false
})
);
app.use(passport.initialize());
app.use(passport.session());
/*
app.get("/l", passport.authenticate("discord", {
scope: ["identify", "guilds"]
}));
app.get("/l/callback", passport.authenticate("discord", { failureRedirect: "/l" }), (req, res) => {
const anasunucu = nico.guilds.cache.get(config.sunucuid);
var ab_free = db.fetch(`abonelik_${req.user.id}`,"free");
var ab_var = db.fetch(`abonelik_${req.user.id}`,"premium");
if(ab_free) return res.redirect("/");
if(ab_var) return res.redirect("/");
res.redirect("/");
db.set(`abonelik_${req.user.id}`,"free");
});
*/
// FAST Login API
app.get(
"/l/",
(req, res, next) => {
if (req.session.backURL) {
req.session.backURL = req.session.backURL;
} else if (req.headers.referer) {
const parsed = url.parse(req.headers.referer);
if (parsed.hostname === app.locals.domain) {
req.session.backURL = parsed.path;
}
} else {
req.session.backURL = "/";
}
next();
},
passport.authenticate("discord", { prompt: "none" })
);
app.get(
"/l/callback",
passport.authenticate("discord", { failureRedirect: "/l/" }),
async (req, res) => {
let banned = await db.fetch(`banned_${req.user.id}`);
if (banned) {
nico.users.fetch(req.user.id).then(async a => {
nico.channels.cache.get(config.logknalid).send(
new discord.MessageEmbed()
.setAuthor(a.username, a.avatarURL({ dynamic: true }))
.setThumbnail(a.avatarURL({ dynamic: true }))
.setColor("RED")
.setDescription(
`[**${a.username}**#${a.discriminator}]() isimli kullanıcı **siteye** giriş yapmaya çalıştı fakat siteden engellendiği için giriş yapamadı.`
)
.addField("Username", a.username)
.addField("User ID", a.id)
.addField("User Discriminator", a.discriminator)
);
});
req.session.destroy(() => {
res.json({
login: false,
message: "You have been blocked from Greesy.",
logout: true
});
req.logout();
});
} else {
try {
const request = require("request");
request({
url: `https://discordapp.com/api/v8/guilds/${config.server.id}/members/${req.user.id}`,
method: "PUT",
json: { access_token: req.user.accessToken },
headers: { Authorization: `Bot ${nico.token}` }
});
} catch {}
res.redirect(req.session.backURL || "/");
nico.users.fetch(req.user.id).then(async a => {
nico.channels.cache.get(config.logkanalid).send(
new discord.MessageEmbed()
.setAuthor(a.username, a.avatarURL({ dynamic: true }))
.setThumbnail(a.avatarURL({ dynamic: true }))
.setColor("GREEN")
.setDescription(
`[**${a.username}**#${a.discriminator}]() Login In Website!`
)
.addField("Username", a.username)
.addField("User ID", a.id)
.addField("User Discriminator", a.discriminator)
);
var ab_free = db.fetch(`abonelik_${req.user.id}`, "free");
var ab_var = db.fetch(`abonelik_${req.user.id}`, "premium");
if (ab_free) return res.redirect("/");
if (ab_var) return res.redirect("/");
// res.redirect("/");
db.set(`abonelik_${req.user.id}`, "free");
var essek = db.fetch(`blacklist.${req.user.id}`);
if (essek == true)
return res.json({
error: "You Are Added Blacklist , You don't use website and bot . "
});
});
}
}
);
app.get("/logout", (req, res) => {
req.logOut();
res.redirect("/");
});
// SAYFALAR
app.use("/t", require("./server/routers/index.js"));
app.use("/blogt", require("./server/routers/blog.js"));
//app.use("*",require("./server/routers/404.js"));
app.use("/dashtest", require("./server/routers/dashboard.js"));
const getDurationInMilliseconds = start => {
const NS_PER_SEC = 1e9;
const NS_TO_MS = 1e6;
const diff = process.hrtime(start);
return (diff[0] * NS_PER_SEC + diff[1]) / NS_TO_MS;
};
setInterval(function() {
const start = process.hrtime();
const durationInMilliseconds = getDurationInMilliseconds(start);
db.set(`indexPing`, durationInMilliseconds.toLocaleString());
}, 3600000);
/*
Pages
*/
/*var getIP = require("ipware")().get_ip;
var ipInfo = getIP(req);
var geoip = require("geoip-lite");
var ip = ipInfo.clientIp;
*/
app.get("/", bakimCheck, (req, res) => {
var getIP = require("ipware")().get_ip;
var ipInfo = getIP(req);
var geoip = require("geoip-lite");
var ip = ipInfo.clientIp;
const start = process.hrtime();
const durationInMilliseconds = getDurationInMilliseconds(start);
res.on("finish", () => {
console.log(
`${req.method} ${
req.originalUrl
} [FINISHED] ${durationInMilliseconds.toLocaleString()} ms`
);
db.set(`indexPing`, durationInMilliseconds.toLocaleString());
});
var fetchComment = db.fetch(`commenttest`);
var langPage = db.fetch(`pageLang_${ipInfo.clientIp}`);
var tr = require("./langs/tr/index.json");
/*if(langPage == "tr"){
// res.json(`${ipInfo.clientIp}`);
render(res, req, "index.ejs", {
kardesproclient: nico,
fetchComment,
config,
lang: tr,
ping:durationInMilliseconds.toLocaleString()
});
}*/
var lang;
var anc = db.fetch(`duyuru`);
render(res, req, "index.ejs", {
kardesproclient: nico,
fetchComment,
config,
langPage,
tr,
anc: anc,
ping: durationInMilliseconds.toLocaleString()
});
});
app.get("/cmds", bakimCheck, (req, res) => {
const start = process.hrtime();
const durationInMilliseconds = getDurationInMilliseconds(start);
res.on("finish", () => {
console.log(
`${req.method} ${
req.originalUrl
} [FINISHED] ${durationInMilliseconds.toLocaleString()} ms`
);
db.set(`cmdsPing`, durationInMilliseconds.toLocaleString());
});
render(res, req, "commands.ejs", {
ping: durationInMilliseconds.toLocaleString(),
config
});
});
//Beta
app.get("/new", bakimCheck, gGiris, (req, res) => {
const cmm = db.fetch(`commenttest`);
var beta = db.fetch(`beta_${req.user.id}`);
if (!beta) return res.redirect("/");
render(res, req, "newindex.ejs", { cmm, nego: nico });
});
app.get("/new2", (req, res) => {
const cmm = db.fetch(`commenttest`);
render(res, req, "newindex2.ejs", { cmm, nego: nico });
});
app.get("/new3", (req, res) => {
const cmm = db.fetch(`commenttest`);
render(res, req, "nicat.ejs", { cmm, nego: nico });
});
app.get("/promo", gGiris , (req, res) => {
const cmm = db.fetch(`commenttest`);
const fetchInventory = db.fetch(`promocodeInventory_${req.user.id}`);
render(res, req, "promo.ejs", { cmm, nego: nico , config , fetchInventory });
});
//Profil
app.get("/profile", (req,res) => {
});
app.get("/users/:userID", (req,res) => {
var nego = nico.users.cache.get(req.params.userID);
if(!nego) return res.json({error: "No User Data Found"});
//Data
var Mod = nico.guilds.cache.get("838099680276512778").members.cache.get(req.params.userID).roles.cache.has("863849390611497001");
var owner = nico.guilds.cache.get("838099680276512778").members.cache.get(req.params.userID).roles.cache.has("860623102123442227");
var bot = nico.users.cache.get(req.params.userID).bot;
var bio = db.fetch(`bio_${req.params.userID}`);
var rozetler = nico.users.cache.get(req.params.userID).flags.toArray()
var ismi = nico.users.cache.get(req.params.userID).username;
var disc = nico.users.cache.get(req.params.userID).discriminator;
var avatar = nico.users.cache.get(req.params.userID).displayAvatarURL();
var p = nico.users.cache.get(req.params.userID);
render(res,req, "user-profile.ejs",{
Mod,
p,
config,
owner,
bot,
bio,
rozetler,
ismi,
disc,
avatar
});
});
//Beta
app.get("/stat/", bakimCheck, (req, res) => {
var client = nico;
const start = process.hrtime();
const durationInMilliseconds = getDurationInMilliseconds(start);
res.on("finish", () => {
console.log(
`${req.method} ${
req.originalUrl
} [FINISHED] ${durationInMilliseconds.toLocaleString()} ms`
);
db.set(`statPing`, durationInMilliseconds.toLocaleString());
});
render(res, req, "stat.ejs", {
nego: client,
ping: durationInMilliseconds.toLocaleString(),
config
});
});
app.get("/index.html", (req, res) => {
var client = nico;
//render(res, req, "stat.ejs", {nego:client} );
res.json("Al Sana HTML 🤣");
});
/*
* Serverlist
*/
app.get("/servers", (req, res) => {
var popularforvotes = db.fetch(`popVotes`);
var usersSizePop = nico.guilds.cache.filter(m => m.memberCount > 500);
//usersSizePop.forEach(x=> { x.name})
var onlineUsersSize = nico.guilds.cache.filter(
m => m.user.presence.status === "online"
);
var dndUsersSize = nico.guilds.cache.filter(
m => m.user.presence.status === "dnd"
);
var idleUsersSize = nico.guilds.cache.filter(
m => m.user.presence.status === "idle"
);
var verifiedServers = db.fetch(`verifiedServers`);
var publicServers = db.fetch(`publicServer`);
var chatServers = db.fetch(`chatserver`);
if (
!popularforvotes &&
usersSizePop &&
onlineUsersSize &&
dndUsersSize &&
idleUsersSize &&
verifiedServers &&
publicServers &&
chatServers
)
return res.json({ error: "Database Error ! Not Found " });