mirror of
https://github.com/mgerb/go-discord-bot
synced 2026-01-09 08:32:48 +00:00
60 lines
1.1 KiB
Go
60 lines
1.1 KiB
Go
package config
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io/ioutil"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// Variables used for command line parameters
|
|
var (
|
|
Config configType
|
|
)
|
|
|
|
type configType struct {
|
|
Token string `json:"token"`
|
|
ClientID string `json:"client_id"`
|
|
ClientSecret string `json:"client_secret"`
|
|
RedirectURI string `json:"redirect_uri"`
|
|
BotPrefix string `json:"bot_prefix"` //prefix to use for bot commands
|
|
AdminEmails []string `json:"admin_emails"`
|
|
ModEmails []string `json:"mod_emails"`
|
|
ServerAddr string `json:"server_addr"`
|
|
JWTSecret string `json:"jwt_secret"`
|
|
Logger bool `json:"logger"`
|
|
|
|
// hard coded folder paths
|
|
SoundsPath string
|
|
ClipsPath string
|
|
YoutubePath string
|
|
}
|
|
|
|
// Init -
|
|
func Init() {
|
|
parseConfig()
|
|
|
|
Config.SoundsPath = "./sounds"
|
|
Config.ClipsPath = "./clips"
|
|
Config.YoutubePath = "./youtube"
|
|
}
|
|
|
|
func parseConfig() {
|
|
|
|
log.Debug("Reading config file...")
|
|
|
|
file, e := ioutil.ReadFile("./config.json")
|
|
|
|
if e != nil {
|
|
log.Fatal("File error: %v\n", e)
|
|
}
|
|
|
|
log.Debug("%s\n", string(file))
|
|
|
|
err := json.Unmarshal(file, &Config)
|
|
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|