-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (38 loc) · 1.24 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
const fs = require('fs');
const Discord = require('discord.js');
const client = new Discord.Client();
const config = require('./config.json');
client.config = config;
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Work')
})
app.listen(port, () => {
console.log(`Su aplicación está escuchando en el puerto. ${port}`)
})
/* Load all events */
fs.readdir("./eventos/", (_err, files) => {
files.forEach((file) => {
if (!file.endsWith(".js")) return;
const event = require(`./eventos/${file}`);
let eventName = file.split(".")[0];
console.log(`👌 Eventos cargados: ${eventName}`);
client.on(eventName, event.bind(null, client));
delete require.cache[require.resolve(`./eventos/${file}`)];
});
});
client.commands = new Discord.Collection();
/* Load all commands */
fs.readdir("./comandos/", (_err, files) => {
files.forEach((file) => {
if (!file.endsWith(".js")) return;
let props = require(`./comandos/${file}`);
let commandName = file.split(".")[0];
client.commands.set(commandName, props);
console.log(`👌 Comandos cargando: ${commandName}`);
});
});
// Login
client.login("Token del Bot");