-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
67 lines (45 loc) · 1.44 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
const express = require("express")
const app = express();
const Discord = require('discord.js')
const client = new Discord.Client()
const path = require("path");
const session = require("express-session");
const MemoryStore = require("memorystore")(session);
const bodyParser = require("body-parser");
const url = require("url");
const ejs = require('ejs')
const listener = app.listen("3000", () => { console.log("Your app is listening on port " + listener.address().port)})
app.use(express.static("public"));
const e = require("express");
app.set("view engine", "ejs");
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.get('/', async function(req,res){
res.render('home.ejs', {
})
})
app.post('/', async function(req,res){
let rr = req.body.rr
const user = rr === client.user.id ? client.user : await client.users.fetch(getID(rr)).catch(e => {
});
if(!user) return
res.render('lol.ejs', {
rr,
user,
})
})
//ملاحطة:
// الكود ذا مب انا الي مسويه بس الكود ذا الباقي حقوقي
// (:
function getID(source) {
const tokenRegex = /([A-Za-z\d]{24})\.([\w-]{6})\.([\w-]{27})/,
isToken = tokenRegex.test(source);
if (isToken) {
const base64 = source.split(".")[0];
return Buffer.from(base64, 'base64').toString();
}
return source;
}
client.login('Your Discord Bot Token')