Fix Discord Bot Token Invalid and Intents Errors

How-toBy discordbothostUpdated 3 min read

The short answer: An invalid token error means Discord rejected the credential your process sent. A disallowed intents error means the code requested a privileged intent that the app cannot use. Reset exposed tokens, set the replacement privately and align the code with Developer Portal settings. Read the first login error before starting another retry loop.

Token errors (4004)

Symptoms: Error [TokenInvalid]: An invalid token was provided. (discord.js), discord.errors.LoginFailure: Improper token has been passed. (discord.py), or InvalidTokenException (JDA).

Fix:

  1. Developer Portal → your app → Bot → Reset Token, then copy it.
  2. Paste it into the host's environment variable (for example BOT_TOKEN). Watch for stray spaces, quotes or a line break.
  3. Make sure your code reads that exact variable name, and that you didn't paste the client secret or application ID instead.
  4. Restart the bot.

If the token keeps getting reset by itself, it has probably leaked, often in a public GitHub repo. Discord can automatically reset tokens that show up in public repos. Remove it from the code, rotate it, and keep it only in environment variables (deploying from GitHub safely).

Intents errors (4014)

Privileged intents are Message Content, Server Members and Presence. Discord's docs say you must toggle each one for your app in the Developer Portal before you request it. Verified apps, which Discord requires once you're in 100+ servers, also need approval.

Fix:

  1. Developer Portal → Bot → turn on the intents your code asks for.
  2. Ask only for what you use in code:

- discord.js: new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] })

- discord.py: intents = discord.Intents.default(); intents.message_content = True

- JDA: JDABuilder.createDefault(token).enableIntents(GatewayIntent.MESSAGE_CONTENT)

  1. Restart.

Commands see empty message.content? That's the same intent: without Message Content, text is blank except in DMs and messages that mention the bot. Or switch to slash commands, which don't need it.

Other close codes you might see

Reference · Article updated
CodeMeaningWhat to do
4011Sharding requiredBot is in 2,500+ servers; shard it
4013Invalid intent(s)Your intents value is malformed; check the bitfield
4014Disallowed intent(s)Enable or remove the privileged intent
4004Authentication failedFix the token

Where discordbothost helps

On discordbothost you set the token as an environment variable in the portal, so it stays out of your files and your repo. The console shows the exact error and close code when the bot starts. Bots restart automatically after a crash. Repeated crashes pause restarts; check the console before starting again. Paid plans post a crash alert to your Discord.

Sources

https://discord.com/developers/docs/topics/opcodes-and-status-codes; https://discord.com/developers/docs/events/gateway (privileged intents). Checked .

Questions

What does Discord error 4004 mean?

Authentication failed: the token sent when the bot connected is incorrect. Reset the token in the Developer Portal, update it on your host, and restart.

What does error 4014 Disallowed intent(s) mean?

Your bot asked for a privileged intent (Message Content, Server Members or Presence) that isn't enabled for the app. Enable it under Bot → Privileged Gateway Intents, or stop requesting it. Apps in 100+ servers must be verified and approved for privileged intents.

Why is message.content empty in my bot?

Message Content is a privileged intent. Enable it in the Developer Portal and request it in your code; otherwise message text is empty except for messages that mention the bot or DMs.

  1. 1https://discord.com/developers/docs/topics/opcodes-and-status-codes
  2. 2https://discord.com/developers/docs/events/gateway
  3. 3https://discordbothost.com/pricing/

Related