hikari.intents
#
Shard intents for controlling which events the application receives.
Intents
#
Bases: 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]
(https://discord.com/developers/applications/) 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 hikari.intents.Intents.GUILDS
intent, then it is
simply a case of accessing it normally.
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.DM_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.DM_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.DM_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.DM_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.DM_MESSAGES)
# or, simplifying
my_intents ^= (Intents.GUILD_MESSAGES | Intents.DM_MESSAGES)
What is and is not covered by intents?
The following unprivileged events require intents to be dispatched:
GUILD_CREATE
GUILD_UPDATE
GUILD_DELETE
GUILD_ROLE_CREATE
GUILD_ROLE_UPDATE
GUILD_ROLE_DELETE
GUILD_BAN_ADD
GUILD_BAN_REMOVE
GUILD_EMOJIS_UPDATE
INTEGRATION_CREATE
INTEGRATION_DELETE
INTEGRATION_UPDATE
INVITE_CREATE
INVITE_DELETE
CHANNEL_CREATE
CHANNEL_UPDATE
CHANNEL_DELETE
CHANNEL_PINS_UPDATE (guilds only)
THREAD_CREATE
THREAD_UPDATE
THREAD_DELETE
THREAD_LIST_SYNC
THREAD_MEMBER_UPDATE
THREAD_MEMBERS_UPDATE
MESSAGE_CREATE
MESSAGE_UPDATE
MESSAGE_DELETE
MESSAGE_BULK_DELETE
MESSAGE_REACTION_ADD
MESSAGE_REACTION_REMOVE
MESSAGE_REACTION_REMOVE_ALL
MESSAGE_REACTION_REMOVE_EMOJI
TYPING_START
VOICE_STATE_UPDATE
WEBHOOKS_UPDATE
The following privileged events require intents to be dispatched:
GUILD_MEMBER_ADD
GUILD_MEMBER_UPDATE
GUILD_MEMBER_REMOVE
PRESENCE_UPDATE
All events not listed above will be dispatched regardless of whether intents are used or not.
ALL
class-attribute
instance-attribute
#
ALL = ALL_UNPRIVILEGED | ALL_PRIVILEGED
All unprivileged and privileged intents.
Warning
This set of intent is privileged, and requires enabling/whitelisting to use.
ALL_DMS
class-attribute
instance-attribute
#
ALL_DMS = DM_MESSAGES | DM_MESSAGE_TYPING | DM_MESSAGE_REACTIONS
All direct message channel (non-guild bound) intents.
ALL_GUILDS
class-attribute
instance-attribute
#
ALL_GUILDS = ALL_GUILDS_UNPRIVILEGED | ALL_GUILDS_PRIVILEGED
All unprivileged guild intents and all privileged guild intents.
This combines hikari.intents.Intents.ALL_GUILDS_UNPRIVILEGED
and
hikari.intents.Intents.ALL_GUILDS_PRIVILEGED
.
Warning
This set of intent is privileged, and requires enabling/whitelisting to use.
ALL_GUILDS_PRIVILEGED
class-attribute
instance-attribute
#
ALL_GUILDS_PRIVILEGED = GUILD_MEMBERS | GUILD_PRESENCES
All privileged guild intents.
Warning
This set of intent is privileged, and requires enabling/whitelisting to use.
ALL_GUILDS_UNPRIVILEGED
class-attribute
instance-attribute
#
ALL_GUILDS_UNPRIVILEGED = (
GUILDS
| GUILD_EMOJIS
| GUILD_INTEGRATIONS
| GUILD_WEBHOOKS
| GUILD_INVITES
| GUILD_VOICE_STATES
| GUILD_MESSAGES
| GUILD_MESSAGE_REACTIONS
| GUILD_MESSAGE_TYPING
| GUILD_MODERATION
| GUILD_SCHEDULED_EVENTS
)
All unprivileged guild-related intents.
ALL_MESSAGES
class-attribute
instance-attribute
#
ALL_MESSAGES = DM_MESSAGES | GUILD_MESSAGES
All message intents.
ALL_MESSAGE_REACTIONS
class-attribute
instance-attribute
#
ALL_MESSAGE_REACTIONS = DM_MESSAGE_REACTIONS | GUILD_MESSAGE_REACTIONS
All message reaction intents.
ALL_MESSAGE_TYPING
class-attribute
instance-attribute
#
ALL_MESSAGE_TYPING = DM_MESSAGE_TYPING | GUILD_MESSAGE_TYPING
All typing indicator intents.
ALL_PRIVILEGED
class-attribute
instance-attribute
#
ALL_PRIVILEGED = ALL_GUILDS_PRIVILEGED | MESSAGE_CONTENT
All privileged intents.
Warning
This set of intent is privileged, and requires enabling/whitelisting to use.
ALL_UNPRIVILEGED
class-attribute
instance-attribute
#
ALL_UNPRIVILEGED = ALL_GUILDS_UNPRIVILEGED | ALL_DMS
All unprivileged intents.
DM_MESSAGES
class-attribute
instance-attribute
#
Subscribes to the events listed below.
MESSAGE_CREATE
(in direct message channels (non-guild bound) only)MESSAGE_UPDATE
(in direct message channels (non-guild bound) only)MESSAGE_DELETE
(in direct message channels (non-guild bound) only)
DM_MESSAGE_REACTIONS
class-attribute
instance-attribute
#
Subscribes to the events listed below.
MESSAGE_REACTION_ADD
(in direct message channels (non-guild bound) only)MESSAGE_REACTION_REMOVE
(in direct message channels (non-guild bound) only)MESSAGE_REACTION_REMOVE_ALL
(in direct message channels (non-guild bound) only)MESSAGE_REACTION_REMOVE_EMOJI
(in direct message channels (non-guild bound) only)
DM_MESSAGE_TYPING
class-attribute
instance-attribute
#
Subscribes to the events listed below.
TYPING_START
(in direct message channels (non-guild bound) only)
GUILDS
class-attribute
instance-attribute
#
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 hikari.intents.Intents.GUILDS
and hikari.intents.Intents.GUILD_MEMBERS
are required to receive
THREAD_MEMBERS_UPDATE
.
GUILD_EMOJIS
class-attribute
instance-attribute
#
Subscribes to the events listed below.
GUILD_EMOJIS_UPDATE
GUILD_INTEGRATIONS
class-attribute
instance-attribute
#
Subscribes to the events listed below.
INTEGRATION_CREATE
INTEGRATION_DELETE
INTEGRATION_UPDATE
GUILD_INVITES
class-attribute
instance-attribute
#
Subscribes to the events listed below.
INVITE_CREATE
INVITE_DELETE
GUILD_MEMBERS
class-attribute
instance-attribute
#
Subscribes to the events listed below.
GUILD_MEMBER_ADD
GUILD_MEMBER_UPDATE
GUILD_MEMBER_REMOVE
THREAD_MEMBERS_UPDATE
Note
Both hikari.intents.Intents.GUILDS
and hikari.intents.Intents.GUILD_MEMBERS
are required to receive
THREAD_MEMBERS_UPDATE
.
Warning
This intent is privileged, and requires enabling/whitelisting to use.
GUILD_MESSAGES
class-attribute
instance-attribute
#
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
class-attribute
instance-attribute
#
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_MESSAGE_TYPING
class-attribute
instance-attribute
#
Subscribes to the events listed below.
TYPING_START
(in guilds only)
GUILD_MODERATION
class-attribute
instance-attribute
#
Subscribes to the events listed below.
GUILD_AUDIT_LOG_ENTRY_CREATE
GUILD_BAN_ADD
GUILD_BAN_REMOVE
GUILD_PRESENCES
class-attribute
instance-attribute
#
Subscribes to the events listed below.
PRESENCE_UPDATE
Warning
This intent is privileged, and requires enabling/whitelisting to use.
GUILD_SCHEDULED_EVENTS
class-attribute
instance-attribute
#
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
GUILD_VOICE_STATES
class-attribute
instance-attribute
#
Subscribes to the events listed below.
VOICE_STATE_UPDATE
GUILD_WEBHOOKS
class-attribute
instance-attribute
#
Subscribes to the events listed below.
WEBHOOKS_UPDATE
MESSAGE_CONTENT
class-attribute
instance-attribute
#
Receive message content for all messages.
DM's to the bot and messages that mention it are exempt from this.
Warning
This intent is privileged, and requires enabling/whitelisting to use.
is_privileged
property
#
is_privileged: bool
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.
difference
#
Perform a set difference with the other set.
This will return all flags in this set that are not in the other value.
Equivalent to using the subtraction -
operator.
intersection
#
Return a combination of flags that are set for both given values.
Equivalent to using the "AND" &
operator.
is_disjoint
#
is_subset
#
Return whether another set contains this set or not.
Equivalent to using the "in" operator.
is_superset
#
Return whether this set contains another set or not.
none
#
none(*flags: Self) -> bool
Check if none of the given flags are part of this value.
Note
This is essentially the opposite of hikari.internal.enums.Flag.any
.
RETURNS | DESCRIPTION |
---|---|
bool
|
split
#
split() -> Sequence[Self]
Return a list of all defined atomic values for this flag.
Any unrecognised bits will be omitted for brevity.
The result will be a name-sorted typing.Sequence
of each member
symmetric_difference
#
Return a set with the symmetric differences of two flag sets.
Equivalent to using the "XOR" ^
operator.
For a ^ b
, this can be considered the same as (a - b) | (b - a)
.