add database
All checks were successful
tests / fmt (push) Successful in 1m46s
tests / clippy (push) Successful in 1m48s
tests / test (push) Successful in 1m50s
tests / pre-commit (push) Successful in 2m5s
tests / build (push) Successful in 2m31s
deploy / release-image (push) Successful in 5m44s

This commit is contained in:
2024-06-20 20:16:19 +02:00
parent 4a69e0f578
commit 8985945659
11 changed files with 920 additions and 2 deletions

View File

@@ -1,7 +1,9 @@
mod handler;
use handler::Handler;
use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions};
mod colors;
mod commands;
mod db;
mod interaction_commands;
mod metadata;
mod signal;
@@ -38,6 +40,16 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
info!("Starting up...");
let (mut shards, state) = {
let db = env::var("DATABASE_URL").map_err(|_| "DATABASE_URL is not set")?;
let options = SqliteConnectOptions::new()
.create_if_missing(true)
.filename(&db);
let pool = SqlitePoolOptions::new()
.max_connections(5)
.connect_with(options)
.await?;
sqlx::migrate!().run(&pool).await?;
let token = env::var("DISCORD_TOKEN").map_err(|_| "DISCORD_TOKEN is not set")?;
let app_id = env::var("DISCORD_APP_ID")
.map_err(|_| "DISCORD_APP_ID is not set")?
@@ -80,6 +92,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
songbird,
standby: Standby::new(),
guild_settings: Default::default(),
pool,
}),
)
};