text: module.exports = {
    name: "help",
    aliases: ["h"],
    description: "Display all commands and descriptions",
    execute(message) {
      let commands = message.client.commands.array();
  
      let helpEmbed = new MessageEmbed()
        .setTitle(`${message.client.user.username} Help`)
        .setDescription("__**Take a look at the commands i have to play music**__")
        .setColor("RED")
        .setTimestamp();
        
      commands.forEach((cmd) => {
        helpEmbed.addField(
          `**${message.client.prefix}${cmd.name} ${cmd.aliases ? `(${cmd.aliases})` : ""}**`,
          `${cmd.description}`,
          true
        );
      });
  
      helpEmbed.setTimestamp();
  
      return message.channel.send(helpEmbed).catch(console.error);
    }
  };
  
  const { MessageEmbed } = require("discord.js");
  
  module.exports = {
    name: "help",
    aliases: ["h"],
    description:
      "Get list of all command and even get to know every command detials",
    usage: "help <cmd>",
    category: "info",
    run: async (client, message, args) => {
      if (args[0]) {
        const command = await client.commands.get(args[0]);
  
        if (!command) {
          return message.channel.send("Unknown Command: " + args[0]);
        }
  
        let embed = new MessageEmbed()
          .setAuthor(command.name, client.user.displayAvatarURL())
          .addField("Description", command.description || "Not Provided :(")
          .addField("Usage", "`" + command.usage + "`" || "Not Provied")
          .setThumbnail(message.guild.iconURL())
          .setColor("GREEN")
          .setTimestamp()
          .setFooter(client.user.username, client.user.displayAvatarURL());
  
        return message.channel.send(embed);
      } else {
        const commands = await client.commands;
  
        let emx = new MessageEmbed()
          .setColor("GREEN")
          .setTimestamp()
          .setFooter(client.user.username, client.user.displayAvatarURL())
          .setThumbnail(message.guild.iconURL())
  
        let com = {};
        for (let comm of commands.array()) {
          let category = comm.category || "Unknown";
          let name = comm.name;
  
          if (!com[category]) {
            com[category] = [];
          }
          com[category].push(name);
        }
  
        for(const [key, value] of Object.entries(com)) {
          let category = key;
  
          let desc = "`" + value.join("`, `") + "`";
  
          emx.addField(`${category.toUpperCase()}[${value.length}]`, desc);
        }
  
        return message.channel.send(emx);
      }
    }
  };
  