generated from FnrDev/fnr-template
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.js
38 lines (33 loc) · 1.04 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
const Discord = require('discord.js');
const client = new Discord.Client({ intents: ['GUILDS', 'GUILD_MESSAGES'] });
const mysql = require('mysql-database');
const database = new mysql();
client.commands = new Discord.Collection();
client.slash = new Discord.Collection();
client.aliases = new Discord.Collection();
require('dotenv').config();
require('colors');
['hanlders', 'events'].forEach(handler => {
require(`./handlers/${handler}`)(client);
});
(async () => {
let db = await database.connect({
host: process.env.HOST,
port: process.env.PORT,
user: process.env.USER,
database: process.env.database
});
db.on('connected', () => {
console.log('[DataBase] DataBase Connected.'.green);
client.db = db;
db.create("buttons");
})
})();
// handle process events
process.on('unhandledRejection', (err) => {
console.error(`Unhandled Promise: ${err}`.red);
});
process.on('uncaughtException', (err) => {
console.error(`Uncaught Exception: ${err}`.red);
});
client.login(process.env.TOKEN);