forked from aiko-chan-ai/agentbot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
43 lines (38 loc) · 1.38 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
const { ShardingManager } = require('discord.js');
require("dotenv").config();
const { TOKEN, TOPGG } = process.env;
const { laysodep } = require('./functions/utils');
const db = require('quick.db');
const AutoPoster = require('topgg-autoposter');
const manager = new ShardingManager('./bot.js', {
totalShards: 'auto',
token: TOKEN,
});
manager.spawn().then(async () => {
const poster = AutoPoster(TOPGG, manager);
poster.on('posted', () => {
console.log('Posted stats to top.gg');
});
let guildCount = await getGuildCount();
manager.broadcastEval(`this.user.setPresence({ status: "online", activity: { name: 'Đang phục vụ ${laysodep(guildCount)} servers', type: 'PLAYING' } })`);
setInterval(async () => {
guildCount = await getGuildCount();
manager.broadcastEval(`this.user.setPresence({ status: "online", activity: { name: 'Đang phục vụ ${laysodep(guildCount)} servers', type: 'PLAYING' } })`);
}, 36e5);
});
// change all voice status to default
const allDb = db.all();
for (let i = 0; i < allDb.length; i++) {
try {
const guild = allDb[i].ID;
db.set(`${guild}.botdangnoi`, false);
}
catch(e) {
continue;
}
}
console.log('botdangnoi reseted!');
async function getGuildCount() {
const arr = await manager.fetchClientValues('guilds.cache.size');
return arr.reduce((p, n) => p + n, 0);
}