diff options
author | Cara Salter <cara@devcara.com> | 2022-01-12 15:45:20 -0500 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2022-01-12 15:45:20 -0500 |
commit | 67e4081aa69f489ad88ee064402d68a5969069c2 (patch) | |
tree | c69b79679d35df650b684fa487b1725b3c211250 /src/main.rs | |
parent | 6bc33b93eb5d55fb855803b0bf8cf7658a60e2b1 (diff) | |
download | glitch-ng-67e4081aa69f489ad88ee064402d68a5969069c2.tar.gz glitch-ng-67e4081aa69f489ad88ee064402d68a5969069c2.zip |
rroles: Implement Reaction Roles
now requires postgresql.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 24 |
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) |