-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
54 lines (44 loc) · 1.23 KB
/
config.go
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
package main
import (
"fmt"
)
type Configuration struct {
Token string `json:"token"`
GuildID string `json:"guild_id"`
LOLChannel string `json:"lol_channel"`
VALChannel string `json:"val_channel"`
ModRoles []string `json:"mod_roles"`
UpdateDateTimer int `json:"update_data_timer"`
PostDataTimer int `json:"post_data_timer"`
Commands struct {
Esports bool `json:"esports"`
Info bool `json:"info"`
Champion bool `json:"champion"`
Spell bool `json:"spell"`
} `json:"commands"`
}
func (config *Configuration) loadConfig() error {
err := loadFile(CONFIG_FILE_PATH, &config)
if err != nil {
return fmt.Errorf("error loading config file: %v", err)
}
if config.Token == "" {
return fmt.Errorf("token field not set")
}
if config.GuildID == "" {
return fmt.Errorf("guild_id field not set")
}
if config.LOLChannel == "" {
return fmt.Errorf("lol_channel field not set")
}
if config.VALChannel == "" {
return fmt.Errorf("val_channel field not set")
}
if config.UpdateDateTimer < 1800000 {
return fmt.Errorf("update_data_timer is set too low")
}
if config.PostDataTimer < 3600000 {
return fmt.Errorf("post_data_timer is set too low")
}
return nil
}