2019-12-13 09:52:36 +07:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"io/ioutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
type config struct {
|
|
|
|
ActiveNerf activeNerf `json:"activeNerf"`
|
|
|
|
CommandPrefix string `json:"prefix"`
|
|
|
|
GuildID string `json:"guildID"`
|
|
|
|
PrestigeRequirement int `json:"prestigeFactor"`
|
|
|
|
StarChannel string `json:"starChannel"`
|
2019-12-13 10:07:39 +07:00
|
|
|
BotToken string `json:"token"`
|
2020-01-04 12:23:37 +07:00
|
|
|
Rewards []Reward `json:"rewards"`
|
2019-12-13 10:07:39 +07:00
|
|
|
LevelRoles []string `json:"roles"`
|
2019-12-13 09:52:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
type activeNerf struct {
|
|
|
|
GeneralChannelID string `json:"channelID"`
|
|
|
|
NotInGeneralNerf int `json:"nerfFactor"`
|
|
|
|
}
|
|
|
|
|
2020-01-04 12:23:37 +07:00
|
|
|
type Reward struct {
|
|
|
|
FriendlyName string `json:"friendlyName"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
Weight int `json:"weight"`
|
|
|
|
Context map[string]interface{} `json:"context"`
|
|
|
|
}
|
|
|
|
|
2019-12-13 09:52:36 +07:00
|
|
|
func init() {
|
|
|
|
configFile, err := ioutil.ReadFile("config.json")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
var output config
|
|
|
|
err = json.Unmarshal([]byte(configFile), &output)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
//Place everything into high level variables
|
|
|
|
GeneralChannelID = output.ActiveNerf.GeneralChannelID
|
|
|
|
NotInGeneralNerf = output.ActiveNerf.NotInGeneralNerf
|
|
|
|
CommandPrefix = output.CommandPrefix
|
|
|
|
GuildID = output.GuildID
|
|
|
|
PrestigeRequirement = output.PrestigeRequirement
|
|
|
|
StarChannel = output.StarChannel
|
2019-12-13 10:07:39 +07:00
|
|
|
BotToken = output.BotToken
|
|
|
|
LevelRoles = output.LevelRoles
|
2020-01-04 12:23:37 +07:00
|
|
|
Rewards = output.Rewards
|
|
|
|
if len(Rewards) == 0 {
|
|
|
|
panic("modules/config: Gacha rewards not provided")
|
|
|
|
}
|
|
|
|
for _, v := range output.Rewards {
|
|
|
|
TotalRewardWeight += v.Weight
|
|
|
|
}
|
2019-12-13 09:52:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
//Exposed Variables
|
|
|
|
var (
|
|
|
|
GeneralChannelID string
|
|
|
|
NotInGeneralNerf int
|
|
|
|
)
|
|
|
|
var CommandPrefix string
|
|
|
|
var GuildID string
|
|
|
|
var PrestigeRequirement int
|
|
|
|
var StarChannel string
|
2019-12-13 10:07:39 +07:00
|
|
|
var BotToken string
|
|
|
|
var LevelRoles []string
|
2020-01-04 12:23:37 +07:00
|
|
|
var (
|
|
|
|
Rewards []Reward
|
|
|
|
TotalRewardWeight int
|
|
|
|
)
|