aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index bb686d2..021886f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,14 +1,17 @@
-use std::time::Duration;
+use std::{time::Duration, sync::Mutex};
use dotenv::dotenv;
+use sqlx::{PgPool, postgres::PgPoolOptions};
type Error = Box<dyn std::error::Error + Send + Sync>;
type Context<'a> = poise::Context<'a, Data, Error>;
mod commands;
+mod handler;
+mod models;
pub struct Data {
-
+ pg: Mutex<PgPool>,
}
/// Show help menu
@@ -63,6 +66,13 @@ async fn main() {
commands::osu::osup(),
commands::osu::osubm(),
+
+ poise::Command {
+ subcommands: vec![
+ commands::reactionroles::init(),
+ ],
+ ..commands::reactionroles::rroles()
+ },
],
on_error: |error| Box::pin(on_error(error)),
pre_command: |ctx| {
@@ -85,6 +95,7 @@ async fn main() {
],
..Default::default()
},
+ listener: |ctx, event, _, data| Box::pin(handler::event_handler(ctx, event, data)),
..Default::default()
};
@@ -92,7 +103,14 @@ async fn main() {
.token(std::env::var("DISCORD_TOKEN").unwrap_or("BAD-TOKEN".into()))
.user_data_setup(move |_ctx, _ready, _framework| {
Box::pin(async move {
- Ok(Data {})
+ let pool = PgPoolOptions::new()
+ .max_connections(5)
+ .connect(&std::env::var("DATABASE_URL").unwrap_or("postgres://postgres@localhost/glitch".to_string()))
+ .await
+ .expect("Couldn't connect to postgresql");
+ Ok(Data {
+ pg: Mutex::new(pool)
+ })
})
})
.options(options)