title: How to iterate through all members of a guild and changing their nicknames with a Discord bot built on JDA
body: <p>I am trying to write a simple call that lists all users of a guild, checks if they have clan tags next to their name and if not adds them, but I cannot for the life of me get it to work. I'm getting NullPointers when checking the nicknames so I presume I am not getting those values correctly.</p>
  
  <p>I am good with Java I've just never used JDA before. I can't find any code examples of something as simple as listing all members and iterating through them. Could someone please point me in the right direction? I have done a bit on REST in university but not a lot.</p>
  
  <p>Adding catch blocks but I'm not getting the values of any of the nicknames into my list so my code isn't doing anything. I've tried implementing in Lists, arrays and arraylists but it seems the issue is getting the information from the guild itself. </p>
  
  <pre><code>if(event.getMessage().getContentRaw().equals("!tags")){
          Guild guild = event.getGuild();
          List&lt;Member&gt; users = guild.getMembers();
          for(Member member: users){
              String s = "";
              try{
                  s = member.getNickname();
                  if(!member.getNickname().startsWith("[NNN]")) {
                      try {
                          member.modifyNickname("[NNN]" + member.getNickname()).queue();
                      } catch (Exception ignored) {
                      }
                  }
              }
              catch(Exception ignored){ }
          }
      }
  </code></pre>