34 lines
949 B
JavaScript
34 lines
949 B
JavaScript
const Discord = require("discord.js");
|
|
const Enmap = require("enmap");
|
|
const fs = require("fs");
|
|
const client = new Discord.Client();
|
|
const config = require("./config.json");
|
|
|
|
client.config = config;
|
|
|
|
fs.readdir("./events/", (err, files) => {
|
|
if (err) return console.error(err);
|
|
files.forEach(file => {
|
|
const event = require(`./events/${file}`);
|
|
let eventName = file.split(".")[0];
|
|
client.on(eventName, event.bind(null, client));
|
|
});
|
|
});
|
|
|
|
client.commands = new Enmap();
|
|
|
|
fs.readdir("./commands/", (err, files) => {
|
|
if (err) return console.error(err);
|
|
files.forEach(file => {
|
|
if (!file.endsWith(".js")) return;
|
|
let props = require(`./commands/${file}`);
|
|
let commandName = file.split(".")[0];
|
|
console.log(`Ladowanie komendy ${commandName}`);
|
|
client.commands.set(commandName, props);
|
|
});
|
|
});
|
|
|
|
if (!process.env.DiscordToken) {
|
|
throw new Error("Token not provided")
|
|
}
|
|
client.login(process.env.DiscordToken);
|