Struct serenity::model::gateway::GatewayIntents
source · #[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
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
Available on crate feature model
only.
pub const fn is_privileged(self) -> bool
model
only.Checks if any of the included intents are privileged.
sourcepub const fn guilds(self) -> bool
Available on crate feature model
only.
pub const fn guilds(self) -> bool
model
only.Shorthand for checking that the set of intents contains the GUILDS intent.
sourcepub const fn guild_members(self) -> bool
Available on crate feature model
only.
pub const fn guild_members(self) -> bool
model
only.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
] insteadAvailable on crate feature model
only.
pub const fn guild_bans(self) -> bool
Self::guild_moderation
] insteadmodel
only.Shorthand 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
Available on crate feature model
only.
pub const fn guild_moderation(self) -> bool
model
only.Shorthand for checking that the set of intents contains the GUILD_MODERATION intent.
sourcepub const fn guild_emojis_and_stickers(self) -> bool
Available on crate feature model
only.
pub const fn guild_emojis_and_stickers(self) -> bool
model
only.Shorthand for checking that the set of intents contains the GUILD_EMOJIS_AND_STICKERS intent.
sourcepub const fn guild_integrations(self) -> bool
Available on crate feature model
only.
pub const fn guild_integrations(self) -> bool
model
only.Shorthand for checking that the set of intents contains the GUILD_INTEGRATIONS intent.
sourcepub const fn guild_webhooks(self) -> bool
Available on crate feature model
only.
pub const fn guild_webhooks(self) -> bool
model
only.Shorthand for checking that the set of intents contains the GUILD_WEBHOOKS intent.
sourcepub const fn guild_invites(self) -> bool
Available on crate feature model
only.
pub const fn guild_invites(self) -> bool
model
only.Shorthand for checking that the set of intents contains the GUILD_INVITES intent.
sourcepub const fn guild_voice_states(self) -> bool
Available on crate feature model
only.
pub const fn guild_voice_states(self) -> bool
model
only.Shorthand for checking that the set of intents contains the GUILD_VOICE_STATES intent.
sourcepub const fn guild_presences(self) -> bool
Available on crate feature model
only.
pub const fn guild_presences(self) -> bool
model
only.Shorthand for checking that the set of intents contains the GUILD_PRESENCES intent.
sourcepub const fn guild_message_reactions(self) -> bool
Available on crate feature model
only.
pub const fn guild_message_reactions(self) -> bool
model
only.Shorthand for checking that the set of intents contains the GUILD_MESSAGE_REACTIONS intent.
sourcepub const fn guild_message_typing(self) -> bool
Available on crate feature model
only.
pub const fn guild_message_typing(self) -> bool
model
only.Shorthand for checking that the set of intents contains the GUILD_MESSAGE_TYPING intent.
sourcepub const fn direct_messages(self) -> bool
Available on crate feature model
only.
pub const fn direct_messages(self) -> bool
model
only.Shorthand for checking that the set of intents contains the DIRECT_MESSAGES intent.
sourcepub const fn direct_message_reactions(self) -> bool
Available on crate feature model
only.
pub const fn direct_message_reactions(self) -> bool
model
only.Shorthand for checking that the set of intents contains the DIRECT_MESSAGE_REACTIONS intent.
sourcepub const fn direct_message_typing(self) -> bool
Available on crate feature model
only.
pub const fn direct_message_typing(self) -> bool
model
only.Shorthand for checking that the set of intents contains the DIRECT_MESSAGE_TYPING intent.
sourcepub const fn message_content(self) -> bool
Available on crate feature model
only.
pub const fn message_content(self) -> bool
model
only.Shorthand for checking that the set of intents contains the MESSAGE_CONTENT intent.
sourcepub const fn guild_scheduled_events(self) -> bool
Available on crate feature model
only.
pub const fn guild_scheduled_events(self) -> bool
model
only.Shorthand for checking that the set of intents contains the GUILD_SCHEDULED_EVENTS intent.
sourcepub const fn auto_moderation_configuration(self) -> bool
Available on crate feature model
only.
pub const fn auto_moderation_configuration(self) -> bool
model
only.Shorthand for checking that the set of intents contains the AUTO_MODERATION_CONFIGURATION intent.
sourcepub const fn auto_moderation_execution(self) -> bool
Available on crate feature model
only.
pub const fn auto_moderation_execution(self) -> bool
model
only.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.
§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§fn eq(&self, other: &GatewayIntents) -> bool
fn eq(&self, other: &GatewayIntents) -> bool
self
and other
values to be equal, and is used
by ==
.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.
§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 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> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.