glyde/intents
Gateway intents: the IDENTIFY bitfield that decides which events Discord delivers.
Three are privileged and need switching on in the developer portal first. Asking for one you have not enabled closes the connection with 4014; a bit Discord has not assigned closes it with 4013, which is why this is opaque.
Types
pub type Intent {
Guilds
GuildMembers
GuildModeration
GuildExpressions
GuildIntegrations
GuildWebhooks
GuildInvites
GuildVoiceStates
GuildPresences
GuildMessages
GuildMessageReactions
GuildMessageTyping
DirectMessages
DirectMessageReactions
DirectMessageTyping
MessageContent
GuildScheduledEvents
AutoModerationConfiguration
AutoModerationExecution
GuildMessagePolls
DirectMessagePolls
}
Constructors
-
Guilds -
GuildMembers -
GuildModeration -
GuildExpressions -
GuildIntegrations -
GuildWebhooks -
GuildInvites -
GuildVoiceStates -
GuildPresences -
GuildMessages -
GuildMessageReactions -
GuildMessageTyping -
DirectMessages -
DirectMessageReactions -
DirectMessageTyping -
MessageContent -
GuildScheduledEvents -
AutoModerationConfiguration -
AutoModerationExecution -
GuildMessagePolls -
DirectMessagePolls
Values
pub fn all() -> Intents
Everything, privileged included. Discord refuses the connection with 4014 unless all three are enabled in the portal.
pub fn all_intents() -> List(Intent)
Every intent Discord currently defines, in bit order. A new variant has to
be added here by hand; nothing in the compiler catches an omission, so
every_bit_is_pinned_test counts this list against the bit table.
pub fn all_unprivileged() -> Intents
Everything that does not need portal setup.
pub fn bit_index(intent: Intent) -> Int
The bit number, not its value, from Discord’s gateway intents table. Discord has assigned nothing to bits 17 to 19 or 22 to 23, and asking for one of those closes the connection with 4013.
pub fn is_privileged(intent: Intent) -> Bool
Exhaustive with no wildcard on purpose. A privileged intent Discord adds
later would otherwise read as unprivileged here, all_unprivileged would
ask for it, and the connection glyde promised would work closes with 4014.
pub fn none() -> Intents
No intents. Ungated events still arrive, READY and INTERACTION_CREATE among them, so this is right for a slash-command bot.
pub fn privileged() -> List(Intent)
Enable these in the developer portal before asking for them. Above 100 servers they also need Discord’s approval.
pub fn privileged_in(intents: Intents) -> List(Intent)
The privileged intents in this set, to name in an error message when Discord answers with 4014.
pub fn to_int(intents: Intents) -> Int
The bitfield for IDENTIFY. Discord wants a number here, unlike a permission set, which it sends and takes as a decimal string.