title: how can I send a direct message to the user mentioned in a message? Discord JS
body: <p>I'm using the discord.js library and node.js to create a Discord bot. Right now I need to code the bot such that when you send a message ie: &quot;!send @ hello&quot; it would send a DM to the user mentioned in the message, in this case the string: &quot;hello&quot;</p>
  <p>Right now I'm trying to do that by doing the following (code is flawed and definitely will not work but I hope you can understand what I am trying to accomplish):</p>
  <pre><code>//get the user mentioned in the message
  user = message.mentions[0]
  //sending the message to said user
  user.send(&quot;message&quot;)
  </code></pre>
  <p>Is there any way to do this?</p>
  <p>this is the error it returns when I try the above code:</p>
  <p>console.log((message.mentions)[0])</p>
  <p>^
  TypeError: Cannot read properties of undefined (reading '0')</p>