Discord Bot Unavailable Guilds Troubles

I started creating my own Discord bot for my friend’s server and I keep running through the same problem.

I wrote a simple thing to have a first interaction between me and the bot:

client.on("messageCreate", message => {
    console.log(message.content);
});

This should write in console the content of any message sent on the discord server the bot is connected on (It’s only connected to my test server)

I didn’t understand why this doesn’t work so I started looking for it and used the “debug” event.

When running node index.js the console tells me:

Booting up...
[WS => Manager] Fetched Gateway Information
URL: wss://gateway.discord.gg
    Recommended Shards: 1
[WS => Manager] Session Limit Information
    Total: 1000
    Remaining: 981
[WS => Manager] Spawning shards: 0
[WS => Shard 0] [CONNECT]
    Gateway    : wss://gateway.discord.gg/
    Version    : 9
    Encoding   : json
    Compression: none
[WS => Shard 0] Setting a HELLO timeout for 20s.
[WS => Shard 0] [CONNECTED] Took 172ms
[WS => Shard 0] Clearing the HELLO timeout.
[WS => Shard 0] Setting a heartbeat interval for 41250ms.
[WS => Shard 0] [IDENTIFY] Shard 0/1 with intents: 8
[WS => Shard 0] [READY] Session f3fcd33aad118dc188b7b63c3eec3eed.
[WS => Shard 0] [ReadyHeartbeat] Sending a heartbeat.
[WS => Shard 0] Shard will not receive any more guild packets.
   Unavailable guild count: 1
Booted !
[WS => Shard 0] Heartbeat acknowledged, latency of 112ms.
[WS => Shard 0] [HeartbeatTimer] Sending a heartbeat.
[WS => Shard 0] Heartbeat acknowledged, latency of 120ms.
[WS => Shard 0] [HeartbeatTimer] Sending a heartbeat.

Then it keeps sending heartbeats and acknowledge it until I stop it.

What tells me something is wrong is this:

“Shard will not receive any more guild packets”

“Unavailable guild count : 1”

Here’s my whole index.js (only my token is in config.json):

console.log("Booting up...");
const { Client, Intents } = require("discord.js"); 
const {spd} = require("./config.json");
const botIntents = 8;
const client = new Client({intents : botIntents});

client.login(spd);

client.once("ready", isBooted);

client.on("messageCreate", message => {
    console.log(message.content);
});

client.on("debug", err => { 
    console.log(err);
});

/////////

function isBooted() {
    console.log(" Booted !");
}

System information:

Windows 10
NPM 8.0.0
Node v16.11.1
Discord.js 13.2.0

Tell me if you need further info to help you.

Answer

It seems the only Intent you are using is GUILD_EMOJIS_AND_STICKERS, which I found out with this intents calculator. You should show each intent so you can easily modify it:

const { Client, Intents } = require("discord.js")
const client = new Client({intents : [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES]});