-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.js
66 lines (57 loc) · 1.88 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const fs = require("fs");
const {Client, Intents, Collection} = require("discord.js");
const moment = require("moment");
const Sequelize = require("sequelize");
const config = require("./config.js");
const { version } = require("./package.json");
const database = require("./config/config.json");
const client = new Client({intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]});
client.commands = new Collection();
const commandFiles = fs
.readdirSync("./commands")
.filter(file => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
const sequelize = new Sequelize(
database.development.database,
database.development.username,
database.development.password,
{
host: database.development.host,
dialect: database.development.dialect,
logging: false,
dialectOptions: {
timezone: "etc/GMT+7"
}
}
);
client.once("ready", () => {
client.user.setActivity(config.activity);
sequelize
.authenticate()
.then(() => {
console.log("Connection has been established successfully.");
})
.catch(err => {
console.error("Unable to connect to the database:", err);
});
console.log("BotEpel version: " + version + " is ready and active!");
console.log(
"My Active Time was at " + moment().format("dddd DD MMMM YYYY HH:mm:ss Z")
);
});
client.on("message", message => {
if (!message.content.startsWith(config.prefix) || message.author.bot) return;
const args = message.content.slice(config.prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if (!client.commands.has(command)) return;
try {
client.commands.get(command).execute(message, args);
} catch (error) {
console.error(error);
message.reply("There was an error trying to execute that command!");
}
});
client.login(config.token);