diff --git a/.env.example b/.env.example index dcf698c..72f2def 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ DISCORD_TOKEN= PREFIX="-h " -HUGO=/path/to/hugo \ No newline at end of file +HUGO=/path/to/hugo +GUILD_DATA=/path/to/guilds.json \ No newline at end of file diff --git a/src/commands/owner.rs b/src/commands/owner.rs index 7752271..7fe9769 100644 --- a/src/commands/owner.rs +++ b/src/commands/owner.rs @@ -14,17 +14,16 @@ use std::env; use crate::ShardManagerContainer; use crate::commands::challenge::get_challenge_number; -const GUILD_DATA_PATH: &str = "guilds.json"; - pub fn get_guild_data() -> Map { - let guild_data_json = match File::open(GUILD_DATA_PATH) { + let guild_data_path = env::var("GUILD_DATA").unwrap(); + let guild_data_json = match File::open(guild_data_path) { Ok(mut file) => { let mut json = String::new(); file.read_to_string(&mut json).unwrap(); json } Err(ref e) if e.kind() == std::io::ErrorKind::NotFound => { - let mut file = File::create(GUILD_DATA_PATH).unwrap(); + let mut file = File::create(guild_data_path).unwrap(); file.write_all(b"{}").unwrap(); file.flush().unwrap(); String::from("{}")