23 lines
855 B
JavaScript
23 lines
855 B
JavaScript
const chalk = require('chalk');
|
|
const fs = require('fs');
|
|
const AsciiTable = require('ascii-table');
|
|
const table = new AsciiTable();
|
|
table.setHeading('Commands', 'Status').setBorder('|', '-', '+', '+');
|
|
|
|
module.exports.name = 'commands';
|
|
module.exports = (client) => {
|
|
fs.readdirSync('./commands/').forEach((dir) => {
|
|
const files = fs.readdirSync(`./commands/${dir}`).filter((file) => file.endsWith('.js'));
|
|
if (files.length <= 0) return;
|
|
files.forEach((file) => {
|
|
let command = require(`../commands/${dir}/${file}`);
|
|
if (command) {
|
|
client.commands.set(command.name, command);
|
|
table.addRow(command.name, chalk.green('Loaded'));
|
|
} else {
|
|
table.addRow(file, chalk.red('Failed'));
|
|
}
|
|
});
|
|
});
|
|
console.log(chalk.magenta(table.toString()));
|
|
} |