55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
import { encode } from "html-entities";
|
|
|
|
function execute(client, event, args) {
|
|
var name = args.toLowerCase();
|
|
|
|
var command = client.commands.filter(c=>(c.name.toLowerCase()==name || c.command.toLowerCase()==name))[0];
|
|
var module = client.modules.filter(m=>m.name.toLowerCase()==name)[0];
|
|
var specific = command ?? module ?? false;
|
|
|
|
if(args != "") {
|
|
if(!command && !module) {
|
|
client.reply(event, `Section "${args}" not found.\nRun "${process.env.PREFIX}help" for a list of commands and modules.`);
|
|
return;
|
|
}
|
|
|
|
if(module) {
|
|
var reply = module.name + "\n";
|
|
reply += module.desc;
|
|
|
|
var replyHTML = `<b>${encode(module.name)}</b><br>` +
|
|
`<i>${encode(module.desc)}</i>`;
|
|
|
|
client.reply(event, reply, replyHTML);
|
|
return;
|
|
}
|
|
|
|
var reply = command.name + "\n" +
|
|
command.desc + "\n\n" +
|
|
command.usage;
|
|
|
|
var replyHTML = `<b>${encode(command.name)}</b><br>` +
|
|
`<i>${encode(command.desc)}</i>` +
|
|
`<br><code>${encode(command.usage)}</code>`;
|
|
|
|
client.reply(event, reply, replyHTML);
|
|
return;
|
|
}
|
|
|
|
var reply = `commands: ${client.commands.map(m => m.name).join(", ")}\n` +
|
|
`modules: ${client.modules.map(m => m.name).join(", ")}\n` +
|
|
`run ${process.env.PREFIX}help <module/command> for more information.`;
|
|
|
|
var replyHTML = `commands: <code>${client.commands.map(m => encode(m.name)).join("</code>, <code>")}</code><br>` +
|
|
`modules: <code>${client.modules.map(m => encode(m.name)).join("</code>, <code>")}</code><br>` +
|
|
encode(`run ${process.env.PREFIX}help <module/command> for more information.`);
|
|
|
|
client.reply(event, reply, replyHTML);
|
|
}
|
|
|
|
export default {
|
|
command: "help",
|
|
name: "help",
|
|
desc: "show list of commands and modules",
|
|
execute
|
|
}
|