Skip to main content

EventHandler

Trait EventHandler 

Source
pub trait EventHandler: Send + Sync {
Show 32 methods // Provided methods fn on_ready<'life0, 'async_trait>( &'life0 self, _ctx: Context, _ready: Ready, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_message<'life0, 'async_trait>( &'life0 self, _ctx: Context, _msg: Message, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_message_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _update: MessageUpdate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_message_delete<'life0, 'async_trait>( &'life0 self, _ctx: Context, _delete: MessageDelete, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_message_delete_bulk<'life0, 'async_trait>( &'life0 self, _ctx: Context, _delete: MessageDeleteBulk, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_reaction_add<'life0, 'async_trait>( &'life0 self, _ctx: Context, _reaction: ReactionAdd, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_reaction_remove<'life0, 'async_trait>( &'life0 self, _ctx: Context, _reaction: ReactionRemove, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_reaction_remove_all<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: ReactionRemoveAll, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_reaction_remove_emoji<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: ReactionRemoveEmoji, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_typing_start<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: TypingStart, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_channel_create<'life0, 'async_trait>( &'life0 self, _ctx: Context, _channel: Channel, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_channel_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _channel: Channel, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_channel_delete<'life0, 'async_trait>( &'life0 self, _ctx: Context, _channel: Channel, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_channel_pins_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: ChannelPinsUpdate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_guild_create<'life0, 'async_trait>( &'life0 self, _ctx: Context, _guild: Guild, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_guild_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _guild: Guild, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_guild_delete<'life0, 'async_trait>( &'life0 self, _ctx: Context, _guild: UnavailableGuild, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_guild_member_add<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildMemberAdd, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_guild_member_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildMemberUpdate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_guild_member_remove<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildMemberRemove, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_guild_ban_add<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildBanAdd, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_guild_ban_remove<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildBanRemove, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_guild_role_create<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildRoleCreate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_guild_role_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildRoleUpdate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_guild_role_delete<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildRoleDelete, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_guild_emojis_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildEmojisUpdate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_guild_stickers_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildStickersUpdate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_guild_role_update_bulk<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildRoleUpdateBulk, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_channel_update_bulk<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: ChannelUpdateBulk, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_invite_create<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: InviteCreate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_invite_delete<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: InviteDelete, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn on_webhooks_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: WebhooksUpdate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... }
}
Expand description

Trait for handling gateway events. Implement the methods you need, ignore the rest.

use fluxer::prelude::*;
use async_trait::async_trait;

struct Bot;

#[async_trait]
impl EventHandler for Bot {
    async fn on_message(&self, ctx: Context, msg: Message) {
        if msg.content.as_deref() == Some("!hello") {
            let ch = msg.channel_id.as_deref().unwrap_or_default();
            let _ = ctx.http.send_message(ch, "Hello!").await;
        }
    }
}

Provided Methods§

Source

fn on_ready<'life0, 'async_trait>( &'life0 self, _ctx: Context, _ready: Ready, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The bot is connected and ready. Ready contains the bot user, session ID, and initial guild list.

Source

fn on_message<'life0, 'async_trait>( &'life0 self, _ctx: Context, _msg: Message, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_message_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _update: MessageUpdate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Only the changed fields are populated in MessageUpdate.

Source

fn on_message_delete<'life0, 'async_trait>( &'life0 self, _ctx: Context, _delete: MessageDelete, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

You only get the ID, not the content.

Source

fn on_message_delete_bulk<'life0, 'async_trait>( &'life0 self, _ctx: Context, _delete: MessageDeleteBulk, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_reaction_add<'life0, 'async_trait>( &'life0 self, _ctx: Context, _reaction: ReactionAdd, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_reaction_remove<'life0, 'async_trait>( &'life0 self, _ctx: Context, _reaction: ReactionRemove, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_reaction_remove_all<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: ReactionRemoveAll, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_reaction_remove_emoji<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: ReactionRemoveEmoji, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_typing_start<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: TypingStart, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_channel_create<'life0, 'async_trait>( &'life0 self, _ctx: Context, _channel: Channel, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_channel_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _channel: Channel, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_channel_delete<'life0, 'async_trait>( &'life0 self, _ctx: Context, _channel: Channel, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_channel_pins_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: ChannelPinsUpdate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_guild_create<'life0, 'async_trait>( &'life0 self, _ctx: Context, _guild: Guild, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fired when the bot joins a guild or when a guild becomes available after an outage.

Source

fn on_guild_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _guild: Guild, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_guild_delete<'life0, 'async_trait>( &'life0 self, _ctx: Context, _guild: UnavailableGuild, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The bot was removed from the guild, or the guild went unavailable.

Source

fn on_guild_member_add<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildMemberAdd, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_guild_member_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildMemberUpdate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_guild_member_remove<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildMemberRemove, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_guild_ban_add<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildBanAdd, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_guild_ban_remove<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildBanRemove, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_guild_role_create<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildRoleCreate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_guild_role_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildRoleUpdate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_guild_role_delete<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildRoleDelete, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_guild_emojis_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildEmojisUpdate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_guild_stickers_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildStickersUpdate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_guild_role_update_bulk<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: GuildRoleUpdateBulk, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_channel_update_bulk<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: ChannelUpdateBulk, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_invite_create<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: InviteCreate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_invite_delete<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: InviteDelete, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn on_webhooks_update<'life0, 'async_trait>( &'life0 self, _ctx: Context, _event: WebhooksUpdate, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§