title: nodejs discord get nickname from a users ID
body: <p>My goals are to obtain the users nickname by using their ID.</p>
  <p>Their ID's are stored as variables which are being collected from a reaction collector.
  I have tried a few methods and failed, most of which either return nothing or errors.</p>
  <p>The below code returns nothing, the getnames() function is empty.  This method was recommended to me buy 2 people from a nodejs discord server which aims to help solve issues, similar to here.</p>
  <pre><code>    // returns player ID's
      function getPlayers() {
              let players = [];
              players.push(queue.tank[0]);        // First (1) in TANK queue
              players.push(queue.heal[0]);        // First (1) in HEAL queue
              players.push(queue.dps[0]);         // First (2) in DPS queue
              players.push(queue.dps[1]);
              return players;
          }
  
      // get nick names from ID's
          function getnames() {
              let players = getPlayers();
              let playerNicks = [];
              let newPlayer = &quot;&quot;;
              players.forEach(async player =&gt; {
              newPlayer = await message.guild.members.fetch(player).then(function (user) {return user.displayName });
              playerNicks.push(newPlayer)
              return playerNicks;
          })}
  
      //formats nicknames into string
          function formatnicknames() {
              let formatted_string2 = '';
              let playerNicks = getnames();
  
              if (playerNicks)
                  formatted_string2 = `${playerNicks[0]} \n${playerNicks[1]} \n${playerNicks[2]} \n${playerNicks[3]}`;
              return formatted_string2;
          }
  </code></pre>
  <p>I have also tried a few variations of the below code, still unable to obtain nickname.</p>
  <pre><code>message.guild.members.cache.get(user.id)
  </code></pre>
  <p>Edit #1</p>
  <p>now tried the following code with no success. (boost1ID contains the ID of 1 user)</p>
  <pre><code>var mem1 = message.guild.members.fetch(boost1ID).nickname
  </code></pre>
  <p>Edit #2</p>
  <p>tried a new method of obtaining displayname from ID.</p>
  <pre><code>                    var guild = client.guilds.cache.get('guildid');
                      var mem1 = guild.member(boost1ID);
                      var mem2 = guild.member(boost2ID);
                      var mem3 = guild.member(boost3ID);
                      var mem4 = guild.member(boost4ID);
                      var nickname1 = mem1 ? mem1.displayName : null;
                      var nickname2 = mem2 ? mem2.displayName : null;
                      var nickname3 = mem3 ? mem3.displayName : null;
                      var nickname4 = mem4 ? mem4.displayName : null;
  
                      var Allnicknames = `${nickname1} ${nickname2} ${nickname3} ${nickname4}`
                      message.channel.send(`testing nicknames: ${Allnicknames}`)
  </code></pre>
  <p>I managed to only return my own name since i dont have a nickname on this server, but the other three users who does have a nickname returned null.</p>