title: Discord.js command that gives a role
body: <p>so I'm trying to make a command that where you type <code>$test</code> and it gives you, for example, a "Test" role. This is my current code but I keep getting an error: "Cannot read property 'addRole' of undefined"</p>
  
  <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 { send } = require("process");
  const { clear } = require("console");
  const client = new Discord.Client();
  var prefix = "$";
  
  client.login("token");
  
  //TEST COMMAND
  client.on("message", message =&gt; {
  
      if (message.content.startsWith(prefix + "test")) {
          message.channel.send("You have been given `Need to be tested` role! You will be tested shortly!")
          client.channels.get("701547440310059059").send(` please test ${message.author}!`)
          const member = message.mentions.members.first();
          let testRole = message.guild.roles.find(role =&gt; role.id == "609021049375293460")
          member.addRole(testRole)
          
      }})
      
      
  client.on('ready',()=&gt;{
      console.log(`[READY] Logged in as ${client.user.tag}! ID: ${client.user.id}`);
      let statuses = [
          "  status "
      ]
      setInterval(function(){
              let status = statuses[Math.floor(Math.random() * statuses.length)];
              client.user.setActivity(status, {type:"WATCHING"})
      
          }, 3000) //Seconds to Random
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>Please let me know how I can do this easily or something.</p>