//! Event handling for the gateway sub-module. use std::sync::Arc; use async_trait::async_trait; use twilight_model::gateway::payload::incoming::Ready; use crate::{ framework::{ events::traits::{EventResult, OnReadyHandler, OnReconnectHandler}, runtime::Runtime, }, state::State, }; /// Logs a ready message when the bot is ready. #[derive(Debug)] pub struct ReadyHandler; #[async_trait] impl OnReadyHandler for ReadyHandler { async fn on_ready(&self, event: &Ready, _: Arc>) -> EventResult { log::info!( "Ready! Logged in as {}#{:>04}", event.user.name, event.user.discriminator ); Ok(()) } } /// Logs a reconnection message when the gateway asks for a reconnection. #[derive(Debug)] pub struct ReconnectHandler; #[async_trait] impl OnReconnectHandler for ReconnectHandler { async fn on_reconnect(&self, _: Arc>) -> EventResult { log::info!("The gateway asked for a reconnection"); Ok(()) } }