Initialize Twilight project, set up basic framework, initialize DB module
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
use twilight_model::gateway::payload::incoming::Ready;
|
||||
|
||||
pub async fn handle_on_ready(event: Ready) {
|
||||
log::info!(
|
||||
"Ready! Logged in as {}#{:>04}",
|
||||
event.user.name,
|
||||
event.user.discriminator
|
||||
);
|
||||
}
|
||||
|
||||
pub async fn handle_on_reconnect() {
|
||||
log::info!("The gateway asked for a reconnection");
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use twilight_model::gateway::payload::incoming::InteractionCreate;
|
||||
|
||||
use crate::framework::handlers::Handlers;
|
||||
|
||||
pub async fn handle_on_interaction_create(event: InteractionCreate, handlers: Arc<Handlers>) {
|
||||
if let Err(e) = handlers.registry.execute(event, handlers.clone()).await {
|
||||
log::error!("An error occurred while processing the interaction! {e:?}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use twilight_model::{gateway::payload::incoming::MessageCreate};
|
||||
|
||||
use crate::{commands, framework::{handlers::Handlers}};
|
||||
|
||||
pub fn handle_on_message_create(
|
||||
event: MessageCreate,
|
||||
handlers: Arc<Handlers>
|
||||
) -> impl Future<Output = ()> {
|
||||
commands::execute_command(event, handlers)
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use twilight_gateway::Event;
|
||||
|
||||
use crate::framework::handlers::Handlers;
|
||||
|
||||
mod core;
|
||||
mod interactions;
|
||||
mod messages;
|
||||
|
||||
pub async fn handle_event(event: Event, handlers: Arc<Handlers>) {
|
||||
log::trace!("{event:?}");
|
||||
|
||||
match event {
|
||||
Event::Ready(event) => core::handle_on_ready(*event).await,
|
||||
Event::GatewayReconnect => core::handle_on_reconnect().await,
|
||||
Event::MessageCreate(event) => {
|
||||
messages::handle_on_message_create(*event, handlers).await
|
||||
}
|
||||
Event::InteractionCreate(event) => {
|
||||
interactions::handle_on_interaction_create(*event, handlers).await
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
pub mod events;
|
||||
Reference in New Issue
Block a user