Initialize Twilight project, set up basic framework, initialize DB module

This commit is contained in:
2025-08-07 04:32:34 -03:00
parent 00d61545eb
commit 24d2344f37
29 changed files with 4095 additions and 0 deletions
+13
View File
@@ -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");
}
+11
View File
@@ -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:?}");
}
}
+12
View File
@@ -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)
}
+25
View File
@@ -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
}
_ => {}
}
}
+1
View File
@@ -0,0 +1 @@
pub mod events;