use std::collections::HashMap; use std::path::PathBuf; use config::Config; use poise::serenity_prelude::ChannelId; use crate::ManifoldResult; use crate::models::fueltank::FuelTank; #[derive(Debug, Deserialize, Serialize)] pub struct Channels { pub log: ChannelId, } #[derive(Debug, Deserialize, Serialize)] pub struct DatabaseConfig { pub host: String, pub user: String, pub pass: String, pub database_name: String, pub port: i32, } #[derive(Debug, Deserialize, Serialize)] pub struct ManifoldConfig { pub prefix: String, pub channels: Channels, pub nickname: String, pub services: HashMap, pub database: DatabaseConfig, pub responses_file_path: PathBuf, } impl ManifoldConfig { pub fn new(config_file: &String, bot_environment: &String) -> ManifoldResult { let settings = Config::builder() .add_source(config::File::with_name(&*format!("config/{}.{}", bot_environment.to_lowercase(), config_file))) .add_source(config::Environment::with_prefix("manifold")) .build()?; Ok(settings.try_deserialize()?) } }