-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
85 lines (66 loc) · 2.43 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/************{ VARIABLES DISCORD }******************/
const config = require(`./settings/config.json`);
const { Client, Intents, Collection } = require('discord.js');
const discord = require('discord.js')
const client = new Client({
messageCacheLifetime: 60,
restTimeOffset: 0,
restWsBridgetimeout: 100,
intents: 98045,
partials: ['MESSAGE', 'CHANNEL', 'REACTION', 'GUILD_MEMBER', 'USER'],
allowedMentions: {
parse: ["users", "roles"],
repliedUser: true
},
cacheWithLimits: {
MessageManager: {
sweepInterval: 300,
sweepFilter: discord.Sweepers.filterByLifetime({
lifetime: 60,
getComparisonTimestamp: m => m.editedTimestamp ?? m.createdTimestamp,
})
}
},
disableMentions: 'everyone'
});
/************{ BASE DE DATOS }******************/
const mongoose = require("mongoose");
mongoose.connect(process.env.MONGO, {
useNewUrlParser: true,
useUnifiedTopology: true,
}).then(() => {
client.logger.log(`> ✅ • Se ha cargado exitosamente la base de datos`, "success");
}).catch(() => {
client.logger.log(`> ⛔ • Uh , no se cargo la base de datos`, "error");
})
/************{ COLECCIONES }******************/
module.exports = client;
client.logger = require('./settings/logger');
client.config = config;
client.cooldowns = new Collection();
client.commands = new Collection();
client.slsCommands = new Collection();
client.categories = require("fs").readdirSync(`./commands/message`);
["eventHandler", "commandHandler", "slsCmdHandler"]
.filter(Boolean)
.forEach(h => {
require(`./handlers/${h}`)(client);
});
/************{ ERROR HANDLER }******************/
client.on('error', error => client.logger.log(error, "error"));
client.on('warn', info => client.logger.log(info, "warn"));
process.on('unhandledRejection', error => client.logger.log("UNHANDLED_REJECTION\n" + error, "error"));
process.on('uncaughtException', error => {
client.logger.log("UNCAUGHT_EXCEPTION\n" + error, "error");
client.logger.log("Uh , paso algo inesperado , reiniciando...", "info");
process.exit(1);
});
/************{ SERVIDOR EXPRESS }******************/
const express = require('express')
const app = express();
const port = 3000
app.get('/', (req, res) => res.send('¡¡ Online Yeah !!'))
app.listen(port, () =>
console.log(`Escuchando a http://localhost:${port}`)
);
client.login(process.env.TOKEN);