forked from cappig/MC-status-bot
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
34 lines (31 loc) · 1017 Bytes
/
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
const db = require('./services/db')
const topgg = require('./services/top.gg')
const pinger = require('./services/pinger')
const logger = require('./modules/nodeLogger')
const envCheck = require('./services/envCheck')
const webserver = require('./services/webserver')
const { ShardingManager } = require('discord.js')
process.on('uncaughtException', async (error, source) => {
require('./modules/nodeLogger').crash(error.stack || error + 'at' + source)
})
const main = async () => {
const shards = new ShardingManager('./bot.js', {
token: process.env.TOKEN,
totalShards: 'auto'
})
//connect to db and cache
await db()
//setup bot and shards
await shards.on('shardCreate', (shard) => {
logger.info(`Launched shard #${shard.id}`)
})
await shards.spawn(shards.totalShards, 500)
await envCheck()
await topgg(shards)
require('./services/thirdparty')()
pinger()
await webserver(shards)
console.log('Ready!')
let botobg = await shards.broadcastEval((bot) => bot.user)
}
main()