-
Notifications
You must be signed in to change notification settings - Fork 95
/
index.js
40 lines (34 loc) · 1.16 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
require('dotenv').config()
const { ShardingManager, DiscordAPIError } = require('discord.js')
proces.env.EMBED_COLOR ||= 'RED'
process.env.prefix ||= '!'
//Hago esto para solo ejecutar una vez el código de TopGG
const { readFile, writeFile } = require('fs')
readFile('start.txt', 'utf8', function (err, data) {
if (data == 'true') {
writeFile('start.txt', 'false', (err) => {
if (err) console.log(err)
})
}
})
const manager = new ShardingManager('./bot.js', {
token: process.env.token,
totalShards: 'auto',
shardList: 'auto',
mode: `process`,
respawn: true,
timeout: 87398
})
process.on('unhandledRejection', (reason) => {
if (reason instanceof DiscordAPIError) return
console.error(reason)
})
if (process.env.mode == 'production') {
const { AutoPoster } = require('topgg-autoposter')
const poster = AutoPoster(process.env.topggToken, manager)
poster.on('posted', (stats) => {
console.log(`Actualizando TopGG... | ${stats.serverCount} servidores.`)
})
}
manager.on('shardCreate', (shard) => console.log(`Iniciando shard ${shard.id}`))
manager.spawn().catch((err) => console.log(err))