galactic-bot/structure/client/components/commands/information/Help.js

48 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-05-01 16:12:54 +02:00
const { Command } = require('../../../../interfaces/');
class HelpCommand extends Command {
constructor(client) {
super(client, {
name: 'help',
module: 'information'
2020-05-01 16:12:54 +02:00
});
this.client = client;
}
async execute(message, { params }) {
if (!params.length) return message.embed({
description: message.format('C_HELP')
});
2020-05-05 15:33:14 +02:00
const [ key ] = params;
let [ result ] = this.client.resolver.components(key, 'command');
if (!result) [ result ] = this.client.resolver.components(key, 'setting');
if (!result) return message.embed({
description: message.format('C_HELP_404', { component: key })
});
2020-05-01 16:12:54 +02:00
2020-05-05 15:33:14 +02:00
//let index = `${result.type.slice(0, 1).toUpperCase()}_${result.name.toUpperCase()}_HELP`;
return message.embed({
2020-05-05 15:33:14 +02:00
description: message.format('C_HELP_TEMPLATE', {
desc: message.format(result.description),
component: result.name.toUpperCase(),
2020-05-24 00:10:10 +02:00
text: result.examples.map(ex => `\`{prefix}${result.type === 'command' ? result.name.toLowerCase() : `settings ${result.name.toLowerCase()}`} ${ex}\``).join('\n')
}),
fields: [
{
name: 'Aliases',
value: result.aliases.map(al => al.toLowerCase()).join(', ')
}
]
2020-05-05 15:33:14 +02:00
});
2020-05-01 16:12:54 +02:00
}
}
module.exports = HelpCommand;