-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
46 lines (35 loc) · 1.4 KB
/
app.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
const Discord = require('discord.js');
const client = new Discord.Client();
const config = require('./config.js');
const redis = require("redis");
const pub = redis.createClient(config.redis);
pub.on("error", (err) => {
console.log(`Error2 ${err}`);
});
const DBL = require("dblapi.js");
const dbl = new DBL('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjUyMDY5NDYxMjA4MDMyODcwOSIsImJvdCI6dHJ1ZSwiaWF0IjoxNTQ3NjMyOTU2fQ.Q8mbinEz3TtHhK3rU5WVVou3qyiirBohq9WR2MsPWJc', client);
const shardmanager = new Discord.ShardingManager('./bot.js', {
totalShards: config.general.shards,
token: config.general.token,
respawn: config.general.respawn
});
shardmanager.spawn(this.totalShards, config.general.delay);
const delay = 7000 + (config.general.shards * config.general.delay);
setTimeout(() => {
shardmanager.fetchClientValues('guilds.size')
.then(results => {
var counts = results.reduce((prev, val) => prev + val, 0);
pub.publish("updateGuildsCount", `${counts}`);
dbl.postStats(`${counts}`);
})
.catch(console.error);
}, delay);
setInterval(() => {
shardmanager.fetchClientValues('guilds.size')
.then(results => {
var counts = results.reduce((prev, val) => prev + val, 0);
pub.publish("updateGuildsCount", `${counts}`);
dbl.postStats(`${counts}`);
})
.catch(console.error);
}, 300000);