Skip to content

Commit

Permalink
Mention the required intents for certain events (#1045)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicky5124 committed Oct 29, 2020
1 parent 50d9643 commit c9971b6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/client/bridge/gateway/intents.rs
Expand Up @@ -42,6 +42,8 @@ __impl_bitflags! {
/// 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*.
///
/// This intent is also necessary to even recieve the events in contains.
GUILD_MEMBERS = 1 << 1;
/// Enables following gateway events:
///
Expand Down Expand Up @@ -77,6 +79,8 @@ __impl_bitflags! {
/// 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*.
///
/// This intent is also necessary to even recieve the events in contains.
GUILD_PRESENCES = 1 << 8;
/// Enables following gateway events:
///
Expand Down
19 changes: 19 additions & 0 deletions src/client/event_handler.rs
Expand Up @@ -131,29 +131,44 @@ pub trait EventHandler: Send + Sync {
/// Dispatched when a user joins a guild.
///
/// Provides the guild's id and the user's member data.
///
/// Note: This event will not trigger unless the "guild members" privileged intent
/// is enabled on the bot application page.
async fn guild_member_addition(&self, _ctx: Context, _guild_id: GuildId, _new_member: Member) {}

/// Dispatched when a user's membership ends by leaving, getting kicked, or being banned.
///
/// Provides the guild's id, the user's data, and the user's member data if available.
///
/// Note: This event will not trigger unless the "guild members" privileged intent
/// is enabled on the bot application page.
#[cfg(feature = "cache")]
async fn guild_member_removal(&self, _ctx: Context, _guild_id: GuildId, _user: User, _member_data_if_available: Option<Member>) {}

/// Dispatched when a user's membership ends by leaving, getting kicked, or being banned.
///
/// Provides the guild's id, the user's data.
///
/// Note: This event will not trigger unless the "guild members" privileged intent
/// is enabled on the bot application page.
#[cfg(not(feature = "cache"))]
async fn guild_member_removal(&self, _ctx: Context, _guild_id: GuildId, _kicked: User) {}

/// Dispatched when a member is updated (e.g their nickname is updated).
///
/// Provides the member's old data (if available) and the new data.
///
/// Note: This event will not trigger unless the "guild members" privileged intent
/// is enabled on the bot application page.
#[cfg(feature = "cache")]
async fn guild_member_update(&self, _ctx: Context, _old_if_available: Option<Member>, _new: Member) {}

/// Dispatched when a member is updated (e.g their nickname is updated).
///
/// Provides the new data.
///
/// Note: This event will not trigger unless the "guild members" privileged intent
/// is enabled on the bot application page.
#[cfg(not(feature = "cache"))]
async fn guild_member_update(&self, _ctx: Context, _new: GuildMemberUpdateEvent) {}

Expand Down Expand Up @@ -264,11 +279,15 @@ pub trait EventHandler: Send + Sync {
/// Provides the channel's id and the message's id.
async fn reaction_remove_all(&self, _ctx: Context, _channel_id: ChannelId, _removed_from_message_id: MessageId) {}

/// This event is legacy, and likely no longer sent by discord.
async fn presence_replace(&self, _ctx: Context, _: Vec<Presence>) {}

/// Dispatched when a user's presence is updated (e.g off -> on).
///
/// Provides the presence's new data.
///
/// Note: This event will not trigger unless the "guild presences" privileged intent
/// is enabled on the bot application page.
async fn presence_update(&self, _ctx: Context, _new_data: PresenceUpdateEvent) {}

/// Dispatched upon startup.
Expand Down

0 comments on commit c9971b6

Please sign in to comment.