-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
79 lines (65 loc) · 1.66 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
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
//
// Config variables module
//
package main
import (
"encoding/json"
"io/ioutil"
"log"
)
const version = "2.0.0"
const configData = "./data/config.json"
// Set build date variable to be set with compilation flag
// go build -ldflags "-X main.BuildDate=$(date -I)"
var buildDate string
var commit string
type Config struct {
Website string `json:"website"`
AudioFiles string `json:"audioFiles"`
RespondData string `json:"respondData"`
MemberData string `json:"memberData"`
BlacklistData string `json:"blacklistData"`
ID ID `json:"ID"`
Modules Modules `json:"modules"`
}
type ID struct {
// Firmcoded IDs
Owner string `json:"owner"`
Guild string `json:"guild"`
}
type Modules struct {
// Interactive modules
Respond bool `json:"respond"`
Info bool `json:"info"`
Sticks bool `json:"sticks"`
Avatar bool `json:"avatar"`
Tiktok bool `json:"tiktok"`
Cry bool `json:"cry"`
Lights bool `json:"lights"`
Tweet bool `json:"tweet"`
// Background modules
SelfEsteem bool `json:"selfEsteem"`
Animals bool `json:"animals"`
Birthday bool `json:"birthday"`
Abuse bool `json:"abuse"`
Guts bool `json:"guts"`
}
var config Config
func configParse() {
data, err := ioutil.ReadFile(configData)
if err != nil {
log.Fatalf("[Fatal][Config] Failed to open file: %v", err)
}
// Link JSON data slice to phrases
err = json.Unmarshal(data, &config)
if err != nil {
log.Fatalf("[Fatal][Config] Could not unmarshal JSON data: %v", err)
}
// Check if commit and build are empty
if buildDate == "" {
buildDate = "Unknown"
}
if commit == "" {
commit = "Unknown"
}
}