Skip to content

Instantly share code, notes, and snippets.

@Strandxo
Created May 10, 2019 20:54
Show Gist options
  • Save Strandxo/27cb505471f3ae4dffae8075f5dda82a to your computer and use it in GitHub Desktop.
Save Strandxo/27cb505471f3ae4dffae8075f5dda82a to your computer and use it in GitHub Desktop.
const { readdirSync } = require("fs")
module.exports = (client) => {
const load = dirs => {
const commands = readdirSync(`./commands/${dirs}/`).filter(d => d.endsWith('.js'));
for (let file of commands) {
let pull = require(`../commands/${dirs}/${file}`);
client.commands.set(pull.config.name, pull);
if (pull.config.aliases) pull.config.aliases.forEach(a => client.aliases.set(a, pull.config.name));
};
};
readdirSync('./commands/').forEach(x => load(x));
};
const { readdirSync } = require("fs")
module.exports = (client) => {
const load = dirs => {
const events = readdirSync(`./events/${dirs}/`).filter(d => d.endsWith('.js'));
for (let file of events) {
const evt = require(`../events/${dirs}/${file}`);
let eName = file.split('.')[0];
client.on(eName, evt.bind(null, client));
};
};
readdirSync('./events/').forEach(x => load(x));
};
const { Client, Collection } = require("discord.js");
const { token } = require("./config.js");
const client = new Client();
["aliases", "commands"].forEach(x => client[x] = new Collection());
["command", "event"].forEach(x => require(`./utilities/${x}`)(client));
client.login(token);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment