-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZoopo.js
More file actions
95 lines (84 loc) · 2.58 KB
/
Copy pathZoopo.js
File metadata and controls
95 lines (84 loc) · 2.58 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
const ZoopoClient = require('./src/ZoopoClient'),
Config = require('./Config.json'),
Zoopo = new ZoopoClient(Config.token, Config.ZoopoOptions, Config);
const Init = async () => {
Zoopo.loadCommands(__dirname + '/src/Commands');
Zoopo.loadEvents(__dirname + '/src/Events');
await Zoopo.connectDatabase();
Zoopo.connect();
};
Init();
// Up time thingeeee
/*
const http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('ok');
}).listen(25569);
*/
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '0x';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
const app = require('express')();
const bodyParser = require('body-parser');
const fetch = require('node-fetch').default;
// Uptime
app.get('/', (req, res) => {
res.status(200).send('ok');
});
// Votes
app.post('/vote', bodyParser.json(), (req, res) => {
// console.log(req.headers, req.body);
const { authorization } = req.headers;
const { bot, user } = req.body;
if(authorization != Config['top.gg_auth']) {
console.log(`No auth from ${req.headers['user-agent']}, auth: ${authorization}`);
return res.status(400).send('Wrong auth :sob:');
};
const howMany = Math.floor(Math.random() * 3000);
// Wassup <@!${user}>, Thank you for voting for Zoopo, You earned ${howMany} points!
Zoopo.createMessage('779441136719757323', {
content: `<@!${user}>`,
embed: {
description: `Thank you for voting for me!`,
fields: [
{
name: 'Points gained',
value: `${howMany}`,
inline: true
},
{
name: 'Vote link',
value: '[Click ME](https://top.gg/bot/807048838362955798/vote)',
inline: true
}
],
color: Number(getRandomColor())
}
})
// console.log(user)
//
fetch('https://afk.monkedev.com/points/add', { method: 'POST', headers: { userid: user, howmany: howMany, auth: Config.adminKey }});
res.status(200).send('ok');
});
const port = process.env.PORT || 25569;
app.listen(port, () => console.log('On port: ' + port));
// Server count
setInterval(() => {
fetch('https://top.gg/api/bots/807048838362955798/stats', {
method: 'POST',
body: JSON.stringify({
server_count: Zoopo.guilds.size,
shard_count: Zoopo.shards.size
}),
headers: {
Authorization: Config['top.gg_token'],
'Content-Type': 'application/json'
}
});
}, 1000 * 60); // 1 min