From c82ab046c89cf917226a4232dfe183c66aa06d16 Mon Sep 17 00:00:00 2001 From: gennyble Date: Sat, 19 Apr 2025 12:26:55 -0500 Subject: splorm --- src/main.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 98e7a5f..494b3dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ use std::{env, error::Error, sync::Arc}; +use confindent::Confindent; use database::{BoardRow, Database, Error as DbError, PermissionSetting}; use twilight_cache_inmemory::{DefaultInMemoryCache, ResourceType}; use twilight_gateway::{Event, EventTypeFlags, Intents, Shard, ShardId, StreamExt}; @@ -61,17 +62,19 @@ macro_rules! success { async fn main() -> anyhow::Result<()> { dotenv::dotenv()?; - let db = Arc::new(Database::new("kindbloot.db")); - db.create_tables(); - - let mut shard = Shard::new( - ShardId::ONE, - env::var("DISCORD_TOKEN")?, - Intents::GUILD_MESSAGES, - ); + let conf = Confindent::from_file("/etc/leaberblord.conf").unwrap(); + let db_dir = conf + .child_owned("Database") + .unwrap_or("/var/leaberblord/leaberblord.sqlite".to_string()); + let token = env::var("DISCORD_TOKEN") + .ok() + .unwrap_or_else(|| conf.child_owned("DiscordToken").unwrap()); - let http = Arc::new(HttpClient::new(env::var("DISCORD_TOKEN")?)); + let db = Arc::new(Database::new(db_dir)); + db.create_tables(); + let mut shard = Shard::new(ShardId::ONE, token.clone(), Intents::GUILD_MESSAGES); + let http = Arc::new(HttpClient::new(token)); let mut cache = DefaultInMemoryCache::builder() .resource_types(ResourceType::MESSAGE) .resource_types(ResourceType::MEMBER) -- cgit 1.4.1-3-g733a5