nodbot/commands/help.js

54 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-06-27 23:41:25 +00:00
module.exports = {
name: 'help',
description: 'Shows the help page.',
2021-07-01 22:12:21 +00:00
execute(message, file) {
2021-06-27 23:41:25 +00:00
const data = [];
const { commands } = message.client;
2021-07-01 22:12:21 +00:00
if (!file.name) {
2021-07-18 18:56:45 +00:00
// const helpStructure = {
// commands = [
// {
// name: commandName,
// aliases: commandAliases,
// description: commandDescription,
// usage: commandUsage,
// cooldown: commandCooldown
// }
// ]
// };
2021-06-27 23:41:25 +00:00
data.push('Here\'s a list of all my commands:');
data.push(commands.map(command => command.name).join(', '));
2021-07-01 22:12:21 +00:00
data.push('\nYou can send `[command name].help` to get info on a specific command!');
2021-06-27 23:41:25 +00:00
return message.author.send(data, { split: true })
.then(() => {
if (message.channel.type === 'dm') return;
message.reply('I\'ve sent you a DM with all my commands!');
})
.catch(error => {
console.error(`Could not send help DM to ${message.author.tag}.\n`, error);
2021-07-01 22:12:21 +00:00
message.reply('It seems like I can\'t DM you! Do you have DMs disabled?');
2021-06-27 23:41:25 +00:00
});
}
2021-07-01 22:12:21 +00:00
const command = commands.get(file.name) || commands.find(c => c.aliases && c.aliases.includes(file.name));
2021-06-27 23:41:25 +00:00
if (!command) {
2021-07-01 22:12:21 +00:00
return message.reply('That\'s not a valid command!');
2021-06-27 23:41:25 +00:00
}
data.push(`**Name:** ${command.name}`);
if (command.aliases) data.push(`**Aliases:** ${command.aliases.join(', ')}`);
if (command.description) data.push(`**Description:** ${command.description}`);
2021-07-06 21:37:29 +00:00
if (command.usage) data.push(`**Usage:** \`${command.usage}.${command.name}\``);
2021-06-27 23:41:25 +00:00
data.push(`**Cooldown:** ${command.cooldown || 3} second(s)`);
message.channel.send(data, { split: true });
},
};