about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs21
1 files changed, 12 insertions, 9 deletions
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)