hikari.intents#
Shard intents for controlling which events the application receives.
Module Contents#
- class hikari.intents.Intents[source]#
Bases:
hikari.internal.enums.Flag
Represents an intent on the gateway.
This is a bitfield representation of all the categories of event that you wish to receive.
Any events not in an intent category will be fired regardless of what intents you provide.
Note
Discord now places limits on certain events you can receive without whitelisting your bot first. On the
Bot
tab in the developer’s portal for your bot, you should now have the option to enable functionality for receiving these events.If you attempt to request an intent type that you have not whitelisted your bot for, you will be disconnected on startup with a
4014
closure code.Warning
If you are using the V7 Gateway, you will be REQUIRED to provide some form of intent value when you connect. Failure to do so may result in immediate termination of the session server-side.
This enum is an
enum.IntFlag
, which means that you can use bitwise operators to join and splice multiple intents into one value.For example, if we wish to only refer to the
GUILDS
intent, then it is simply a case of accessing it normally.my_intents = Intents.GUILDS
If we wanted to have several intents grouped together, we would use the bitwise-or operator to combine them (
|
). This can be done in-place with the|=
operator if needed.# One or two values that fit on one line. my_intents = Intents.GUILD_MESSAGES | Intents.PRIVATE_MESSAGES # Several intents together. You may find it useful to format these like # so to keep your code readable. my_intents = ( Intents.GUILDS | Intents.GUILD_EMOJIS | Intents.GUILD_INTEGRATIONS | Intents.GUILD_MESSAGES | Intents.GUILD_MODERATION | Intents.PRIVATE_MESSAGES )
To check if an intent is present in a given intents bitfield, you can use the bitwise-and operator (
&
) to check. This returns the “intersection” or “crossover” between the left and right-hand side of the&
. You can then use the==
operator to check that specific values are present. You can check in-place with the&=
operator if needed.# Check if an intent is set: if (my_intents & Intents.GUILD_MESSAGES) == Intents.GUILD_MESSAGES: print("Guild messages are enabled") # Checking if ALL in a combination are set: expected_intents = (Intents.GUILD_MESSAGES | Intents.PRIVATE_MESSAGES) if (my_intents & expected_intents) == expected_intents: print("Messages are enabled in guilds and private messages.") # Checking if AT LEAST ONE in a combination is set: expected_intents = (Intents.GUILD_MESSAGES | Intents.PRIVATE_MESSAGES) if my_intents & expected_intents: print("Messages are enabled in guilds or private messages.")
Removing one or more intents from a combination can be done with the bitwise-xor (
^
) operator. The^=
operator can do this in-place.# Remove GUILD_MESSAGES my_intents = my_intents ^ Intents.GUILD_MESSAGES # or, simplifying: my_intents ^= Intents.GUILD_MESSAGES # Remove all messages events. my_intents = my_intents ^ (Intents.GUILD_MESSAGES | Intents.PRIVATE_MESSAGES) # or, simplifying my_intents ^= (Intents.GUILD_MESSAGES | Intents.PRIVATE_MESSAGES)
- property is_privileged: bool[source]#
Determine whether the intent requires elevated privileges.
If this is
True
, you will be required to opt-in to using this intent on the Discord Developer Portal before you can utilise it in your application.
- ALL[source]#
All unprivileged and privileged intents.
Warning
This set of intent is privileged, and requires enabling/whitelisting to use.
- ALL_GUILDS[source]#
All unprivileged guild intents and all privileged guild intents.
This combines
Intents.ALL_GUILDS_UNPRIVILEGED
andIntents.ALL_GUILDS_PRIVILEGED
.Warning
This set of intent is privileged, and requires enabling/whitelisting to use.
- ALL_GUILDS_PRIVILEGED[source]#
All privileged guild intents.
Warning
This set of intent is privileged, and requires enabling/whitelisting to use.
- ALL_PRIVILEGED[source]#
All privileged intents.
Warning
This set of intent is privileged, and requires enabling/whitelisting to use.
- DM_MESSAGES[source]#
Subscribes to the events listed below.
MESSAGE_CREATE
(in private message channels (non-guild bound) only)MESSAGE_UPDATE
(in private message channels (non-guild bound) only)MESSAGE_DELETE
(in private message channels (non-guild bound) only)
- DM_MESSAGE_REACTIONS[source]#
Subscribes to the events listed below.
MESSAGE_REACTION_ADD
(in private message channels (non-guild bound) only)MESSAGE_REACTION_REMOVE
(in private message channels (non-guild bound) only)MESSAGE_REACTION_REMOVE_ALL
(in private message channels (non-guild bound) only)MESSAGE_REACTION_REMOVE_EMOJI
(in private message channels (non-guild bound) only)
- DM_MESSAGE_TYPING[source]#
Subscribes to the events listed below.
TYPING_START
(in private message channels (non-guild bound) only)
- GUILDS[source]#
Subscribes to the events listed below.
GUILD_CREATE
GUILD_UPDATE
GUILD_DELETE
GUILD_ROLE_CREATE
GUILD_ROLE_UPDATE
GUILD_ROLE_DELETE
CHANNEL_CREATE
CHANNEL_UPDATE
CHANNEL_DELETE
CHANNEL_PINS_UPDATE
THREAD_CREATE
THREAD_UPDATE
THREAD_DELETE
THREAD_LIST_SYNC
THREAD_MEMBER_UPDATE
THREAD_MEMBERS_UPDATE
Note
Both
GUILDS
andGUILD_MEMBERS
are required to receiveTHREAD_MEMBERS_UPDATE
.
- GUILD_INTEGRATIONS[source]#
Subscribes to the events listed below.
INTEGRATION_CREATE
INTEGRATION_DELETE
INTEGRATION_UPDATE
- GUILD_MEMBERS[source]#
Subscribes to the events listed below.
GUILD_MEMBER_ADD
GUILD_MEMBER_UPDATE
GUILD_MEMBER_REMOVE
THREAD_MEMBERS_UPDATE
Note
Both
GUILDS
andGUILD_MEMBERS
are required to receiveTHREAD_MEMBERS_UPDATE
.Warning
This intent is privileged, and requires enabling/whitelisting to use.
- GUILD_MESSAGES[source]#
Subscribes to the events listed below.
MESSAGE_CREATE
(in guilds only)MESSAGE_UPDATE
(in guilds only)MESSAGE_DELETE
(in guilds only)MESSAGE_BULK_DELETE
(in guilds only)
- GUILD_MESSAGE_REACTIONS[source]#
Subscribes to the events listed below.
MESSAGE_REACTION_ADD
(in guilds only)MESSAGE_REACTION_REMOVE
(in guilds only)MESSAGE_REACTION_REMOVE_ALL
(in guilds only)MESSAGE_REACTION_REMOVE_EMOJI
(in guilds only)
- GUILD_MODERATION[source]#
Subscribes to the events listed below.
GUILD_AUDIT_LOG_ENTRY_CREATE
GUILD_BAN_ADD
GUILD_BAN_REMOVE
- GUILD_PRESENCES[source]#
Subscribes to the events listed below.
PRESENCE_UPDATE
Warning
This intent is privileged, and requires enabling/whitelisting to use.
- GUILD_SCHEDULED_EVENTS[source]#
Subscribes to the events listed below.
GUILD_SCHEDULED_EVENT_CREATE
GUILD_SCHEDULED_EVENT_UPDATE
GUILD_SCHEDULED_EVENT_DELETE
GUILD_SCHEDULED_EVENT_USER_ADD
GUILD_SCHEDULED_EVENT_USER_REMOVE