command help

This commit is contained in:
mmacierzanka committed 2021-06-21 19:39:48 +02:00
1 parent 5c899b1129
commit dc4787fcea
1 file changed
+38 -4
+38 -4
View File
@@ -16,14 +16,47 @@ class HelpMessage extends Command {
usage: params.usage, usage: params.usage,
permissions: 0, permissions: 0,
description: params.description, description: params.description,
function: () => { function: (m, a) => {
const helpMsg = new MessageEmbed() const helpMsg = new MessageEmbed()
if(helpMsg != null) {
helpMsg.setColor(params.color); helpMsg.setColor(params.color);
helpMsg.setDescription(params.bottomText);
helpMsg.setTimestamp(); helpMsg.setTimestamp();
helpMsg.setTitle(params.title);
helpMsg.setFooter(botName || ''); helpMsg.setFooter(botName || '');
if(helpMsg != null) {
if(a && a[0]) {
const cmd: Command | null = cmdManager.get(a[0], 'ALL');
if(cmd) {
helpMsg.setTitle(`${cmd.name} ${cmd.visible ? '' : '[HIDDEN]'}`);
helpMsg.setDescription(cmd.description);
if(cmd.usage) helpMsg.addField('Usage:', `${prefix}${cmd.name} ${cmd.usage}`, false);
if(cmd.permissions) {
let permList: string = '';
cmd.permissions.toArray(false).map(p => {
permList += p + '\n';
});
helpMsg.addField('Permissions:', permList, false);
}
if(cmd.aliases) {
let aList: string = '';
cmd.aliases.map(a => {
aList += a + '\n';
});
helpMsg.addField('Aliases:', aList, false);
}
if(cmd.keywords) {
let kwrdList: string = '';
cmd.keywords.map(k => {
kwrdList += k + '\n';
});
helpMsg.addField('Keywords:', kwrdList, false);
}
}
else {
throw new ReferenceError(`Command "${a[0]}" does not exist`);
}
}
else {
helpMsg.setTitle(params.title);
helpMsg.setDescription(params.bottomText);
cmdManager.list.map((c) => { cmdManager.list.map((c) => {
if(c.visible) { if(c.visible) {
@@ -35,6 +68,7 @@ class HelpMessage extends Command {
} }
}); });
} }
}
return helpMsg; return helpMsg;
} }
}); });