1pub mod conf {
3 use serde::Deserialize;
4 use std::fs::File;
5 use std::io::{Error, Read};
6 use toml;
7
8 #[derive(Deserialize)]
9 pub struct Config {
11 pub token: String,
12 pub moderation: Option<bool>,
13 pub leveling: Option<bool>,
14 pub moderating: Option<ModerationSettings>,
15 }
16
17 #[derive(Deserialize)]
18 pub struct ModerationSettings {
20 pub enablebl: Option<bool>,
21 pub blacklist: Option<Vec<String>>,
22 pub modrole: u64,
23 }
24
25 pub fn load_config(path: &str) -> Result<Config, Error> {
35 let mut file: File = match File::open(path) {
36 Ok(f) => f,
37 Err(e) => {
38 return Err(e);
39 }
40 };
41 let mut contents: String = String::new();
42 match file.read_to_string(&mut contents) {
43 Ok(_n) => (),
44 Err(e) => {
45 return Err(e);
46 }
47 }
48 let cfg: Config = toml::from_str(contents.as_str()).unwrap();
49 Ok(cfg)
50 }
51}
52
53pub mod val {
55 pub const VERSION: &str = "0.2.6";
56}