diff options
| author | Fuwn <[email protected]> | 2021-06-24 15:06:43 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-06-24 15:06:43 -0700 |
| commit | 2bccd50b7a11dda0ae239ce13efcdac118bfee92 (patch) | |
| tree | 28f665461bb9746d70878071b11537d784a59842 /src/config.rs | |
| download | dos-bot-2bccd50b7a11dda0ae239ce13efcdac118bfee92.tar.xz dos-bot-2bccd50b7a11dda0ae239ce13efcdac118bfee92.zip | |
feat(dos-bot): :star:
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..afdba2d --- /dev/null +++ b/src/config.rs @@ -0,0 +1,32 @@ +// 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 RolesRole { + pub message: u64, + pub role: u64, +} +#[derive(Serialize, Deserialize, Debug)] +pub struct Config { + pub token: String, + pub roles: Vec<RolesRole>, +} +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() } +} |