Move guild data path into environment variable
This commit is contained in:
parent
4f1d9f62e2
commit
72333cc116
2 changed files with 5 additions and 5 deletions
|
@ -1,3 +1,4 @@
|
|||
DISCORD_TOKEN=
|
||||
PREFIX="-h "
|
||||
HUGO=/path/to/hugo
|
||||
HUGO=/path/to/hugo
|
||||
GUILD_DATA=/path/to/guilds.json
|
|
@ -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<String, Value> {
|
||||
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("{}")
|
||||
|
|
Loading…
Add table
Reference in a new issue