aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
blob: 13d015e7f24c04d714778f1dca12c845329c7f47 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use serenity::{
    model::id::{
        GuildId,
        UserId,
        ChannelId,
    },
};

use envconfig::Envconfig;

#[derive(Envconfig)]
pub struct Config {
    #[envconfig(from = "DATABASE_URL")]
    pub db_string: String,

    #[envconfig(from = "MAX_HIST")]
    pub max_hist: usize,

    #[envconfig(from = "DEFAULT_HIST")]
    pub default_hist: usize,

    #[envconfig(from = "STEAM_API_KEY")]
    pub steam_api_key: String,

    pub discord: DiscordConfig,

    pub sheets: SheetsConfig,
}

#[derive(Envconfig)]
pub struct DiscordConfig {
    pub auth: DiscordAuth,

    #[envconfig(from = "TARGET_GUILD")]
    guild: u64,

    #[envconfig(from = "OWNER_ID")]
    owner: u64,

    #[envconfig(from = "VOICE_CHANNEL")]
    voice_channel: u64,
}

impl DiscordConfig {
    #[inline]
    pub fn guild(&self) -> GuildId {
        self.guild.into()
    }

    #[inline]
    pub fn owner(&self) -> UserId {
        self.owner.into()
    }

    #[inline]
    pub fn voice_channel(&self) -> ChannelId {
        self.voice_channel.into()
    }
}

#[derive(Envconfig)]
pub struct DiscordAuth {
    #[envconfig(from = "THULANI_CLIENT_ID")]
    pub client_id: u64,

    #[envconfig(from = "THULANI_TOKEN")]
    pub token: String,
}

#[derive(Envconfig)]
pub struct SheetsConfig {
    #[envconfig(from = "SHEETS_API_KEY")]
    pub api_key: String,

    #[envconfig(from = "SPREADSHEET_ID")]
    pub spreadsheet: String,

    #[envconfig(from = "MAX_SHEET_COLUMN")]
    pub max_column: String,
}