config.rs 1.28 KB
Newer Older
1
use serenity;
Timothy du Heaume's avatar
Timothy du Heaume committed
2 3 4
use std::fs;
use serde::Deserialize;
use toml;
5

Timothy du Heaume's avatar
Timothy du Heaume committed
6 7 8 9 10 11 12 13 14
lazy_static! {
    static ref CONFIG_FILE: String = fs::read_to_string("config.toml").unwrap();
}

lazy_static! {
    pub static ref CONFIG: UccbotConfig = toml::from_str(&CONFIG_FILE).unwrap();
}

#[derive(Deserialize)]
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
pub struct UccbotConfig {
    pub server_id: u64,
    // #general
    pub main_channel: serenity::model::id::ChannelId,
    // #the-corner
    pub welcome_channel: serenity::model::id::ChannelId,
    // #general
    pub announcement_channel: serenity::model::id::ChannelId,
    pub bot_id: u64,
    pub vote_pool_size: i8,
    pub vote_role: u64,
    pub tiebreaker_role: u64,
    pub unregistered_member_role: u64,
    pub registered_member_role: u64,
    pub command_prefix: &'static str,
    pub for_vote: &'static str,
    pub against_vote: &'static str,
    pub abstain_vote: &'static str,
    pub approve_react: &'static str,
    pub disapprove_react: &'static str,
    pub unsure_react: &'static str,
}

impl UccbotConfig {
    pub fn allowed_reacts(&self) -> Vec<String> {
        vec!(self.for_vote.to_string(),
        self.against_vote.to_string(),
        self.abstain_vote.to_string(),
        self.approve_react.to_string(),
        self.disapprove_react.to_string(),
        self.unsure_react.to_string())
    }
}