Finished help command.

Also categorized all commands.
This commit is contained in:
Keanu Timmermans 2020-07-01 15:35:37 +02:00
parent a5da139b97
commit e04587ffca
9 changed files with 44 additions and 9 deletions

View File

@ -1,4 +1,5 @@
{
"prefix": "!!",
"token": "<token>"
"prefix": "!!", // Bot Prefix
"token": "<token>", // Bot Token
"owners": ["<id>"] // Array of bot owner IDs
}

View File

@ -9,7 +9,8 @@ module.exports = class extends Command {
constructor(...args) {
super(...args, {
aliases: ['info', 'bot', 'botinfo']
aliases: ['info', 'bot', 'botinfo'],
category: 'Information'
});
}

View File

@ -36,7 +36,8 @@ module.exports = class extends Command {
constructor(...args) {
super(...args, {
aliases: ['server', 'guild', 'guildinfo']
aliases: ['server', 'guild', 'guildinfo'],
category: 'Information'
});
}

View File

@ -22,7 +22,8 @@ module.exports = class extends Command {
constructor(...args) {
super(...args, {
aliases: ['user', 'ui']
aliases: ['user', 'ui'],
category: 'Information'
});
}

View File

@ -5,7 +5,8 @@ module.exports = class extends Command {
constructor(...args) {
super(...args, {
aliases: ['help', 'halp']
aliases: ['help', 'halp'],
category: 'Utilities'
});
}
@ -22,13 +23,33 @@ module.exports = class extends Command {
if (!cmd) return message.channel.send(`\`${command}\` is not a valid command.`);
embed.setAuthor(`${this.client.utils.captalise(cmd.name)} Command Help`, this.client.user.displayAvatarURL());
embed.setAuthor(`${this.client.utils.capitalise(cmd.name)} Command Help`, this.client.user.displayAvatarURL());
embed.setDescription([
`** Aliases:** ${cmd.aliases.length ? cmd.aliases.map(alias => `\`${alias}\``).join(' ') : 'No Aliases'}`,
`** Description:** ${cmd.description}`,
`** Category:** ${cmd.category}`,
`** Usage:** ${cmd.usage}`
]);
return message.channel.send(embed);
} else {
embed.setDescription([
`These are the available commands for ${message.guild.name}`,
`This bot's prefix is: ${this.client.prefix}`,
`Command Parameters: \`<>\` is a strict & \`[]\` is optional`
]);
let categories;
if (!this.client.owners.includes(message.author.id)) {
categories = this.client.utils.removeDuplicates(this.client.commands.filter(cmd => cmd.category !== 'Owner').map(cmd => cmd.category));
} else {
categories = this.client.utils.removeDuplicates(this.client.commands.map(cmd => cmd.category));
}
for (const category of categories) {
embed.addField(`**${this.client.utils.capitalise(category)}**`, this.client.commands.filter(cmd =>
cmd.category === category).map(cmd => `\`${cmd.name}\``).join(' '));
}
return message.channel.send(embed);
}
}

View File

@ -4,7 +4,8 @@ module.exports = class extends Command {
constructor(...args) {
super(...args, {
aliases: ['pong']
aliases: ['pong'],
category: 'Utilities'
});
}

View File

@ -3,6 +3,13 @@ const ms = require('ms');
module.exports = class extends Command {
constructor(...args) {
super(...args)({
aliases: ['uptime'],
category: 'Utilities'
});
}
async run(message) {
message.channel.send(`My uptime is \`${ms(this.client.uptime, { long: true })}\``);
}

View File

@ -15,6 +15,8 @@ module.exports = class BotClient extends Client {
this.utils = new Util(this);
this.owners = options.owners;
this.once('ready', () => {
console.log(`Logged in as ${this.user.username}.`);
});

View File

@ -6,7 +6,7 @@ module.exports = class Command {
this.aliases = options.aliases || [];
this.description = options.description || 'No description provided.';
this.category = options.category || 'Miscellaneous';
this.usage = `${this.client.prefix}${this.name} ${options.usage || ''}`.trim()
this.usage = `${this.client.prefix}${this.name} ${options.usage || ''}`.trim();
}
// eslint-disable-next-line no-unused-vars