title: Discord.js/javascript issue with a error. ReferenceError: command not defined
body: <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const Discord = require("discord.js");
  
  
  const bot = new Discord.Client();
  
  let prefix="!"
  
  bot.on("ready", () =&gt; {
    bot.user.setStatus("idle");
  console.log(`Demon Is Online`)
  
  
  const update = () =&gt; {
      bot.user.setActivity("!help | residing on " + bot.guilds.size + " Servers", { type: 'WATCHING' }); 
  };
  
  bot.on('ready', update);
  bot.on('guildCreate', update);
  bot.on('guildRemove', update);
  
  bot.on("message", message =&gt; {
      if(message.author.bot) return;
      if(message.channel.type === "dm") return;
  
      let messageArray = message.content.split(" ");
      let command = messageArray[0];
      let args = messageArray.slice(1);
  
     if(!command.startsWith(prefix)) return;
  
  });
  
      if(command === `${prefix}userinfo`) {
          let embed = new Discord.RichEmbed()
          .setAuthor(message.author.username)
          .setColor("#3498db")
          .setThumbnail( `${message.author.avatarURL}`)
          .addField("Name", `${message.author.username}#${message.author.discriminator}`)
          .addField("ID", message.author.id)
         
          message.reply("I've Sent Your User Info Through DM!");
          message.channel.send({embed}); 
  
  }}); 
  
  
      if("command" === `${prefix}help`) {
          let embed = new Discord.RichEmbed()
          .addField("!help", "gives you this current information")
          .setTitle("Help")
          .setColor("#3498db")
          .addField("!userinfo", "gives you info about a user(currently being worked on)")
          .addField("!serverinfo","gives you info about a server(currently working on it)") 
          .addField("link to support server","https://discord.gg/NZ2Zvjm")
          .addField("invite link for bot","https://discordapp.com/api/oauth2/authorize?client_id=449983742224760853&amp;permissions=84993&amp;scope=bot")
  
  
    message.reply("here's a list of commands that i'm able to do")
          message.channel.send({embed});
      
  
   
      messageArray = message.content.split("");
      let command = messageArray[0];
          if(command === `${prefix}serverinfo`) {
              let embed = new Discord.RichEmbed()
              .setAuthor(message.author.username)
              .setColor("#3498db")
              .addField("Name", `${message.guild.name}`)
              .addField("Owner", `${message.guild.owner.user}`)
              .addField("Server ID" , message.guild.id)
              .addField("User Count", `${message.guild.members.filter(m =&gt; m.presence.status !== 'offline').size} / ${message.guild.memberCount}`)
              .addField("Roles", `${message.guild.roles.size}`);
  
  
              message.channel.send({embed});
           } 
          };
  
  bot.login("token goes here")</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have this code that I need help with its stopping my discord bot from coming online. I use javascript and discord.js and node.js and could use help I tried searching youtube and also servers on discord and asking some friends but they all tell me to learn the language which I been trying. but anyways here's my error </p>
  
  <p><a href="https://i.stack.imgur.com/rz4b5.png" rel="nofollow noreferrer">output</a></p>