Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix CLIENT_MISSING_INTENTS error?

I started learning about discord.js, but now I am facing this issue. I tried some googling, but I couldn't manage to fix it.

const Discord = require('discord.js');
// const Discord = require('discord.js');

// Using Intents class
const client = new Discord.Client();

client.on('message', (msg) => {
  // Send back a reply when the specific command has been written by a user.
  if (msg.content === '!hello') {
    msg.reply('Hello, World!');
  }
});

client.login('my_token');

This is the error I am getting:

Enter image description here

like image 855
NewJs Avatar asked Aug 07 '21 16:08

NewJs


People also ask

What is intents in discord JS?

Intents are named groups of pre-defined WebSocket events, which the discord. js client will receive. If you omit DirectMessageTyping , for example, you will no longer receive typing events from direct messages. If you provide no intents, discord.

What is presence intent discord?

Guild Presences (Presence Intent) is used for getting member presences, which includes: "Playing"/"Streaming"/"Watching"/"Competing" activities. Custom Status. User status: online, idle, dnd, or offline.

What version is discord JS?

14.0. 1. 14.0. 1 release bump, no new features.


3 Answers

You need to specify the events which you want your bot to receive using gateway intents.

Instead of

const client = new Discord.Client();

Use

const client = new Discord.Client({ intents: [Enter intents here] })

For example

const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] })

Here's another useful page: Gateways


  • Intents help you control which events your bot receives. See Privileged Intents for more information.
  • You need node.js 16.6 or higher to use discord.js13. npm install node@16 in shell.
  • The list of events are under the events tab at Client.
like image 62
Dregg Avatar answered Oct 23 '22 13:10

Dregg


You can instead just degrade the discord.js version by typing this into the shell:

npm i [email protected]

The latest discord.js version doesn't function very well, so I use v12. It isn't a complicated script.

like image 29
user16793483 Avatar answered Oct 23 '22 12:10

user16793483


client = new Discord.Client({intents: 32767})
like image 45
dishu Avatar answered Oct 23 '22 11:10

dishu