forked from RahulR100/mcstatusbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathready.js
More file actions
38 lines (35 loc) · 1.02 KB
/
ready.js
File metadata and controls
38 lines (35 loc) · 1.02 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
const deployCommands = require('../functions/deployCommands');
const updateChannels = require('../functions/updateChannels');
const ping = require('web-pingjs');
module.exports = {
name: 'ready',
once: true,
async execute(client) {
await deployCommands.execute();
await client.user.setActivity('/help', { type: 'WATCHING' });
console.log('Ready!');
await updateServers(client);
await wakeDyno();
setInterval(updateServers, 5 * 60 * 1000, client);
setInterval(wakeDyno, 20 * 60 * 1000);
}
}
async function updateServers(client) {
client.guilds.cache
.forEach(async guild => {
let serverList = await serverDB.get(guild.id) ? await serverDB.get(guild.id) : [];
for (const server of serverList) {
await updateChannels.execute(server);
};
});
console.log('Servers updated.')
}
async function wakeDyno() {
await ping('https://mcstatus-discordbot.herokuapp.com/')
.then(() => {
console.log('Pinged Heroku server.',)
})
.catch(err => {
console.error('Could not ping Heroku server. ', err);
});
}