Haha-Yes/hahayes.js
2018-09-06 19:00:29 +02:00

39 lines
No EOL
1 KiB
JavaScript

const Discord = require("discord.js");
const Enmap = require("enmap");
const fs = require("fs");
const client = new Discord.Client();
const config = require("./config.json");
const responseObject = require("./reply.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(`Attempting to load command ${commandName}`);
client.commands.set(commandName, props);
});
});
client.on("message", (message) => {
if(responseObject[message.content]) {
message.channel.send(responseObject[message.content]);
}
});
client.login(config.token);