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 = `${encode(module.name)}
` +
`${encode(module.desc)}`;
client.reply(event, reply, replyHTML);
return;
}
var reply = command.name + "\n" +
command.desc + "\n\n" +
command.usage;
var replyHTML = `${encode(command.name)}
` +
`${encode(command.desc)}` +
`
${encode(command.usage)}
`;
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 for more information.`;
var replyHTML = `commands: ${client.commands.map(m => encode(m.name)).join("
, ")}
` +
`modules: ${client.modules.map(m => encode(m.name)).join("
, ")}
` +
encode(`run ${process.env.PREFIX}help for more information.`);
client.reply(event, reply, replyHTML);
}
export default {
command: "help",
name: "help",
desc: "show list of commands and modules",
execute
}