Skip to content

Instantly share code, notes, and snippets.

@advaith1
Last active Jun 1, 2022
Embed
What would you like to do?
Discord Gateway Intents Explainer

Intents Explainer

If you're wondering what Gateway Intents are, what Privileged Intents are, why your bot can't see statuses, or why your bot can't see member joins anymore, then this page should explain it to you!

if you do not know what intents are, please read this entire page

Intro

First, a short explanation of how bots work: bots can make requests over the REST (HTTP) API to retreive information and do actions, and they get real-time updates from Discord in the form of websocket gateway events. They can also fetch server members via the gateway.

Examples of gateway events you are probably familiar with are Message Create (a message was sent) and Guild Member Add (a user joined a server).

What are Gateway Intents?

Gateway Intents are groups of events. Bots can choose which intents to receive events from. You can see the docs and full list of intents here.

Need help with setting intents in your code? These links should help: discord.js, discord.py, JDA

Privileged Intents

Discord has made 3 intents privileged intents: GUILD_MEMBERS (Server Members), GUILD_PRESENCES (Presence), and Message Content. These intents are now disabled by default in Gateway v6.

What are these privileged intents needed for?

Guild Members (Server Members Intent) is used for:

  • Doing something when someone joins a server (Guild Member Add event)
  • Doing something when a member/user's data is updated (Guild Member Update event)
  • Doing something when someone leaves a server (Guild Member Remove event)
  • Getting the entire list of members in a server (Request/List Guild Members)

It is not needed for:

  • Seeing data of the author of a message (that is included in the message data)
  • Getting a specific member/user by ID
  • Getting a guild member by their name
  • Getting a guild's member count (that can be retreived with the Get Guild endpoint)

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

The intent is needed to fetch this data as well as get the Presence Update event when it changes; all users other than the bot will appear offline with no activities if you do not have this intent.

It is not needed for setting the bot's status/presence.

The presence intent is also required for the initial guild member list (which includes all members for small guilds and online members + members without roles for larger guilds), but note that your bot will not be whitelisted for the presence intent if you just need it for member caching. You should be fetching members/users when needed instead of relying on your bot's member/user cache.

The Message Content intent is used for reading the content, embeds, attachments, and components of a message. It is not needed for sending messages, it only affects reading. You should be using Slash Commands instead of using messages for commands; you will not get the intent if your sue case for it can be replaced with Interactions. For more information, read the FAQ and Policy.

The Message Content intent will go into effect on September 1, 2022.

Common Privileged Intent Misconceptions

  • You do not need, and will not get, privileged intents to get a "user count" for your bot. If intents affects your "user count", then you are probably showing the amount of cached users. Instead, if you really want a "user count", add up the member counts of all servers; for help doing this in your library, go to its support server.

  • You do not need privileged intents to get a server's member count or online member count. Instead, you should fetch the guild and and use the approximate_member_count and approximate_presence_count properties. (discord.py seems to not currently support this, so if you use discord.py you should do a direct API request. discord.js supports this.)

Getting Privileged Intents

You cannot just specify privileged intents in your list and get them, you must enable or be whitelisted for them:

for bots in less than 76 servers:

  • Go to the Developer Portal, select your bot, and click the Bot tab
  • Turn on the switches for the intents you need
Click to show screenshot

for bigger bots:

You should request the privileged intents your bot requires in the bot verification form when applying for verification.

Note: You will not be approved for privileged intents for userinfo/serverinfo commands.

If your bot is verified but you did not do that and you need the intent now, go to your application's Bot tab in the Developer Portal and request them.

Default Behavior

On Gateway v8 and v9, sending intents is required to connect. On v6, bots now get events from all intents they qualify for. This includes all non-privileged intents as well as all intents you have enabled (for bots in <100 servers) or all events you are whitelisted for (for bigger bots).

discord.js v13 uses Gateway v9, and older versions use gateway v6. New versions of discord.py use Gateway v6 but send an intents value of all non-privileged intents by default, so if you want privileged intents you have to specify intents in your code.

Verified bots: Don't know if you are whitelisted? Click to see an image showing the states of the intent switches for verified bots.
@twisttaan
Copy link

twisttaan commented May 31, 2022

image

advaith is the documentation
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment