use config::{Config, ConfigError, File}; use serde::Deserialize; use std::path::Path; #[derive(Debug, Deserialize, Clone)] pub struct DiscordConfig { pub token: String, pub app_id: u64, } #[derive(Debug, Deserialize, Clone)] pub struct ApiConfig { pub token: String, pub base_url: String, } #[derive(Debug, Deserialize, Clone)] pub struct GeoffreyBotConfig { pub api: ApiConfig, pub discord: DiscordConfig, } impl GeoffreyBotConfig { pub fn new(config_path: &Path) -> Result { let mut cfg = Config::new(); cfg.merge(File::from(config_path.to_path_buf()))?; cfg.try_into() } }