1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Haha-Yes/index.js

47 lines
1.7 KiB
JavaScript

const { CommandoClient, Command } = require('discord.js-commando');
const path = require('path');
const { token, prefix, ownerID, supportServer } = require('./config.json');
6 years ago
const fs = require("fs");
6 years ago
// Prefix and ownerID and invite to support server
const client = new CommandoClient({
commandPrefix: prefix,
owner: ownerID,
invite: supportServer,
unknownCommandResponse: false,
disableEveryone: true,
});
6 years ago
// Command groups
client.registry
6 years ago
.registerDefaultTypes()
.registerGroups([
['fun', 'Fun'],
['utility', 'Utility'],
['admin', 'Admins'],
['owner', 'Owner'],
6 years ago
])
.registerDefaultGroups()
.registerDefaultCommands()
.registerCommandsIn(path.join(__dirname, 'commands'));
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}`)];
});
});
6 years ago
6 years ago
client.on('error', console.error);
6 years ago
client.login(token);