feat: now use env vars to get teh server and roles for committee
This commit is contained in:
parent
d673dce6fa
commit
6739c7e068
3 changed files with 43 additions and 9 deletions
18
src/lib.rs
18
src/lib.rs
|
@ -4,6 +4,7 @@ use chrono::{Datelike, SecondsFormat, Utc};
|
|||
use dotenvy::dotenv;
|
||||
use rand::{distributions::Alphanumeric, thread_rng, Rng};
|
||||
use serenity::client::Context;
|
||||
use serenity::model::id::{GuildId, RoleId};
|
||||
use serenity::model::prelude::application_command::ApplicationCommandInteraction;
|
||||
use serenity::prelude::TypeMapKey;
|
||||
use std::{env, sync::Arc};
|
||||
|
@ -26,6 +27,10 @@ pub struct Config {
|
|||
pub wolves_url: String,
|
||||
// API key for accessing more general resources
|
||||
pub wolves_api: String,
|
||||
|
||||
// discord server for committee
|
||||
pub committee_server: GuildId,
|
||||
pub committee_role: RoleId,
|
||||
}
|
||||
impl TypeMapKey for Config {
|
||||
type Value = Arc<RwLock<Config>>;
|
||||
|
@ -47,6 +52,8 @@ pub fn get_config() -> Config {
|
|||
mail_pass: "".to_string(),
|
||||
wolves_url: "".to_string(),
|
||||
wolves_api: "".to_string(),
|
||||
committee_server: GuildId(0),
|
||||
committee_role: RoleId(0),
|
||||
};
|
||||
|
||||
if let Ok(x) = env::var("DATABASE_HOME") {
|
||||
|
@ -81,6 +88,17 @@ pub fn get_config() -> Config {
|
|||
config.wolves_api = x.trim().to_string();
|
||||
}
|
||||
|
||||
if let Ok(x) = env::var("COMMITTEE_DISCORD") {
|
||||
if let Ok(x) = x.trim().parse::<u64>() {
|
||||
config.committee_server = GuildId(x);
|
||||
}
|
||||
}
|
||||
if let Ok(x) = env::var("COMMITTEE_DISCORD") {
|
||||
if let Ok(x) = x.trim().parse::<u64>() {
|
||||
config.committee_role = RoleId(x);
|
||||
}
|
||||
}
|
||||
|
||||
config
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue