-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
71 lines (57 loc) · 1.81 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const path = require('path')
const fs = require('fs')
const Discord = require('discord.js')
const schedule = require('node-schedule')
const config = require('./config.json')
require('dotenv').config()
const client = new Discord.Client()
client.on('ready', async () => {
console.log(`Bot iniciado como ${client.user.tag}`)
client.user.setActivity(`${config.prefix}help`, {
type: 'LISTENING',
})
const job = schedule.scheduleJob('*/40 * * * *', function () {
console.log(
'Cantidad de servidores a los que el bot pertenece: ' +
client.guilds.cache.size
)
client.user.setActivity(`${config.prefix}help`, {
type: 'LISTENING',
})
})
const baseFile = 'command-base.js'
const commandBase = require(`./commands/${baseFile}`)
const readCommands = (dir) => {
const files = fs.readdirSync(path.join(__dirname, dir))
var descriptions = {}
for (const file of files) {
const stat = fs.lstatSync(path.join(__dirname, dir, file))
if (stat.isDirectory()) {
readCommands(path.join(dir, file))
} else if (file !== baseFile) {
const option = require(path.join(__dirname, dir, file))
if (typeof option.commands === 'string') {
option.commands = [option.commands]
}
descriptions[option.commands[0]] = option.description
commandBase(client, option)
}
}
fs.writeFileSync('./descriptions.json', JSON.stringify(descriptions))
}
readCommands('commands')
})
client.login(process.env.TOKEN)
if (process.platform === 'win32') {
var rl = require('readline').createInterface({
input: process.stdin,
output: process.stdout,
})
rl.on('SIGINT', function () {
process.emit('SIGINT')
})
}
process.on('SIGINT', function () {
console.log('Have a good mantainance work!')
process.exit()
})