forked from tedztar/mcstatusbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (30 loc) · 1.19 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
const Discord = require("discord.js");
const express = require('express');
const fs = require('fs');
const Keyv = require('keyv');
client = new Discord.Client({ intents: [Discord.Intents.FLAGS.GUILDS] });
embedColor = "#7289DA";
// Heroku
express().listen(process.env.PORT || 5000);
// Database
serverDB = process.env.NODE_ENV == 'production' ? new Keyv(`${process.env.DATABASE_URL}?sslmode=no-verify`) : new Keyv();
serverDB.on('error', err => console.error('Keyv connection error:', err));
// Command Handler
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync(`${__dirname}/commands`).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`${__dirname}/commands/${file}`);
client.commands.set(command.data.name, command);
}
// Event Handler
const eventFiles = fs.readdirSync(`${__dirname}/events`).filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const event = require(`${__dirname}/events/${file}`);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args, client));
}
else {
client.on(event.name, (...args) => event.execute(...args, client));
}
}
client.login(process.env.TOKEN);