title: discord.js list all my bot commands
body: <p>i made a discord bot with discord.js and tried to do a help command to show the user all available commands.</p>
  
  <p>example command: <em>avatar.js</em></p>
  
  <pre><code>module.exports.run = async(bot, message, args) =&gt; {
      let msg = await message.channel.send("doing some magic ...");
      let target = message.mentions.users.first() || message.author;
  
      await message.channel.send({files: [
          {
              attachment: target.displayAvatarURL,
              name: "avatar.png"
          }
      ]});
  
      msg.delete();
  }
  
  module.exports.help = {
      name: "avatar",
      description: "show the avatar of a user",
      usage: "[@user]"
  }
  </code></pre>
  
  <p>Then i tried to send a message with the complete list of the commands like:</p>
  
  <ul>
  <li><strong>command 1</strong></li>
  <li>description</li>
  <li>usage</li>
  <li><strong>command 2</strong></li>
  <li>description</li>
  <li>usage</li>
  <li>...</li>
  </ul>
  
  <p><em>help.js</em></p>
  
  <pre><code>const fs = require("fs");
  const Discord = require("discord.js");
  
  module.exports.run = async(bot, message, args, con) =&gt; {
      fs.readdir("./cmds/", (err, files) =&gt; {
          if(err) console.error(err);
  
          let jsfiles = files.filter(f =&gt; f.split(".").pop() === "js");
          if(jsfiles.length &lt;= 0) {
              console.log("No commands to load!");
              return;
          }
  
          var namelist = "";
          var desclist = "";
          var usage = "";
  
          let result = jsfiles.forEach((f, i) =&gt; {
              let props = require(`./${f}`);
              namelist = props.help.name;
              desclist = props.help.description;
              usage = props.help.usage;
          });
  
          message.author.send(`**${namelist}** \n${desclist} \n${usage}`);
      });
  }
  
  module.exports.help = {
      name: "help",
      description: "show all commands",
      usage: ""
  }
  </code></pre>
  
  <p>my code is kinda working but it only sends the first command.</p>
  
  <p>Im pretty new to javascript and i can't find a solution to this.
  I tried to google everything on foreach maps discord collections and stuff but i cant find a example where the results get combined together.</p>
  
  <p>If anybody can help me or give me a hint where i can search for something like this. Would be awesome.</p>