Skip to content

Instantly share code, notes, and snippets.

@advaith1
Last active Nov 10, 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 went 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 did not support this until v2.)

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 v14 uses Gateway v10, v13 uses Gateway v9, and older versions use gateway v6. discord.py v2 uses Gateway v10. Some versions of discord.py v1 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.
@0x4576616e
Copy link

0x4576616e commented Oct 27, 2020

πŸ‘

@drouethug
Copy link

drouethug commented Oct 27, 2020

πŸ‘

@6881
Copy link

6881 commented Oct 28, 2020

πŸ‘

@krisppurg
Copy link

krisppurg commented Oct 28, 2020

πŸ‘

@Monoverde888
Copy link

Monoverde888 commented Nov 1, 2020

pretty epic

@Lilwiggy
Copy link

Lilwiggy commented Nov 3, 2020

πŸ‘

@Rayrnond
Copy link

Rayrnond commented Dec 14, 2020

πŸ‘

@Ronish1122
Copy link

Ronish1122 commented Jan 30, 2021

πŸ‘

@mnshazlie
Copy link

mnshazlie commented Feb 17, 2021

image

@isaackogan
Copy link

isaackogan commented Apr 13, 2021

πŸ‘

@ndzn
Copy link

ndzn commented Apr 27, 2021

πŸ‘

@ZeroDiscord
Copy link

ZeroDiscord commented Apr 28, 2021

good stuff

@wnm210
Copy link

wnm210 commented May 31, 2021

good job

@AMC-lightning-oreo
Copy link

AMC-lightning-oreo commented Jun 14, 2021

THX DUDE THIS IS VERY HELPFUL!

@ParzivalHack
Copy link

ParzivalHack commented Jul 15, 2021

This helped me a lot with my discord bot. I just filled the verification form. Hope it will get verified soon.

@JDJGInc
Copy link

JDJGInc commented Jul 30, 2021

discord.py has no tutorials on a direct api request

@Cakepvpanda
Copy link

Cakepvpanda commented Jul 30, 2021

thank you this will be very helpful

@ExordiumX
Copy link

ExordiumX commented Aug 26, 2021

Wtf does the intent 1 << 1 mean? How would I put that in my code.. (not using a library)

@MeguminSama
Copy link

MeguminSama commented Aug 26, 2021

Wtf does the intent 1 << 1 mean? How would I put that in my code.. (not using a library)

https://en.wikipedia.org/wiki/Bitwise_operation

@advaith1
Copy link
Author

advaith1 commented Aug 26, 2021

@DanDev95 it computes to a number; to use multiple intents, use the | operator:

intents: 1 << 0 | 1 << 1 | 1 << 2

that computes to intents: 7

you can use https://ziad87.net/intents/ to see the result number (and events) of having certain intents

to learn about the operators:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Left_shift
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR

@LightningBolt62
Copy link

LightningBolt62 commented Oct 9, 2021

Thank you so much! This was extremely helpful.

@ahmed-RiK
Copy link

ahmed-RiK commented Oct 27, 2021

This helped me a lot with my discord bot. I just filled the verification form. Hope it will get verified soon.

Did u git verified?

@JDJGInc
Copy link

JDJGInc commented Dec 8, 2021

Fun fact I actually added approrixmate_member_count and approximate_prescence_count to some discord.py forks myself.
So 🀷 Yeah it exists.

@zLevii
Copy link

zLevii commented Dec 23, 2021

This is a really helpful documentation

@oq-x
Copy link

oq-x commented Feb 16, 2022

πŸ‘

@JDJGInc
Copy link

JDJGInc commented Mar 6, 2022

with_counts has been added to dpy :)
Please update the gist thank you.

@Abaios
Copy link

Abaios commented Apr 5, 2022

πŸ‘

@twisttaan
Copy link

twisttaan commented May 31, 2022

image

advaith is the documentation
image

@JDJGInc
Copy link

JDJGInc commented Aug 18, 2022

"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.)"

https://pypi.org/project/discord.py/2.0.0/
(also it's on a release one)

@papiforcex
Copy link

papiforcex commented Oct 30, 2022

πŸ‘

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