treewide: allow for running w/o storage
This commit is contained in:
parent
827b5a4bd7
commit
a9a63f36ad
14 changed files with 174 additions and 90 deletions
|
@ -1,27 +1,32 @@
|
|||
mod bot;
|
||||
mod discord;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct Config {
|
||||
pub discord: discord::Config,
|
||||
pub redis_url: String,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
discord: discord::Config::default(),
|
||||
redis_url: "redis://localhost:6379".to_string(),
|
||||
}
|
||||
}
|
||||
bot: bot::Config,
|
||||
discord: discord::Config,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn new_from_env() -> Self {
|
||||
let discord = discord::Config::new_from_env();
|
||||
|
||||
pub fn new(bot_config: bot::Config, discord_config: discord::Config) -> Self {
|
||||
Self {
|
||||
discord,
|
||||
..Default::default()
|
||||
bot: bot_config,
|
||||
discord: discord_config,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_from_env() -> Self {
|
||||
let bot = bot::Config::new_from_env();
|
||||
let discord = discord::Config::new_from_env();
|
||||
|
||||
Self::new(bot, discord)
|
||||
}
|
||||
|
||||
pub fn bot_config(self) -> bot::Config {
|
||||
self.bot
|
||||
}
|
||||
|
||||
pub fn discord_config(self) -> discord::Config {
|
||||
self.discord
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue