xMdb/hypixel-guild-chat-bot

feature request: improved help command

Miqhtiedev opened this issue · 1 comments

Improved Help Command

I propose that the help command lists all the commands by category when it is ran as well as allows you to view usage and description of any command by doing ${prefix}help <command>

Implementation Method

  • First assign each command a category when it gets registered
const commandFolders = fs.readdirSync('./commands');
for (const folder of commandFolders) {
  const commandFiles = fs.readdirSync(`./commands/${folder}`).filter(file => file.endsWith('.js'));
  for (const file of commandFiles) {
    const command = require(`./commands/${folder}/${file}`);
    bot.commands.set(command.name, {
      aliases: command.aliases,
      description: command.description,
      usage: command.usage,
      slowmode: command.slowmode,
      cooldown: commnad.cooldown,
      execute: command.execute, 
      category: folder // <---------
    });
  }
}
  • In the help command you can loop through all the commands and generate a list of every unique category.
  • Loop through the list of each category and add a new field to the embed named after that category and add all commands to that field formatted command, command, etc
  • If the command has a first argument check if that argument is the name of a command and if so display info such as usage description aliases etc
  • If there is no command found say no command found named args[0] do ${prefix}help to see all commands

Reasons for implementation

  • No need to manually enter each new command in when you make it
  • No need to have to separate commands for info about commands (commands & help)
  • Improved experience for users
  • Put categories to use

I am offering to PR this myself, please tell me if you want me to

xMdb commented

Thanks for the request. I originally didn't add this because I felt it was not needed due to the limited amount of commands it has, but in the interest of improving user experience and putting categories to use, I'm looking to add it anyways. A PR would be appreciated!