title: nodejs: (node:612) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function
body: <p>I have a discord bot (actually two, one's in python) that I run with my raspberry pi 4 4gb ram model. I made it so that it automatically executes js and python scripts on startup (via crontab) and places the output in a file.</p>
  <p>When I try to send a embed via the bot i get this,:</p>
  <pre><code>(node:612) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function
      at Function.normalizeFields (/HOMENAS/KitBot/node_modules/discord.js/src/structures/MessageEmbed.js:443:8)
      at MessageEmbed.setup (/HOMENAS/KitBot/node_modules/discord.js/src/structures/MessageEmbed.js:77:91)
      at new MessageEmbed (/HOMENAS/KitBot/node_modules/discord.js/src/structures/MessageEmbed.js:18:10)
      at embedLikes.map.e (/HOMENAS/KitBot/node_modules/discord.js/src/structures/APIMessage.js:164:40)
      at Array.map (&lt;anonymous&gt;)
      at APIMessage.resolveData (/HOMENAS/KitBot/node_modules/discord.js/src/structures/APIMessage.js:164:31)
      at TextChannel.send (/HOMENAS/KitBot/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:166:62)
      at Client.client.on.message (/HOMENAS/KitBot/server.js:13:23)
      at Client.emit (events.js:198:13)
      at MessageCreateAction.handle (/HOMENAS/KitBot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
  (node:612) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
  (node:612) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  (node:612) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function
      at Function.normalizeFields (/HOMENAS/KitBot/node_modules/discord.js/src/structures/MessageEmbed.js:443:8)
      at MessageEmbed.setup (/HOMENAS/KitBot/node_modules/discord.js/src/structures/MessageEmbed.js:77:91)
      at new MessageEmbed (/HOMENAS/KitBot/node_modules/discord.js/src/structures/MessageEmbed.js:18:10)
      at embedLikes.map.e (/HOMENAS/KitBot/node_modules/discord.js/src/structures/APIMessage.js:164:40)
      at Array.map (&lt;anonymous&gt;)
      at APIMessage.resolveData (/HOMENAS/KitBot/node_modules/discord.js/src/structures/APIMessage.js:164:31)
      at TextChannel.send (/HOMENAS/KitBot/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:166:62)
      at Client.client.on.message (/HOMENAS/KitBot/server.js:13:23)
      at Client.emit (events.js:198:13)
      at MessageCreateAction.handle (/HOMENAS/KitBot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
  (node:612) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
  
  </code></pre>
  <p><strong>Note: /HOMENAS/KitBot is the directory where the bot's files are at (in my NAS SSD).</strong></p>
  <p>I read that it may be something to do with the Node's version but I have v14.4.0 and I still get the error.</p>
  <pre><code>pi@raspberrypi:~ $ node -v
  v14.4.0
  </code></pre>
  <p>Do you guys have any idea on what the problem may be?</p>
  <p><strong>EDIT:</strong>
  Here is my embed code (its a censoring mechanism) code:</p>
  <pre class="lang-js prettyprint-override"><code>var forbidenWords = require('./profanewords.json');
  var d = new Date();
  var n = d.getHours();
  client.on('message', message =&gt; {
    for (var i = 0; i &lt; forbidenWords.length; i++) {
      if (message.content.toLowerCase().includes(forbidenWords[i]) &amp;&amp; message.guild.id != 702111932848537622 ) {
        message.delete()
        const warnmsg = new Discord.MessageEmbed()
          .setColor('#FF0000')
          .setDescription(`Woah, **${message.author.username}**! This is a family friendly server. Don't use that language here!`)
        message.channel.send(warnmsg);
        break;
      } 
    }
  });
  </code></pre>
  <p>profanewords.json contains a list of profane words</p>
  <p>I know forbidenwords is misspelt and I will fix that later</p>