2018-09-18 20:32:33 +02:00
|
|
|
const { CommandoClient, Command } = require('discord.js-commando');
|
2018-09-07 00:24:03 +02:00
|
|
|
const path = require('path');
|
2018-09-18 20:32:33 +02:00
|
|
|
const { token, prefix, ownerID, supportServer } = require('./config.json');
|
2018-09-08 02:25:58 +02:00
|
|
|
const fs = require("fs");
|
2018-09-07 00:24:03 +02:00
|
|
|
|
2018-09-07 21:28:42 +02:00
|
|
|
// Prefix and ownerID and invite to support server
|
2018-09-07 00:24:03 +02:00
|
|
|
const client = new CommandoClient({
|
2018-09-18 13:52:20 +02:00
|
|
|
commandPrefix: prefix,
|
|
|
|
owner: ownerID,
|
|
|
|
invite: supportServer,
|
2018-09-10 18:52:19 +02:00
|
|
|
unknownCommandResponse: false,
|
2018-09-17 21:17:37 +02:00
|
|
|
disableEveryone: true,
|
2018-09-07 00:24:03 +02:00
|
|
|
});
|
2018-09-07 21:28:42 +02:00
|
|
|
// Command groups
|
2018-09-07 00:24:03 +02:00
|
|
|
client.registry
|
2018-09-07 19:07:10 +02:00
|
|
|
.registerDefaultTypes()
|
|
|
|
.registerGroups([
|
2018-09-18 02:18:54 +02:00
|
|
|
['fun', 'Fun'],
|
|
|
|
['utility', 'Utility'],
|
|
|
|
['admin', 'Admins'],
|
|
|
|
['owner', 'Owner'],
|
2018-09-07 19:07:10 +02:00
|
|
|
])
|
|
|
|
.registerDefaultGroups()
|
|
|
|
.registerDefaultCommands()
|
|
|
|
.registerCommandsIn(path.join(__dirname, 'commands'));
|
2018-09-08 23:34:08 +02:00
|
|
|
|
2018-09-18 20:32:33 +02:00
|
|
|
fs.readdir("./events/", (err, files) => {
|
|
|
|
if (err) return console.error(err);
|
|
|
|
files.forEach(file => {
|
|
|
|
// If the file is not a JS file, ignore it (thanks, Apple)
|
|
|
|
if (!file.endsWith(".js")) return;
|
|
|
|
// Load the event file itself
|
|
|
|
const event = require(`./events/${file}`);
|
|
|
|
// Get just the event name from the file name
|
|
|
|
let eventName = file.split(".")[0];
|
|
|
|
// super-secret recipe to call events with all their proper arguments *after* the `client` var.
|
|
|
|
// without going into too many details, this means each event will be called with the client argument,
|
|
|
|
// followed by its "normal" arguments, like message, member, etc etc.
|
|
|
|
// This line is awesome by the way. Just sayin'.
|
|
|
|
client.on(eventName, event.bind(null, client));
|
|
|
|
delete require.cache[require.resolve(`./events/${file}`)];
|
|
|
|
});
|
|
|
|
});
|
2018-09-08 01:37:16 +02:00
|
|
|
|
2018-09-07 19:07:10 +02:00
|
|
|
client.on('error', console.error);
|
2018-09-07 00:24:03 +02:00
|
|
|
|
2018-09-07 19:07:10 +02:00
|
|
|
client.login(token);
|