Fancy usage of arrays in config files
This commit is contained in:
parent
ce4fcb44e0
commit
4464c878e9
13
main.go
13
main.go
|
@ -42,7 +42,14 @@ func main() {
|
|||
log.Fatalln("Invalid token/token is not set")
|
||||
}
|
||||
|
||||
channelStrs := strings.Split(viper.GetString("channels"), ",")
|
||||
var channelStrs []string
|
||||
|
||||
if viper.ConfigFileUsed() != "" {
|
||||
channelStrs = viper.GetStringSlice("channels")
|
||||
} else {
|
||||
channelStrs = strings.Split(viper.GetString("channels"), ",")
|
||||
}
|
||||
|
||||
channels = make([]discord.ChannelID, len(channelStrs))
|
||||
|
||||
for i, channelStr := range channelStrs {
|
||||
|
@ -55,7 +62,11 @@ func main() {
|
|||
channels[i] = discord.ChannelID(sf)
|
||||
}
|
||||
|
||||
if viper.ConfigFileUsed() != "" {
|
||||
prohibitedPhrases = viper.GetStringSlice("phohibitedPhrases")
|
||||
} else {
|
||||
prohibitedPhrases = strings.Split(viper.GetString("prohibitedPhrases"), ",")
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
|
|
Loading…
Reference in New Issue