title: Discord API valid intents must be provided for the client
body: <p>I am programming a Discord bot. When I try to run a node, I get this in the <a href="https://en.wikipedia.org/wiki/Cmd.exe" rel="nofollow noreferrer">CMD</a> window:</p>
  <blockquote>
  <p>C:\Users\utente\Desktop\bouncerBot\node_modules\discord.js\src\client\Client.js:544
  throw new TypeError('CLIENT_MISSING_INTENTS'); <br />
  ^</p>
  <p>TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for <br />
  the Client. <br />
  at Client._validateOptions (C:\Users\utente\Desktop\bouncerBot\node_modules\←[4mdiscord.js←[24m\src\client\Client.js:544:13) <br />
  at new Client (C:\Users\utente\Desktop\bouncerBot\node_modules\←[4mdiscord.js←[24m\src\client\Client.js:73:10) <br />
  at Object. (C:\Users\utente\Desktop\bouncerBot\main.js:2:16) ←[90m    at <br />
  Module._compile (internal/modules/cjs/loader.js:1072:14)←[39m ←[90m <br />
  at Object.Module._extensions..js <br />
  (internal/modules/cjs/loader.js:1101:10)←[39m ←[90m    at Module.load <br />
  (internal/modules/cjs/loader.js:937:32)←[39m ←[90m    at <br />
  Function.Module._load (internal/modules/cjs/loader.js:778:12)←[39m <br />
  ←[90m    at Function.executeUserEntryPoint [as runMain] <br />
  (internal/modules/run_main.js:76:12)←[39m ←[90m    at <br />
  internal/main/run_main_module.js:17:47←[39m { <br />
  [←[32mSymbol(code)←[39m]: ←[32m'CLIENT_MISSING_INTENTS'←[39m } \</p>
  <p>C:\Users\utente\Desktop\bouncerBot&gt;node . <br />
  C:\Users\utente\Desktop\bouncerBot\node_modules\discord.js\src\client\Client.js:544 <br />
  throw new TypeError('CLIENT_MISSING_INTENTS'); <br />
  ^ \</p>
  <p>TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for <br />
  the Client. <br />
  at Client._validateOptions (C:\Users\utente\Desktop\bouncerBot\node_modules\←[4mdiscord.js←[24m\src\client\Client.js:544:13) <br />
  at new Client (C:\Users\utente\Desktop\bouncerBot\node_modules\←[4mdiscord.js←[24m\src\client\Client.js:73:10) <br />
  at Object. (C:\Users\utente\Desktop\bouncerBot\main.js:3:16) ←[90m    at <br />
  Module._compile (internal/modules/cjs/loader.js:1072:14)←[39m ←[90m <br />
  at Object.Module._extensions..js <br />
  (internal/modules/cjs/loader.js:1101:10)←[39m ←[90m    at Module.load <br />
  (internal/modules/cjs/loader.js:937:32)←[39m ←[90m    at <br />
  Function.Module._load (internal/modules/cjs/loader.js:778:12)←[39m <br />
  ←[90m    at Function.executeUserEntryPoint [as runMain] <br />
  (internal/modules/run_main.js:76:12)←[39m ←[90m    at <br />
  internal/main/run_main_module.js:17:47←[39m { <br />
  [←[32mSymbol(code)←[39m]: ←[32m'CLIENT_MISSING_INTENTS'←[39m</p>
  </blockquote>
  <p>I tried to search online for solutions, but I didn't find anything. I also activated the following potions in the bot settings, but nothing changes:</p>
  <p><a href="https://i.stack.imgur.com/ntykc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ntykc.png" alt="Enter image description here" /></a></p>
  <p>This is my code, even if it is not the cause of the error:</p>
  <h3>File <em>Main.js</em></h3>
  <pre><code>const Discord = require('discord.js');
  const fs = require('fs');
  const client = new Discord.Client();
  
  let rawdata = fs.readFileSync('config.json');
  let config = JSON.parse(rawdata);
  
  const TOKEN = config.botToken
  const prefix = config.prefix
  
  client.login(TOKEN)
  client.on('message', message =&gt; {
      if (!message.content.startsWith(prefix) || message.author.bot)
          return;
      const args = message.content.slice(prefix.lenght).split(/ +/)
      const command = args[1].toLowerCase()
      console.log(args)
      // Command test!
  })
  
  client.once('ready', () =&gt; {
      console.log(&quot;Discord bot online&quot;)
  });
  </code></pre>
  <h3>File <em>config.json</em>:</h3>
  <pre><code>{
      &quot;botToken&quot;:&quot;&quot;,
      &quot;prefix&quot;:&quot;!pgc&quot;
  }
  </code></pre>
  <p>I also tried to update the code as follows:</p>
  <pre><code>const Discord = require('discord.js');
  const fs = require('fs');
  
  const { Client, Intents } = require('discord.js');
  
  const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
  
  let rawdata = fs.readFileSync('config.json');
  let config = JSON.parse(rawdata);
  
  const TOKEN = config.botToken
  const prefix = config.prefix
  
  client.on('message', message =&gt; {
      if (!message.content.startsWith(prefix) || message.author.bot)
          return;
      const args = message.content.slice(prefix.lenght).split(/ +/)
      const command = args[1].toLowerCase()
      console.log(args)
      // Command test!
  })
  
  client.once('ready', () =&gt; {
      console.log(&quot;Discord bot online&quot;)
  });
  
  client.login(TOKEN)
  </code></pre>
  <p>But I still get an error:</p>
  <blockquote>
  <p>(node:12216) UnhandledPromiseRejectionWarning: ReferenceError: <br />
  AbortController is not defined <br />
  at RequestHandler.execute (C:\Users\utente\Desktop\bouncerBot\node_modules\discord.js\src\rest\RequestHandler.js:172:15) <br />
  at RequestHandler.execute (C:\Users\utente\Desktop\bouncerBot\node_modules\discord.js\src\rest\RequestHandler.js:176:19) <br />
  at RequestHandler.push (C:\Users\utente\Desktop\bouncerBot\node_modules\discord.js\src\rest\RequestHandler.js:50:25) <br />
  at async WebSocketManager.connect (C:\Users\utente\Desktop\bouncerBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:128:9) <br />
  at async Client.login (C:\Users\utente\Desktop\bouncerBot\node_modules\discord.js\src\client\Client.js:245:7) <br />
  (Use <code>node --trace-warnings ...</code> to show where the warning was
  created) (node:12216) 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(). To terminate the node process on
  unhandled promise rejection, use the CLI flag
  <code>--unhandled-rejections=strict</code> (see
  <a href="https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode" rel="nofollow noreferrer">https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode</a>).
  (rejection id: 2) (node:12216) [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.</p>
  </blockquote>