blob: 57fc8235096e47a855e6dcc226d32493aee1bf88 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
// Copyright (C) 2021-2021 Fuwn
// SPDX-License-Identifier: GPL-3.0-only
use config::ConfigError;
use serde_derive::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub struct Config {
pub token: String,
pub admin_roles: Vec<u64>,
}
impl Config {
#[allow(future_prelude_collision)]
fn new() -> Result<Self, ConfigError> {
let mut c = config::Config::default();
c.merge(config::File::with_name(".dos-bot/config.json"))
.expect("unable to access configuration file");
c.try_into()
}
/// # Panics
/// if the configuration file is unable to be accessed.
#[must_use]
pub fn get() -> Self { Self::new().unwrap() }
}
|