#[repr(packed(1))]pub struct GatewayIntents(/* private fields */);
Expand description
Gateway Intents will limit the events your bot will receive via the gateway. By default, all intents except Privileged Intents are selected.
§What are Intents
A [gateway intent] sets the types of gateway events (e.g. member joins, guild integrations, guild emoji updates, …) the bot shall receive. Carefully picking the needed intents greatly helps the bot to scale, as less intents will result in less events to be received via the network from Discord and less processing needed for handling the data.
§Privileged Intents
The intents GatewayIntents::GUILD_PRESENCES
, GatewayIntents::GUILD_MEMBERS
and
GatewayIntents::MESSAGE_CONTENT
are Privileged Intents. They need to be enabled in
the developer portal.
Note: Once the bot is in 100 guilds or more, the bot must be verified in order to use privileged intents.
Implementations§
Source§impl GatewayIntents
impl GatewayIntents
Sourcepub const GUILDS: Self
pub const GUILDS: Self
Enables the following gateway events:
- 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
- STAGE_INSTANCE_CREATE
- STAGE_INSTANCE_UPDATE
- STAGE_INSTANCE_DELETE
Info: The THREAD_MEMBERS_UPDATE event contains different data depending on which intents are used. See Discord’s Docs for more information.
Sourcepub const GUILD_MEMBERS: Self
pub const GUILD_MEMBERS: Self
Enables the following gateway events:
- GUILD_MEMBER_ADD
- GUILD_MEMBER_UPDATE
- GUILD_MEMBER_REMOVE
- THREAD_MEMBERS_UPDATE
Info: This intent is privileged. In order to use it, you must head to your application in the Developer Portal and enable the toggle for Privileged Intents, as well as enabling it in your code.
Info: The THREAD_MEMBERS_UPDATE event contains different data depending on which intents are used. See Discord’s Docs for more information.
Sourcepub const GUILD_MODERATION: Self
pub const GUILD_MODERATION: Self
Enables the following gateway events:
- GUILD_AUDIT_LOG_ENTRY_CREATE
- GUILD_BAN_ADD
- GUILD_BAN_REMOVE
Sourcepub const GUILD_BANS: Self
👎Deprecated: Use [Self::GUILD_MODERATION
] instead
pub const GUILD_BANS: Self
Self::GUILD_MODERATION
] insteadBackwards compatibility with old gateway event name. Same as GUILD_MODERATION
Sourcepub const GUILD_EMOJIS_AND_STICKERS: Self
pub const GUILD_EMOJIS_AND_STICKERS: Self
Enables the following gateway events:
- GUILD_EMOJIS_UPDATE
- GUILD_STICKERS_UPDATE
Sourcepub const GUILD_INTEGRATIONS: Self
pub const GUILD_INTEGRATIONS: Self
Enables the following gateway events:
- GUILD_INTEGRATIONS_UPDATE
- INTEGRATION_CREATE
- INTEGRATION_UPDATE
- INTEGRATION_DELETE
Sourcepub const GUILD_WEBHOOKS: Self
pub const GUILD_WEBHOOKS: Self
Enables the following gateway event:
- WEBHOOKS_UPDATE
Sourcepub const GUILD_INVITES: Self
pub const GUILD_INVITES: Self
Enables the following gateway events:
- INVITE_CREATE
- INVITE_DELETE
Sourcepub const GUILD_VOICE_STATES: Self
pub const GUILD_VOICE_STATES: Self
Enables the following gateway event:
- VOICE_STATE_UPDATE
Note: this intent is mandatory for songbird
to function properly.
Sourcepub const GUILD_PRESENCES: Self
pub const GUILD_PRESENCES: Self
Enables the following gateway event:
- PRESENCE_UPDATE
Info: This intent is privileged. In order to use it, you must head to your application in the Developer Portal and enable the toggle for Privileged Intents, as well as enabling it in your code.
Sourcepub const GUILD_MESSAGES: Self
pub const GUILD_MESSAGES: Self
Enables the following gateway events in guilds:
- MESSAGE_CREATE
- MESSAGE_UPDATE
- MESSAGE_DELETE
- MESSAGE_DELETE_BULK
Sourcepub const GUILD_MESSAGE_REACTIONS: Self
pub const GUILD_MESSAGE_REACTIONS: Self
Enables the following gateway events in guilds:
- MESSAGE_REACTION_ADD
- MESSAGE_REACTION_REMOVE
- MESSAGE_REACTION_REMOVE_ALL
- MESSAGE_REACTION_REMOVE_EMOJI
Sourcepub const GUILD_MESSAGE_TYPING: Self
pub const GUILD_MESSAGE_TYPING: Self
Enable following gateway event:
- TYPING_START
Sourcepub const DIRECT_MESSAGES: Self
pub const DIRECT_MESSAGES: Self
Enables the following gateway events for direct messages:
- MESSAGE_CREATE
- MESSAGE_UPDATE
- MESSAGE_DELETE
- CHANNEL_PINS_UPDATE
Sourcepub const DIRECT_MESSAGE_REACTIONS: Self
pub const DIRECT_MESSAGE_REACTIONS: Self
Enable following gateway events for direct messages:
- MESSAGE_REACTION_ADD
- MESSAGE_REACTION_REMOVE
- MESSAGE_REACTION_REMOVE_ALL
- MESSAGE_REACTION_REMOVE_EMOJI
Sourcepub const DIRECT_MESSAGE_TYPING: Self
pub const DIRECT_MESSAGE_TYPING: Self
Enables the following gateway events for direct messages:
- TYPING_START
Sourcepub const MESSAGE_CONTENT: Self
pub const MESSAGE_CONTENT: Self
Enables receiving message content in gateway events
See Discord’s Docs for more information
Info: This intent is privileged. In order to use it, you must head to your application in the Developer Portal and enable the toggle for Privileged Intents, as well as enabling it in your code.
Sourcepub const GUILD_SCHEDULED_EVENTS: Self
pub const GUILD_SCHEDULED_EVENTS: Self
Enables the following gateway events:
- GUILD_SCHEDULED_EVENT_CREATE
- GUILD_SCHEDULED_EVENT_UPDATE
- GUILD_SCHEDULED_EVENT_DELETE
- GUILD_SCHEDULED_EVENT_USER_ADD
- GUILD_SCHEDULED_EVENT_USER_REMOVE
Sourcepub const AUTO_MODERATION_CONFIGURATION: Self
pub const AUTO_MODERATION_CONFIGURATION: Self
Enables the following gateway events:
- AUTO_MODERATION_RULE_CREATE
- AUTO_MODERATION_RULE_UPDATE
- AUTO_MODERATION_RULE_DELETE
Sourcepub const AUTO_MODERATION_EXECUTION: Self
pub const AUTO_MODERATION_EXECUTION: Self
Enables the following gateway events:
- AUTO_MODERATION_ACTION_EXECUTION
Sourcepub const GUILD_MESSAGE_POLLS: Self
pub const GUILD_MESSAGE_POLLS: Self
Enables the following gateway events for guilds:
- MESSAGE_POLL_VOTE_ADD
- MESSAGE_POLL_VOTE_REMOVE
Sourcepub const DIRECT_MESSAGE_POLLS: Self
pub const DIRECT_MESSAGE_POLLS: Self
Enables the following gateway events for direct messages:
- MESSAGE_POLL_VOTE_ADD
- MESSAGE_POLL_VOTE_REMOVE
Source§impl GatewayIntents
impl GatewayIntents
Sourcepub const fn bits(&self) -> u64
pub const fn bits(&self) -> u64
Get the underlying bits value.
The returned value is exactly the bits set in this flags value.
Sourcepub const fn from_bits(bits: u64) -> Option<Self>
pub const fn from_bits(bits: u64) -> Option<Self>
Convert from a bits value.
This method will return None
if any unknown bits are set.
Sourcepub const fn from_bits_truncate(bits: u64) -> Self
pub const fn from_bits_truncate(bits: u64) -> Self
Convert from a bits value, unsetting any unknown bits.
Sourcepub const fn from_bits_retain(bits: u64) -> Self
pub const fn from_bits_retain(bits: u64) -> Self
Convert from a bits value exactly.
Sourcepub fn from_name(name: &str) -> Option<Self>
pub fn from_name(name: &str) -> Option<Self>
Get a flags value with the bits of a flag with the given name set.
This method will return None
if name
is empty or doesn’t
correspond to any named flag.
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Whether any set bits in a source flags value are also set in a target flags value.
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Whether all set bits in a source flags value are also set in a target flags value.
Sourcepub fn remove(&mut self, other: Self)
pub fn remove(&mut self, other: Self)
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
remove
won’t truncate other
, but the !
operator will.
Sourcepub fn toggle(&mut self, other: Self)
pub fn toggle(&mut self, other: Self)
The bitwise exclusive-or (^
) of the bits in two flags values.
Sourcepub fn set(&mut self, other: Self, value: bool)
pub fn set(&mut self, other: Self, value: bool)
Call insert
when value
is true
or remove
when value
is false
.
Sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
The bitwise and (&
) of the bits in two flags values.
Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
The bitwise or (|
) of the bits in two flags values.
Sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
difference
won’t truncate other
, but the !
operator will.
Sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
The bitwise exclusive-or (^
) of the bits in two flags values.
Sourcepub const fn complement(self) -> Self
pub const fn complement(self) -> Self
The bitwise negation (!
) of the bits in a flags value, truncating the result.
Source§impl GatewayIntents
impl GatewayIntents
Sourcepub const fn iter(&self) -> Iter<GatewayIntents>
pub const fn iter(&self) -> Iter<GatewayIntents>
Yield a set of contained flags values.
Each yielded flags value will correspond to a defined named flag. Any unknown bits will be yielded together as a final flags value.
Sourcepub const fn iter_names(&self) -> IterNames<GatewayIntents>
pub const fn iter_names(&self) -> IterNames<GatewayIntents>
Yield a set of contained named flags values.
This method is like iter
, except only yields bits in contained named flags.
Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
Source§impl GatewayIntents
impl GatewayIntents
Sourcepub const fn non_privileged() -> GatewayIntents
pub const fn non_privileged() -> GatewayIntents
Gets all of the intents that aren’t considered privileged by Discord.
Sourcepub const fn privileged() -> GatewayIntents
pub const fn privileged() -> GatewayIntents
Gets all of the intents that are considered privileged by Discord. Use of these intents will require explicitly whitelisting the bot.
Source§impl GatewayIntents
impl GatewayIntents
Sourcepub const fn is_privileged(self) -> bool
pub const fn is_privileged(self) -> bool
Checks if any of the included intents are privileged.
Sourcepub const fn guilds(self) -> bool
pub const fn guilds(self) -> bool
Shorthand for checking that the set of intents contains the GUILDS intent.
Sourcepub const fn guild_members(self) -> bool
pub const fn guild_members(self) -> bool
Shorthand for checking that the set of intents contains the GUILD_MEMBERS intent.
Sourcepub const fn guild_bans(self) -> bool
👎Deprecated: Use [Self::guild_moderation
] instead
pub const fn guild_bans(self) -> bool
Self::guild_moderation
] insteadShorthand for checking that the set of intents contains the GUILD_BANS intent.
This is the same as calling guild_moderation since Discord changed the name
Sourcepub const fn guild_moderation(self) -> bool
pub const fn guild_moderation(self) -> bool
Shorthand for checking that the set of intents contains the GUILD_MODERATION intent.
Sourcepub const fn guild_emojis_and_stickers(self) -> bool
pub const fn guild_emojis_and_stickers(self) -> bool
Shorthand for checking that the set of intents contains the GUILD_EMOJIS_AND_STICKERS intent.
Sourcepub const fn guild_integrations(self) -> bool
pub const fn guild_integrations(self) -> bool
Shorthand for checking that the set of intents contains the GUILD_INTEGRATIONS intent.
Sourcepub const fn guild_webhooks(self) -> bool
pub const fn guild_webhooks(self) -> bool
Shorthand for checking that the set of intents contains the GUILD_WEBHOOKS intent.
Sourcepub const fn guild_invites(self) -> bool
pub const fn guild_invites(self) -> bool
Shorthand for checking that the set of intents contains the GUILD_INVITES intent.
Sourcepub const fn guild_voice_states(self) -> bool
pub const fn guild_voice_states(self) -> bool
Shorthand for checking that the set of intents contains the GUILD_VOICE_STATES intent.
Sourcepub const fn guild_presences(self) -> bool
pub const fn guild_presences(self) -> bool
Shorthand for checking that the set of intents contains the GUILD_PRESENCES intent.
Sourcepub const fn guild_message_reactions(self) -> bool
pub const fn guild_message_reactions(self) -> bool
Shorthand for checking that the set of intents contains the GUILD_MESSAGE_REACTIONS intent.
Sourcepub const fn guild_message_typing(self) -> bool
pub const fn guild_message_typing(self) -> bool
Shorthand for checking that the set of intents contains the GUILD_MESSAGE_TYPING intent.
Sourcepub const fn direct_messages(self) -> bool
pub const fn direct_messages(self) -> bool
Shorthand for checking that the set of intents contains the DIRECT_MESSAGES intent.
Sourcepub const fn direct_message_reactions(self) -> bool
pub const fn direct_message_reactions(self) -> bool
Shorthand for checking that the set of intents contains the DIRECT_MESSAGE_REACTIONS intent.
Sourcepub const fn direct_message_typing(self) -> bool
pub const fn direct_message_typing(self) -> bool
Shorthand for checking that the set of intents contains the DIRECT_MESSAGE_TYPING intent.
Sourcepub const fn message_content(self) -> bool
pub const fn message_content(self) -> bool
Shorthand for checking that the set of intents contains the MESSAGE_CONTENT intent.
Sourcepub const fn guild_scheduled_events(self) -> bool
pub const fn guild_scheduled_events(self) -> bool
Shorthand for checking that the set of intents contains the GUILD_SCHEDULED_EVENTS intent.
Sourcepub const fn auto_moderation_configuration(self) -> bool
pub const fn auto_moderation_configuration(self) -> bool
Shorthand for checking that the set of intents contains the AUTO_MODERATION_CONFIGURATION intent.
Sourcepub const fn auto_moderation_execution(self) -> bool
pub const fn auto_moderation_execution(self) -> bool
Shorthand for checking that the set of intents contains the AUTO_MODERATION_EXECUTION intent.
Trait Implementations§
Source§impl Binary for GatewayIntents
impl Binary for GatewayIntents
Source§impl BitAnd for GatewayIntents
impl BitAnd for GatewayIntents
Source§impl BitAndAssign for GatewayIntents
impl BitAndAssign for GatewayIntents
Source§fn bitand_assign(&mut self, other: Self)
fn bitand_assign(&mut self, other: Self)
The bitwise and (&
) of the bits in two flags values.
Source§impl BitOr for GatewayIntents
impl BitOr for GatewayIntents
Source§fn bitor(self, other: GatewayIntents) -> Self
fn bitor(self, other: GatewayIntents) -> Self
The bitwise or (|
) of the bits in two flags values.
Source§type Output = GatewayIntents
type Output = GatewayIntents
|
operator.Source§impl BitOrAssign for GatewayIntents
impl BitOrAssign for GatewayIntents
Source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
The bitwise or (|
) of the bits in two flags values.
Source§impl BitXor for GatewayIntents
impl BitXor for GatewayIntents
Source§impl BitXorAssign for GatewayIntents
impl BitXorAssign for GatewayIntents
Source§fn bitxor_assign(&mut self, other: Self)
fn bitxor_assign(&mut self, other: Self)
The bitwise exclusive-or (^
) of the bits in two flags values.
Source§impl Clone for GatewayIntents
impl Clone for GatewayIntents
Source§fn clone(&self) -> GatewayIntents
fn clone(&self) -> GatewayIntents
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for GatewayIntents
impl Debug for GatewayIntents
Source§impl Default for GatewayIntents
impl Default for GatewayIntents
Source§impl<'de> Deserialize<'de> for GatewayIntents
impl<'de> Deserialize<'de> for GatewayIntents
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Extend<GatewayIntents> for GatewayIntents
impl Extend<GatewayIntents> for GatewayIntents
Source§fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
The bitwise or (|
) of the bits in each flags value.
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl Flags for GatewayIntents
impl Flags for GatewayIntents
Source§const FLAGS: &'static [Flag<GatewayIntents>]
const FLAGS: &'static [Flag<GatewayIntents>]
Source§fn from_bits_retain(bits: u64) -> GatewayIntents
fn from_bits_retain(bits: u64) -> GatewayIntents
Source§fn from_bits_truncate(bits: Self::Bits) -> Self
fn from_bits_truncate(bits: Self::Bits) -> Self
Source§fn from_name(name: &str) -> Option<Self>
fn from_name(name: &str) -> Option<Self>
Source§fn iter_names(&self) -> IterNames<Self>
fn iter_names(&self) -> IterNames<Self>
Source§fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
Source§fn contains(&self, other: Self) -> boolwhere
Self: Sized,
fn contains(&self, other: Self) -> boolwhere
Self: Sized,
Source§fn insert(&mut self, other: Self)where
Self: Sized,
fn insert(&mut self, other: Self)where
Self: Sized,
|
) of the bits in two flags values.Source§fn remove(&mut self, other: Self)where
Self: Sized,
fn remove(&mut self, other: Self)where
Self: Sized,
&!
). Read moreSource§fn toggle(&mut self, other: Self)where
Self: Sized,
fn toggle(&mut self, other: Self)where
Self: Sized,
^
) of the bits in two flags values.Source§fn intersection(self, other: Self) -> Self
fn intersection(self, other: Self) -> Self
&
) of the bits in two flags values.Source§fn difference(self, other: Self) -> Self
fn difference(self, other: Self) -> Self
&!
). Read moreSource§fn symmetric_difference(self, other: Self) -> Self
fn symmetric_difference(self, other: Self) -> Self
^
) of the bits in two flags values.Source§fn complement(self) -> Self
fn complement(self) -> Self
!
) of the bits in a flags value, truncating the result.Source§impl FromIterator<GatewayIntents> for GatewayIntents
impl FromIterator<GatewayIntents> for GatewayIntents
Source§fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
The bitwise or (|
) of the bits in each flags value.
Source§impl Hash for GatewayIntents
impl Hash for GatewayIntents
Source§impl IntoIterator for GatewayIntents
impl IntoIterator for GatewayIntents
Source§impl LowerHex for GatewayIntents
impl LowerHex for GatewayIntents
Source§impl Not for GatewayIntents
impl Not for GatewayIntents
Source§impl Octal for GatewayIntents
impl Octal for GatewayIntents
Source§impl PartialEq for GatewayIntents
impl PartialEq for GatewayIntents
Source§impl Serialize for GatewayIntents
impl Serialize for GatewayIntents
Source§impl Sub for GatewayIntents
impl Sub for GatewayIntents
Source§fn sub(self, other: Self) -> Self
fn sub(self, other: Self) -> Self
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
difference
won’t truncate other
, but the !
operator will.
Source§type Output = GatewayIntents
type Output = GatewayIntents
-
operator.Source§impl SubAssign for GatewayIntents
impl SubAssign for GatewayIntents
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
The intersection of a source flags value with the complement of a target flags value (&!
).
This method is not equivalent to self & !other
when other
has unknown bits set.
difference
won’t truncate other
, but the !
operator will.
Source§impl UpperHex for GatewayIntents
impl UpperHex for GatewayIntents
impl Copy for GatewayIntents
impl Eq for GatewayIntents
impl StructuralPartialEq for GatewayIntents
Auto Trait Implementations§
impl Freeze for GatewayIntents
impl RefUnwindSafe for GatewayIntents
impl Send for GatewayIntents
impl Sync for GatewayIntents
impl Unpin for GatewayIntents
impl UnwindSafe for GatewayIntents
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.