2019-12-13 09:52:36 +07:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"io/ioutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
type config struct {
|
|
|
|
ActiveNerf activeNerf `json:"activeNerf"`
|
2020-01-04 14:15:50 +07:00
|
|
|
Admins []string `json:"admin"`
|
2019-12-13 09:52:36 +07:00
|
|
|
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 {
|
2020-01-05 09:00:23 +07:00
|
|
|
GeneralChannelID []string `json:"channelID"`
|
|
|
|
NotInGeneralNerf int `json:"nerfFactor"`
|
2019-12-13 09:52:36 +07:00
|
|
|
}
|
|
|
|
|
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
|
2020-01-04 14:15:50 +07:00
|
|
|
Admins = output.Admins
|
2019-12-13 09:52:36 +07:00
|
|
|
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 (
|
2020-01-05 09:00:23 +07:00
|
|
|
GeneralChannelID []string
|
2019-12-13 09:52:36 +07:00
|
|
|
NotInGeneralNerf int
|
|
|
|
)
|
2020-01-04 14:15:50 +07:00
|
|
|
var Admins []string
|
2019-12-13 09:52:36 +07:00
|
|
|
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
|
|
|
|
)
|