title: Discord JS v12: How do you get a message's content by it's ID?
body: <p>I'm relatively new to discord.js, and I've started building a bot project that allows a user to create a message via command, have that message stored in a hidden channel on my private server, and then said message can be extracted through the message ID.</p>
  <p>I have the write working and it returns the message ID of the message sent in the hidden channel, but I'm completely stumped on the get command. I've tried searching around online but every method I tried would return errors like &quot;Cannot read property 'fetch' of undefined&quot; or &quot;'channel' is not defined&quot;. Here are some examples of what I tried, any help would be appreciated. Note that my args is already accurate, and &quot;args[0]&quot; is the first argument after the command. &quot;COMMAND_CHANNEL&quot; is the channel where the command is being executed while &quot;MESSAGE_DATABASE&quot; is the channel where the targeted message is stored.</p>
  <pre class="lang-js prettyprint-override"><code>let msgValue = channel.messages.cache.get(args[0])
  client.channels.cache.get(COMMAND_CHANNEL).send(msgValue.content)
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>let msgValue = msg.channel.message.fetch(args[0])
      .then(message =&gt; client.channels.cache.get(COMMAND_CHANNEL).send(msgValue.content))
      .catch(console.error);
  </code></pre>
  <p>I even tried using node-fetch to call the discord API itself</p>
  <pre class="lang-js prettyprint-override"><code>const api = require(&quot;node-fetch&quot;)
  let msgValue = api(`https://discordapp.com/api/v8/channels/${MESSAGE_DATABASE}/messages/${args[0]}`)
      .then(message =&gt; client.channels.cache.get(COMMAND_CHANNEL).send(msgValue.content))
      .catch(console.error);
  </code></pre>
  <p>Am I missing something or am I making some sort of mistake?</p>
  <p>Edit: Thanks for the help! I finished my bot, it's just a little experimental bot that allows you to create secret messages that can only be viewed through their ID upon executing the command :get_secret_message &lt;message_id&gt;. I posted it on top.gg but it hasn't been approved yet, so in the meantime if anyone wants to mess around with it here is the link: <a href="https://discord.com/api/oauth2/authorize?client_id=800368784484466698&amp;permissions=76800&amp;scope=bot" rel="nofollow noreferrer">https://discord.com/api/oauth2/authorize?client_id=800368784484466698&amp;permissions=76800&amp;scope=bot</a></p>
  <p>List of commands:</p>
  <p>:write_secret_message  - Write a secret message, upon execution the bot will DM you the message ID.</p>
  <p>:get_secret_message &lt;message_id&gt; - Get a secret message by its ID, upon execution the bot will DM you the message content.</p>
  <p>:invite - Get the bot invite link.</p>
  <p>NOTE: Your DMs must be turned on or the bot won't be able to DM any of the info.</p>
  <p>My test message ID: 800372849155637290</p>