title: Discord JS - Reverse lookup to obtain userID from their display name
body: <p>We're currently building a bot that will review specific messages and perform follow-up administrative actions on it. One of the actions will read a message and extract a named user (string - not link), search for it and return the ID of the user - which is then used elsewhere.</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>if (message.channel.id === register) {
         // The post is in the register channel
         if (message.content.includes('doing business with you')) {
             //it's a successful claim
             Rclaimedby = message.content.match(/\*\*(.*?)\*\*/)[1];
             const Ruser = client.users.cache.find(user =&gt; user.username == Rclaimedby).id;</code></pre>
  </div>
  </div>
  </p>
  <p>The text snippet will just have the individuals name as a string, which the regex will extract. If the individual doesn't have a nickname set, it'll work and the rest of the code works. However, as soon as that name isn't their &quot;normal&quot; name, it doesn't work and crashes with a TypeError.</p>
  <p>I need to be able to use that stripped name and find the ID regardless of whether they have a nickname or not, but I've been searching for days (and a LOT of trial and error) and can't find a way around it.</p>
  <p>To help, the message content would say something like:</p>
  <blockquote>
  <p>(...) doing business with you <strong>normalname</strong> (...) or
  (...) doing business with you <strong>randomnickname</strong> (...)</p>
  </blockquote>
  <p>Help?</p>