about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgennyble <gen@nyble.dev>2025-04-19 12:26:55 -0500
committergennyble <gen@nyble.dev>2025-04-19 12:26:55 -0500
commitc82ab046c89cf917226a4232dfe183c66aa06d16 (patch)
treed9485d0de2463997f52ff9f19b18140a711a86e3
parent407d34e99e8749950c835b8cb5e445e526e8cd40 (diff)
downloadleaberblord-c82ab046c89cf917226a4232dfe183c66aa06d16.tar.gz
leaberblord-c82ab046c89cf917226a4232dfe183c66aa06d16.zip
splorm
-rw-r--r--Cargo.lock10
-rw-r--r--Cargo.toml3
-rw-r--r--TODO5
-rw-r--r--src/main.rs21
4 files changed, 29 insertions, 10 deletions
diff --git a/Cargo.lock b/Cargo.lock
index ef4ce70..8170992 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -125,6 +125,12 @@ dependencies = [
 ]
 
 [[package]]
+name = "confindent"
+version = "2.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ea618ded77af626818bde0f0802da7c20d47e38e23e37be40f6f807a76079e82"
+
+[[package]]
 name = "core-foundation"
 version = "0.10.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -471,6 +477,7 @@ name = "leaberblord"
 version = "0.1.0"
 dependencies = [
  "anyhow",
+ "confindent",
  "dotenv",
  "rusqlite",
  "tokio",
@@ -493,6 +500,7 @@ version = "0.32.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "fbb8270bb4060bd76c6e96f20c52d80620f1d82a3470885694e41e0f81ef6fe7"
 dependencies = [
+ "cc",
  "pkg-config",
  "vcpkg",
 ]
@@ -701,6 +709,7 @@ dependencies = [
  "hashlink",
  "libsqlite3-sys",
  "smallvec",
+ "time",
 ]
 
 [[package]]
@@ -981,6 +990,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40"
 dependencies = [
  "deranged",
+ "itoa",
  "num-conv",
  "powerfmt",
  "serde",
diff --git a/Cargo.toml b/Cargo.toml
index 9bbf72d..f63574d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,8 +5,9 @@ edition = "2024"
 
 [dependencies]
 anyhow = "1.0.98"
+confindent = "2.2.1"
 dotenv = "0.15.0"
-rusqlite = "0.34.0"
+rusqlite = { version = "0.34.0", features = ["bundled", "time"] }
 tokio = { version = "1.44.2", features = ["full"] }
 twilight-cache-inmemory = "0.16.0"
 twilight-gateway = "0.16.0"
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..0057cf8
--- /dev/null
+++ b/TODO
@@ -0,0 +1,5 @@
+Use the cache!
+	We do not- I mean, we set the cache /up/ but we do not make use of it
+	kind of really at all.
+	I think the only place we kind of need this is in `add_points` where
+	we get the members of the guild.
\ No newline at end of file
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)