-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
44 lines (32 loc) · 1.11 KB
/
main.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
const Discord = require('discord.js')
const recursive = require('recursive-readdir')
const moment = require('moment')
const { connect } = require('./helper/database.js')
const cron = require('./helper/cron.js')
const { prefix, token } = require(`./config.json`)
const client = new Discord.Client();
const locale = moment.locale('en');
const uptime = moment().format('LLL');
client.commands = new Discord.Collection();
recursive("commands/", function(err, files){
files.forEach(commands => {
var filesName = "./" + commands
const command = require(filesName)
client.commands.set(command.name, command);
});
})
client.on('ready', async () => {
await connect();
cron(client);
});
client.on('message', async message => {
//commands
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
let cmdToExecute = client.commands.get(command);
if(cmdToExecute){
cmdToExecute.execute(client, message, args);
}
});
client.login(token);