radium-v2/commands/help.js

40 lines
No EOL
1.8 KiB
JavaScript

const desc = "displays a list of commands";
const usages = " - help [command]";
const trustLevel = 0;
const path = require("path");
const fs = require("fs");
const config = require("../config.json");
const list = fs.readdirSync(__dirname);
function inject (client) {
const command = ((args) => {
if (!args[0]) {
let result = [];
for (const command in list) {
if (require(`./${path.parse(list[command]).name}.js`).trustLevel === 0) {
result.push(config.publicColor + path.parse(list[command]).name)
} else
if (require(`./${path.parse(list[command]).name}.js`).trustLevel === 1) {
result.push(config.trustedColor + path.parse(list[command]).name)
} else
if (require(`./${path.parse(list[command]).name}.js`).trustLevel === 2) {
result.push(config.ownerColor + path.parse(list[command]).name)
}
}
client.bcraw(`&7Commands: &8(${config.publicColor}Public ${config.trustedColor}Trusted ${config.ownerColor}Owner&8) &8(${config.publicColor}${result.length}&8) &7» ${result.join("&8, ")}`);
} else
if (!args[0].includes(".") || !args[0].includes("/")) {
try {
client.bcraw(`${config.publicColor}Description: ${config.trustedColor}${require(`./${args[0]}.js`).desc}\n${config.publicColor}Usages: ${config.trustedColor}${require(`./${args[0]}.js`).usages}\n${config.publicColor}Trust level: ${config.trustedColor}${require(`./${args[0]}.js`).trustLevel}`);
} catch (err) {
client.cmdError(`Command not found`);
console.log(err.toString());
}
}
})
client.runCommand = command;
return command;
}
module.exports = { inject, desc, usages, trustLevel };